Skip to content

Commit e083772

Browse files
authored
ref(replay-internal): Add mechanism to error caught by replayIntegration in debug mode (#17606)
Decided to go with `handled: true` since we handle the error but only optionally send it to sentry for debug purposes closes #17265
1 parent bd0671d commit e083772

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

packages/replay-internal/src/util/logger.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ function makeReplayDebugLogger(): ReplayDebugLogger {
7474
coreDebug.error(PREFIX, error);
7575

7676
if (_capture) {
77-
captureException(error);
77+
captureException(error, {
78+
mechanism: {
79+
handled: true,
80+
type: 'auto.function.replay.debug',
81+
},
82+
});
7883
} else if (_trace) {
7984
// No need for a breadcrumb if `_capture` is enabled since it should be
8085
// captured as an exception

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,12 @@ describe('Integration | sendReplayEvent', () => {
399399
expect(spyHandleException).toHaveBeenCalledTimes(5);
400400
const expectedError = new Error('Unable to send Replay - max retries exceeded');
401401
(expectedError as any).cause = new Error('Something bad happened');
402-
expect(spyHandleException).toHaveBeenLastCalledWith(expectedError);
402+
expect(spyHandleException).toHaveBeenLastCalledWith(expectedError, {
403+
mechanism: {
404+
handled: true,
405+
type: 'auto.function.replay.debug',
406+
},
407+
});
403408

404409
const spyHandleExceptionCall = spyHandleException.mock.calls;
405410
expect(spyHandleExceptionCall[spyHandleExceptionCall.length - 1][0]?.cause.message).toEqual(

packages/replay-internal/test/unit/util/logger.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ describe('logger', () => {
5252
const err = new Error('An error');
5353
debug.exception(err, 'a message');
5454
if (captureExceptions) {
55-
expect(mockCaptureException).toHaveBeenCalledWith(err);
55+
expect(mockCaptureException).toHaveBeenCalledWith(err, {
56+
mechanism: {
57+
handled: true,
58+
type: 'auto.function.replay.debug',
59+
},
60+
});
5661
}
5762
expect(mockLogError).toHaveBeenCalledWith('[Replay] ', 'a message');
5863
expect(mockLogError).toHaveBeenLastCalledWith('[Replay] ', err);
@@ -75,7 +80,12 @@ describe('logger', () => {
7580
const err = new Error('An error');
7681
debug.exception(err);
7782
if (captureExceptions) {
78-
expect(mockCaptureException).toHaveBeenCalledWith(err);
83+
expect(mockCaptureException).toHaveBeenCalledWith(err, {
84+
mechanism: {
85+
handled: true,
86+
type: 'auto.function.replay.debug',
87+
},
88+
});
7989
expect(mockAddBreadcrumb).not.toHaveBeenCalled();
8090
}
8191
expect(mockLogError).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)