Conversation
Pull Request Test Coverage Report for Build cfbde458-1260-4070-97a6-d093d2b09807Details
💛 - Coveralls |
Add Segment-based telemetry to track CLI usage anonymously. Users can opt-out via `astro telemetry disable` or ASTRO_TELEMETRY_DISABLED=1. Features: - Fire-and-forget pattern using detached subprocess - Tracks command paths (not arguments/values) - Detects agent (Claude Code, Cursor) and CI environments - Anonymous user ID stored in config Co-Authored-By: Claude <noreply@anthropic.com>
for more information, see https://pre-commit.ci
3dee135 to
a283e63
Compare
There was a problem hiding this comment.
Pull request overview
Introduces anonymous telemetry to the Astro CLI, including opt-in/out controls and an internal sender command that posts command-usage events to the Astronomer telemetry API.
Changes:
- Add
pkg/telemetryfor enablement checks, context detection, payload construction, and async “fire-and-forget” sending via a detached subprocess. - Add
astro telemetry {enable|disable}plus hidden internal_telemetry-sendcommand. - Add config keys for telemetry enabled state and anonymous ID persistence.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/telemetry/telemetry.go | Core telemetry logic (enablement, anonymous ID, context detection, async spawn). |
| pkg/telemetry/send.go | HTTP sender + stdin-driven sender entrypoint for subprocess. |
| pkg/telemetry/telemetry_test.go | Unit tests for enablement, context detection, URL override, anonymous ID, and command path parsing. |
| cmd/telemetry.go | User-facing astro telemetry command and subcommands. |
| cmd/telemetry_send.go | Hidden internal _telemetry-send command wiring. |
| cmd/telemetry_test.go | Tests for telemetry command wiring and status output. |
| cmd/root.go | Hooks telemetry tracking into the root command and registers telemetry commands. |
| config/types.go | Adds new config fields for telemetry. |
| config/config.go | Registers defaults for telemetry config keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Skip PersistentPreRunE chain for _telemetry-send subprocess to avoid network I/O, token validation, and recursive telemetry tracking - Use ordered slices instead of maps in DetectContext to ensure deterministic results (generic CI checked last) - Accept full 2xx range in Send() instead of only 200 - Collect real OS version via uname/ver instead of duplicating GOOS/GOARCH Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Already identified by the top-level source field on the payload. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The value is runtime.GOARCH (cpu architecture), not a platform. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Set SilenceUsage/SilenceErrors at construction time on _telemetry-send command instead of inside RunE - Write minimal config to in-memory fs before InitConfig in tests to avoid touching the real filesystem Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace test-only extractCommandPath/splitCommandPath helpers with actual cobra commands so the test exercises the production code path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Bound stdin read in _telemetry-send to 64KB via io.LimitReader - Drain response body before close to allow HTTP connection reuse - Replace fragile cmd.Name() string match with cobra annotation for PersistentPreRunE bypass - Log subprocess spawn failures in debug mode - Add one-time first-run notice to stderr informing users about telemetry and how to opt out Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Check return value of io.Copy (errcheck) - Extract magic number to named constant maxStdinBytes (mnd) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jlaneve
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1alpha1/telemetry) with sourceastro-cliastro telemetry disableorASTRO_TELEMETRY_DISABLED=1Commands
astro telemetry- Show current telemetry statusastro telemetry enable- Enable telemetryastro telemetry disable- Disable telemetryEnvironment Variables
ASTRO_TELEMETRY_DISABLED=1- Disable telemetry (overrides config)ASTRO_TELEMETRY_API_URL- Override the telemetry API endpointASTRO_TELEMETRY_DEBUG=1- Run telemetry synchronously with debug output to stderrTest plan
astro telemetryshows enabled/disabled stateastro telemetry disable/astro telemetry enablework correctlyASTRO_TELEMETRY_DISABLED=1overrides configASTRO_TELEMETRY_DEBUG=1shows request/response on stderr🤖 Generated with Claude Code