@@ -28,18 +28,30 @@ The minimum supported version of Nuxt is `3.0.0`.
28
28
This package is a wrapper around ` @sentry/node ` for the server and ` @sentry/vue ` for the client side, with added
29
29
functionality related to Nuxt.
30
30
31
- What is working:
31
+ ** What is working:**
32
32
33
33
- Error Reporting
34
+ - Vue
35
+ - Node
36
+ - Nitro
34
37
35
- What is partly working:
38
+ ** What is partly working:**
36
39
37
40
- Tracing by setting ` tracesSampleRate `
41
+ - UI (Vue) traces
42
+ - HTTP (Node) traces
38
43
39
- What is not yet(!) included:
44
+ ** What is not yet(!) included:**
40
45
41
46
- 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
43
55
44
56
## Automatic Setup
45
57
@@ -96,10 +108,38 @@ Add a `sentry.server.config.(js|ts)` file to the root of your project:
96
108
import * as Sentry from ' @sentry/nuxt' ;
97
109
98
110
Sentry .init ({
99
- dsn: env .DSN ,
111
+ dsn: process . env .DSN ,
100
112
});
101
113
```
102
114
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
+
103
143
### 5. Vite Setup
104
144
105
145
todo: add vite setup
0 commit comments