microsoft / microsoft/GitHub-Copilot-for-Azure
Simplify telemetry hook client detection with explicit caller arguments
- Dominant language
- Python
- Stars
- 250
- Forks
- 204
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 67
Description
## Problem
The shared `track-telemetry.sh` and `track-telemetry.ps1` scripts infer the active client from hook payload fields and environment variables. Session-start payloads can omit tool- and transcript-specific fields, so the Copilot/VS Code manifest currently needs an additional environment-variable marker to distinguish VS Code from Claude Code.
Client detection is spread across payload heuristics such as `COPILOT_CLI`, `cursor_version`, VS Code tool/transcript markers, and the fallback Claude format. This is difficult to reason about and can become fragile as hook payload schemas evolve.
## Proposed improvement
Allow the telemetry scripts (and the Cursor Node dispatcher) to accept an explicit argument identifying the calling hook manifest or client family. Update each client-specific hook manifest to pass a distinct value, for example:
- `copilot-hooks.json`: `copilot-vscode` or a more specific value when the runtime can distinguish the client
- `claude-hooks.json`: `claude`
- `cursor-hooks.json`: `cursor`
Use this argument as the primary client signal while retaining payload-based detection where it is still needed, such as distinguishing Copilot CLI from VS Code within their shared manifest or identifying VS Code Insiders.
## Expected outcome
- Reduce reliance on undocumented or optional payload fields.
- Remove the special-purpose `AZURE_SKILLS_HOOK_CLIENT_FAMILY` environment variable if explicit arguments cover the same need.
- Keep Bash, PowerShell, and Node dispatcher behavior consistent.
- Preserve backward compatibility for direct script invocation and older clients by falling back to the existing detection logic when no argument is supplied.
- Add cross-client tests for argument-based detection and fallback behavior.
Contributor guide
Research direction
Start with the shared track-telemetry.sh and track-telemetry.ps1 scripts, then inspect copilot-hooks.json, claude-hooks.json, cursor-hooks.json, and the Cursor Node dispatcher. Trace the existing client-detection fallback before adding cross-client tests. Done means explicit arguments work consistently, fallback behavior remains compatible, and the special-purpose environment marker is no longer needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, powershell, shell
- Domain
- observability, tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100