https://github.com/mkrawiec/ngx-raven-interceptor
Angular 4.3.0+ Http Error Interceptor for Sentry
https://github.com/mkrawiec/ngx-raven-interceptor
angular angular2 http-client interceptor raven sentry
Last synced: 2 months ago
JSON representation
Angular 4.3.0+ Http Error Interceptor for Sentry
- Host: GitHub
- URL: https://github.com/mkrawiec/ngx-raven-interceptor
- Owner: mkrawiec
- License: mit
- Created: 2017-09-10T11:56:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-11T16:17:33.000Z (over 8 years ago)
- Last Synced: 2025-02-15T02:37:19.766Z (over 1 year ago)
- Topics: angular, angular2, http-client, interceptor, raven, sentry
- Language: TypeScript
- Size: 40 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ngx-raven-interceptor
Angular 4.3.0+ Http Error Interceptor for Sentry.
Once included, it will log every failed HTTP request from `HttpClient` to Sentry.
### Installation
`npm install --save ngx-raven-interceptor`
Make sure that raven is [installed and configured properly](https://docs.sentry.io/clients/javascript/integrations/angular/) as well as hooked up as `ErrorHandler` in your app.
Include `RavenInterceptorModule` in root `@NgModule` of your app.
```typescript
import { BrowserModule } from '@angular/platform-browser'
import { NgModule, ErrorHandler } from '@angular/core'
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'
import { AppComponent } from './app.component'
import { RavenErrorHandler } from './error-handler'
import { RavenInterceptorModule } from 'ngx-raven-interceptor'
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule,
RavenInterceptorModule.forRoot() // HERE
],
providers: [
{ provide: ErrorHandler, useClass: RavenErrorHandler }
],
bootstrap: [AppComponent]
})
export class AppModule { }
```
### Configuration
You can provide config object to the `forRoot()` function to whitelist or blacklist specific error codes from sending Sentry events
For example to log only 500, 502, 503 error codes:
RavenInterceptorModule.forRoot({ whitelistCodes: [500, 501, 503] })
Or you can invert the logic and skip only certain error codes:
RavenInterceptorModule.forRoot({ blacklistCodes: [400] })