Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: use original interface option to add request data #118

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/sentry.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -68,7 +68,7 @@ export class SentryInterceptor implements NestInterceptor {
}

private captureHttpException(scope: Scope, http: HttpArgumentsHost, exception: HttpException): void {
const data = Handlers.parseRequest(<any>{},http.getRequest(), this.options);
const data = addRequestDataToEvent(<any>{},http.getRequest(), this.options?.addRequestDataOptions);

scope.setExtra('req', data.request);

Expand Down
18 changes: 4 additions & 14 deletions lib/sentry.interfaces.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<AddRequestDataToEventOptions, 'deps'>;
}