Skip to content

Suggest not to use SentryGlobalGraphQLFilter in newer SDK versions #11832

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

Merged
merged 3 commits into from
Nov 19, 2024
Merged
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
29 changes: 16 additions & 13 deletions platform-includes/getting-started-use/javascript.nestjs.mdx
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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],
Expand Down Expand Up @@ -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: [
Expand All @@ -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 `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()`:

Expand Down
Loading