Skip to content

feat: sync Rokt session ID to mParticle via setIntegrationAttribute#67

Open
crisryantan wants to merge 5 commits intomparticle-integrations:mainfrom
crisryantan:feature/sync-rokt-session-id-to-mparticle
Open

feat: sync Rokt session ID to mParticle via setIntegrationAttribute#67
crisryantan wants to merge 5 commits intomparticle-integrations:mainfrom
crisryantan:feature/sync-rokt-session-id-to-mparticle

Conversation

@crisryantan
Copy link
Contributor

@crisryantan crisryantan commented Mar 19, 2026

Summary

Syncs the Rokt session ID back to mParticle so server-side integrations can link mParticle events to Rokt sessions via the Transactions v2 API.

  • After selectPlacements() resolves, reads the session ID from selection.context.sessionId
  • Subscribes to SESSION_ID_UPDATED events for subsequent session changes
  • Calls mParticle.getInstance().setIntegrationAttribute(181, { roktSessionId }) to attach the ID to all future event batches
  • Best-effort: early events before session ID arrives will not have the attribute. Wrapped in try/catch to never break the partner page
  • Guarded with thenable check so existing callers that don't return a Promise from selectPlacements are unaffected

Testing Plan

  • Unit tests: 5 new tests covering happy path, SESSION_ID_UPDATED subscription, empty session ID guard, missing getInstance resilience, and Selection return value preservation
  • All 132 existing tests pass (Chrome Headless)
  • Manual verification: call selectPlacements(), then check mParticle.getInstance().getIntegrationAttributes(181) returns { roktSessionId: '<session-id>' }
  • Verify outbound mParticle event batch contains integration_attributes.181.roktSessionId

🤖 Generated with Claude Code

Copy link
Collaborator

@alexs-mparticle alexs-mparticle left a comment

Choose a reason for hiding this comment

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

@crisryantan please remove the dist files from your pr

@crisryantan crisryantan force-pushed the feature/sync-rokt-session-id-to-mparticle branch 2 times, most recently from 60cc70a to 17c775b Compare March 20, 2026 22:41
sel.context.sessionId
.then(function (sessionId) {
_setRoktSessionId(sessionId);
logSelectPlacementsEvent(
Copy link
Collaborator

Choose a reason for hiding this comment

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

@crisryantan Should we also logSelectPlacementsEvent in a catch, and in an else statement? I assume this may happen if a selection fails, in which case we should still send the original selectPlacements event.

crisryantan and others added 3 commits March 24, 2026 10:45
After selectPlacements resolves, read the session ID from the Selection
context and subscribe to SESSION_ID_UPDATED events. The session ID is
forwarded to mParticle via setIntegrationAttribute(181, { roktSessionId })
so server-side integrations can link events back to Rokt sessions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove redundant SESSION_ID_UPDATED subscription (context.sessionId already captures on each selection)
- Move logSelectPlacementsEvent after session ID is set to guarantee server receives sessionId
- Remove dist files from tracking (release process builds these)
- Remove "still" from test name

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@crisryantan crisryantan force-pushed the feature/sync-rokt-session-id-to-mparticle branch from 17c775b to b5a58c5 Compare March 23, 2026 23:45
crisryantan and others added 2 commits March 24, 2026 10:49
Address PR review feedback to ensure logSelectPlacementsEvent fires in
all code paths (catch, else), not just the happy path where sessionId
resolves successfully.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The dist/ folder should not include changes from this PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants