feat(segment-session-replay-plugin): integrate TRC targeting evaluation#1536
Draft
lewgordon-amplitude wants to merge 4 commits intomainfrom
Draft
feat(segment-session-replay-plugin): integrate TRC targeting evaluation#1536lewgordon-amplitude wants to merge 4 commits intomainfrom
lewgordon-amplitude wants to merge 4 commits intomainfrom
Conversation
Added evaluateTargetingAndCapture calls to enable TRC (Targeted Replay Capture) capabilities in the Segment session replay plugin. This brings feature parity with the browser plugin by evaluating targeting conditions before capturing session replays. Changes: - Convert Segment events to Amplitude event format for targeting evaluation - Call evaluateTargetingAndCapture in track/page methods via updateSessionIdAndAddProperties - Call evaluateTargetingAndCapture in identify method with user properties - Added comprehensive test coverage for all edge cases - Updated README with TRC documentation and important usage notes SR-2535 Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
bugbot run |
…or TRC evaluation
Segment track events contain both `type` ('track') and `event` (actual event name).
TRC event-name rules require the actual event name to match targeting conditions.
Changed priority from `ctx.event.type || ctx.event.event` to `ctx.event.event || ctx.event.type`
so track events like 'Button Clicked' are evaluated correctly instead of generic 'track'.
Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
bugbot run |
…le events Prevents delayed/offline events from older sessions from incorrectly triggering replay capture for the current session. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
bugbot run |
…rties Pass userProperties argument for TRC evaluation and validate session for identify events to prevent stale data from affecting targeting decisions. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Author
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| let nextSessionId: number | undefined; | ||
| if (ctx.event.integrations && (ctx.event.integrations['Actions Amplitude'] as AmplitudeIntegrationData)) { | ||
| nextSessionId = (ctx.event.integrations['Actions Amplitude'] as AmplitudeIntegrationData).session_id; | ||
| } |
There was a problem hiding this comment.
Redundant session ID extraction in identify handler
Low Severity
The nextSessionId extraction from ctx.event.integrations['Actions Amplitude'] duplicates the existing sessionId extraction already performed earlier in the same identify handler (visible at line 70 and above). Both variables end up holding the same value. Reusing the existing sessionId variable would reduce duplication and risk of the two extractions drifting apart.
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
Added evaluateTargetingAndCapture calls to enable TRC (Targeted Replay Capture) capabilities in the Segment session replay plugin. This brings feature parity with the browser plugin by evaluating targeting conditions before capturing session replays.
Checklist
Note
Medium Risk
Changes when session replay capture may start by adding TRC evaluation to the event pipeline; incorrect session-id gating or event mapping could cause replays to be over/under-captured, but the logic is scoped and covered by new unit tests.
Overview
Adds Targeted Replay Capture support to the Segment session replay plugin by calling
sessionReplay.evaluateTargetingAndCapturefortrack/page(viaupdateSessionIdAndAddProperties) andidentifyevents, converting Segment payloads into Amplitude event format and passing Segment traits as user properties.Targeting evaluation is skipped for delayed/offline events from older sessions by comparing the event’s
integrations['Actions Amplitude'].session_idto the current session, and tests/docs are expanded to cover TRC behavior, timestamp fallbacks, and session gating.Written by Cursor Bugbot for commit c1cec70. This will update automatically on new commits. Configure here.