-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(browser): Add environment variable support for Spotlight configuration #18198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
6cb5513
f16380f
fda3d61
bcff50d
cd42ebd
0ac2828
0915965
6ea8d90
870be3b
1cf7f7f
b6fda2b
469940b
be6f1b5
c9b13e3
d129a79
f542f62
4c28587
f9b555a
e12b3fc
ab56171
6cbd1fd
3bc5309
c78da67
fb3f764
d556863
64c4692
75f2b49
9f1e28f
a23d53a
90eca4e
f16915a
c7c9b95
cb298e2
5fdcf7d
c12edfc
2ea8c45
433c0ac
212a8bb
516ede0
5df223a
102dc61
d4662e5
7cffb67
dde88ca
9c6d19a
de9943d
f7d1ffd
3cf3a95
42d832c
4c6aaad
d9d7124
a313e1c
77be213
0d69896
e32150d
2346b4c
e549260
93eceb5
33df6a0
669c71b
8d639f4
ca898d9
855ff97
5deeb64
9ef14ff
fcab9df
693c80e
7c1107f
9a9ba91
65860d4
1ab6f28
7501e60
351046b
eca64b5
0ad25a3
b9d3337
b2716ec
94d86a0
43572cf
df539cf
c23f1d7
e5409e6
bf2e634
b16f01d
40c4967
1642e35
67d1d4b
ce30f02
5bc01a0
939e0cd
f24fa13
c7652fe
bb65b10
d62b54e
12481ec
d873831
4f2f69d
0a8c255
bae7fb6
d72f2f2
87f6dc6
f00a377
6465550
8d3702a
1c05b4c
130bd92
70435c7
7d9e165
6e7eb39
ad6b021
03eb6e5
73ea2d6
51262cf
fa8debc
ee9ae35
4189085
86cce1f
76980e2
1614dbb
7b8612c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| --- | ||
| name: Migrate E2E to Spotlight | ||
| overview: Replace the custom event proxy server with Spotlight for E2E test event capture. This eliminates race conditions by using Spotlight's reliable event streaming instead of the fragile timestamp-based filtering in the current proxy. | ||
| todos: | ||
| - id: add-spotlight-dep | ||
| content: Add @spotlightjs/spotlight as devDependency to test-utils | ||
| status: completed | ||
| - id: create-spotlight-helpers | ||
| content: Create spotlight.ts with startSpotlight() and event waiting helpers | ||
| status: completed | ||
| - id: update-playwright-config | ||
| content: Add Spotlight support to getPlaywrightConfig() | ||
| status: completed | ||
| - id: migrate-first-app | ||
| content: Migrate react-router-7-lazy-routes as proof of concept | ||
| status: in_progress | ||
| - id: migrate-remaining | ||
| content: Migrate remaining ~106 test apps incrementally | ||
| status: pending | ||
| - id: cleanup-old-proxy | ||
| content: Remove deprecated event proxy code after full migration | ||
| status: pending | ||
| --- | ||
|
|
||
| # Migrate E2E Tests from Event Proxy to Spotlight | ||
|
|
||
| ## Current Architecture | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| subgraph current [Current Setup] | ||
| App[Test App] -->|"tunnel: localhost:3031"| Proxy[Event Proxy Server] | ||
| Proxy -->|Buffer + Timestamp Filter| Buffer[(Event Buffer)] | ||
| Test[Playwright Test] -->|waitForTransaction| Buffer | ||
| end | ||
| ``` | ||
|
|
||
| **Problems with current approach:** | ||
|
|
||
| - Timestamp filtering has race conditions (stale events leak through) | ||
| - Complex buffer management with timing edge cases | ||
| - 108 test apps, ~162 files use `tunnel: localhost:3031` | ||
|
|
||
| ## Proposed Architecture | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| subgraph proposed [Spotlight Setup] | ||
| App2[Test App] -->|"DSN: spotlight@localhost:PORT/0"| Spotlight[Spotlight Sidecar] | ||
| Spotlight -->|JSON Stream| Stream[(stdout/stderr)] | ||
| Test2[Playwright Test] -->|waitForTransaction| Stream | ||
| end | ||
| ``` | ||
|
|
||
| **Benefits:** | ||
|
|
||
| - No timestamp filtering needed - Spotlight streams events in order | ||
| - Production-tested event handling | ||
| - Cleaner architecture with less custom code | ||
|
|
||
| ## Implementation Plan | ||
|
|
||
| ### Phase 1: Add Spotlight Infrastructure | ||
|
|
||
| 1. **Add `@spotlightjs/spotlight` dependency** to [`dev-packages/test-utils/package.json`](dev-packages/test-utils/package.json) | ||
|
|
||
| 2. **Create new Spotlight-based helpers** in [`dev-packages/test-utils/src/spotlight.ts`](dev-packages/test-utils/src/spotlight.ts): | ||
| - `startSpotlight(options)` - Spawns `spotlight run` with dynamic port, parses port from stderr | ||
| - `waitForSpotlightEvent(filter)` - Reads from Spotlight's JSON output stream | ||
| - `waitForTransaction()`, `waitForError()`, etc. - High-level wrappers matching current API | ||
|
|
||
| 3. **Update [`dev-packages/test-utils/src/playwright-config.ts`](dev-packages/test-utils/src/playwright-config.ts)**: | ||
| - Add option to use Spotlight instead of event proxy | ||
| - Configure webServer to run Spotlight with dynamic port | ||
| - Pass port via environment variable to test app | ||
|
|
||
| ### Phase 2: Create Migration Path | ||
|
|
||
| 4. **Design backward-compatible API**: | ||
| - Keep existing `waitForTransaction()` signature | ||
| - New implementation reads from Spotlight instead of HTTP streaming | ||
| - Port is passed via `SPOTLIGHT_PORT` env var | ||
|
|
||
| 5. **Update DSN handling in test apps**: | ||
| - Replace `tunnel: 'http://localhost:3031'` with DSN workaround | ||
| - DSN format: `http://spotlight@localhost:${SPOTLIGHT_PORT}/0` | ||
| - This makes SDK operate in "normal" mode (no tunnel) | ||
|
|
||
| ### Phase 3: Migrate Test Apps (Incremental) | ||
|
|
||
| 6. **Migration per test app involves**: | ||
| - Remove `start-event-proxy.mjs` | ||
| - Update `playwright.config.mjs` to use new Spotlight config | ||
| - Update Sentry init to use DSN workaround instead of tunnel | ||
| - No changes needed to test files (API stays the same) | ||
|
|
||
| 7. **Start with problematic apps**: | ||
| - `react-router-7-lazy-routes` (the failing one) | ||
| - `react-router-7-framework` | ||
| - Then expand to remaining ~106 apps | ||
|
|
||
| ### Phase 4: Cleanup | ||
|
|
||
| 8. **After all apps migrated**: | ||
| - Remove old event proxy code from `event-proxy-server.ts` | ||
| - Update documentation | ||
| - Remove unused dependencies | ||
|
|
||
| ## Key Technical Details | ||
|
|
||
| ### Port Extraction from Spotlight | ||
|
|
||
| Spotlight outputs startup info to stderr. We parse it to get the dynamic port: | ||
|
|
||
| ``` | ||
| Spotlight listening on http://localhost:8969 | ||
| ``` | ||
|
|
||
| ### DSN Workaround Format | ||
|
|
||
| Per [Spotlight docs](https://spotlightjs.com/docs/cli/run/#unsupported-sdks-dsn-workaround): | ||
|
|
||
| ```javascript | ||
| Sentry.init({ | ||
| dsn: `http://spotlight@localhost:${process.env.SPOTLIGHT_PORT}/0`, | ||
| }); | ||
| ``` | ||
|
|
||
| ### Playwright Config Changes | ||
|
|
||
| ```javascript | ||
| // Before | ||
| webServer: [ | ||
| { command: 'node start-event-proxy.mjs', port: 3031 }, | ||
| { command: 'yarn start', port: 3030 }, | ||
| ]; | ||
|
|
||
| // After - spotlight run auto-detects and runs the app | ||
| webServer: [{ command: 'yarn spotlight run -p 0 -f json', port: 3030 }]; | ||
| ``` | ||
|
|
||
| Note: `spotlight run` automatically: | ||
|
|
||
| - Detects the start script from package.json (`dev`, `develop`, `serve`, `start`) | ||
| - Starts the Spotlight sidecar on the specified port (or dynamic with `-p 0`) | ||
| - Streams events to stdout in JSON format (with `-f json`) | ||
| - Sets `SENTRY_SPOTLIGHT` env var for the child process | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Cursor AI planning file accidentally committed to repoThe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Cursor planning file accidentally included in commitA Cursor AI development planning file was committed to the repository. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Plan file accidentally committed to repositoryA Cursor IDE plan file ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Accidentally committed Cursor plan fileThe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Development plan file accidentally committed to repositoryA Cursor IDE development plan file was committed to the repository. This contains implementation notes and todos with statuses like "in_progress" and "pending" that are internal development artifacts. The |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ tmp | |
| .tmp_build_stderr | ||
| pnpm-lock.yaml | ||
| .last-run.json | ||
| .next | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Angular17</title> | ||
| <base href="/"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
| </head> | ||
| <body> | ||
| <app-root></app-root> | ||
| </body> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Angular17</title> | ||
| <base href="/" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
| </head> | ||
| <body> | ||
| <app-root></app-root> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Angular 18</title> | ||
| <base href="/"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
| </head> | ||
| <body> | ||
| <app-root></app-root> | ||
| </body> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Angular 18</title> | ||
| <base href="/" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
| </head> | ||
| <body> | ||
| <app-root></app-root> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Angular19</title> | ||
| <base href="/"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <link rel="icon" type="image/x-icon" href="favicon.ico"> | ||
| </head> | ||
| <body> | ||
| <app-root></app-root> | ||
| </body> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Angular19</title> | ||
| <base href="/" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <link rel="icon" type="image/x-icon" href="favicon.ico" /> | ||
| </head> | ||
| <body> | ||
| <app-root></app-root> | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Internal planning file accidentally committed to repository
The
.cursor/plans/directory contains internal planning documentation (a Cursor AI migration plan) that was accidentally committed to the repository. This file includes implementation todos and internal planning notes that likely shouldn't be part of the codebase.