c is not a function when defining custom beforeSend function
See original GitHub issueHi, I’m currently trying to customize sentry to prevent the report of several messages that are very noisy in my dashboard. First I tried writing all the errors I want to disable to be tracked inside the ignoreErrors section of config, but it did nothing, after that I tried to make a custom beforeSend function inside the sentry.config attribute, but when building the app it throwed me the same error reported here although I have the latests version. Finally i ended up writing my custom beforeSend function inside the publicRuntimeConfig as one of the comments in this repo issues section said, but now i’m getting this error:
The build finishes well, but this error appears each 5 seconds in my sentry console. How to solve it?
Version
@nuxtjs/sentry: 5.1.3 nuxt: 2.15.4
Sentry configuration
sentry: {
dsn: credentials.SentryConf.dsn,
lazy: true,
disabled: !isProd,
disableServerSide: true,
tracing: true,
clientIntegrations: {
ExtraErrorData
},
ignoreErrors: [
'unhandledRejection',
'UnhandledRejection',
'unhandledPromiseRejection',
'ReportingObserver',
'Cannot set headers after they are sent to the client',
'ResizeObserver loop limit exceeded'
]
},
publicRuntimeConfig: {
sentry: { // It is necessary to set this config here, because in the common sentry settings it thrown the following error: https://github.com/nuxt-community/sentry-module/issues/266, tested with version 5.1.3
config: {
beforeSend(event, hint){
if (hint.originalException.stack) {
// eslint-disable-next-line dot-notation
const errorStack = JSON.stringify(hint.originalException.stack)
const errorsToIgnore = [
'unhandledRejection',
'UnhandledRejection',
'unhandledPromiseRejection',
'ReportingObserver',
'Cannot set headers after they are sent to the client',
'ResizeObserver loop limit exceeded',
'postMessage',
'createError',
'Non-Error promise rejection captured with keys: details, error',
'Request failed with status code 403',
'Network Error',
'disconnected'
]
const shouldIgnoreError = errorsToIgnore.some(elem => errorStack.toLowerCase().includes(elem.toLowerCase()))
return shouldIgnoreError ? null : event;
}
return event;
}
}
}
},
Steps to reproduce
Just create a nuxt project with the versions and settings mentioned above.
What is Expected?
The expected behavior is that sentry ignored the array of errors I’ve manually set and not show the c is not a function
error,
What is actually happening?
I’m receiving hundreds of times the c is not a function
error.
I’m new to Sentry, so if I’m doing it bad, please explain me how to avoid Sentry reports of the array of error I have set. Thanks a lot.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
Just do
ExtraErrorData: {},
. As long as it’s one of the official integrations this will enable it.Closing then. I think it would work better with later versions of Nuxt. There were some fixes around serializing functions in the config.
In Nuxt 2.15.8 all cases worked correctly when I’ve tested.