Skip to content

Adds anonymous telemetry#2009

Merged
schnie merged 11 commits intomainfrom
telemetry
Feb 25, 2026
Merged

Adds anonymous telemetry#2009
schnie merged 11 commits intomainfrom
telemetry

Conversation

@schnie
Copy link
Member

@schnie schnie commented Feb 11, 2026

Summary

  • Add anonymous telemetry to track CLI command usage
  • Events are sent to the Astronomer telemetry API (/v1alpha1/telemetry) with source astro-cli
  • Fire-and-forget pattern using a detached subprocess ensures no impact on CLI responsiveness
  • Users can opt out via astro telemetry disable or ASTRO_TELEMETRY_DISABLED=1

Commands

  • astro telemetry - Show current telemetry status
  • astro telemetry enable - Enable telemetry
  • astro telemetry disable - Disable telemetry

Environment Variables

  • ASTRO_TELEMETRY_DISABLED=1 - Disable telemetry (overrides config)
  • ASTRO_TELEMETRY_API_URL - Override the telemetry API endpoint
  • ASTRO_TELEMETRY_DEBUG=1 - Run telemetry synchronously with debug output to stderr

Test plan

  • astro telemetry shows enabled/disabled state
  • astro telemetry disable / astro telemetry enable work correctly
  • ASTRO_TELEMETRY_DISABLED=1 overrides config
  • ASTRO_TELEMETRY_DEBUG=1 shows request/response on stderr
  • All existing and new tests pass

🤖 Generated with Claude Code

@schnie schnie requested a review from a team as a code owner February 11, 2026 14:42
@coveralls-official
Copy link

coveralls-official bot commented Feb 11, 2026

Pull Request Test Coverage Report for Build cfbde458-1260-4070-97a6-d093d2b09807

Details

  • 112 of 251 (44.62%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 35.131%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/root.go 10 12 83.33%
cmd/telemetry_send.go 10 12 83.33%
cmd/telemetry.go 52 62 83.87%
pkg/telemetry/send.go 0 35 0.0%
pkg/telemetry/telemetry.go 40 130 30.77%
Totals Coverage Status
Change from base Build 96e87396-dad3-4edc-9a17-8881e17d45df: 0.03%
Covered Lines: 23090
Relevant Lines: 65726

💛 - Coveralls

@schnie schnie marked this pull request as draft February 13, 2026 17:20
schnie and others added 2 commits February 20, 2026 12:57
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>
@schnie schnie changed the title feat: add anonymous telemetry tracking Adds anonymous telemetry tracking Feb 20, 2026
@schnie schnie force-pushed the telemetry branch 3 times, most recently from 3dee135 to a283e63 Compare February 20, 2026 19:04
@schnie schnie marked this pull request as ready for review February 20, 2026 19:51
@schnie schnie self-assigned this Feb 23, 2026
@schnie schnie requested a review from Copilot February 23, 2026 16:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/telemetry for 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-send command.
  • 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.

schnie and others added 3 commits February 23, 2026 12:34
- 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>
@schnie schnie changed the title Adds anonymous telemetry tracking Adds anonymous telemetry Feb 23, 2026
jlaneve and others added 2 commits February 25, 2026 13:37
- 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>
@schnie schnie merged commit 80a727b into main Feb 25, 2026
3 of 5 checks passed
@schnie schnie deleted the telemetry branch February 25, 2026 19:19
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.

3 participants