Skip to content
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

[Nuxt] Disable Sentry module by adding sentry.enabled to Nuxt config #14935

Open
Kapcash opened this issue Jan 8, 2025 · 1 comment
Open
Assignees

Comments

@Kapcash
Copy link

Kapcash commented Jan 8, 2025

Problem Statement

Context

When running unit tests using the defineVitestConfig method from @nuxt/test-utils/config package, it will read the nuxt.config.ts file and setup the @sentry/nuxt module if found in the modules array.

This causes the sentry vite plugin to boot and it logs warnings from sentry:

[Sentry] Enabled source map generation in the build options with `nitro.rollupConfig.output.sourcemap: hidden`.
module.mjs:367
[Sentry] Disabled source map setting in the Nuxt config: `nitro.rollupConfig.output.sourcemapExcludeSources`. Source maps will include the actual code to be able to un-minify code snippets in Sentry.
module.mjs:343
[Sentry] Setting `sentry.sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload: [".*/**/public/**/*.map"]` to delete generated source maps after they were uploaded to Sentry.
module.mjs:227
[sentry-rollup-plugin] Warning: No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-rollup-plugin] Warning: No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-vite-plugin] Warning: No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-vite-plugin] Warning: No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
index.mjs:8919
[sentry-vite-plugin] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.

Note: the "No auth token provided" warning is because the environment variable I configured is not available in test mode.

Expected behaviour

I want to be able to disable the Sentry module during test mode, so I don't have these logs everytime I run the tests, and also because it seems like Sentry is gonna run along with my tests, which I don't really want.

A workaround I found is to conditionally add the module depending on the NODE_ENV variable:

// nuxt.config.ts
  modules: [
    process.env.NODE_ENV !== 'test' && '@sentry/nuxt/module',
  ],

Doing so, the module is not added and therefore not setup in my test environment.

Solution Brainstorm

Maybe simply an enabled configuration boolean on the module so we can opt-out conditionally?

// nuxt.config.ts

sentry: {
  enabled: process.env.NODE_ENV !== 'test',
},
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 8, 2025
@s1gr1d s1gr1d self-assigned this Jan 8, 2025
@s1gr1d
Copy link
Member

s1gr1d commented Jan 8, 2025

This came up already and I think it's a good idea. I'll put it in the backlog.

@getsantry getsantry bot removed the status in GitHub Issues with 👀 3 Jan 8, 2025
@s1gr1d s1gr1d changed the title [Nuxt] Disable Sentry module in test mode [Nuxt] Disable Sentry module by adding sentry.enabled to Nuxt config Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants