Skip to content

Commit

Permalink
fix: sentry only logs 5xx errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSlimvReal committed Oct 10, 2023
1 parent ca52330 commit d57174f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import {
HttpException,
MiddlewareConsumer,
Module,
NestModule,
} from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { SentryInterceptor, SentryModule } from '@ntegral/nestjs-sentry';
import { SeverityLevel } from '@sentry/types';
Expand All @@ -13,7 +18,18 @@ const lowSeverityLevels: SeverityLevel[] = ['log', 'info'];

@Module({
providers: [
{ provide: APP_INTERCEPTOR, useFactory: () => new SentryInterceptor() },
{
provide: APP_INTERCEPTOR,
useFactory: () =>
new SentryInterceptor({
filters: [
{
type: HttpException,
filter: (exception: HttpException) => 500 > exception.getStatus(), // Only report 500 errors
},
],
}),
},
],
imports: [
ConfigModule.forRoot({ isGlobal: true }),
Expand Down

0 comments on commit d57174f

Please sign in to comment.