I have a hook called logError
in my React code that reports to rollbar with rollbar.error
.
It looks like this:
export const logError = (labeledMessage: string, error: any = {}) => {
console.error(
JSON.stringify({
message: labeledMessage,
error: inspect(error),
}),
);
rollbar.error(labeledMessage, error);
};
It is used like this in other components:
if (!mapboxgl.accessToken) {
logError('[Map]: Access token is missing');
setHasError(true);
}
In my rollbar conf
var _rollbarConfig = {
accessToken: "TOKEN",
captureUncaught: true,
captureUnhandledRejections: true,
payload: {
environment: "development",
client: {
javascript: {
source_map_enabled: true,
guess_uncaught_frames: true
}
}
},
checkIgnore: function(isUncaught, args, payload) {
var error = args[0];
if (error && error.message) {
return false; // Do not ignore, send to Rollbar
}
return true; // Ignore all other errors
}
};
It seems to work ignoring all other errors client side in rollbar. For example, I triggered a hydration error that is not reported to rollbar with this checkIgnore function.
However, the logError logError('[Map]: Access token is missing');
is not reporting at all. Can anyone spot the wrong in checkIgnore?