diff --git a/packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts b/packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts index ec0b54653be1..3560a2598160 100644 --- a/packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts +++ b/packages/browser-integration-tests/suites/integrations/httpclient/axios/test.ts @@ -38,7 +38,7 @@ sentryTest( value: 'HTTP Client Error with status code: 500', mechanism: { type: 'http.client', - handled: true, + handled: false, }, }, ], diff --git a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts index 07eafb3185ae..6885de912437 100644 --- a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts +++ b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/simple/test.ts @@ -38,7 +38,7 @@ sentryTest( value: 'HTTP Client Error with status code: 500', mechanism: { type: 'http.client', - handled: true, + handled: false, }, }, ], diff --git a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts index dd829a2bcc22..3caa6bd19652 100644 --- a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts +++ b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequest/test.ts @@ -36,7 +36,7 @@ sentryTest('works with a Request passed in', async ({ getLocalTestPath, page }) value: 'HTTP Client Error with status code: 500', mechanism: { type: 'http.client', - handled: true, + handled: false, }, }, ], diff --git a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts index 208db16c84c9..1ae88e8c5f5b 100644 --- a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts +++ b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndBodyAndOptions/test.ts @@ -38,7 +38,7 @@ sentryTest( value: 'HTTP Client Error with status code: 500', mechanism: { type: 'http.client', - handled: true, + handled: false, }, }, ], diff --git a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts index a288f6fae1fb..9840f91ba272 100644 --- a/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts +++ b/packages/browser-integration-tests/suites/integrations/httpclient/fetch/withRequestAndOptions/test.ts @@ -36,7 +36,7 @@ sentryTest('works with a Request (without body) & options passed in', async ({ g value: 'HTTP Client Error with status code: 500', mechanism: { type: 'http.client', - handled: true, + handled: false, }, }, ], diff --git a/packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts b/packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts index 06f6bd4f0217..a3283be9cc00 100644 --- a/packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts +++ b/packages/browser-integration-tests/suites/integrations/httpclient/xhr/test.ts @@ -38,7 +38,7 @@ sentryTest( value: 'HTTP Client Error with status code: 500', mechanism: { type: 'http.client', - handled: true, + handled: false, }, }, ], diff --git a/packages/integrations/src/captureconsole.ts b/packages/integrations/src/captureconsole.ts index 993fb9414052..124985662dd5 100644 --- a/packages/integrations/src/captureconsole.ts +++ b/packages/integrations/src/captureconsole.ts @@ -1,5 +1,6 @@ import type { EventProcessor, Hub, Integration } from '@sentry/types'; import { + addExceptionMechanism, addInstrumentationHandler, CONSOLE_LEVELS, GLOBAL_OBJ, @@ -64,6 +65,12 @@ function consoleHandler(hub: Hub, args: unknown[], level: string): void { scope.setExtra('arguments', args); scope.addEventProcessor(event => { event.logger = 'console'; + + addExceptionMechanism(event, { + handled: false, + type: 'console', + }); + return event; }); diff --git a/packages/integrations/src/httpclient.ts b/packages/integrations/src/httpclient.ts index 98da9d46d3af..5492116d7722 100644 --- a/packages/integrations/src/httpclient.ts +++ b/packages/integrations/src/httpclient.ts @@ -416,6 +416,7 @@ export class HttpClient implements Integration { addExceptionMechanism(event, { type: 'http.client', + handled: false, }); return event; diff --git a/packages/integrations/test/captureconsole.test.ts b/packages/integrations/test/captureconsole.test.ts index ba906f0ea2fd..9a107f8dbd66 100644 --- a/packages/integrations/test/captureconsole.test.ts +++ b/packages/integrations/test/captureconsole.test.ts @@ -397,4 +397,36 @@ describe('CaptureConsole setup', () => { GLOBAL_OBJ.console.log('some message'); }).not.toThrow(); }); + + it("marks captured exception's mechanism as unhandled", () => { + // const addExceptionMechanismSpy = jest.spyOn(utils, 'addExceptionMechanism'); + + const captureConsoleIntegration = new CaptureConsole({ levels: ['error'] }); + const mockHub = getMockHub(captureConsoleIntegration); + captureConsoleIntegration.setupOnce( + () => undefined, + () => mockHub, + ); + + const mockScope = mockHub.getScope(); + + const someError = new Error('some error'); + GLOBAL_OBJ.console.error(someError); + + const addedEventProcessor = (mockScope.addEventProcessor as jest.Mock).mock.calls[0][0]; + const someEvent: Event = { + exception: { + values: [{}], + }, + }; + addedEventProcessor(someEvent); + + expect(mockHub.captureException).toHaveBeenCalledTimes(1); + expect(mockScope.addEventProcessor).toHaveBeenCalledTimes(1); + + expect(someEvent.exception?.values?.[0].mechanism).toEqual({ + handled: false, + type: 'console', + }); + }); });