From e7fe84868580333ad824e8769a8faab2a6b63f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Louren=C3=A7o?= Date: Fri, 29 Dec 2023 16:45:33 -0300 Subject: [PATCH] refactor!: use original interface option to add request data --- lib/sentry.interceptor.ts | 4 ++-- lib/sentry.interfaces.ts | 18 ++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/sentry.interceptor.ts b/lib/sentry.interceptor.ts index e978677..803ca57 100644 --- a/lib/sentry.interceptor.ts +++ b/lib/sentry.interceptor.ts @@ -17,7 +17,7 @@ import { Observable } from 'rxjs'; import { tap } from 'rxjs/operators'; // Sentry imports import { Scope } from '@sentry/hub'; -import { Handlers } from '@sentry/node'; +import { Handlers, addRequestDataToEvent } from '@sentry/node'; import { SentryService } from './sentry.service'; import { SentryInterceptorOptions, SentryInterceptorOptionsFilter } from './sentry.interfaces'; @@ -68,7 +68,7 @@ export class SentryInterceptor implements NestInterceptor { } private captureHttpException(scope: Scope, http: HttpArgumentsHost, exception: HttpException): void { - const data = Handlers.parseRequest({},http.getRequest(), this.options); + const data = addRequestDataToEvent({},http.getRequest(), this.options?.addRequestDataOptions); scope.setExtra('req', data.request); diff --git a/lib/sentry.interfaces.ts b/lib/sentry.interfaces.ts index 4410406..bb6f27b 100644 --- a/lib/sentry.interfaces.ts +++ b/lib/sentry.interfaces.ts @@ -1,7 +1,7 @@ -import { ModuleMetadata, Type } from "@nestjs/common/interfaces"; +import { ConsoleLoggerOptions } from '@nestjs/common'; +import { ModuleMetadata, Type } from '@nestjs/common/interfaces'; +import { AddRequestDataToEventOptions } from '@sentry/node'; import { Integration, Options } from '@sentry/types'; -import { ConsoleLoggerOptions, HttpException } from "@nestjs/common"; -import { SeverityLevel } from "@sentry/node"; export interface SentryCloseOptions { enabled: boolean; @@ -38,15 +38,5 @@ export interface SentryInterceptorOptionsFilter { export interface SentryInterceptorOptions { filters?: SentryInterceptorOptionsFilter[]; - tags?: { [key: string]: string }; - extra?: { [key: string]: any }; - fingerprint?: string[]; - level?: SeverityLevel; - - // https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/handlers.ts#L163 - request?: boolean; - serverName?: boolean; - transaction?: boolean | 'path' | 'methodPath' | 'handler'; // https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/handlers.ts#L16 - user?: boolean | string[]; - version?: boolean; + addRequestDataOptions?: Omit; } \ No newline at end of file