GlitchTip recommends using @micro-sentry/angular. Alternatively, users who need performance data need to use @sentry/angular-ivy
.
@micro-sentry features a very small bundle size and is easy to configure.
Install @micro-sentry/angular
:
$ npm install --save @micro-sentry/angular
In app.module.ts
add MicroSentryModule with your GlitchTip DSN.
import { MicroSentryModule } from '@micro-sentry/angular';
@NgModule({
imports: [
MicroSentryModule.forRoot({
dsn: "YOUR-GLITCHTIP-DSN-HERE",
}),
],
})
SENTRY_ENVIRONMENT
. No default is used in browser. MicroSentryModule.forRoot({
dsn: "YOUR-GLITCHTIP-DSN-HERE",
environment: "production",
release: "1.0.0"
}),
@sentry/angular-ivy has more features including performance tracking. The package adds up to 277 KB to your JS bundle size.
Install @sentry/angular-ivy
:
$ npm install --save @sentry/angular-ivy
For best results, add this snippet to your main.ts. If you need to set the DSN dynamically, you may set this elsewhere as well.
import { init } from "@sentry/angular-ivy";
init({
dsn: "YOUR-GLITCHTIP-DSN-HERE",
autoSessionTracking: false,
});
A more robust configuration example:
import { init } from '@sentry/angular-ivy';
.init({
dsn: "YOUR-GLITCHTIP-DSN-HERE",
environment: "production",
release: "1.0.0",
autoSessionTracking: false,
tracesSampleRate: 0.01,
});
SENTRY_RELEASE
.SENTRY_ENVIRONMENT
. No default is used in browser.It's possible to send performance transactions to GlitchTip.
Install @sentry/tracing
Add integration to SDK configuration:
Sentry.init({
dsn: "GlitchTip DSN",
integrations: [
new Integrations.BrowserTracing({
tracingOrigins: ["localhost", "https://example.com"],
routingInstrumentation: Sentry.routingInstrumentation,
}),
],
// Capture 1% of transactions
tracesSampleRate: 0.01,
});
Provide a custom Angular ErrorHandler. In your root modules file, adjust providers:
providers: [
{
provide: ErrorHandler,
useValue: Sentry.createErrorHandler({
showDialog: true,
}),
},
],