Skip to content

Commit

Permalink
fix(interceptor): fixes api changes of NestJS version 6
Browse files Browse the repository at this point in the history
BREAKING CHANGE: NestJS version required is 6.x

fix #11
  • Loading branch information
mentos1386 committed Mar 21, 2019
1 parent f09d5a0 commit 9ea75fc
Show file tree
Hide file tree
Showing 5 changed files with 3,923 additions and 5,202 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ $ npm i --save nest-raven
```

### Versions

* **3.x** Is for nest v5.x and introduces @sentry/minimal
* **4.x** Is for Next v6.x
* **3.x** Is for Nest v5.x and introduces @sentry/minimal
* **2.x** Is for Nest v5.x
* **1.x** Is for Nest v4.x

Expand Down Expand Up @@ -69,7 +69,7 @@ With this setup, sentry will pick up all exceptions (even 400 types).
#### Global
If you want to set up interceptor as global, you have to follow Nest
instructions [here](https://docs.nestjs.com/interceptors). Something like
this:
this. This only works for Controllers not for Gateways (limitation by NestJS):

> app.module.ts
Expand Down
6 changes: 4 additions & 2 deletions lib/raven.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ExecutionContext, Injectable,
NestInterceptor,
CallHandler,
} from '@nestjs/common';
import { IRavenInterceptorOptions } from './raven.interfaces';
import { Observable } from 'rxjs';
Expand All @@ -18,13 +19,14 @@ export class RavenInterceptor implements NestInterceptor {

intercept(
context: ExecutionContext,
call$: Observable<any>,
next: CallHandler,
): Observable<any> {
const httpRequest = context.switchToHttp().getRequest();
const userData = httpRequest ? httpRequest.user : null;

// first param would be for events, second is for errors
return call$.pipe(
return next.handle()
.pipe(
tap(null, (exception) => {
if (this.shouldReport(exception)) {
Sentry.withScope(scope => this.captureException(scope, httpRequest, userData, exception));
Expand Down
Loading

0 comments on commit 9ea75fc

Please sign in to comment.