[Nuxt]: Wrong issue environment tag
Is there an existing issue for this?
- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [x] I have reviewed the documentation https://docs.sentry.io/
- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nuxt
SDK Version
9.5.0
Framework Version
No response
Link to Sentry event
https://sentry-pri-nuxt.sentry.io/issues/32395492/events/8dfaac86dd084cc19ec6cea251cf4958/
Reproduction Example/SDK Setup
No response
Steps to Reproduce
- Create a new Nuxt project by following the official guide here: Nuxt Installation Guide.
- Set up a new organization in Sentry.
- Create a new Nuxt project in Sentry.
- Use the Sentry wizard to instrument the Nuxt project.
- Run
yarn devto start the development environment. - Trigger an error in the application.
- Go to the issue details in Sentry.
- The 'environment' tag should be set to 'dev'/'development' instead of 'production'.
Expected Result
The 'environment' tag should be set to 'dev'/'development' instead of 'production'.
Actual Result
Currently I am seeing 'production'
- Contributes to https://github.com/getsentry/sentry/issues/79408#issuecomment-2706156295
I think this is a larger issue than Nuxt because at this point, our SDKs don't universally auto-detect environemnt.
Most importantly, it's almost impossible to auto-detect dev vs prod reliably, especially in browser-side SDKs.
I checked various SDKs for environment default values:
- In some SDKs we check
process.env.NODE_ENV(e.g. remix), - in the Node SDK we allow users to set the
SENTRY_ENVIRONMENTenv variable. - In NextJS (server-side) we check for the vercel env
- by default afaict, we don't set any environment tag which makes Relay set
production
I actually don't know what the expected behaviour is and how SDKs of other languages handle this. We should investigate this further and ideally settle on common behaviour. Thanks for raising!
This is more about the dev mode environment, right?
Someone created a PR for Nuxt but we closed it as it was not finished (https://github.com/getsentry/sentry-javascript/pull/15179). We can pick it up again but I think it would make sense to create a solution to detect the dev environment for all SDKs.
In the case of Nuxt, it's just looking for import.meta.dev as it is Vite-based. We could just check what's available during dev mode.
heads-up: I took the liberty to re-classify this as an Improvement instead of a bug. So far this was somewhat "expected" SDK behaviour.
same as : #15147