raven-node
raven-node copied to clipboard
Ignore Errors does not working
Do you want to request a feature or report a bug? bug
Has someone had this problem before? Yes
What is the current behavior?
I want to use ignoreErrors in the config. I use it like this: // setting up configuration. Raven.config('https://' + SentryId.publicKey + ':' + SentryId.secretKey + '@' + SentryId.host + '/' + SentryId.project, { // configuring extra contextual information for the installation. name:XXXXX, environment:XXXXXX, tags:{api:XXXXXXX}, ignoreErrors:[ 'BadRequestException:', 'NotFoundException', 'UnauthrizedException' ] } )
I still got this errors with those strings
What is the expected behavior? To get errors without those strings
Thank you
Can you please provide an event that should but is not matching this errors filter?
You can gather them using
Raven.config('__DSN__', {
dataCallback: function (event) {
console.log(JSON.stringify(event, null, 2));
}
})
Cheers!
I don't think the ignoreErrors configuration exists for the Node client.
It's not documented at all, and #202 implies it has never been built.
I too would prefer support for ignoreErrors though, because it's easier for admins to add lines to simple configuration like that instead of messing with a callback. It's also not documented what format data has that is passed to shouldSendCallback.
Aaaaaghr... I again misread that its raven-js issue. @eladhaz05 for now, please use shouldSendCallback for this purpose.
@adamchainz I totally agree. We are in the process of unifying all JS SDKs and it soon won't be an issue. It'll take a while, but we'll get there soon :)
you @'d the wrong adam
Haha, sorry @adamchainz! And thanks for letting me know 🤦♂️ cc @adamreisnz
Hah, similar names :)
@kamilogorek great to hear, look forward to a unified SDK!
I've written a custom helper for this based on code found in raven-js, you can use it to support ignoreErrors while waiting for the SDK's to be unified.
Helper:
/**
* Join an array of string/regex patterns into a single regex (adapted from raven-js)
*/
function joinRegex(patterns) {
//Initialize sources
const sources = [];
//Loop patterns
for (const pattern of patterns) {
//If it's a string, we need to escape it
if (typeof pattern === 'string') {
sources.push(pattern.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'));
}
//If it's a regular expression already, we want to extract the source
else if (pattern && pattern.source) {
sources.push(pattern.source);
}
//Intentionally skip other cases
}
//Return combined regular expression
return new RegExp(sources.join('|'), 'i');
}
Configuration converter:
if (Array.isArray(cfg.ignoreErrors) && cfg.ignoreErrors.length > 0) {
const ignoreErrors = joinRegex(cfg.ignoreErrors);
cfg.shouldSendCallback = function(data) {
if (data.message && typeof data.message.match === 'function') {
return !data.message.match(ignoreErrors);
}
return true;
};
}
This essentially defines a shouldSendCallback config property if you've passed ignoreErrors instead.