From 05e4c94cc1fac7ecb421c6b28a00959ecc25f8bd Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Wed, 10 Jul 2024 14:59:11 +0200 Subject: [PATCH 1/3] docs(nuxt): Add additional information in readme --- packages/nuxt/README.md | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/packages/nuxt/README.md b/packages/nuxt/README.md index 163d92836897..a287e24bf73b 100644 --- a/packages/nuxt/README.md +++ b/packages/nuxt/README.md @@ -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 no connected 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 @@ -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. 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 From c94bcea92959480f02ba68ef68f5a6037c9e2626 Mon Sep 17 00:00:00 2001 From: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:52:44 +0200 Subject: [PATCH 2/3] Update packages/nuxt/README.md Co-authored-by: Francesco Novy --- packages/nuxt/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/README.md b/packages/nuxt/README.md index a287e24bf73b..f3f0fc97ae2a 100644 --- a/packages/nuxt/README.md +++ b/packages/nuxt/README.md @@ -44,7 +44,7 @@ functionality related to Nuxt. **What is not yet(!) included:** - Source Maps -- Nuxt-specific traces and no connected traces +- Nuxt-specific traces and connecting frontend & backend traces **Known Issues:** From 013d47b0d52c7b40c0555016f2d75a912dedb4d6 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Wed, 10 Jul 2024 16:54:26 +0200 Subject: [PATCH 3/3] review changes --- packages/nuxt/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/README.md b/packages/nuxt/README.md index f3f0fc97ae2a..9ce6e908a793 100644 --- a/packages/nuxt/README.md +++ b/packages/nuxt/README.md @@ -114,7 +114,7 @@ Sentry.init({ **Alternative Setup (ESM-compatible)** -This setup makes sure Sentry is imported on the server before any other imports. This however leads to an +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: