Skip to content

Commit 58bb657

Browse files
mydeaLms24
andauthored
feat(replay): Send client_report when replay sending fails (#7093)
Co-authored-by: Lukas Stracke <[email protected]>
1 parent 9fb6d0d commit 58bb657

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

packages/replay/src/replay.ts

Lines changed: 9 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,16 @@ 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 client = getCurrentHub().getClient();
816+
817+
if (client) {
818+
client.recordDroppedEvent('send_error', 'replay');
819+
}
813820
}
814821
}
815822

packages/replay/src/util/addEvent.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getCurrentHub } from '@sentry/core';
12
import { logger } from '@sentry/utils';
23

34
import { SESSION_IDLE_DURATION } from '../constants';
@@ -46,5 +47,11 @@ export async function addEvent(
4647
} catch (error) {
4748
__DEBUG_BUILD__ && logger.error(error);
4849
replay.stop();
50+
51+
const client = getCurrentHub().getClient();
52+
53+
if (client) {
54+
client.recordDroppedEvent('internal_sdk_error', 'replay');
55+
}
4956
}
5057
}

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)