feat: [AI-7401] stamp launch_surface on serve telemetry events
Goal
Tie IDE sessions to Altimate Code telemetry (AI-7401). The serve harness already emits session_start, session_end, and agent_outcome (completed / aborted / abandoned / error) plus returning-user identity (machine_id, first_launch). The one missing dimension is launch surface — there is no way to tell an IDE-webview session from a CLI/TUI one. This adds it.
Change
packages/opencode/src/altimate/telemetry/index.ts:
- Read
ALTIMATE_LAUNCH_SURFACEonce at telemetry init into a module-levellaunchSurface. - Stamp it as a
launch_surfaceproperty on every App Insights envelope, alongside the existingmachine_id(omitted when the env var is unset). - Reset it on
shutdown().
The IDE extension sets ALTIMATE_LAUNCH_SURFACE=ide when it spawns altimate serve (see paired PR AltimateAI/vscode-altimate-mcp-server#<EXT_PR>). Direct CLI/TUI invocations leave it unset, so launch_surface is absent — querying launch_surface == "ide" selects IDE sessions; everything else is terminal.
No new event types and no per-session plumbing: the existing lifecycle events simply gain a filterable dimension.
Tests
Two new cases in test/telemetry/telemetry.test.ts (present-when-set, omitted-when-unset). Full file: 132 pass / 0 fail.
🤖 Generated with Claude Code
https://claude.ai/code/session_013aDZXEPBPcBAYNNcrKZomN
Summary by cubic
Add a launch_surface property to all serve telemetry events to distinguish IDE vs terminal sessions (AI-7401). Read ALTIMATE_LAUNCH_SURFACE at init, trim/lowercase, allow only ide/cli/tui, and omit the field when unset or unrecognized.
Summary by CodeRabbit
-
New Features
- Telemetry events now include the app’s launch surface (e.g., IDE, CLI, TUI) to better distinguish how the app was started.
-
Bug Fixes
- Improved normalization and validation of launch-surface data, ensuring it’s omitted when unavailable or unrecognized.
- Added test coverage for launch-surface behavior across multiple environment-variable scenarios.