Skip to content

Add per-command CLI telemetry#791

Merged
FarazPatankar merged 6 commits intomasterfrom
feat/cli-telemetry
Feb 12, 2026
Merged

Add per-command CLI telemetry#791
FarazPatankar merged 6 commits intomasterfrom
feat/cli-telemetry

Conversation

@FarazPatankar
Copy link
Contributor

@FarazPatankar FarazPatankar commented Feb 12, 2026

Summary

  • Adds per-command telemetry that sends a cliEventTrack GraphQL mutation after each CLI invocation
  • Tracks command name, subcommand, duration, success/error (truncated to 256 chars), OS, arch, CLI version, and CI flag
  • User identity comes from existing auth headers — silently skipped when unauthenticated
  • Opt out via DO_NOT_TRACK=1 (follows consoledonottrack.com convention)
  • Updates schema.json with latest from the API

Files changed

File Change
src/telemetry.rs New module — CliTrackEvent struct and async send() function
src/main.rs mod telemetry; declaration
src/macros.rs Wrap command dispatch with timing + telemetry call
src/gql/mutations/strings/CliEventTrack.graphql New mutation definition
src/gql/mutations/mod.rs Register CliEventTrack struct, add DNS_RECORD_TYPE_TXT variant from schema update
src/gql/schema.json Updated from API

Design decisions

  • Typed graphql_client codegen — uses post_graphql::<mutations::CliEventTrack, _>(), matching the rest of the codebase
  • 3-second timeout via tokio::time::timeout prevents stalling on exit
  • Awaited (not spawned) — ensures telemetry completes before process exit, including after interactive commands
  • No new dependencies — uses existing graphql_client, reqwest (via GQLClient), and tokio

Test plan

  • cargo build compiles cleanly
  • cargo test — all 106 tests pass
  • cargo clippy — no new warnings
  • RUST_LOG=reqwest=debug cargo run -- whoami — confirm telemetry POST fires
  • DO_NOT_TRACK=1 cargo run -- whoami — confirm no telemetry POST
  • cargo run -- link (interactive) — confirm telemetry fires after prompt completion
  • cargo run -- login (unauthenticated) — confirm no crash, telemetry silently skipped

FarazPatankar and others added 2 commits February 12, 2026 10:46
Sends command name, subcommand, duration, success/error, OS, arch,
CLI version, and CI flag to the Railway API after each invocation.
Silently skipped when unauthenticated, on network failure, or when
the user opts out via DO_NOT_TRACK=1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pull updated schema with cliEventTrack mutation and replace the raw
JSON POST with typed codegen via graphql_client, matching the rest
of the codebase. Also adds DNS_RECORD_TYPE_TXT from the schema update.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FarazPatankar FarazPatankar added the release/minor Author minor release label Feb 12, 2026
FarazPatankar and others added 2 commits February 12, 2026 16:53
Shows a notice to stderr informing users about CLI usage data
collection, with DO_NOT_TRACK=1 opt-out. Persisted to
~/.railway/notices.json so it only displays once. Suppressed
in CI/non-TTY and when telemetry is already disabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds RAILWAY_NO_TELEMETRY=1 as a Railway-specific alternative to
DO_NOT_TRACK=1 for disabling CLI telemetry. Updates the notice
text to mention both variables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FarazPatankar and others added 2 commits February 12, 2026 20:57
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FarazPatankar FarazPatankar merged commit 330ac9e into master Feb 12, 2026
6 checks passed
@FarazPatankar FarazPatankar deleted the feat/cli-telemetry branch February 12, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/minor Author minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments