Skip to content

Commit bae6b5e

Browse files
committed
feat(replay): Capture client report when retry fails
1 parent 5e39384 commit bae6b5e

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/replay/src/replay.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,9 @@ export class ReplayContainer implements ReplayContainerInterface {
831831
return;
832832
}
833833

834+
const client = getCurrentHub().getClient();
835+
client?.recordDroppedEvent('retry_failed', 'replay_event');
836+
834837
// This means we retried 3 times, and all of them failed
835838
// In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
836839
this.stop();

packages/replay/test/integration/sendReplayEvent.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ describe('Integration | sendReplayEvent', () => {
386386
const TEST_EVENT = { data: {}, timestamp: BASE_TIMESTAMP, type: 3 };
387387

388388
const spyHandleException = jest.spyOn(SentryCore, 'captureException');
389+
const spyRecordDroppedEvent = jest.spyOn(SentryCore.getCurrentHub().getClient()!, 'recordDroppedEvent');
389390

390391
// Suppress console.errors
391392
const mockConsole = jest.spyOn(console, 'error').mockImplementation(jest.fn());
@@ -432,6 +433,10 @@ describe('Integration | sendReplayEvent', () => {
432433
// Replay should be completely stopped now
433434
expect(replay.isEnabled()).toBe(false);
434435

436+
// Failed retry is recorded
437+
expect(spyRecordDroppedEvent).toHaveBeenCalledTimes(1);
438+
expect(spyRecordDroppedEvent).toHaveBeenLastCalledWith('retry_failed', 'replay_event');
439+
435440
// Events are ignored now, because we stopped
436441
mockRecord._emitter(TEST_EVENT);
437442
await advanceTimers(DEFAULT_FLUSH_MIN_DELAY);

packages/types/src/clientreport.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export type EventDropReason =
66
| 'network_error'
77
| 'queue_overflow'
88
| 'ratelimit_backoff'
9-
| 'sample_rate';
9+
| 'sample_rate'
10+
| 'retry_failed';
1011

1112
export type Outcome = {
1213
reason: EventDropReason;

0 commit comments

Comments
 (0)