Skip to content
Open
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
8 changes: 4 additions & 4 deletions docs/platforms/javascript/guides/nestjs/install/esm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

<Alert>We do not support ESM in Node versions before 18.19.0.</Alert>
Expand Down
32 changes: 18 additions & 14 deletions platform-includes/getting-started-verify/javascript.nestjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,29 @@ First, let's verify that Sentry captures errors and creates issues in your Sentr
<SplitSection>
<SplitSectionText>

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.

</SplitSectionText>
<SplitSectionCode>

```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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Why do we need this, this shuold be instrumented automatically anyway?

{
op: "test",
name: "My First Test Span",
},
() => {
throw new Error("My first Sentry error!");
}
);
}
}
```

Expand Down
Loading