diff --git a/packages/replay-internal/src/util/logger.ts b/packages/replay-internal/src/util/logger.ts index 89ded3c69468..dfdd44b18472 100644 --- a/packages/replay-internal/src/util/logger.ts +++ b/packages/replay-internal/src/util/logger.ts @@ -74,7 +74,12 @@ function makeReplayDebugLogger(): ReplayDebugLogger { coreDebug.error(PREFIX, error); if (_capture) { - captureException(error); + captureException(error, { + mechanism: { + handled: true, + type: 'auto.function.replay.debug', + }, + }); } else if (_trace) { // No need for a breadcrumb if `_capture` is enabled since it should be // captured as an exception diff --git a/packages/replay-internal/test/integration/sendReplayEvent.test.ts b/packages/replay-internal/test/integration/sendReplayEvent.test.ts index 3b6c9b5764e1..1e870a8f577b 100644 --- a/packages/replay-internal/test/integration/sendReplayEvent.test.ts +++ b/packages/replay-internal/test/integration/sendReplayEvent.test.ts @@ -399,7 +399,12 @@ describe('Integration | sendReplayEvent', () => { expect(spyHandleException).toHaveBeenCalledTimes(5); const expectedError = new Error('Unable to send Replay - max retries exceeded'); (expectedError as any).cause = new Error('Something bad happened'); - expect(spyHandleException).toHaveBeenLastCalledWith(expectedError); + expect(spyHandleException).toHaveBeenLastCalledWith(expectedError, { + mechanism: { + handled: true, + type: 'auto.function.replay.debug', + }, + }); const spyHandleExceptionCall = spyHandleException.mock.calls; expect(spyHandleExceptionCall[spyHandleExceptionCall.length - 1][0]?.cause.message).toEqual( diff --git a/packages/replay-internal/test/unit/util/logger.test.ts b/packages/replay-internal/test/unit/util/logger.test.ts index a52512dabed8..a3fc85099525 100644 --- a/packages/replay-internal/test/unit/util/logger.test.ts +++ b/packages/replay-internal/test/unit/util/logger.test.ts @@ -52,7 +52,12 @@ describe('logger', () => { const err = new Error('An error'); debug.exception(err, 'a message'); if (captureExceptions) { - expect(mockCaptureException).toHaveBeenCalledWith(err); + expect(mockCaptureException).toHaveBeenCalledWith(err, { + mechanism: { + handled: true, + type: 'auto.function.replay.debug', + }, + }); } expect(mockLogError).toHaveBeenCalledWith('[Replay] ', 'a message'); expect(mockLogError).toHaveBeenLastCalledWith('[Replay] ', err); @@ -75,7 +80,12 @@ describe('logger', () => { const err = new Error('An error'); debug.exception(err); if (captureExceptions) { - expect(mockCaptureException).toHaveBeenCalledWith(err); + expect(mockCaptureException).toHaveBeenCalledWith(err, { + mechanism: { + handled: true, + type: 'auto.function.replay.debug', + }, + }); expect(mockAddBreadcrumb).not.toHaveBeenCalled(); } expect(mockLogError).toHaveBeenCalledTimes(1);