Skip to content

Implement PostToolUse telemetry hook scripts#30

Draft
IEvangelist wants to merge 3 commits into
mainfrom
dapine/agent-telemetry-hooks
Draft

Implement PostToolUse telemetry hook scripts#30
IEvangelist wants to merge 3 commits into
mainfrom
dapine/agent-telemetry-hooks

Conversation

@IEvangelist

@IEvangelist IEvangelist commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

Replaces the no-op placeholder track-telemetry.{sh,ps1} hooks with the real implementation. The scripts run on every agent PostToolUse event, parse the hook JSON across Copilot CLI (camelCase), Claude Code, and VS Code (snake_case) payloads, and detect:

  • Aspire skill invocations — the skill/Skill tool with an allowlisted Aspire skill name, or a SKILL.md read under an Aspire skills path.
  • Aspire MCP tool callsaspire-* (Copilot), mcp__aspire__* (Claude), mcp_aspire_* (VS Code).
  • Aspire skill reference-file reads — non-SKILL.md files under an Aspire skill folder.

Matching events are forwarded to aspire agent telemetry (resolved from PATH; ASPIRE_CLI_COMMAND overrides for testing). Non-Aspire tool uses are ignored.

Privacy: only Aspire-owned identifiers are emitted (allowlisted skill/tool name, the skill-relative reference path, a session id) — never absolute paths, repo/user names, file contents, or tool arguments. Output is redirected to null so a banner can never contaminate the hook's JSON stdout, and every path ends in {"continue":true} / exit 0 so a failure can't break the agent session.

Opt-out: a single switch — the script skips entirely when ASPIRE_CLI_TELEMETRY_OPTOUT is set, and the Aspire CLI command honors the same switch before publishing.

The companion aspire agent telemetry command and aspire agent init auto-registration live in microsoft/aspire#18009; transparency docs in microsoft/aspire.dev#1229. Draft pending coordinated review.

Part of microsoft/aspire#18008

Testing

Validated both scripts (Git Bash + PowerShell 7) with sample Copilot CLI / Claude Code / VS Code payloads: skill, MCP-tool, and reference-file detection; aspire: skill-prefix stripping; non-Aspire tool calls ignored; and the opt-out env var suppressing all output. The companion repo adds TelemetryHookScriptTests that exercise the materialized scripts end-to-end.

Replace the no-op placeholder track-telemetry.{sh,ps1} hooks with the real
implementation. The scripts parse the hook JSON across Copilot CLI (camelCase),
Claude Code, and VS Code (snake_case) payloads, detect Aspire skill invocations,
Aspire MCP tool calls (aspire-*, mcp__aspire__*, mcp_aspire_*), and Aspire skill
reference-file reads, then forward a low-cardinality usage event to
'aspire agent telemetry'.

Only Aspire-owned identifiers are emitted (skill/tool name, the skill-relative
reference path, a session id) - never absolute paths, repo names, or user names.
Telemetry is suppressed when ASPIRE_CLI_TELEMETRY_OPTOUT or
ASPIRE_CLI_AGENT_TELEMETRY_OPTOUT is set; the Aspire CLI independently
re-validates and re-checks opt-out before publishing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Honor only ASPIRE_CLI_TELEMETRY_OPTOUT in the PostToolUse telemetry hook
scripts. Drop the AI-specific ASPIRE_CLI_AGENT_TELEMETRY_OPTOUT check; the
Aspire CLI command honors the same switch before publishing, so the script
short-circuit and the CLI now share one opt-out.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The hook scripts gate on a single ASPIRE_CLI_TELEMETRY_OPTOUT switch. Update
the opt-out comment to describe it as the single opt-out that also gates the
`aspire agent telemetry` command path, matching the embedded copies in
microsoft/aspire so the two stay byte-identical. Comment-only; no behavior
change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant