-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(replay): Ensure
replay_id
is removed from frozen DSC
- Loading branch information
Showing
5 changed files
with
108 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
dev-packages/browser-integration-tests/suites/replay/dsc/subject.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window._triggerError = function (errorCount) { | ||
Sentry.captureException(new Error(`This is error #${errorCount}`)); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
packages/replay-internal/src/util/resetReplayIdOnDynamicSamplingContext.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getActiveSpan, getCurrentScope, getDynamicSamplingContextFromSpan } from '@sentry/core'; | ||
import type { DynamicSamplingContext } from '@sentry/types'; | ||
|
||
/** | ||
* Reset the `replay_id` field on the DSC. | ||
*/ | ||
export function resetReplayIdOnDynamicSamplingContext(): void { | ||
// Reset DSC on the current scope, if there is one | ||
const dsc = getCurrentScope().getPropagationContext().dsc; | ||
if (dsc) { | ||
delete dsc.replay_id; | ||
} | ||
|
||
// Clear it from frozen DSC on the active span | ||
const activeSpan = getActiveSpan(); | ||
if (activeSpan) { | ||
const dsc = getDynamicSamplingContextFromSpan(activeSpan); | ||
delete (dsc as Partial<DynamicSamplingContext>).replay_id; | ||
} | ||
} |