Skip to content

feat: add source field to session_start telemetry#968

Open
altimate-harness-bot[bot] wants to merge 4 commits into
mainfrom
feat/telemetry-source-field
Open

feat: add source field to session_start telemetry#968
altimate-harness-bot[bot] wants to merge 4 commits into
mainfrom
feat/telemetry-source-field

Conversation

@altimate-harness-bot

@altimate-harness-bot altimate-harness-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds source to every telemetry event by injecting it globally in toAppInsightsEnvelopes(), matching the existing cli_version injection pattern
  • Stores source as a module-level variable (clientSource); callers set it once at startup via Telemetry.setSource()
  • In session/prompt.ts, calls Telemetry.setSource(Flag.ALTIMATE_CLI_CLIENT) at init — defaults to "cli" for terminal invocations

Source values

Value When
"cli" Default — user runs altimate in terminal
"vscode" VS Code extension spawns the server (set via ALTIMATE_CLI_CLIENT=vscode env var, injected in companion PR AltimateAI/vscode-altimate-mcp-server#386)

Why global injection (not per-event type)

cli_version is already injected globally into every App Insights event envelope. source follows the same pattern — zero per-event-type changes needed, and all 30+ event types get the field automatically.

Requested by @saravmajestic via harness

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.
@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@saravmajestic saravmajestic marked this pull request as ready for review June 26, 2026 03:14

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

saravmajestic added 2 commits June 26, 2026 03:28
…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.
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@dev-punia-altimate dev-punia-altimate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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,

Comment on lines 227 to +229
permission: Info.shape.permission,
workspaceID: WorkspaceID.zod.optional(),
metadata: z.record(z.string(), z.unknown()).optional(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[🔵 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:

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,

@dev-punia-altimate

Copy link
Copy Markdown
Contributor

🤖 Code Review — OpenCodeReview (Gemini) — No Issues Found

No supported files changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants