diff --git a/dev-packages/e2e-tests/test-applications/angular-17/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/angular-17/tests/errors.test.ts index e6bd5ad180a9..391086555708 100644 --- a/dev-packages/e2e-tests/test-applications/angular-17/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/angular-17/tests/errors.test.ts @@ -19,7 +19,7 @@ test('sends an error', async ({ page }) => { type: 'Error', value: 'Error thrown from Angular 17 E2E test app', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, @@ -54,7 +54,7 @@ test('assigns the correct transaction value after a navigation', async ({ page } type: 'Error', value: 'Error thrown from user page', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, diff --git a/dev-packages/e2e-tests/test-applications/angular-18/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/angular-18/tests/errors.test.ts index 36d23bd077a5..98d4ce9d1169 100644 --- a/dev-packages/e2e-tests/test-applications/angular-18/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/angular-18/tests/errors.test.ts @@ -19,7 +19,7 @@ test('sends an error', async ({ page }) => { type: 'Error', value: 'Error thrown from Angular 18 E2E test app', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, @@ -54,7 +54,7 @@ test('assigns the correct transaction value after a navigation', async ({ page } type: 'Error', value: 'Error thrown from user page', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, diff --git a/dev-packages/e2e-tests/test-applications/angular-19/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/angular-19/tests/errors.test.ts index c6e8bc43abed..7fa706c00504 100644 --- a/dev-packages/e2e-tests/test-applications/angular-19/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/angular-19/tests/errors.test.ts @@ -19,7 +19,7 @@ test('sends an error', async ({ page }) => { type: 'Error', value: 'Error thrown from Angular 18 E2E test app', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, @@ -54,7 +54,7 @@ test('assigns the correct transaction value after a navigation', async ({ page } type: 'Error', value: 'Error thrown from user page', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, diff --git a/dev-packages/e2e-tests/test-applications/angular-20/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/angular-20/tests/errors.test.ts index 98ae26e195cc..a6e12b6a79c4 100644 --- a/dev-packages/e2e-tests/test-applications/angular-20/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/angular-20/tests/errors.test.ts @@ -19,7 +19,7 @@ test('sends an error', async ({ page }) => { type: 'Error', value: 'Error thrown from Angular 20 E2E test app', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, @@ -54,7 +54,7 @@ test('assigns the correct transaction value after a navigation', async ({ page } type: 'Error', value: 'Error thrown from user page', mechanism: { - type: 'angular', + type: 'auto.function.angular.error_handler', handled: false, }, }, diff --git a/packages/angular/src/errorhandler.ts b/packages/angular/src/errorhandler.ts index 31f945b08731..ceb05c0b9e9f 100644 --- a/packages/angular/src/errorhandler.ts +++ b/packages/angular/src/errorhandler.ts @@ -111,7 +111,7 @@ class SentryErrorHandler implements AngularErrorHandler, OnDestroy { // Capture handled exception and send it to Sentry. const eventId = runOutsideAngular(() => Sentry.captureException(extractedError, { - mechanism: { type: 'angular', handled: false }, + mechanism: { type: 'auto.function.angular.error_handler', handled: false }, }), ); diff --git a/packages/angular/test/errorhandler.test.ts b/packages/angular/test/errorhandler.test.ts index af532c12d9ae..09b6d69d3337 100644 --- a/packages/angular/test/errorhandler.test.ts +++ b/packages/angular/test/errorhandler.test.ts @@ -1,7 +1,7 @@ import { HttpErrorResponse } from '@angular/common/http'; import * as SentryBrowser from '@sentry/browser'; import type { Client, Event } from '@sentry/core'; -import { vi } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { createErrorHandler, SentryErrorHandler } from '../src/errorhandler'; const captureExceptionSpy = vi.spyOn(SentryBrowser, 'captureException'); @@ -9,7 +9,7 @@ const captureExceptionSpy = vi.spyOn(SentryBrowser, 'captureException'); vi.spyOn(console, 'error').mockImplementation(() => {}); const captureExceptionEventHint = { - mechanism: { handled: false, type: 'angular' }, + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, }; class CustomError extends Error { @@ -71,7 +71,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(str); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(str, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(str, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an empty Error', () => { @@ -79,7 +81,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(err, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(err, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts a non-empty Error', () => { @@ -88,7 +92,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(err, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(err, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an error-like object without stack', () => { @@ -169,7 +175,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(err, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(err, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an instance of class not extending Error but that has an error-like shape', () => { @@ -178,7 +186,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(err, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(err, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an instance of a class that does not extend Error and does not have an error-like shape', () => { @@ -251,7 +261,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(ngErr, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(ngErr, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an `HttpErrorResponse` with `Error`', () => { @@ -261,7 +273,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(httpErr, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(httpErr, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an `HttpErrorResponse` with `ErrorEvent`', () => { @@ -431,7 +445,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(err, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(err, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an `HttpErrorResponse` with an instance of class not extending Error but that has an error-like shape', () => { @@ -441,7 +457,9 @@ describe('SentryErrorHandler', () => { createErrorHandler().handleError(err); expect(captureExceptionSpy).toHaveBeenCalledTimes(1); - expect(captureExceptionSpy).toHaveBeenCalledWith(innerErr, { mechanism: { handled: false, type: 'angular' } }); + expect(captureExceptionSpy).toHaveBeenCalledWith(innerErr, { + mechanism: { handled: false, type: 'auto.function.angular.error_handler' }, + }); }); it('extracts an `HttpErrorResponse` with an instance of a class that does not extend Error and does not have an error-like shape', () => {