Skip to content

Commit

Permalink
docs(nuxt): Add additional information in readme (#12850)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Novy <[email protected]>
  • Loading branch information
s1gr1d and mydea authored Jul 10, 2024
1 parent 3ad3bdd commit 6ba59c5
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions packages/nuxt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,30 @@ The minimum supported version of Nuxt is `3.0.0`.
This package is a wrapper around `@sentry/node` for the server and `@sentry/vue` for the client side, with added
functionality related to Nuxt.

What is working:
**What is working:**

- Error Reporting
- Vue
- Node
- Nitro

What is partly working:
**What is partly working:**

- Tracing by setting `tracesSampleRate`
- UI (Vue) traces
- HTTP (Node) traces

What is not yet(!) included:
**What is not yet(!) included:**

- Source Maps
- Connected Traces
- Nuxt-specific traces and connecting frontend & backend traces

**Known Issues:**

- When adding `sentry.server.config.(ts/js)`, you get this error: "Failed to register ESM hook", but the application
will still work
- When initializing Sentry on the server with `instrument.server.(js|ts)`, you get an `'import-in-the-middle'` error,
and the application won't work

## Automatic Setup

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

Sentry.init({
dsn: env.DSN,
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 a `instrument.server.(js|ts)` file to your `public` folder:

```javascript
import * as Sentry from '@sentry/nuxt';

// Only run `init` when DSN is available
if (process.env.SENTRY_DSN) {
Sentry.init({
dsn: process.env.DSN,
});
}
```

Add an import flag to the node options, so the file loads before any other imports:

```json
{
"scripts": {
"preview": "NODE_OPTIONS='--import ./public/instrument.server.mjs' nuxt preview"
}
}
```

### 5. Vite Setup

todo: add vite setup
Expand Down

0 comments on commit 6ba59c5

Please sign in to comment.