diff --git a/packages/replay/src/replay.ts b/packages/replay/src/replay.ts index bb66d0fa28fd..c162a26cd5da 100644 --- a/packages/replay/src/replay.ts +++ b/packages/replay/src/replay.ts @@ -1,6 +1,6 @@ /* eslint-disable max-lines */ // TODO: We might want to split this file up import { EventType, record } from '@sentry-internal/rrweb'; -import { captureException } from '@sentry/core'; +import { captureException, getCurrentHub } from '@sentry/core'; import type { Breadcrumb, ReplayRecordingMode } from '@sentry/types'; import { logger } from '@sentry/utils'; @@ -807,9 +807,16 @@ export class ReplayContainer implements ReplayContainerInterface { } catch (err) { this._handleException(err); - // This means we retried 3 times, and all of them failed + // This means we retried 3 times and all of them failed, + // or we ran into a problem we don't want to retry, like rate limiting. // In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments this.stop(); + + const client = getCurrentHub().getClient(); + + if (client) { + client.recordDroppedEvent('send_error', 'replay'); + } } } diff --git a/packages/replay/src/util/addEvent.ts b/packages/replay/src/util/addEvent.ts index cb66d0c7822c..e243ce11b56b 100644 --- a/packages/replay/src/util/addEvent.ts +++ b/packages/replay/src/util/addEvent.ts @@ -1,3 +1,4 @@ +import { getCurrentHub } from '@sentry/core'; import { logger } from '@sentry/utils'; import { SESSION_IDLE_DURATION } from '../constants'; @@ -46,5 +47,11 @@ export async function addEvent( } catch (error) { __DEBUG_BUILD__ && logger.error(error); replay.stop(); + + const client = getCurrentHub().getClient(); + + if (client) { + client.recordDroppedEvent('internal_sdk_error', 'replay'); + } } } diff --git a/packages/types/src/clientreport.ts b/packages/types/src/clientreport.ts index 7b4e181d1102..b6ab1766e68c 100644 --- a/packages/types/src/clientreport.ts +++ b/packages/types/src/clientreport.ts @@ -6,7 +6,9 @@ export type EventDropReason = | 'network_error' | 'queue_overflow' | 'ratelimit_backoff' - | 'sample_rate'; + | 'sample_rate' + | 'send_error' + | 'internal_sdk_error'; export type Outcome = { reason: EventDropReason;