Files
baserow/web-frontend/modules/core/utils/sentryErrors.js
Davide Silvestri 1c2480f1dc fix: Keep the default Sentry filters when the app config extends them (#7011)
* fix: keep the default Sentry filters when the app config extends them

The app config replaced ignoreErrors and beforeSend instead of extending
them, so deployments that set their own dropped Baserow's silenced error
patterns, the handled API error filter and the private link redaction.

* fix: preserve Sentry redaction across app hooks
2026-12-03 11:12:29 +01:00

36 lines
1.3 KiB
JavaScript

import { redactPrivateLinks } from '@baserow/modules/core/utils/templatePrivateLink'
// API error codes to silence in Sentry, keyed by HTTP status code.
// These are handled by the application (e.g. forceLogoff) and are not bugs.
export const SILENCED_API_ERRORS = {
401: ['ERROR_INVALID_ACCESS_TOKEN', 'ERROR_INVALID_REFRESH_TOKEN'],
}
// Browser-extension RPC artifact that rejects a promise when its internal
// object registry can't resolve an id. Not a Baserow error.
export const SILENCED_ERROR_PATTERNS = [
/Object Not Found Matching Id:\d+, MethodName:\w+, ParamCount:\d+/,
]
const isSilenced = (err) => {
if (err?.fatal === false) {
return true
}
if (err?.fatal === true && err?.data?.report === false) {
return true
}
if (err?.name === 'AxiosError' && !err?.response) {
return true
}
const status = err?.response?.status || err?.statusCode
const errorCode = err?.response?.data?.error || err?.data?.error
return Boolean(SILENCED_API_ERRORS[status]?.includes(errorCode))
}
/**
* The Sentry `beforeSend` of Baserow: drops the errors the app handles, like
* network failures and expired tokens, and redacts private links.
*/
export const filterAndRedactEvent = (event, hint) =>
isSilenced(hint?.originalException) ? null : redactPrivateLinks(event)