Skip to content

Commit b0b631e

Browse files
committed
Add Sentry usage to ESM docs
1 parent a319b76 commit b0b631e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/esm.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ node --env-file=.env -r @aikidosec/firewall/instrument your-app.js
3131
> [!NOTE]
3232
> The `--env-file` flag cannot be used in `NODE_OPTIONS`.
3333
34+
## Use Zen together with Sentry (ESM)
35+
36+
You need to use Node.js v24.11.1 / v25.1.0 or later to use Zen together with Sentry in an ESM application.
37+
Follow the [Sentry instructions for ESM](https://docs.sentry.io/platforms/javascript/guides/node/install/esm/) to set up Sentry. After that, add the Zen import inside the `instrument.mjs` file as shown below.
38+
39+
```js
40+
import "@aikidosec/firewall/instrument";
41+
import * as Sentry from "@sentry/node";
42+
43+
Sentry.init({
44+
// ...
45+
});
46+
```
47+
48+
Import the `instrument.mjs` file using the `--import` flag when starting your application. The `-r @aikidosec/firewall/instrument` CLI flag is not needed in this case.
49+
50+
```sh
51+
node --import ./instrument.mjs your-app.js
52+
```
53+
3454
## Known issues
3555

3656
- Zen can not protect ESM sub-dependencies of an ESM package. For example if an ESM package `foo` imports a sub-dependency `bar` that is also an ESM package, Zen will not be able to protect the code in `bar`. This is because the V8 engine does not allow Node.js to observe the evaluation of inner ESM packages (yet). Open issue: [Adding an evaluation hook for v8::Module](https://issues.chromium.org/u/1/issues/384413088). See a full example below.

0 commit comments

Comments
 (0)