ngx-raven
v1.0.5
Published
RavenJS wrapper for Angular
Downloads
12
Readme
NgxRaven
Angular wrapper for Sentry's RavenJS
Installation
npm i -S ngx-raven raven-js
Usage
Import Raven module in your AppModule (top level module)
import {RavenModule} from 'ngx-raven';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
RavenModule.forRoot({
dsn: '__PUBLIC_DSN__',
reportDialog: true, // optional, false by default
enabled: environment.production
})
],
bootstrap: [AppComponent]
})
export class AppModule { }
Inject RavenService in your AppComponent (top level component)
import {RavenModule} from 'ngx-raven';
@Component({
selector: 'app-root',
template: ``,
styles: [``]
})
export class AppComponent {
constructor(private ravenService: RavenService) {}
}
Raven will initialize and install itself after the injection, all exceptions will be automatically sent to your Sentry server.
You can use the RavenService to access raven instance inside your components or other services:
export class AppComponent {
constructor(private ravenService: RavenService) {
// Check if raven is initialised and installed
console.log(this.ravenService.raven.isSetup());
}
}
You can also read/write in the Raven Module Configuration by injecting it:
export class AppComponent {
constructor(private ravenService: RavenService, private ravenConfig: RavenConfig) {
// Check if raven is initialised
console.log(this.ravenService.raven.isSetup());
console.log(this.ravenConfig.dsn);
this.ravenConfig.reportDialog = false;
}
}