Commit 130fe7a0 authored by tom's avatar tom

fix rollbar filter by error class name

parent 9654d8ce
...@@ -6,7 +6,7 @@ import config from 'configs/app'; ...@@ -6,7 +6,7 @@ import config from 'configs/app';
import { ABSENT_PARAM_ERROR_MESSAGE } from 'lib/errors/throwOnAbsentParamError'; import { ABSENT_PARAM_ERROR_MESSAGE } from 'lib/errors/throwOnAbsentParamError';
import { RESOURCE_LOAD_ERROR_MESSAGE } from 'lib/errors/throwOnResourceLoadError'; import { RESOURCE_LOAD_ERROR_MESSAGE } from 'lib/errors/throwOnResourceLoadError';
import { isBot, isHeadlessBrowser, isNextJsChunkError, getRequestInfo } from './utils'; import { isBot, isHeadlessBrowser, isNextJsChunkError, getRequestInfo, getExceptionClass } from './utils';
const feature = config.features.rollbar; const feature = config.features.rollbar;
...@@ -37,16 +37,23 @@ export const clientConfig: Configuration | undefined = feature.isEnabled ? { ...@@ -37,16 +37,23 @@ export const clientConfig: Configuration | undefined = feature.isEnabled ? {
return true; return true;
} }
return false; const exceptionClass = getExceptionClass(item);
}, const IGNORED_EXCEPTION_CLASSES = [
hostSafeList: [ config.app.host ].filter(Boolean),
ignoredMessages: [
// these are React errors - "NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node." // these are React errors - "NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node."
// they could be caused by browser extensions // they could be caused by browser extensions
// one of the examples - https://github.com/facebook/react/issues/11538 // one of the examples - https://github.com/facebook/react/issues/11538
// we can ignore them for now // we can ignore them for now
'NotFoundError', 'NotFoundError',
];
if (exceptionClass && IGNORED_EXCEPTION_CLASSES.includes(exceptionClass)) {
return true;
}
return false;
},
hostSafeList: [ config.app.host ].filter(Boolean),
ignoredMessages: [
// these are errors that we throw on when make a call to the API // these are errors that we throw on when make a call to the API
RESOURCE_LOAD_ERROR_MESSAGE, RESOURCE_LOAD_ERROR_MESSAGE,
ABSENT_PARAM_ERROR_MESSAGE, ABSENT_PARAM_ERROR_MESSAGE,
......
import _get from 'lodash/get';
import type { Dictionary } from 'rollbar'; import type { Dictionary } from 'rollbar';
export function isBot(userAgent: string | undefined) { export function isBot(userAgent: string | undefined) {
...@@ -56,3 +57,9 @@ export function getRequestInfo(item: Dictionary): { url: string } | undefined { ...@@ -56,3 +57,9 @@ export function getRequestInfo(item: Dictionary): { url: string } | undefined {
} }
return { url: item.request.url }; return { url: item.request.url };
} }
export function getExceptionClass(item: Dictionary) {
const exceptionClass = _get(item, 'body.trace.exception.class');
return typeof exceptionClass === 'string' ? exceptionClass : undefined;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment