Closed KarelVendla closed 4 months ago
Hi @KarelVendla thanks for writing in!
First off, technically, Nuxt isn't officially supported by Sentry. We're tracking support requests in https://github.com/getsentry/sentry-javascript/discussions/6929. Feel free to add a reply or 👍 to the discussion - this helps us prioritize things.
With that out of the way; this sounds very familiar to me and I think it is a weird interaction between Vite and the way how we re-export most functions (like captureMessage
) from sub dependencies (e.g. @sentry/core
). However, so far, I only observed this behavior on the server side. I know way too little about Nuxt plugins but it given they run on the server and you also showed a middleware snippet, I'd assume this is the case.
Please also note, using @sentry/vue
on the server side is not supported or recommended by us, as it builds on top of the @sentry/browser
package which contains a lot of browser-specific functionality.
I can't tell you how to fix this exactly but you probably need to create an index file that re-exports the necessary exports. Then you import * as Sentry from './mySentryIndexNamingIsHard'
in your plugin. This is more or less how we solved this in e.g. our SvelteKit or Astro SDKs:
https://github.com/getsentry/sentry-javascript/blob/develop/packages/sveltekit/src/server/index.ts
I'm going to close this issue as for now there's nothing concrete from our end to do (other than nuxt support in the first place, tracked in #6929). Feel free to tag me if you think this needs to be reopened. Thanks!
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/vue
SDK Version
7.102.1
Framework Version
Nuxt 3.8.2
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Import and use sentry (For example within a middleware as that is where our problems started). in my SDK setup example we have setup a sentry.ts plugin for our nuxt project.
Create a sentry plugin
exampleMiddleware.global.ts
Build nuxt project (npm run build) Run nuxt project (npm run start)
Expected Result
Expect Sentry to send a captured message on every page load to sentry.
console.logged sentry before building
Actual Result
I get an error
Console.logged Sentry after building