Skip to content

Conversation

cipher-fox
Copy link

Description:

I discovered a problem with the request type of SentryInterceptorOptions as it is defined as a boolean type and did not allow me to specify the keys to be removed from the request object as described in the sentry documentation.

Sentry Docs

With this fix, when you use the SentryInterceptor() you will have the option to specify the request fields that you want to extract from the request object. The following example extract only the headers from the request:

@Module({
  imports: [
    SentryModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) =>
        configService.get('SENTRY_CONFIG'),
      inject: [ConfigService],
    }),
  ],
  controllers: [AppController],
  providers: [
    {
      provide: APP_INTERCEPTOR,
      useFactory: () =>
        new SentryInterceptor({
          request: ['headers'],
        }),
    },
  ],
})
export class AppModule implements NestModule {}

Tests results:

Captura de pantalla 2023-01-23 a las 14 49 47


Sentry results:

Captura de pantalla 2023-01-23 a las 14 44 07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants