I have sentry in my Angular (2+) project and it works very well. Although Sentry is great on the live version of the site I like to see my errors logged in the console in a local environment and tracking them is of little value. Within Angular my app.module looks like this:
Raven
.config('sentryurlhere', {
release: environment.release,
environment: environment.env
})
.install();
export class RavenErrorHandler implements ErrorHandler {
handleError(err:any) : void {
Raven.captureException(err.originalError || err);
}
}
@NgModule({
imports: [...],
declarations: [...],
providers: [
...
{provide: ErrorHandler, useClass: RavenErrorHandler}
],
bootstrap: [....]
})
My current solution to disable Sentry while in a local environment is to comment out the provider and hope I remember to revert that before I commit. Its a poor solution. I was wondering if anyone with an Angular app has a good solution for this? I suppose I could conditionally build a providers array based on the env and either include or exclude the Sentry provider; that seems messy.