From 495e594d21713cdc9282299eb699d108414c789d Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Mon, 4 Nov 2024 13:26:40 +0100 Subject: [PATCH 01/10] switch esm and commonjs --- .../javascript.nestjs.mdx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/platform-includes/getting-started-config/javascript.nestjs.mdx b/platform-includes/getting-started-config/javascript.nestjs.mdx index f251262e7edce..3d8b8b3531c49 100644 --- a/platform-includes/getting-started-config/javascript.nestjs.mdx +++ b/platform-includes/getting-started-config/javascript.nestjs.mdx @@ -1,8 +1,8 @@ -```javascript {tabTitle:CommonJS} {filename: instrument.js} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}} -const Sentry = require("@sentry/nestjs"); -const { nodeProfilingIntegration } = require("@sentry/profiling-node"); +```javascript {tabTitle:ESM} {filename: instrument.mjs} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}} +import * as Sentry from "@sentry/nestjs"; +import { nodeProfilingIntegration } from '@sentry/profiling-node'; -// Ensure to call this before requiring any other modules! +// Ensure to call this before importing any other modules! Sentry.init({ dsn: "___PUBLIC_DSN___", integrations: [ @@ -20,11 +20,11 @@ Sentry.init({ }); ``` -```javascript {tabTitle:ESM} {filename: instrument.mjs} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}} -import * as Sentry from "@sentry/nestjs"; -import { nodeProfilingIntegration } from '@sentry/profiling-node'; +```javascript {tabTitle:CommonJS} {filename: instrument.js} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}} +const Sentry = require("@sentry/nestjs"); +const { nodeProfilingIntegration } = require("@sentry/profiling-node"); -// Ensure to call this before importing any other modules! +// Ensure to call this before requiring any other modules! Sentry.init({ dsn: "___PUBLIC_DSN___", integrations: [ @@ -41,3 +41,4 @@ Sentry.init({ profilesSampleRate: 1.0, }); ``` + From acbb11a6748e97b8ea52fb96aba9de8b1e3346cd Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Tue, 5 Nov 2024 14:02:32 +0100 Subject: [PATCH 02/10] add filename --- platform-includes/getting-started-use/javascript.nestjs.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index 0c94c841ef363..c135baf7a3e65 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -55,7 +55,7 @@ In case you do not have a global catch-all exception filter, add the `SentryGlob module. This filter will report all unhandled errors to Sentry that are not caught by any other error filter. **Important:** The `SentryGlobalFilter` needs to be registered before any other exception filters. -```javascript {3, 9} +```javascript {filename: app.module.ts} {3, 9} import { Module } from '@nestjs/common'; import { APP_FILTER } from '@nestjs/core'; import { SentryGlobalFilter } from '@sentry/nestjs/setup'; From ce9f19650ba81aae15021da0205325d2bda81a49 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Tue, 5 Nov 2024 14:07:36 +0100 Subject: [PATCH 03/10] update global filter --- platform-includes/getting-started-use/javascript.nestjs.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index c135baf7a3e65..898fa7a396b5a 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -58,13 +58,13 @@ module. This filter will report all unhandled errors to Sentry that are not caug ```javascript {filename: app.module.ts} {3, 9} import { Module } from '@nestjs/common'; import { APP_FILTER } from '@nestjs/core'; -import { SentryGlobalFilter } from '@sentry/nestjs/setup'; +import { SentryGlobalGenericFilter } from '@sentry/nestjs/setup'; @Module({ providers: [ { provide: APP_FILTER, - useClass: SentryGlobalFilter, + useClass: SentryGlobalGenericFilter, }, // ..other providers ], @@ -72,7 +72,7 @@ import { SentryGlobalFilter } from '@sentry/nestjs/setup'; export class AppModule {} ``` -**Note:** In NestJS + GraphQL applications replace the `SentryGlobalFilter` with the `SentryGlobalGraphQLFilter`. +**Note:** SentryGlobalGenericFilter will catch both HTTP and GraphQL errors. 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 30caea5382302c2dcd12da421c3225d5de9d60bc Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Fri, 15 Nov 2024 10:19:22 +0100 Subject: [PATCH 04/10] add docs for event emitter --- .../guides/nestjs/features/event-emitter.mdx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx new file mode 100644 index 0000000000000..9144481a25779 --- /dev/null +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -0,0 +1,18 @@ +--- +title: NestJS Event Emitter +description: "Learn about instrumenting NestJS event based services." +--- + + + The @nestjs/event-emitter module is auto-instrumented from version `@sentry/nestjs` 8.39.0 and up. + + +The NestJS SDK wraps the `@OnEvent` decorator automatically to: + +- Create performance traces for event handler executions +- Automatically capture any unhandled exceptions that occur in event handlers +- Maintain visibility into asynchronous event-driven flows + +When an event handler is executed, a new span is created to track its performance, and any errors are automatically reported to Sentry while preserving the original error behavior. + +This instrumentation works transparently with existing NestJS event handlers without requiring any code changes to your application. \ No newline at end of file From 235fafc9bb108adb741457d802719f75ea4497d7 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Fri, 15 Nov 2024 10:21:14 +0100 Subject: [PATCH 05/10] update global filter --- platform-includes/getting-started-use/javascript.nestjs.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index 898fa7a396b5a..7dea03cd96e4c 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -51,9 +51,9 @@ export class YourCatchAllExceptionFilter implements ExceptionFilter { } ``` -In case you do not have a global catch-all exception filter, add the `SentryGlobalFilter` to the providers of your main +In case you do not have a global catch-all exception filter, add the `SentryGlobalGenericFilter` to the providers of your main module. This filter will report all unhandled errors to Sentry that are not caught by any other error filter. -**Important:** The `SentryGlobalFilter` needs to be registered before any other exception filters. +**Important:** The `SentryGlobalGenericFilter` needs to be registered before any other exception filters. ```javascript {filename: app.module.ts} {3, 9} import { Module } from '@nestjs/common'; From 5262c3fd62912d6452c736ea1b09ed9b87614691 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 21 Nov 2024 10:06:46 +0100 Subject: [PATCH 06/10] Update docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx Co-authored-by: Alex Krawiec --- .../javascript/guides/nestjs/features/event-emitter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx index 9144481a25779..6115e351b9b1c 100644 --- a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -1,6 +1,6 @@ --- title: NestJS Event Emitter -description: "Learn about instrumenting NestJS event based services." +description: "Learn about instrumenting NestJS event-based services." --- From 9e7980fb2026f9a242fdf576634c86d2f835a5a8 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 21 Nov 2024 10:06:55 +0100 Subject: [PATCH 07/10] Update docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx Co-authored-by: Alex Krawiec --- .../javascript/guides/nestjs/features/event-emitter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx index 6115e351b9b1c..3623b52a6ab7d 100644 --- a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -9,7 +9,7 @@ description: "Learn about instrumenting NestJS event-based services." The NestJS SDK wraps the `@OnEvent` decorator automatically to: -- Create performance traces for event handler executions +- Create performance traces for event handler executions. - Automatically capture any unhandled exceptions that occur in event handlers - Maintain visibility into asynchronous event-driven flows From 38b6da5e1c429b8d040d26ea6a70e792c1396a0f Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 21 Nov 2024 10:07:05 +0100 Subject: [PATCH 08/10] Update docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx Co-authored-by: Alex Krawiec --- .../javascript/guides/nestjs/features/event-emitter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx index 3623b52a6ab7d..f60c16c59f62d 100644 --- a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -11,7 +11,7 @@ The NestJS SDK wraps the `@OnEvent` decorator automatically to: - Create performance traces for event handler executions. - Automatically capture any unhandled exceptions that occur in event handlers -- Maintain visibility into asynchronous event-driven flows +- Maintain visibility into asynchronous event-driven flows. When an event handler is executed, a new span is created to track its performance, and any errors are automatically reported to Sentry while preserving the original error behavior. From 5e1f6244f0d05b58cd7dc69e29d1263c55e4fcce Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 21 Nov 2024 10:07:13 +0100 Subject: [PATCH 09/10] Update docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx Co-authored-by: Alex Krawiec --- .../javascript/guides/nestjs/features/event-emitter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx index f60c16c59f62d..9349ef66a2504 100644 --- a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -10,7 +10,7 @@ description: "Learn about instrumenting NestJS event-based services." The NestJS SDK wraps the `@OnEvent` decorator automatically to: - Create performance traces for event handler executions. -- Automatically capture any unhandled exceptions that occur in event handlers +- Automatically capture any unhandled exceptions that occur in event handlers. - Maintain visibility into asynchronous event-driven flows. When an event handler is executed, a new span is created to track its performance, and any errors are automatically reported to Sentry while preserving the original error behavior. From d71b3884901bdf034bf83f13a973200a72c37aba Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 21 Nov 2024 10:07:24 +0100 Subject: [PATCH 10/10] Update docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx Co-authored-by: Alex Krawiec --- .../javascript/guides/nestjs/features/event-emitter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx index 9349ef66a2504..eb381e5f0f31f 100644 --- a/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx +++ b/docs/platforms/javascript/guides/nestjs/features/event-emitter.mdx @@ -4,7 +4,7 @@ description: "Learn about instrumenting NestJS event-based services." --- - The @nestjs/event-emitter module is auto-instrumented from version `@sentry/nestjs` 8.39.0 and up. + The @nestjs/event-emitter module is auto-instrumented in `@sentry/nestjs` 8.39.0 and up. The NestJS SDK wraps the `@OnEvent` decorator automatically to: