Commit bb5ee63
committed
feat(react-19-e2e): add SENTRY_LIGHTHOUSE_MODE instrumentation
Mirrors the dynamic-import pattern from default-browser/src/index.js so the
react-19 E2E test app can serve as a third (CRA) cell in the Lighthouse
matrix alongside default-browser (webpack) and nextjs-16 (Next.js SSR).
CRA exposes only env vars prefixed REACT_APP_*, so the gate is
process.env.REACT_APP_SENTRY_LIGHTHOUSE_MODE. Three branches:
- 'no-sentry': sync render with no Sentry import; CRA dead-code-eliminates
the @sentry/react chunk entirely (the dynamic import in the else branch
becomes unreachable when the env var inlines to 'no-sentry').
- 'tracing-replay': Sentry.init + browserTracingIntegration + replayIntegration.
- 'init-only' / unset: Sentry.init with no integrations, error handlers
attached to createRoot (preserves the existing E2E behavior when the env
var is unset).
The createRoot call moves inside the async IIFE in the else branch because
the onUncaughtError / onCaughtError options need the dynamically-imported
Sentry.reactErrorHandler. React handles its own scheduling so the extra
microtask before render is invisible to Playwright tests.1 parent 06f87a5 commit bb5ee63
1 file changed
Lines changed: 52 additions & 20 deletions
Lines changed: 52 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 5 | + | |
12 | 6 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments