项目作者: mkrawiec

项目描述 :
Angular 4.3.0+ Http Error Interceptor for Sentry
高级语言: TypeScript
项目地址: git://github.com/mkrawiec/ngx-raven-interceptor.git
创建时间: 2017-09-10T11:56:49Z
项目社区:https://github.com/mkrawiec/ngx-raven-interceptor

开源协议:MIT License

下载


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 as well as hooked up as ErrorHandler in your app.

Include RavenInterceptorModule in root @NgModule of your app.

  1. import { BrowserModule } from '@angular/platform-browser'
  2. import { NgModule, ErrorHandler } from '@angular/core'
  3. import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'
  4. import { AppComponent } from './app.component'
  5. import { RavenErrorHandler } from './error-handler'
  6. import { RavenInterceptorModule } from 'ngx-raven-interceptor'
  7. @NgModule({
  8. declarations: [
  9. AppComponent
  10. ],
  11. imports: [
  12. BrowserModule,
  13. HttpClientModule,
  14. RavenInterceptorModule.forRoot() // HERE
  15. ],
  16. providers: [
  17. { provide: ErrorHandler, useClass: RavenErrorHandler }
  18. ],
  19. bootstrap: [AppComponent]
  20. })
  21. 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:

  1. RavenInterceptorModule.forRoot({ whitelistCodes: [500, 501, 503] })

Or you can invert the logic and skip only certain error codes:

  1. RavenInterceptorModule.forRoot({ blacklistCodes: [400] })