Skip to content

Commit 6ba59c5

Browse files
s1gr1dmydea
andauthored
docs(nuxt): Add additional information in readme (#12850)
Co-authored-by: Francesco Novy <[email protected]>
1 parent 3ad3bdd commit 6ba59c5

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

packages/nuxt/README.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,30 @@ The minimum supported version of Nuxt is `3.0.0`.
2828
This package is a wrapper around `@sentry/node` for the server and `@sentry/vue` for the client side, with added
2929
functionality related to Nuxt.
3030

31-
What is working:
31+
**What is working:**
3232

3333
- Error Reporting
34+
- Vue
35+
- Node
36+
- Nitro
3437

35-
What is partly working:
38+
**What is partly working:**
3639

3740
- Tracing by setting `tracesSampleRate`
41+
- UI (Vue) traces
42+
- HTTP (Node) traces
3843

39-
What is not yet(!) included:
44+
**What is not yet(!) included:**
4045

4146
- Source Maps
42-
- Connected Traces
47+
- Nuxt-specific traces and connecting frontend & backend traces
48+
49+
**Known Issues:**
50+
51+
- When adding `sentry.server.config.(ts/js)`, you get this error: "Failed to register ESM hook", but the application
52+
will still work
53+
- When initializing Sentry on the server with `instrument.server.(js|ts)`, you get an `'import-in-the-middle'` error,
54+
and the application won't work
4355

4456
## Automatic Setup
4557

@@ -96,10 +108,38 @@ Add a `sentry.server.config.(js|ts)` file to the root of your project:
96108
import * as Sentry from '@sentry/nuxt';
97109

98110
Sentry.init({
99-
dsn: env.DSN,
111+
dsn: process.env.DSN,
100112
});
101113
```
102114

115+
**Alternative Setup (ESM-compatible)**
116+
117+
This setup makes sure Sentry is imported on the server before any other imports. As of now, this however leads to an
118+
import-in-the-middle error ([related reproduction](https://github.com/getsentry/sentry-javascript-examples/pull/38)).
119+
120+
Add a `instrument.server.(js|ts)` file to your `public` folder:
121+
122+
```javascript
123+
import * as Sentry from '@sentry/nuxt';
124+
125+
// Only run `init` when DSN is available
126+
if (process.env.SENTRY_DSN) {
127+
Sentry.init({
128+
dsn: process.env.DSN,
129+
});
130+
}
131+
```
132+
133+
Add an import flag to the node options, so the file loads before any other imports:
134+
135+
```json
136+
{
137+
"scripts": {
138+
"preview": "NODE_OPTIONS='--import ./public/instrument.server.mjs' nuxt preview"
139+
}
140+
}
141+
```
142+
103143
### 5. Vite Setup
104144

105145
todo: add vite setup

0 commit comments

Comments
 (0)