feat: add trackEvent for custom pipeline events#384
Open
talissoncosta wants to merge 6 commits intofeat/send-evaluation-data-to-analytics-pipelinefrom
Open
feat: add trackEvent for custom pipeline events#384talissoncosta wants to merge 6 commits intofeat/send-evaluation-data-to-analytics-pipelinefrom
talissoncosta wants to merge 6 commits intofeat/send-evaluation-data-to-analytics-pipelinefrom
Conversation
Add trackEvent(eventName, metadata?) to the public type definitions, allowing custom events to be sent through the evaluation analytics pipeline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add trackEvent method that sends custom_event through the analytics pipeline batch endpoint. Events tracked before identify() are buffered in pendingCustomEvents and drained once identity is set, preserving original timestamps. Pending events are cleared on logout. Includes helper methods (getPageUrl, currentTraitsSnapshot, sdkMetadata, buildCustomEvent) to keep the implementation clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover custom event shape, no-op without config, no-op with empty name, queue-before-identify with drain, immediate flush when flushInterval is 0, no deduplication, timestamp preservation, cleanup on logout, and pending buffer maxBuffer cap. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… trackEvent Use the stricter Record<string, unknown> for user-provided metadata, which forces consumers to narrow values before using them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace string literals 'flag_evaluation' and 'custom_event' with PipelineEventType.FLAG_EVALUATION and PipelineEventType.CUSTOM_EVENT to avoid magic strings and ensure type safety. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace 'custom_event' string literals with PipelineEventType.CUSTOM_EVENT in test assertions and helpers - Export PipelineEventType from index.ts for consumer access - Add test for identify → logout → track cycle to verify state resets Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
trackEvent(eventName, metadata?)public method to send custom events through the evaluation analytics pipeline (v1/analytics/batch)identify()are buffered and drained once identity is set, preserving original timestampsevaluationAnalyticsConfig; no-op otherwise. Pending events are cleared onlogout()PipelineEventTypeenum (FLAG_EVALUATION,CUSTOM_EVENT) to replace magic strings, exported fromindex.tsfor consumer accessRecord<string, unknown>instead ofRecord<string, any>for metadata, enforcing type narrowing on consumersTest plan
flushInterval === 0, no deduplication, timestamp preservation, logout cleanup, maxBuffer cap, identify → logout → buffer cycle