Skip to content

Commit 56937f6

Browse files
committed
feat(replay): Send client_report when replay sending fails
This leverages the new client_report categories.
1 parent fcf17a8 commit 56937f6

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

packages/replay/src/replay.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */ // TODO: We might want to split this file up
22
import { EventType, record } from '@sentry-internal/rrweb';
3-
import { captureException } from '@sentry/core';
3+
import { captureException, getCurrentHub } from '@sentry/core';
44
import type { Breadcrumb, ReplayRecordingMode } from '@sentry/types';
55
import { logger } from '@sentry/utils';
66

@@ -807,9 +807,17 @@ export class ReplayContainer implements ReplayContainerInterface {
807807
} catch (err) {
808808
this._handleException(err);
809809

810-
// This means we retried 3 times, and all of them failed
810+
// This means we retried 3 times and all of them failed,
811+
// or we ran into a problem we don't want to retry, like rate limiting.
811812
// In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
812813
this.stop();
814+
815+
const hub = getCurrentHub();
816+
const client = hub.getClient();
817+
818+
if (client) {
819+
client.recordDroppedEvent('send_error', 'replay');
820+
}
813821
}
814822
}
815823

packages/replay/src/util/addEvent.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { logger } from '@sentry/utils';
22

33
import { SESSION_IDLE_DURATION } from '../constants';
44
import type { AddEventResult, RecordingEvent, ReplayContainer } from '../types';
5+
import { getCurrentHub } from '@sentry/core';
56

67
/**
78
* Add an event to the event buffer
@@ -46,5 +47,12 @@ export async function addEvent(
4647
} catch (error) {
4748
__DEBUG_BUILD__ && logger.error(error);
4849
replay.stop();
50+
51+
const hub = getCurrentHub();
52+
const client = hub.getClient();
53+
54+
if (client) {
55+
client.recordDroppedEvent('internal_sdk_error', 'replay');
56+
}
4957
}
5058
}

packages/types/src/clientreport.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export type EventDropReason =
66
| 'network_error'
77
| 'queue_overflow'
88
| 'ratelimit_backoff'
9-
| 'sample_rate';
9+
| 'sample_rate'
10+
| 'send_error'
11+
| 'internal_sdk_error';
1012

1113
export type Outcome = {
1214
reason: EventDropReason;

0 commit comments

Comments
 (0)