mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem Browser translation (e.g. Chrome Translate) and some extensions rewrite DOM text nodes, which makes React throw `insertBefore` / `removeChild` errors. We drop all of these via `ignoreErrors`, so we have no signal on how often they still happen after the dynamic-text ESLint rule (#52949). Linear: [FE-5008](https://linear.app/supabase/issue/FE-5008/sample-sentry-events-for-browser-translation-crashes-instead-of), from the investigation in [FE-5013](https://linear.app/supabase/issue/FE-5013/investigate-how-we-currently-hide-browser-translation-insertremove). ## Solution Stop ignoring these errors in Studio and send a 5% sample, tagged so they are easy to find in Sentry. - Move the insert/remove node messages from `BROWSER_NOISE_IGNORE_ERRORS` into a new `BROWSER_TRANSLATION_DOM_ERRORS` list in `packages/common/sentry.ts`. `docs` and `www` add it to `ignoreErrors`, so their behavior is unchanged. - In Studio's `beforeSend`, tag matching events with `browser_translation`, `page_translated` and `sample_rate`. The existing `shouldDropForSampleRate` applies the rate. - `page_translated` is best effort: it checks for the `translated-ltr` / `translated-rtl` class on `<html>` and Google Translate `<font>` wrappers. Firefox and Edge are less reliable, so `false` is not proof. - `filterSentryEvent` skips its 1% non-crash sampling for tagged events. Without this the rates would multiply and 5% would really be 0.05%. - The generic `parentNode` / `removeChild` null reads stay ignored. They have many unrelated causes, so tagging them as translation would mislead. Not in this PR: - The `text content does not match` and hydration ignores. They are related symptoms and should be a follow-up. - The user-facing fallback in `InsertBeforeRemoveChildErrorHandler`. ## Review instructions 1. Check that `docs` and `www` still ignore the five DOM messages, via `BROWSER_TRANSLATION_DOM_ERRORS` in their `instrumentation-client.ts`. 2. Run `pnpm exec vitest run lib/sentry-client-options.test.ts` from `apps/studio`, and `pnpm exec vitest run sentry.test.ts` from `packages/common`. 3. After merge, filter Sentry for `browser_translation:true` on the production Studio project and compare `page_translated` true against false. ## Before merging Sentry also has server-side inbound filters on the production Studio project. Someone with project access should confirm the `error-message` filter doesn't match these messages. If it does, the sampled events will be dropped on arrival. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill (not applicable)
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
// This file configures the initialization of Sentry on the client.
|
|
// The added config here will be used whenever a user loads a page in their browser.
|
|
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
|
|
import * as Sentry from '@sentry/nextjs'
|
|
import { hasConsented, IS_PLATFORM } from 'common'
|
|
import {
|
|
BROWSER_NOISE_IGNORE_ERRORS,
|
|
BROWSER_TRANSLATION_DOM_ERRORS,
|
|
filterSentryEvent,
|
|
} from 'common/sentry'
|
|
|
|
import { IS_DEV } from './lib/constants'
|
|
|
|
if (!IS_DEV) {
|
|
Sentry.init({
|
|
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
|
|
|
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
|
debug: false,
|
|
|
|
integrations: (defaultIntegrations) => [
|
|
...defaultIntegrations,
|
|
Sentry.thirdPartyErrorFilterIntegration({
|
|
filterKeys: ['supabase-docs'],
|
|
behaviour: 'apply-tag-if-exclusively-contains-third-party-frames',
|
|
}),
|
|
],
|
|
|
|
ignoreErrors: [
|
|
...BROWSER_NOISE_IGNORE_ERRORS,
|
|
...BROWSER_TRANSLATION_DOM_ERRORS,
|
|
|
|
// [Charis 2025-05-05]
|
|
// We should fix hydration problems but let's not make this a blocker for
|
|
// now.
|
|
/(?:text content does not match)|hydration|hydrating/i,
|
|
],
|
|
|
|
beforeSend(event) {
|
|
return filterSentryEvent(event, { isPlatform: IS_PLATFORM, hasConsent: hasConsented() })
|
|
},
|
|
})
|
|
}
|
|
|
|
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart
|