Skip to content

feat(analytics-controller): add optional invocation options for track, identify, view#8701

Open
gauthierpetetin wants to merge 3 commits into
mainfrom
feat/analytics-invocation-options
Open

feat(analytics-controller): add optional invocation options for track, identify, view#8701
gauthierpetetin wants to merge 3 commits into
mainfrom
feat/analytics-invocation-options

Conversation

@gauthierpetetin
Copy link
Copy Markdown
Contributor

@gauthierpetetin gauthierpetetin commented May 5, 2026

Explanation

Add the possibility to forward context, callback, messageId, and timestamp to AnalyticsController for trackEvent, identify, and trackView functions, , as this is needed in Extension.

References

NA

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes the AnalyticsPlatformAdapter interface and controller method signatures to accept a new options object, which may require updates in downstream adapter implementations. Also adjusts event-splitting behavior to mutate messageId for anonymous/sensitive events, which could affect deduplication/tracing semantics.

Overview
Adds support for forwarding invocation metadata through AnalyticsController.trackEvent, identify, and trackView into AnalyticsPlatformAdapter calls via a new AnalyticsInvocationOptions type (includes context, callback, messageId, timestamp).

When anonymous-event splitting is enabled and an invocation messageId is provided, the controller now derives a distinct messageId for the anonymous/sensitive counterpart to avoid SDK deduping. Tests, exports, and changelog were updated accordingly.

Reviewed by Cursor Bugbot for commit 5f45ca2. Bugbot is set up for automated code reviews on this repo. Configure here.

…, identify, view

Forward AnalyticsInvocationOptions (context, callback, messageId, timestamp)
from AnalyticsController to AnalyticsPlatformAdapter for trackEvent,
identify, and trackView. Extend adapter method signatures with optional
third argument. Export AnalyticsContext and AnalyticsInvocationCallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gauthierpetetin gauthierpetetin force-pushed the feat/analytics-invocation-options branch from 7a3f783 to 002a571 Compare May 11, 2026 11:06
@gauthierpetetin gauthierpetetin marked this pull request as ready for review May 11, 2026 11:33
@gauthierpetetin gauthierpetetin requested review from a team as code owners May 11, 2026 11:33
/**
* Optional context object attached to the invocation.
*/
context?: AnalyticsContext;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: there's already a context attached by Segment SDK, how does this interfere with it?

/**
* Optional callback when the invocation completes or fails.
*/
callback?: AnalyticsInvocationCallback;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: What are the use cases of this? The tracking should never block or interfere with UX, so it's best effort and errors are handled inside controller, right?

/**
* Optional stable identifier for deduplication or tracing.
*/
messageId?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q; we already have a message ID in the Segment payload. How is this different?

/**
* Optional event time. ISO strings, Unix timestamps in milliseconds, or Date values are typical.
*/
timestamp?: Date | number | string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: we already have a timestamp in Segment payload. How is this different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants