From a508319f9500bc6fe1ae0efe2a31109501768a88 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Fri, 4 Oct 2024 14:48:44 +0200 Subject: [PATCH 1/3] feat(nuxt): Add warning when Netlify build discovered --- packages/nuxt/src/module.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index 4f6fe76928cd..09ff2e0745d6 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -88,6 +88,17 @@ export default defineNuxtModule({ }); } + consoleSandbox(() => { + const serverDir = nitro.options.output.serverDir; + + if (serverDir.includes('.netlify')) { + // eslint-disable-next-line no-console + console.warn( + '[Sentry] Warning: The Sentry SDK discovered a Netlify build. The server-side Sentry support with ESM is experimental and may not work as expected. Please check out the docs for how to use Sentry on different deployment providers: https://docs.sentry.io/platforms/javascript/guides/nuxt/deployment-provider-setup/', + ); + } + }); + if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') { addServerConfigToBuild(moduleOptions, nuxt, nitro, serverConfigFile); From c5f57b21d3a093947aca54ad646c3b77b798def4 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Thu, 5 Dec 2024 13:00:30 +0100 Subject: [PATCH 2/3] change warning log and add vercel --- packages/nuxt/src/module.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index 09ff2e0745d6..bc0980ff6e39 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -91,10 +91,19 @@ export default defineNuxtModule({ consoleSandbox(() => { const serverDir = nitro.options.output.serverDir; - if (serverDir.includes('.netlify')) { + // Netlify env: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata + if (serverDir.includes('.netlify') || !!process.env.NETLIFY) { // eslint-disable-next-line no-console console.warn( - '[Sentry] Warning: The Sentry SDK discovered a Netlify build. The server-side Sentry support with ESM is experimental and may not work as expected. Please check out the docs for how to use Sentry on different deployment providers: https://docs.sentry.io/platforms/javascript/guides/nuxt/deployment-provider-setup/', + '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and some errors may not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/', + ); + } + + // Vercel env: https://vercel.com/docs/projects/environment-variables/system-environment-variables#VERCEL + if (serverDir.includes('.vercel') || !!process.env.VERCEL) { + // eslint-disable-next-line no-console + console.warn( + '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK support for ESM on Vercel is currently experimental. Traces are not collected, but errors are reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/', ); } }); From 344a09360b02e9300c2696d2cba4be9da6e6b28b Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Thu, 5 Dec 2024 15:47:15 +0100 Subject: [PATCH 3/3] review suggestions --- packages/nuxt/src/module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index bc0980ff6e39..e246430f69d6 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -95,7 +95,7 @@ export default defineNuxtModule({ if (serverDir.includes('.netlify') || !!process.env.NETLIFY) { // eslint-disable-next-line no-console console.warn( - '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and some errors may not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/', + '[Sentry] Warning: The Sentry SDK detected a Netlify build. Server-side support for the Sentry Nuxt SDK on Netlify is currently unreliable due to technical limitations of serverless functions. Traces are not collected, and errors may occasionally not be reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/', ); } @@ -103,7 +103,7 @@ export default defineNuxtModule({ if (serverDir.includes('.vercel') || !!process.env.VERCEL) { // eslint-disable-next-line no-console console.warn( - '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK support for ESM on Vercel is currently experimental. Traces are not collected, but errors are reported. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/', + '[Sentry] Warning: The Sentry SDK detected a Vercel build. The Sentry Nuxt SDK currently does not support tracing on Vercel. For more information on setting up Sentry on the Nuxt server-side, please refer to the documentation: https://docs.sentry.io/platforms/javascript/guides/nuxt/install/', ); } });