From bdf033019e0ff9230a9d7a9224697527dd6cb490 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 15 Nov 2024 13:48:20 +0100 Subject: [PATCH 1/3] Suggest not to use `SentryGlobalGraphQLFilter` in newer SDK versions --- .../getting-started-use/javascript.nestjs.mdx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index 0c94c841ef363a..f335893d16fa8d 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -1,10 +1,10 @@ ```javascript {filename: main.ts} // Import this first! -import './instrument'; +import "./instrument"; // Now import other modules -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; +import { NestFactory } from "@nestjs/core"; +import { AppModule } from "./app.module"; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -17,15 +17,15 @@ bootstrap(); Afterwards, add the `SentryModule` as a root module to your main module: ```javascript {filename: app.module.ts} {2, 8} -import { Module } from '@nestjs/common'; -import { SentryModule } from '@sentry/nestjs/setup'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { Module } from "@nestjs/common"; +import { SentryModule } from "@sentry/nestjs/setup"; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; @Module({ imports: [ - SentryModule.forRoot(), - // ...other modules + SentryModule.forRoot(), + // ...other modules ], controllers: [AppController], providers: [AppService], @@ -56,9 +56,9 @@ module. This filter will report all unhandled errors to Sentry that are not caug **Important:** The `SentryGlobalFilter` needs to be registered before any other exception filters. ```javascript {3, 9} -import { Module } from '@nestjs/common'; -import { APP_FILTER } from '@nestjs/core'; -import { SentryGlobalFilter } from '@sentry/nestjs/setup'; +import { Module } from "@nestjs/common"; +import { APP_FILTER } from "@nestjs/core"; +import { SentryGlobalFilter } from "@sentry/nestjs/setup"; @Module({ providers: [ @@ -72,7 +72,10 @@ import { SentryGlobalFilter } from '@sentry/nestjs/setup'; export class AppModule {} ``` -**Note:** In NestJS + GraphQL applications replace the `SentryGlobalFilter` with the `SentryGlobalGraphQLFilter`. +{/* TODO(v9): Remove this note. */} + +**Note:** If you have a NestJS + GraphQL application and you are using the `@sentry/nestjs` SDK version `8.38.0` or earlier, replace the `SentryGlobalFilter` with the `SentryGlobalGraphQLFilter`. +In SDK versions `8.39.0` and above, the `SentryGlobalFilter` will handle GraphQL contexts automatically. By default, exceptions with status code 4xx are not sent to Sentry. If you still want to capture these exceptions, you can do so manually with `Sentry.captureException()`: From e0b0a1498b476e462037fc1a216675fb988c3404 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 15 Nov 2024 13:58:50 +0100 Subject: [PATCH 2/3] Remove --- platform-includes/getting-started-use/javascript.nestjs.mdx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index f335893d16fa8d..1bb12212fa5db4 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -72,11 +72,6 @@ import { SentryGlobalFilter } from "@sentry/nestjs/setup"; export class AppModule {} ``` -{/* TODO(v9): Remove this note. */} - -**Note:** If you have a NestJS + GraphQL application and you are using the `@sentry/nestjs` SDK version `8.38.0` or earlier, replace the `SentryGlobalFilter` with the `SentryGlobalGraphQLFilter`. -In SDK versions `8.39.0` and above, the `SentryGlobalFilter` will handle GraphQL contexts automatically. - By default, exceptions with status code 4xx are not sent to Sentry. If you still want to capture these exceptions, you can do so manually with `Sentry.captureException()`: ```javascript {9} From 6d47dac37bf99f0aea2147e52cbfc1119788e329 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 15 Nov 2024 14:00:24 +0100 Subject: [PATCH 3/3] SentryGlobalGenericFilter --- platform-includes/getting-started-use/javascript.nestjs.mdx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index 1bb12212fa5db4..1c6117c1974c53 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -72,6 +72,11 @@ import { SentryGlobalFilter } from "@sentry/nestjs/setup"; export class AppModule {} ``` +{/* TODO(v9): Remove this note. */} + +**Note:** If you have a NestJS + GraphQL application and you are using the `@sentry/nestjs` SDK version `8.38.0` or earlier, replace the `SentryGlobalFilter` with the `SentryGlobalGenericFilter`. +In SDK versions `8.39.0` and above, the `SentryGlobalGenericFilter` is deprecated because the `SentryGlobalFilter` will handle GraphQL contexts automatically. + By default, exceptions with status code 4xx are not sent to Sentry. If you still want to capture these exceptions, you can do so manually with `Sentry.captureException()`: ```javascript {9}