-
Notifications
You must be signed in to change notification settings - Fork 114
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
fix: better handling of functions options in config #267
fix: better handling of functions options in config #267
Conversation
Codecov Report
@@ Coverage Diff @@
## master #267 +/- ##
=======================================
Coverage 55.55% 55.55%
=======================================
Files 1 1
Lines 27 27
Branches 8 8
=======================================
Hits 15 15
Misses 9 9
Partials 3 3 Continue to review full report at Codecov.
|
It works for me! |
This doesn't seem to help. With a configuration like: sentry: {
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779',
config: {
beforeSend (event, hint) {
const ignoreErrorInBeforeSend = [
{
check: (event, hint) => {
// Ignore fbevent.js postMessage error in iOS device
if (hint.originalException.stack) {
// eslint-disable-next-line dot-notation
const errorStack = JSON.stringify(hint.originalException.stack)
return /postMessage/.test(errorStack)
}
return false
}
}
]
const shouldIgnoreError = ignoreErrorInBeforeSend.some(rule =>
rule.check(event, hint)
)
return shouldIgnoreError ? null : event
}
},
} it produces: const config = {
dsn:"https:\u002F\u002Ffe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt\u002F1429779",
environment:"development",
beforeSend:beforeSend (event, hint) {
const ignoreErrorInBeforeSend = [
{
check: (event, hint) => {
// Ignore fbevent.js postMessage error in iOS device
if (hint.originalException.stack) {
// eslint-disable-next-line dot-notation
const errorStack = JSON.stringify(hint.originalException.stack)
return /postMessage/.test(errorStack)
}
return false
}
}
]
const shouldIgnoreError = ignoreErrorInBeforeSend.some(rule =>
rule.check(event, hint)
)
return shouldIgnoreError ? null : event
},
release:"a21baf77b07df7892b8dcac059ef4e39c53d5eb7"
} which is still invalid due to |
Thanks for your review! |
Sorry, may I ask you how to run the test? My result: /* eslint-disable object-curly-spacing, quote-props, quotes, key-spacing, comma-spacing */
const config = {
dsn:"https:\u002F\u002Ffe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt\u002F1429779",
environment:"production",
beforeSend:function (event, hint) {
const ignoreErrorInBeforeSend = [
{
check: (event, hint) => {
// Ignore fbevent.js postMessage error in iOS device
if (hint.originalException.stack) {
// eslint-disable-next-line dot-notation
const errorStack = JSON.stringify(hint.originalException.stack);
return /postMessage/.test(errorStack);
}
return false;
}
}
];
const shouldIgnoreError = ignoreErrorInBeforeSend.some(rule => rule.check(event, hint));
return shouldIgnoreError ? null : event;
},
release:"b6fb6ef3295f635286d1df9db735a25f781000d5"
} I got correct |
I'm testing on this repo itself with this change: diff --git a/test/fixture/default/nuxt.config.js b/test/fixture/default/nuxt.config.js
index af2f3db..dc77268 100644
--- a/test/fixture/default/nuxt.config.js
+++ b/test/fixture/default/nuxt.config.js
@@ -17,7 +17,29 @@ const config = {
],
sentry: {
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779',
- config: {},
+ config: {
+ beforeSend (event, hint) {
+ const ignoreErrorInBeforeSend = [
+ {
+ check: (event, hint) => {
+ // Ignore fbevent.js postMessage error in iOS device
+ if (hint.originalException.stack) {
+ // eslint-disable-next-line dot-notation
+ const errorStack = JSON.stringify(hint.originalException.stack)
+ return /postMessage/.test(errorStack)
+ }
+
+ return false
+ }
+ }
+ ]
+
+ const shouldIgnoreError = ignoreErrorInBeforeSend.some(rule =>
+ rule.check(event, hint)
+ )
+ return shouldIgnoreError ? null : event
+ }
+ },
clientIntegrations: {
// Integration from @Sentry/browser package.
TryCatch: { eventTarget: false } And then:
|
Thanks! With |
Sounds like a bug in |
Maybe I can try it, otherwise, I have to use some hack to fix this issue. |
Any updates on this? |
I found and fixed the Nuxt issue (nuxt/nuxt#8779) so once the Nuxt fix is integrated this fix will work in more (all?) cases. This fix is good in itself though and I will merge it soon. |
BTW. I haven't tried, but it should be possible to use the Runtime config to define |
Thanks for helping! |
Fixes #266
Check config when the option is a function then using
serializeFunction(option)
instead of usingserialize(option)