Skip to content

Commit 39c0b1d

Browse files
authored
fix(replay): Stop global event handling for paused replays (#13815)
1 parent 0d39763 commit 39c0b1d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/replay-internal/src/coreHandlers/handleGlobalEvent.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { shouldSampleForBufferEvent } from './util/shouldSampleForBufferEvent';
1414
export function handleGlobalEventListener(replay: ReplayContainer): (event: Event, hint: EventHint) => Event | null {
1515
return Object.assign(
1616
(event: Event, hint: EventHint) => {
17-
// Do nothing if replay has been disabled
18-
if (!replay.isEnabled()) {
17+
// Do nothing if replay has been disabled or paused
18+
if (!replay.isEnabled() || replay.isPaused()) {
1919
return event;
2020
}
2121

packages/replay-internal/test/integration/coreHandlers/handleGlobalEvent.test.ts

+19
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,23 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
397397

398398
expect(handleGlobalEventListener(replay)(errorEvent, {})).toEqual(errorEvent);
399399
});
400+
401+
it('does not add replayId if replay is paused', async () => {
402+
const transaction = Transaction();
403+
const error = Error();
404+
405+
replay['_isPaused'] = true;
406+
407+
expect(handleGlobalEventListener(replay)(transaction, {})).toEqual(
408+
expect.not.objectContaining({
409+
// no tags at all here by default
410+
tags: expect.anything(),
411+
}),
412+
);
413+
expect(handleGlobalEventListener(replay)(error, {})).toEqual(
414+
expect.objectContaining({
415+
tags: expect.not.objectContaining({ replayId: expect.anything() }),
416+
}),
417+
);
418+
});
400419
});

0 commit comments

Comments
 (0)