From f7105a78208f30887283b56e19f0f3a00e5db441 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Fri, 18 Oct 2024 15:44:52 +0200 Subject: [PATCH 1/3] docs(nuxt): Manual setup for beta --- .../javascript.nuxt.mdx | 36 +++++++------------ .../javascript.nuxt.mdx | 2 +- .../javascript.nuxt.mdx | 9 +++++ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/platform-includes/getting-started-config/javascript.nuxt.mdx b/platform-includes/getting-started-config/javascript.nuxt.mdx index 1d49cbbabeddb2..673fdd2246c056 100644 --- a/platform-includes/getting-started-config/javascript.nuxt.mdx +++ b/platform-includes/getting-started-config/javascript.nuxt.mdx @@ -1,7 +1,7 @@ To set up the Sentry SDK, register the Sentry Nuxt module and initialize the SDK for client and server. At build time, the Sentry Nuxt Module looks for the following two files: -- Client-Side: `sentry.client.config.(js|ts)` in the root containing `Sentry.init` -- Server-Side: `instrument.server.mjs` in the `public` directory containing `Sentry.init` +- Client-Side: `sentry.client.config.ts` in the root containing `Sentry.init` +- Server-Side: `sentry.server.config.ts` in the root containing `Sentry.init` In these files, you can specify the full range of Sentry SDK options. @@ -44,40 +44,28 @@ Sentry.init({ import * as Sentry from '@sentry/nuxt'; Sentry.init({ - dsn: "___PUBLIC_DSN___" + dsn: "___PUBLIC_DSN___", + + // We recommend adjusting this value in production, or using tracesSampler + // for finer control + tracesSampleRate: 1.0 }); ``` The Nuxt `useRuntimeConfig()` does not work in the Sentry server config due to technical reasons (the config file has to be loaded before Nuxt is loaded). To be able to use `process.env` you either have to add `--env-file=.env` to your node command -or use the `dotenv` package: -```bash {tabTitle: env-file} -node --env-file=.env --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs +```bash {tabTitle: node} +node --env-file=.env .output/server/index.mjs ``` +or use the `dotenv` package: - -```javascript {tabTitle: dotenv} {filename:sentry.server.config.ts} {1,4} +```javascript {tabTitle: Server Config} {filename:sentry.server.config.ts} {1,3} import dotenv from 'dotenv'; -import * as Sentry from '@sentry/nuxt'; dotenv.config(); -Sentry.init({ - dsn: "___PUBLIC_DSN___" -}); +// ... rest of the file ``` -2. Add an [--import flag](https://nodejs.org/api/cli.html#--importmodule) to the Node options of your `node` command you run -in production (not `nuxt preview`), so the file loads before any other imports (keep in mind the `.mjs` file ending). -Depending on your setup, you might need to adjust the path to the `sentry.server.config.mjs` file: - -```json {filename:package.json} {4} -{ - "scripts": { - "preview": "nuxt preview", - "start": "node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs" - } -} -``` diff --git a/platform-includes/getting-started-primer/javascript.nuxt.mdx b/platform-includes/getting-started-primer/javascript.nuxt.mdx index fa793c6a02b4bd..9449c322619f6c 100644 --- a/platform-includes/getting-started-primer/javascript.nuxt.mdx +++ b/platform-includes/getting-started-primer/javascript.nuxt.mdx @@ -1,4 +1,4 @@ - This SDK is considered **experimental and in an alpha state**. It may experience breaking changes. Please reach out on + This SDK is **in an beta state**. It may experience breaking changes. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns. diff --git a/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx b/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx index 0ae7f5defe1021..e507915b6462de 100644 --- a/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx +++ b/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx @@ -24,3 +24,12 @@ export default defineNuxtConfig({ } }); ``` + +Nuxt sets default values for the source maps ([Nuxt docs](https://nuxt.com/docs/api/nuxt-config#sourcemap)) and the SDK currently keeps the source maps settings if they are explicitly defined. +To enable this source maps setting, add the following code to you Nuxt config: + +```javascript {filename:nuxt.config.ts} {2} +export default defineNuxtConfig({ + sourcemap: { client: true } +}); +``` From 36eeb6a1a976ef03600c1c63268e61e05e953e0e Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Fri, 18 Oct 2024 16:20:47 +0200 Subject: [PATCH 2/3] review comments --- .../getting-started-primer/javascript.nuxt.mdx | 2 +- .../getting-started-sourcemaps/javascript.nuxt.mdx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/platform-includes/getting-started-primer/javascript.nuxt.mdx b/platform-includes/getting-started-primer/javascript.nuxt.mdx index 9449c322619f6c..440506e7a340a1 100644 --- a/platform-includes/getting-started-primer/javascript.nuxt.mdx +++ b/platform-includes/getting-started-primer/javascript.nuxt.mdx @@ -1,4 +1,4 @@ - This SDK is **in an beta state**. It may experience breaking changes. Please reach out on + This SDK is **in an beta state**. It may still experience changes in behavior. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns. diff --git a/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx b/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx index e507915b6462de..af914e6a290bc5 100644 --- a/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx +++ b/platform-includes/getting-started-sourcemaps/javascript.nuxt.mdx @@ -25,11 +25,13 @@ export default defineNuxtConfig({ }); ``` -Nuxt sets default values for the source maps ([Nuxt docs](https://nuxt.com/docs/api/nuxt-config#sourcemap)) and the SDK currently keeps the source maps settings if they are explicitly defined. -To enable this source maps setting, add the following code to you Nuxt config: +To upload source maps, the Sentry Nuxt Module will automatically enable source map generation in your project if it is not already enabled. +However, you need to explicitly enable source map generation on the client-side. To do this, add the following code to your Nuxt configuration: ```javascript {filename:nuxt.config.ts} {2} export default defineNuxtConfig({ sourcemap: { client: true } }); ``` + +This step is necessary because Nuxt sets default values for source maps ([Nuxt docs](https://nuxt.com/docs/api/nuxt-config#sourcemap)), and the Sentry Nuxt Module keeps these settings when they are explicitly defined. From 4ec71d28821f7485739cd4996c6fc7697b85ab87 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 21 Oct 2024 10:21:04 +0200 Subject: [PATCH 3/3] add note about different deployment providers --- platform-includes/getting-started-config/javascript.nuxt.mdx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform-includes/getting-started-config/javascript.nuxt.mdx b/platform-includes/getting-started-config/javascript.nuxt.mdx index 673fdd2246c056..1adacfbb3cf7ac 100644 --- a/platform-includes/getting-started-config/javascript.nuxt.mdx +++ b/platform-includes/getting-started-config/javascript.nuxt.mdx @@ -69,3 +69,8 @@ dotenv.config(); // ... rest of the file ``` + + + In the beta state of the Nuxt SDK, some features may not work with certain deployment providers. Check the progress on GitHub: [Compatibility with different Deployment Platforms](https://github.com/getsentry/sentry-javascript/issues/14029) + +