add: v30 analytics + synonym_set/items APIs #312
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change Summary
Introduce Analytics v30+ API alongside legacy AnalyticsV1, add Analytics Events GET endpoint, make analytics event type optional, and deprecate Synonym/Synonyms in favor of Synonym Sets. Tests updated with version gating via isV30OrAbove.
Changes
Added Features
Analyticsthat follows the OpenAPI schema, exposed asclient.analytics.AnalyticsRulesandAnalyticsRule(v30+) with:create()supporting single or array payloads (POST /analytics/rules).upsert(name, ...)(PUT /analytics/rules/{ruleName}).retrieve(ruleTag?)withrule_tagfilter support.src/Typesense/Analytics.tssrc/Typesense/AnalyticsRules.tssrc/Typesense/AnalyticsRule.tsAnalyticsEvents.retrieve({ user_id, name, n })(GET /analytics/events).AnalyticsEventsRetrieveSchema.src/Typesense/AnalyticsEvents.ts(newretrieve+ response type)AnalyticsEventCreateSchema.typeis now optional.src/Typesense/AnalyticsEvent.tsBackward Compatibility (V1)
AnalyticsV1keeps existing behavior, moved rule classes under V1:AnalyticsRuleV1,AnalyticsRulesV1client.analyticsV1continues to work (legacy).src/Typesense/AnalyticsV1.tssrc/Typesense/AnalyticsRuleV1.tssrc/Typesense/AnalyticsRulesV1.tsDeprecations
client.analytics.src/Typesense/AnalyticsV1.tssynonym_sets) starting with v30.src/Typesense/Synonyms.tssrc/Typesense/Synonym.tsTest Coverage
typesense.analyticsV1.rules()paths remain, tests gated withdescribe.skipIf(await isV30OrAbove(...)).typesense.analytics.rules()tests for:create()(POST)upsert()(PUT)retrieve()with and withoutrule_tagtest/Typesense/AnalyticsRules.spec.tstest/Typesense/AnalyticsRule.spec.ts.retrievetest gated to v30+ usingdescribe.skipIf(!(await isV30OrAbove(typesense))).test/Typesense/AnalyticsEvents.spec.tsisV30OrAbove()continues to be used for conditional test execution.test/utils.ts(unchanged, newly referenced)Migration Notes
client.analytics(v30+) instead ofclient.analyticsV1.analytics.rules().create(payload)for POST (single or array).analytics.rules().upsert(ruleName, payload)for PUT.analytics.rules().retrieve(ruleTag?)to fetch all rules (optionally filtered).analytics.events().retrieve({ user_id, name, n })for recent events.typefield increate()payload is optional.Synonym/Synonymsare deprecated as of v30; migrate toSynonym SetsAPIs.PR Checklist