Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 134
feat: [AI-7401] stamp launch_surface on serve telemetry events#970
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -596,6 +596,82 @@ describe("telemetry.toAppInsightsEnvelopes (indirect)", () => { | ||
| } | ||
| }) | ||
| test("launch_surface is stamped on every event when ALTIMATE_LAUNCH_SURFACE is set", async () => { | ||
| const origSurface = process.env.ALTIMATE_LAUNCH_SURFACE | ||
| process.env.ALTIMATE_LAUNCH_SURFACE = "ide" | ||
| const { fetchCalls, cleanup } = await initWithMockedFetch() | ||
| try { | ||
| Telemetry.track({ type: "session_start", timestamp: 1700000000000, session_id: "sess-ide" }) | ||
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. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bashset -euo pipefail
echo"== telemetry test context =="
sed -n '520,650p' packages/opencode/test/telemetry/telemetry.test.ts | cat -n
echoecho"== Event type / Telemetry.track declaration search =="
rg -n "type Event|interface Event|Telemetry\.track|track\(" packages/opencode -g '!**/dist/**' -g '!**/build/**'echoecho"== likely telemetry source files =="
fd -a "telemetry" packages/opencode/src packages/opencode/test packages/opencode -t fRepository: AltimateAI/altimate-code Length of output: 29640 🏁 Script executed: #!/bin/bashset -euo pipefail
echo"== altimate telemetry type definition =="
sed -n '1,220p' packages/opencode/src/altimate/telemetry/index.ts | cat -n
echoecho"== track implementation area =="
sed -n '1360,1405p' packages/opencode/src/altimate/telemetry/index.ts | cat -n
echoecho"== any event construction helpers around session_start =="
rg -n '"session_start"|session_start' packages/opencode/src/altimate/telemetry/index.ts packages/opencode/test/telemetry/telemetry.test.ts packages/opencode/test/altimate/telemetry-signals.test.tsRepository: AltimateAI/altimate-code Length of output: 14026 Add the required 🤖 Prompt for AI Agents | ||
| await Telemetry.flush() | ||
| expect(fetchCalls.length).toBeGreaterThan(0) | ||
| const envelopes = JSON.parse(fetchCalls[0].body) | ||
cubic-dev-ai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| expect(envelopes.length).toBeGreaterThan(0) | ||
| expect(envelopes[0].data.baseData.properties.launch_surface).toBe("ide") | ||
| } finally { | ||
| cleanup() | ||
| if (origSurface !== undefined) process.env.ALTIMATE_LAUNCH_SURFACE = origSurface | ||
| else delete process.env.ALTIMATE_LAUNCH_SURFACE | ||
| } | ||
| }) | ||
| test("launch_surface is omitted when ALTIMATE_LAUNCH_SURFACE is unset (CLI/TUI)", async () => { | ||
| const origSurface = process.env.ALTIMATE_LAUNCH_SURFACE | ||
| delete process.env.ALTIMATE_LAUNCH_SURFACE | ||
| const { fetchCalls, cleanup } = await initWithMockedFetch() | ||
| try { | ||
| Telemetry.track({ type: "session_start", timestamp: 1700000000000, session_id: "sess-cli" }) | ||
| await Telemetry.flush() | ||
| expect(fetchCalls.length).toBeGreaterThan(0) | ||
| const envelopes = JSON.parse(fetchCalls[0].body) | ||
| expect(envelopes.length).toBeGreaterThan(0) | ||
| expect(envelopes[0].data.baseData.properties.launch_surface).toBeUndefined() | ||
| } finally { | ||
| cleanup() | ||
| if (origSurface !== undefined) process.env.ALTIMATE_LAUNCH_SURFACE = origSurface | ||
| else delete process.env.ALTIMATE_LAUNCH_SURFACE | ||
| } | ||
| }) | ||
| test("launch_surface normalizes casing and surrounding whitespace", async () => { | ||
| const origSurface = process.env.ALTIMATE_LAUNCH_SURFACE | ||
| process.env.ALTIMATE_LAUNCH_SURFACE = " IDE " | ||
| const { fetchCalls, cleanup } = await initWithMockedFetch() | ||
| try { | ||
| Telemetry.track({ type: "session_start", timestamp: 1700000000000, session_id: "sess-norm" }) | ||
| await Telemetry.flush() | ||
| expect(fetchCalls.length).toBeGreaterThan(0) | ||
| const envelopes = JSON.parse(fetchCalls[0].body) | ||
| expect(envelopes.length).toBeGreaterThan(0) | ||
| expect(envelopes[0].data.baseData.properties.launch_surface).toBe("ide") | ||
| } finally { | ||
| cleanup() | ||
| if (origSurface !== undefined) process.env.ALTIMATE_LAUNCH_SURFACE = origSurface | ||
| else delete process.env.ALTIMATE_LAUNCH_SURFACE | ||
| } | ||
| }) | ||
| test("launch_surface drops unrecognized values to keep the dimension low-cardinality", async () => { | ||
| const origSurface = process.env.ALTIMATE_LAUNCH_SURFACE | ||
| process.env.ALTIMATE_LAUNCH_SURFACE = "totally-bogus" | ||
| const { fetchCalls, cleanup } = await initWithMockedFetch() | ||
| try { | ||
| Telemetry.track({ type: "session_start", timestamp: 1700000000000, session_id: "sess-bogus" }) | ||
| await Telemetry.flush() | ||
| expect(fetchCalls.length).toBeGreaterThan(0) | ||
| const envelopes = JSON.parse(fetchCalls[0].body) | ||
| expect(envelopes.length).toBeGreaterThan(0) | ||
| expect(envelopes[0].data.baseData.properties.launch_surface).toBeUndefined() | ||
| } finally { | ||
| cleanup() | ||
| if (origSurface !== undefined) process.env.ALTIMATE_LAUNCH_SURFACE = origSurface | ||
| else delete process.env.ALTIMATE_LAUNCH_SURFACE | ||
| } | ||
| }) | ||
| test("numeric fields go to measurements, string fields go to properties", async () => { | ||
| const { fetchCalls, cleanup } = await initWithMockedFetch() | ||
| try { | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
P3:
KNOWN_LAUNCH_SURFACESincludes"cli"and"tui"as accepted values, but no code path ever sets them — the IDE extension only ever sets"ide"and direct CLI/TUI leaves the env var unset. These are effectively dead allowlist entries that could inflate perceived surface support. Either remove them or add a comment reserving them for future use. If they remain, consider that settingALTIMATE_LAUNCH_SURFACE=climanually would pass through, so there is no harm — but dead entries risk misleading future maintainers.Prompt for AI agents