Skip to content

Commit 4ce406a

Browse files
committed
chore(angular): Add Angular version to event contexts
Query and send the Angular version to Sentry to help us investigate which Angular versions are used by our users to make support decisions
1 parent 0d07854 commit 4ce406a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/angular/src/errorhandler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpErrorResponse } from '@angular/common/http';
2-
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
2+
import { ErrorHandler as AngularErrorHandler, Inject, Injectable, VERSION } from '@angular/core';
33
import * as Sentry from '@sentry/browser';
44

55
import { runOutsideAngular } from './zone';
@@ -32,15 +32,17 @@ class SentryErrorHandler implements AngularErrorHandler {
3232
...options,
3333
};
3434
}
35-
3635
/**
3736
* Method called for every value captured through the ErrorHandler
3837
*/
3938
public handleError(error: unknown): void {
4039
const extractedError = this._extractError(error) || 'Handled unknown error';
4140

4241
// Capture handled exception and send it to Sentry.
43-
const eventId = runOutsideAngular(() => Sentry.captureException(extractedError));
42+
const angularVersion = VERSION && VERSION.major ? parseInt(VERSION.major, 10) : 0;
43+
const eventId = runOutsideAngular(() =>
44+
Sentry.captureException(extractedError, { contexts: { angular: { version: angularVersion } } }),
45+
);
4446

4547
// When in development mode, log the error to console for immediate feedback.
4648
if (this._options.logErrors) {

0 commit comments

Comments
 (0)