feat: add source field to session_start telemetry#968
feat: add source field to session_start telemetry#968altimate-harness-bot[bot] wants to merge 4 commits into
Conversation
Adds source: string to the session_start event type definition and populates it with Flag.ALTIMATE_CLI_CLIENT at the call site. Defaults to "cli" for terminal invocations; overridden to "vscode" when the VS Code extension spawns the server via ALTIMATE_CLI_CLIENT env var.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
…sion metadata)
- Add optional metadata column to SessionTable (JSON blob, backward-compatible)
- Add metadata field to Session.Info schema, fromRow, toRow, create, and createNext
- Add source?: string to session_start event type in telemetry/index.ts
- In prompt.ts session_start emit, override source with session.metadata?.source
when present, falling back to Flag.ALTIMATE_CLI_CLIENT for sessions without it
VS Code extensions (datamates, poweruser) can now pass { metadata: { source: "datamates" } }
in POST /session to produce distinguishable session_start telemetry even though both
extensions share the same altimate serve process. The global source injection in
toAppInsightsEnvelopes() (clientSource) is unchanged and still covers all other events.
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
dev-punia-altimate
left a comment
There was a problem hiding this comment.
🤖 Code Review — OpenCodeReview (Gemini) — 1 finding(s)
- 1 anchored to a line (posted inline when the comment stream is on)
- 0 without a line anchor
All findings (full text)
1. packages/opencode/src/session/index.ts (L227-L229)
[🔵 LOW] Here you can use Info.shape.metadata to reuse the type definition and maintain consistency with how permission is defined, avoiding duplicate Zod schema declarations.
Suggested change:
permission: Info.shape.permission,
workspaceID: WorkspaceID.zod.optional(),
metadata: Info.shape.metadata,
| permission: Info.shape.permission, | ||
| workspaceID: WorkspaceID.zod.optional(), | ||
| metadata: z.record(z.string(), z.unknown()).optional(), |
There was a problem hiding this comment.
[🔵 LOW] Here you can use Info.shape.metadata to reuse the type definition and maintain consistency with how permission is defined, avoiding duplicate Zod schema declarations.
Suggested change:
| permission: Info.shape.permission, | |
| workspaceID: WorkspaceID.zod.optional(), | |
| metadata: z.record(z.string(), z.unknown()).optional(), | |
| permission: Info.shape.permission, | |
| workspaceID: WorkspaceID.zod.optional(), | |
| metadata: Info.shape.metadata, |
🤖 Code Review — OpenCodeReview (Gemini) — No Issues FoundNo supported files changed. |
Summary
sourceto every telemetry event by injecting it globally intoAppInsightsEnvelopes(), matching the existingcli_versioninjection patternsourceas a module-level variable (clientSource); callers set it once at startup viaTelemetry.setSource()session/prompt.ts, callsTelemetry.setSource(Flag.ALTIMATE_CLI_CLIENT)at init — defaults to"cli"for terminal invocationsSource values
"cli"altimatein terminal"vscode"ALTIMATE_CLI_CLIENT=vscodeenv var, injected in companion PR AltimateAI/vscode-altimate-mcp-server#386)Why global injection (not per-event type)
cli_versionis already injected globally into every App Insights event envelope.sourcefollows the same pattern — zero per-event-type changes needed, and all 30+ event types get the field automatically.Requested by @saravmajestic via harness