Skip to content

feat: anonymous telemetry ping (1/day, opt-out)#334

Merged
pszymkowiak merged 3 commits intomasterfrom
feat/telemetry
Mar 5, 2026
Merged

feat: anonymous telemetry ping (1/day, opt-out)#334
pszymkowiak merged 3 commits intomasterfrom
feat/telemetry

Conversation

@pszymkowiak
Copy link
Collaborator

Summary

  • Fire-and-forget daily ping to POST /telemetry for BPI usage metrics
  • SHA-256 anonymous device hash (hostname:user), no PII collected
  • Sends: version, OS, arch, 24h command count, top 5 commands, savings %
  • Token injected at compile time via option_env!() — not in source code

Opt-out

  • Env var: RTK_TELEMETRY_DISABLED=1
  • Config: [telemetry] enabled = false in ~/.config/rtk/config.toml

Implementation

  • src/telemetry.rs: core module (maybe_ping, device hash, marker file throttle)
  • src/config.rs: TelemetryConfig struct
  • src/tracking.rs: 3 new DB query helpers (count_commands_since, top_commands, overall_savings_pct)
  • src/main.rs: call maybe_ping() at startup
  • .github/workflows/release.yml: inject RTK_TELEMETRY_TOKEN secret in all 3 build jobs

Design

  • 23h marker file throttle — no double pings
  • 2s HTTP timeout — never blocks CLI
  • Spawned in background thread — zero impact on startup
  • Graceful: if anything fails, silently ignored

Test plan

  • cargo test — 609 pass
  • cargo clippy — 0 new warnings
  • Ping sent and received (verified 204 on prod API)
  • Opt-out via RTK_TELEMETRY_DISABLED=1 works (no marker created)
  • Throttle works (no double ping on consecutive runs)
  • Token compiled into binary, not in source
  • Stats visible via GET /telemetry/stats (admin endpoint on rtk-api)

Fire-and-forget daily ping to track active installs for BPI metrics.
- SHA-256 device hash (hostname:user), no PII
- Opt-out: RTK_TELEMETRY_DISABLED=1 or config.toml [telemetry] enabled=false
- Token injected at compile time via option_env!, not in source
- 23h throttle via marker file, 2s timeout, non-blocking thread
All 3 build jobs (binary, DEB, RPM) now receive the token from
GitHub secrets so option_env!() compiles it into release binaries.
@aeppling
Copy link
Contributor

aeppling commented Mar 5, 2026

ok pour moi, peut-être certaines constantes que tu préfèrerais avoir en dehors du code

URL and token are both injected at compile time — no hardcoded
server address in source code. Builds without the env var simply
skip telemetry silently.
@pszymkowiak pszymkowiak merged commit baff6a2 into master Mar 5, 2026
2 of 4 checks passed
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.

2 participants