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
Analytics
that follows the OpenAPI schema, exposed asclient.analytics
.AnalyticsRules
andAnalyticsRule
(v30+) with:create()
supporting single or array payloads (POST /analytics/rules).upsert(name, ...)
(PUT /analytics/rules/{ruleName}).retrieve(ruleTag?)
withrule_tag
filter support.src/Typesense/Analytics.ts
src/Typesense/AnalyticsRules.ts
src/Typesense/AnalyticsRule.ts
AnalyticsEvents.retrieve({ user_id, name, n })
(GET /analytics/events).AnalyticsEventsRetrieveSchema
.src/Typesense/AnalyticsEvents.ts
(newretrieve
+ response type)AnalyticsEventCreateSchema.type
is now optional.src/Typesense/AnalyticsEvent.ts
Backward Compatibility (V1)
AnalyticsV1
keeps existing behavior, moved rule classes under V1:AnalyticsRuleV1
,AnalyticsRulesV1
client.analyticsV1
continues to work (legacy).src/Typesense/AnalyticsV1.ts
src/Typesense/AnalyticsRuleV1.ts
src/Typesense/AnalyticsRulesV1.ts
Deprecations
client.analytics
.src/Typesense/AnalyticsV1.ts
synonym_sets
) starting with v30.src/Typesense/Synonyms.ts
src/Typesense/Synonym.ts
Test 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_tag
test/Typesense/AnalyticsRules.spec.ts
test/Typesense/AnalyticsRule.spec.ts
.retrieve
test gated to v30+ usingdescribe.skipIf(!(await isV30OrAbove(typesense)))
.test/Typesense/AnalyticsEvents.spec.ts
isV30OrAbove()
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.type
field increate()
payload is optional.Synonym
/Synonyms
are deprecated as of v30; migrate toSynonym Sets
APIs.PR Checklist