-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(nuxt): Add readme docs for server-side setup (ESM) #13019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,21 +102,6 @@ Sentry.init({ | |
|
||
### 4. Server-side setup | ||
|
||
Add a `sentry.server.config.(js|ts)` file to the root of your project: | ||
|
||
```javascript | ||
import * as Sentry from '@sentry/nuxt'; | ||
|
||
Sentry.init({ | ||
dsn: process.env.DSN, | ||
}); | ||
``` | ||
|
||
**Alternative Setup (ESM-compatible)** | ||
|
||
This setup makes sure Sentry is imported on the server before any other imports. As of now, this however leads to an | ||
import-in-the-middle error ([related reproduction](https://github.com/getsentry/sentry-javascript-examples/pull/38)). | ||
|
||
Add an `instrument.server.mjs` file to your `public` folder: | ||
|
||
```javascript | ||
|
@@ -130,7 +115,8 @@ if (process.env.SENTRY_DSN) { | |
} | ||
``` | ||
|
||
Add an import flag to the node options, so the file loads before any other imports: | ||
Add an import flag to the `NODE_OPTIONS` of your preview script in the `package.json`, so the file loads before any | ||
other imports: | ||
|
||
```json | ||
{ | ||
|
@@ -140,6 +126,18 @@ Add an import flag to the node options, so the file loads before any other impor | |
} | ||
``` | ||
|
||
If you are getting an `import-in-the-middle` error message, add the package with a minimum version of `1.10.0` as a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: I'm curious - Is there a concrete reason in Nuxt apps why users would run into this error? I think this is already rather specific for the SDK readme as it sounds a bit more like troubleshooting. Generally, I'd tend towards keeping the Readmes in the repo rather short in favour of more detailed docs. They almost inevitably diverge at some point 🥲 But given we don't have docs yet for nuxt we can also leave this in and rethink if we need it once we give the readme a pass before going stable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can look at this in a follow up, but maybe we can auto-add this package to the exclude config for the users 🤔 |
||
dependency to your `package.json` | ||
([issue reference](https://github.com/getsentry/sentry-javascript-examples/pull/38#issuecomment-2245259327)): | ||
|
||
```json | ||
{ | ||
"dependencies": { | ||
"import-in-the-middle": "1.10.0" | ||
} | ||
} | ||
``` | ||
|
||
### 5. Vite Setup | ||
|
||
todo: add vite setup | ||
|
Uh oh!
There was an error while loading. Please reload this page.