Skip to content

fix(analytics-browser): defer session_start until Context plugin is ready - #1825

Draft
stevenchien-amplitude wants to merge 1 commit into
mainfrom
stevenchien/sr-4611-fix-session-start-init-race
Draft

fix(analytics-browser): defer session_start until Context plugin is ready#1825
stevenchien-amplitude wants to merge 1 commit into
mainfrom
stevenchien/sr-4611-fix-session-start-init-race

Conversation

@stevenchien-amplitude

@stevenchien-amplitude stevenchien-amplitude commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Linear: SR-4611 — Investigate session replay plugin and session_start 400s

Fixes intermittent 400 ingestion errors where session_start events were missing both user_id and device_id (Pet Media app 628463).

During AmplitudeBrowser._init(), setSessionId() was called before the Context plugin was registered. Because super._init() sets isReady = true first, session events could dispatch before Context enriched them with device_id, user_id, and library — matching the bad payloads from DPL-258.

This moves setSessionId() to run after Destination, Context, and IdentityEventSender are installed.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No

Test plan

  • Added regression test: should enrich session_start during init with device_id and library
  • All 138 browser-client tests pass locally
AI Prompt

Investigate SR-4611 (session replay plugin and session_start 400s), post findings on the ticket, and implement a fix for the SDK init race causing missing device_id on session_start events.

…eady

Move setSessionId() to after Destination and Context plugins are registered
during init so session_start events are enriched with device_id and library.
Fixes intermittent 400 ingestion errors reported in SR-4611.

Co-authored-by: Cursor <cursoragent@cursor.com>
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

SR-4611

@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 58.38 KB (+0.02% 🔺)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 132.01 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 209.46 KB (+0.01% 🔺)
@amplitude/element-selector (gzipped esm) 1.75 KB (0%)

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.

1 participant