mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 19:05:06 +03:00
## Problem Docs discarded every browser exception because its third-party stack-frame filter never returned a value from its predicate. Errors captured by the page error boundaries were discarded too. ## Fix Use Studio's Sentry SDK tagging approach with a matching webpack application key, retaining page-crashing exceptions even when their frames are classified as third-party. Preserve consent and platform checks, and pass the source-map upload token through Turbo. ## How to test - Run `pnpm --filter docs run test:local:unwatch lib/sentry-client.test.ts` with the documented local Supabase prerequisites satisfied. Eleven filter regression checks passed locally using an isolated Vitest configuration. - On a production-mode preview with the docs DSN configured, accept telemetry consent and trigger a temporary client render error. Verify that the docs Sentry project receives it with `globalErrorBoundary: true` and readable stack traces. - Verify that third-party-only errors are filtered and declining consent suppresses browser reports. Prettier, focused filter/test TypeScript checks, and an in-memory transport check using the real Sentry SDK passed. Full app typecheck and lint are blocked locally by existing dependency/generated-file drift; the standard docs suite requires unavailable Docker access. Live Sentry ingestion and source-map uploads still need deployment verification. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved error monitoring to distinguish documentation app boundary crashes from other exceptions. - Reduced noise in error reports by filtering third-party-only errors and respecting platform and consent settings. - Preserved reporting for first-party failures and critical application crashes. - **Chores** - Improved Sentry build and deployment configuration for more consistent error tracking. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import type { ErrorEvent } from '@sentry/nextjs'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { filterSentryEvent } from './sentry-client'
|
|
|
|
describe('filterSentryEvent', () => {
|
|
it('forwards first-party exceptions', () => {
|
|
const event: ErrorEvent = {
|
|
type: undefined,
|
|
exception: {
|
|
values: [
|
|
{ stacktrace: { frames: [{ filename: 'https://supabase.com/docs/_next/app.js' }] } },
|
|
],
|
|
},
|
|
}
|
|
expect(filterSentryEvent(event, { isPlatform: true, hasConsent: true })).toBe(event)
|
|
})
|
|
|
|
it('forwards errors without stack frames', () => {
|
|
const event: ErrorEvent = {
|
|
type: undefined,
|
|
exception: { values: [{ value: 'Page crashed' }] },
|
|
}
|
|
expect(filterSentryEvent(event, { isPlatform: true, hasConsent: true })).toBe(event)
|
|
})
|
|
|
|
it.each([true, 'true'])('drops third-party-only errors tagged %s', (tag) => {
|
|
expect(
|
|
filterSentryEvent(
|
|
{ type: undefined, tags: { third_party_code: tag } },
|
|
{ isPlatform: true, hasConsent: true }
|
|
)
|
|
).toBeNull()
|
|
})
|
|
|
|
it.each([true, 'true'])('retains error-boundary crashes tagged %s', (tag) => {
|
|
const event: ErrorEvent = {
|
|
type: undefined,
|
|
tags: { third_party_code: true, globalErrorBoundary: tag },
|
|
}
|
|
expect(filterSentryEvent(event, { isPlatform: true, hasConsent: true })).toBe(event)
|
|
})
|
|
|
|
it('does not forward errors outside the platform', () => {
|
|
expect(
|
|
filterSentryEvent({ type: undefined }, { isPlatform: false, hasConsent: true })
|
|
).toBeNull()
|
|
})
|
|
|
|
it('retains errors explicitly tagged as first-party', () => {
|
|
const event: ErrorEvent = { type: undefined, tags: { third_party_code: false } }
|
|
expect(filterSentryEvent(event, { isPlatform: true, hasConsent: true })).toBe(event)
|
|
})
|
|
|
|
it.each([
|
|
{},
|
|
{ globalErrorBoundary: true },
|
|
{ globalErrorBoundary: 'true', third_party_code: true },
|
|
])(
|
|
'does not forward errors without permission to report, including boundary crashes: %j',
|
|
(tags) => {
|
|
expect(
|
|
filterSentryEvent({ type: undefined, tags }, { isPlatform: true, hasConsent: false })
|
|
).toBeNull()
|
|
}
|
|
)
|
|
})
|