Skip to content

captureException with the js sdk in Angular #2409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hdayacr opened this issue Feb 3, 2020 · 3 comments
Closed

captureException with the js sdk in Angular #2409

hdayacr opened this issue Feb 3, 2020 · 3 comments

Comments

@hdayacr
Copy link

hdayacr commented Feb 3, 2020

There is a lot of captureException and incomprehensible (like “Object.s” as title ) errors in Sentry

There is my configuration

    "@angular/animations": "^8.0.0",
    "@angular/cdk": "^8.0.0",
    "@angular/common": "^8.0.0",
    "@angular/compiler": "^8.0.0",
    "@angular/core": "^8.0.0",
    "@angular/forms": "^8.0.0",
    "@angular/material": "^8.0.0",
    "@angular/platform-browser": "^8.0.0",
    "@angular/platform-browser-dynamic": "^8.0.0",
    "@angular/platform-server": "^8.0.0",
    "@angular/router": "^8.0.0",
    "@sentry/browser": "^5.11.2",

in my main. module.ts:

Sentry.init({
     dsn: 'BLABLABLA',
     release: environment.version,
     environment: environment.production === true ? 'production' : 'staging'
 });

...

export class SentryErrorHandler extends ErrorHandler {

 constructor() {
     super();
 }

 handleError(err: any): void {
     if (environment.production === true || environment.preprod === true) {
         Sentry.captureMessage(err.originalError || err);
     }
     throw err;
 }
}
...

providers: [
     {provide: ErrorHandler, useClass: SentryErrorHandler},
...

I changed from Sentry.captureException to Sentry.captureMessage but the problem is still present.

Screenshot of the exceptions thrown:

Capture d’écran 2020-02-03 à 11 17 36

Capture d’écran 2020-02-03 à 11 17 49

As you can see in the screenshot, there is a “synthetic error” thrown in the sentry sdk code base.

Everything is configured as the documentation mention it, I also upload the sourcemaps correctly.

@kamilogorek
Copy link
Contributor

Duplicate of #2292

@kamilogorek kamilogorek marked this as a duplicate of #2292 Feb 3, 2020
@hdayacr
Copy link
Author

hdayacr commented Feb 4, 2020

Ok I rendered the SentryErrorHandler injectable and implements ErrorHandler instead of extends and there are no more problems like that.
So I change from

export class SentryErrorHandler extends ErrorHandler {

 constructor() {
     super();
 }

 handleError(err: any): void {
     if (environment.production === true || environment.preprod === true) {
         Sentry.captureMessage(err.originalError || err);
     }
     throw err;
 }
}

to

@Injectable()
export class SentryErrorHandler implements ErrorHandler {

 constructor() { }

 handleError(err: any): void {
     if (environment.production === true || environment.preprod === true) {
         Sentry.captureException(err.originalError || err);
     }
     throw err;
 }
}

I had the first config for 2 years without problems but since the upgrade to Angular 8 I have several sentry exceptions.

@kamilogorek
Copy link
Contributor

Awesome, thanks letting us know. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants