diff --git a/web/renderer/app.ts b/web/renderer/app.ts index 39844a30..cfb0bb50 100644 --- a/web/renderer/app.ts +++ b/web/renderer/app.ts @@ -115,12 +115,6 @@ function createApp(pageContext: PageContext) { }, queryCache: new QueryCache({ onError(err) { - if (err.name == 'Error' && err.message.length == 0) { - // cube.js RequestError, ignore - // FIXME import it from cubejs and match the class - return - } - app.runWithContext(() => { const sentry = useSentry() sentry?.captureException(err) diff --git a/web/renderer/sentry.ts b/web/renderer/sentry.ts index fbb78a0a..359501e7 100644 --- a/web/renderer/sentry.ts +++ b/web/renderer/sentry.ts @@ -51,6 +51,26 @@ export function initSentry(dsn: string, app: App, router?: Router) { tracesSampleRate: 0.01, profilesSampleRate: 0.25, // relative to tracesSampleRate trackComponents: true, + beforeSend(event, hint) { + const error = hint.originalException as any + + if (error && error.name == 'Error' && error.message.length == 0) { + // cube.js RequestError, ignore + // FIXME import it from cubejs and match the class + return null + } + + if (error == 'Hydration completed but contains mismatches.') { + // ignore hydration mismatches when the page is auto-translated + const isAutoTranslated = !!document.querySelector('html.translated-ltr, head.translated-rtl, ya-tr-span, *[_msttexthash]') + + if (isAutoTranslated) { + return null + } + } + + return event + }, }) app.provide(SentryInjectionKey, Sentry) diff --git a/web/server/index.ts b/web/server/index.ts index b4613a6c..190edef5 100644 --- a/web/server/index.ts +++ b/web/server/index.ts @@ -31,6 +31,17 @@ async function startServer() { levels: ['error', 'assert'], }), ], + beforeSend(event, hint) { + const error = hint.originalException as any + + if (error && error.name == 'Error' && error.message.length == 0) { + // cube.js RequestError, ignore + // FIXME import it from cubejs and match the class + return null + } + + return event + }, }) app.use(Sentry.Handlers.requestHandler())