feat: add anonymous telemetry and error tracking#135
Merged
Conversation
Add opt-out telemetry via PostHog HTTP API and error tracking via Sentry HTTP envelope API — no SDK dependencies added (ARCH-006 compliant). - PostHog analytics: command usage, flags, exit codes, duration, coarse geo - Sentry error capture: crash reports with stack traces for exit-code-2 errors - IP anonymization: PostHog resolves geo server-side then discards IP - Opt-out: ARCHGATE_TELEMETRY=0 env var or `archgate telemetry disable` - First-run notice: one-time stderr message about data collection - Telemetry command: status/enable/disable subcommands - Docs: telemetry reference page (EN + pt-BR) with full privacy policy - Tests: telemetry-config, telemetry, sentry, telemetry-notice
Deploying archgate-cli with
|
| Latest commit: |
72e6d72
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5efde030.archgate-cli.pages.dev |
| Branch Preview URL: | https://feat-telemetry.archgate-cli.pages.dev |
Add proper Portuguese diacritical marks (ã, é, ê, ç, í, ó, ú, etc.) throughout the pt-BR telemetry docs page.
Telemetry is documented in the docs site instead of showing a CLI notice.
Use the official Sentry SDK for breadcrumbs and distributed tracing. - Breadcrumbs track command execution flow for crash context - Tracing propagated to plugins.archgate.dev via sentry-trace headers - addBreadcrumb() exported for use across CLI modules - flushSentry() ensures events are sent before process exit
…tags - install_method: binary, proto, local, or package-manager - install_path: process.execPath for debugging platform-specific issues - release: set to plain version string (e.g., "0.17.2")
…n.env
- New ADR ARCH-014 with automated rule no-process-env
- Replace all process.env references in src/ with Bun.env
- Replace require("package.json") with static import (bundled at compile)
- Remove unnecessary typeof Bun guards (CLI only runs on Bun)
Use the official PostHog Node SDK for event capture with automatic batching, retry, and flush. Adds timeout to shutdown to prevent hanging on exit. Integration test harness disables telemetry via ARCHGATE_TELEMETRY=0 to prevent SDK event loops from holding the subprocess open.
Use Sentry's lightweight "light" variant which excludes all OpenTelemetry auto-instrumentation (600+ modules of OTel for MongoDB, Redis, Express, Kafka, etc.). The light mode provides error capture + breadcrumbs which is all a CLI needs. Binary size impact: 0 MB increase (was +10 MB with @sentry/bun). Module count: 434 (same as baseline, was 1,129 with @sentry/bun).
…ntime name - install_path: use Bun.main (entry script) instead of process.execPath (which returns the bun binary, e.g. .proto/tools/bun/1.3.11/bun.exe) - runtime: filter out NodeContext integration which overrides our runtime context with "node" — we set it explicitly to "bun" - install_method detection also uses archgate path instead of bun path
PostHog signup not available yet. The telemetry module and posthog-node dependency are kept for when PostHog is ready — just not wired into cli.ts. Sentry error tracking remains active. Also fixes cli.ts telemetry integration that was accidentally reverted during the binary size comparison.
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
fetch())fetch())archgate telemetry [status|enable|disable]commandARCHGATE_TELEMETRY=0env var orarchgate telemetry disableKey design decisions
Files added
src/helpers/telemetry-config.ts~/.archgate/config.jsonsrc/helpers/telemetry.tssrc/helpers/sentry.tssrc/helpers/telemetry-notice.tssrc/commands/telemetry.tsarchgate telemetrycommandtests/helpers/telemetry*.test.tstests/helpers/sentry.test.tsdocs/.../reference/telemetry.mdxTest plan
bun run validatepasses (lint, typecheck, format, 492 tests, 21/21 ADR checks, build)ARCHGATE_TELEMETRY=0prevents all network callsarchgate telemetry disablepersists to config and stops tracking