Skip to content

feat(audience): stamp sessionId on every message envelope#2895

Open
nattb8 wants to merge 1 commit into
mainfrom
feat/sdk-628-session-id-every-event
Open

feat(audience): stamp sessionId on every message envelope#2895
nattb8 wants to merge 1 commit into
mainfrom
feat/sdk-628-session-id-every-event

Conversation

@nattb8

@nattb8 nattb8 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Why

session_id only reached some events via ad hoc per-call-site properties.session_id, and identify()/alias() on the web SDK had none at all since those message types have no properties field. Every event should carry it consistently so a session can be reconstructed with a plain equality join instead of per-event-type special-casing.

What

sessionId is now on the top-level envelope for every message type: track, page, session_start, session_end, identify, alias. The old nested properties.session_id writes are removed (confirmed nothing downstream reads them), so there's a single consistent field everywhere, no duplication.

Also fixed a related bug in the web SDK: page()/track()/identify()/alias() called getOrCreateSession() but discarded the result, so a session rollover after 30 minutes of inactivity was invisible, the SDK kept stamping a stale id and never fired a new session_start. Pixel already handled this correctly; the web SDK now matches it.

Linear: SDK-628

Test plan

  • core lint + tests pass
  • pixel lint + tests pass
  • sdk lint + tests pass
  • New/updated tests confirm sessionId present on identify/alias messages
  • Existing tests updated to assert the top-level field instead of the removed nested one
  • New regression test confirms a session rollover fires a new session_start and updates sessionId, instead of keeping a stale id

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

✅ Pixel Bundle Size — @imtbl/pixel

Metric Size Delta vs main
Gzipped 6673 bytes (6.51 KB) -8 bytes
Raw (minified) 18540 bytes -60 bytes

Budget: 10.00 KB gzipped (warn at 8.00 KB)

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

✅ Audience Bundle Size — @imtbl/audience

Metric Size Delta vs main (f75b277)
Gzipped 19536 bytes (19.07 KB) +16 bytes
Raw (minified) 57256 bytes +63 bytes

Budget: 24.00 KB gzipped (warn at 20.00 KB)

@nx-cloud

nx-cloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 91eb9a7

Command Status Duration Result
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 1s View ↗
nx affected -t build,lint,test ✅ Succeeded 7s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-07 06:39:17 UTC

@nx-cloud

nx-cloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2e1608d

Command Status Duration Result
nx affected -t build,lint,test ✅ Succeeded 12s View ↗
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 8s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-07 02:48:06 UTC

@nattb8 nattb8 marked this pull request as ready for review July 7, 2026 05:31
@nattb8 nattb8 requested a review from a team as a code owner July 7, 2026 05:31
@nattb8 nattb8 force-pushed the feat/sdk-628-session-id-every-event branch from 2e1608d to a8c3dd9 Compare July 7, 2026 06:05
JCSanPedro
JCSanPedro previously approved these changes Jul 7, 2026
Session id was previously injected ad hoc into the properties object at
each call site, so identify() and alias() on the web SDK carried no
session correlation since those message types have no properties field.
Adding sessionId to the shared BaseMessage envelope closes that gap
while keeping the existing properties.session_id fields for backward
compatibility.
@nattb8 nattb8 force-pushed the feat/sdk-628-session-id-every-event branch from a8c3dd9 to 91eb9a7 Compare July 7, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants