Commit cc3ecb2
fix(replay): Set replay_id on DSC after buffer-to-session conversion (#20686)
Follow-up to a code review comment on
#20129 -- this sets a
replayId on the DSC when a buffer mode replay is saved and converted to
a session-based replay.
Normally, we attach the replay_id to a DSC using the `createDsc` hook,
but only when replay is enabled and recordingMode is `session` (and not
for `buffer`).
https://github.com/getsentry/sentry-javascript/blob/billy/fix-dsc-after-buffer-to-session/packages/replay-internal/src/util/addGlobalListeners.ts#L40-L46
What I'm unsure of is if this does anything since we're mutating the DSC
after an unknown period of time (e.g. we're in buffer mode, and an error
happens after 30 minutes).
## Slop
- When `sendBufferedReplayOrFlush` converts from buffer to session mode,
it calls `startRecording()` directly but never updates the cached DSC
with `replay_id`
- The `createDsc` hook only fires for new spans, not for an
already-cached DSC on the scope (set by `browserTracingIntegration`), so
`replay_id` was missing from outgoing requests until a new span happened
to be created
- Adds `setReplayIdOnDynamicSamplingContext()` (symmetric to the
existing `resetReplayIdOnDynamicSamplingContext()`) and calls it after
the buffer-to-session conversion completes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 7f2aa3d commit cc3ecb2
2 files changed
Lines changed: 24 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| 621 | + | |
621 | 622 | | |
622 | 623 | | |
623 | 624 | | |
| |||
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
386 | 408 | | |
387 | 409 | | |
388 | 410 | | |
| |||
0 commit comments