diff --git a/docs/platforms/javascript/guides/nestjs/install/esm.mdx b/docs/platforms/javascript/guides/nestjs/install/esm.mdx index 9ba9ba454e9a06..7a8297bd044044 100644 --- a/docs/platforms/javascript/guides/nestjs/install/esm.mdx +++ b/docs/platforms/javascript/guides/nestjs/install/esm.mdx @@ -28,17 +28,17 @@ Sentry.init({ }); ``` -**Step 2:** Adjust your application's start command to use the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter: +**Step 2:** Load `instrument.mjs` with the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter when your application starts. Set it through `NODE_OPTIONS`, which applies to the Node.js process that runs your app: ```bash # Note: This is only available for Node v18.19.0 onwards. -"start": "--import ./instrument.mjs nest start" +NODE_OPTIONS="--import ./instrument.mjs" nest start ``` -If you can't pass the `--import` flag to the Node.js binary, you can alternatively use the `NODE_OPTIONS` environment variable as follows: +If you run your build output directly, pass the flag to `node` instead: ```bash -NODE_OPTIONS="--import ./instrument.mjs" npm run start +node --import ./instrument.mjs dist/main.js ``` We do not support ESM in Node versions before 18.19.0. diff --git a/platform-includes/getting-started-verify/javascript.nestjs.mdx b/platform-includes/getting-started-verify/javascript.nestjs.mdx index a8e42429fd124f..0bfc2204712701 100644 --- a/platform-includes/getting-started-verify/javascript.nestjs.mdx +++ b/platform-includes/getting-started-verify/javascript.nestjs.mdx @@ -27,25 +27,29 @@ First, let's verify that Sentry captures errors and creates issues in your Sentr -To test your tracing configuration, update the previous code snippet by starting a performance trace to measure the time it takes for the execution of your code. +To test your tracing configuration, update the previous code snippet to start a span around the error. The span is recorded as part of the request's trace. -```javascript -@Get("/debug-sentry") +```javascript {filename:app.controller.ts} +import { Controller, Get } from "@nestjs/common"; +import * as Sentry from "@sentry/nestjs"; + +@Controller() +export class AppController { + @Get("/debug-sentry") getError() { - Sentry.startSpan( - { - op: "test", - name: "My First Test Transaction", - }, - () => { - setTimeout(() => { - throw new Error("My first Sentry error!"); - }, 99); - }, - ); + return Sentry.startSpan( + { + op: "test", + name: "My First Test Span", + }, + () => { + throw new Error("My first Sentry error!"); + } + ); + } } ```