sentry config issues
Was looking at my sentry config and noticed a couple of issues
- I'd like to add a whitelistUrls array to my config, but the options of this array are merged on every build. So after 3 builds my urls are all listed three times (in sentry.server.config.js)
- Whitelist urls in Sentry should allow for regexp, but these arent correctly stringified atm. I tihnk we could check for
value instanceof RegExpand then just callvalue.toString()? - Functions arent correctly stringified. Id like to try using sentry's user feedback feature but then you need to pass a
beforeSendfn to your options. Nuxt should already provide aserializeFunctionhelper in the template context, maybe we could use that or did you use String for functions on purpose?
Looking at it a bit more maybe it doesnt matter at all because these props arent used when reading sentry.server.config.js?
- I'd like to add a whitelistUrls array to my config, but the options of this array are merged on every build.
I was checking this out and there actually seems to be pretty bad issue that drops whitelistUrls (or any other customizations in config.serverConfig). The code in initSentry called from:
this.nuxt.hook('listen', () => listenHook(this, options))
is overwriting config.serverConfig.
Well, as you said, it works in practice but still is kinda unexpected.
Whitelist urls in Sentry should allow for regexp, but these arent correctly stringified atm. I tihnk we could check for value instanceof RegExp and then just call value.toString()?
👍
- Functions arent correctly stringified. Id like to try using sentry's user feedback feature but then you need to pass a
beforeSendfn to your options. Nuxt should already provide aserializeFunctionhelper in the template context, maybe we could use that or did you use String for functions on purpose?
As you probably know, the core team discourages serialization of functions. The options are:
- override module's plugin by create a file in
app/plugin-name.js - just creating a normal plugin that extends functionality (but maybe wouldn't work in this case)
- (my favourite but not necessarily core's team favourite) assign a path to the option like
beforeSend: '~/config/sentry-before-send.js'and import that within the module.
(see also internal discussion about that at https://discord.com/channels/473401852243869706/735157506300575775/747511148282118495 )
Thanks. Actually I dont have a big issue with serializing functions, at least not in how we should use them here as part of an external config object. I agree we should discourage it as much as possible and should look for a better way of passing module options in v3, but for v2 we shouldnt implement & spent time on implementations mostly for the sake of code purity. Especially when it only makes configuration more difficult and isnt rly needed for like 99% of the use-cases.
HI, facing an issue while configuring sentry using @nuxtjs.sentry in nuxt3:
Object literal may only specify known properties, and 'sentry' does not exist in type 'NuxtConfig'.ts(2345)
My 'nuxt.config.ts' is as follows: `// https://nuxt.com/docs/api/configuration/nuxt-config // import { defineNuxtConfig } from 'nuxt3';
export default defineNuxtConfig({ modules: ['@nuxtjs/sentry', '@sentry/tracing', 'nuxt-windicss'], sentry: { dsn: 'https://[email protected]/4504229195677696', tracing: { tracesSampleRate: 1.0, vueOptions: { tracing: true, tracingOptions: { hooks: ['mount', 'update'], timeout: 2000, trackComponents: true, }, }, browserOptions: {}, }, }, runtimeConfig: { // The private keys which are only available server-side apiSecret: '123', // Keys within public are also exposed client-side public: { apiBase: '/api', }, nitro: { preset: 'node-cluster', }, vite: { css: { preprocessorOptions: { scss: { additionalData: '@use "@/assets/_colors.scss" as *;', }, }, }, }, }, app: { pageTransition: { name: 'slide', mode: 'out-in', // default }, layoutTransition: { name: 'fade', mode: 'out-in', // default }, head: { charset: 'utf-16', viewport: 'width=500, initial-scale=1', title: 'My App', meta: [ // { name: 'description', content: 'My amazing site.' }, ], }, }, }); `
Can anyone let me know what I'm doing wrong please.
@ArnabBanerjee When working with any project management system, the expectation is that you create a separate ticket (issue) for new problem, unless it's clearly related. I see no connection here, so please either make the connection clear, or create a new issue.
However, also note that almost no one has bandwidth to help you 1-1. It's unlikely you'll get direct support for a one-off issue that affects only you. Unless you can show that there's an issue with the library, you're going to be on your own.
@ArnabBanerjee This module doesn't currently support Nuxt 3. Follow https://github.com/nuxt-community/sentry-module/pull/456 and further PRs if you want to stay updated.
But I agree with @bmulholland comment and will mark last 3 comments as off-topic now.
@ArnabBanerjee When working with any project management system, the expectation is that you create a separate ticket (issue) for new problem, unless it's clearly related. I see no connection here, so please either make the connection clear, or create a new issue.
However, also note that almost no one has bandwidth to help you 1-1. It's unlikely you'll get direct support for a one-off issue that affects only you. Unless you can show that there's an issue with the library, you're going to be on your own.
Yup sure @bmulholland, will raise a ticket for the same.
@ArnabBanerjee This module doesn't currently support Nuxt 3. Follow https://github.com/nuxt-community/sentry-module/pull/456 and further PRs if you want to stay updated.
But I agree with @bmulholland comment and will mark last 3 comments as off-topic now.
@rchl thanks for the information, will follow 👍
The first two points from the initial comment should be working just fine now.
The third point about serializing beforeSend should work too as far as I can tell. Unless the beforeSend needs to rely on something that is imported. Then serializing won't be enough and we would have to support specifying a file that exports a config.