Refactor Analytics Client for V2 Namespaced Events #1361
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.
Explanation
This PR refactors the SDK Analytics client to support our new V2 namespaced analytics architecture. The client is now split into analytics.v1 (for backward compatibility) and a new analytics.v2 for namespaced event tracking.
References
Checklist
Note
Introduce a namespaced V2 analytics client alongside legacy V1, add /v2 schema/types, refactor client API, update tests, and rewrite README with new usage and migration.
packages/sdk-analytics/src/analytics.ts):analytics.v1andanalytics.v2; singleenable()gates both.setGlobalProperty,track(name, props); batched sending to/v1/events.setup(namespace, props)andtrack(namespace, eventName, props); batched sending to/v2/events.packages/sdk-analytics/src/schema.ts):POST /v2/eventsendpoint.EventV2union withsdk/connectandmobile/sdk-connect-v2payloads and properties.packages/sdk-analytics/src/analytics.test.ts):setup.packages/sdk-analytics/README.md):Written by Cursor Bugbot for commit 23d2697. This will update automatically on new commits. Configure here.