Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(replay): Send client_report when replay sending fails #7093

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/replay/src/replay.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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');
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions packages/replay/src/util/addEvent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getCurrentHub } from '@sentry/core';
import { logger } from '@sentry/utils';

import { SESSION_IDLE_DURATION } from '../constants';
Expand Down Expand Up @@ -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');
}
}
}
4 changes: 3 additions & 1 deletion packages/types/src/clientreport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down