Telemetry¶
Overview¶
The telemetry package provides an opt-in framework for collecting pseudonymous usage analytics from CLI tools built on GTB. It is designed around three principles:
- Explicit consent — telemetry is never enabled by default. Users must opt in via
telemetry enable, theinitprompt, or theTELEMETRY_ENABLEDenvironment variable. - Privacy by design — no personally identifiable information is collected. Machine IDs are derived from multiple system signals and hashed with SHA-256. Command arguments, file contents, and IP addresses are never recorded.
- Pluggable backends — tool authors choose where data goes. The framework ships noop, stdout, file, HTTP, and OpenTelemetry (OTLP) backends, and supports custom implementations.
Quick Start¶
Enable telemetry for your tool¶
props.Tool{
Name: "mytool",
Features: props.SetFeatures(
props.Enable(props.TelemetryCmd),
),
Telemetry: props.TelemetryConfig{
Endpoint: "https://analytics.example.com/events",
},
}
Emit events from commands¶
func runMyCommand(p *props.Props) error {
start := time.Now()
// ... command logic ...
p.Collector.TrackCommand("my-command", time.Since(start).Milliseconds(), 0, nil)
return nil
}
User opt-in¶
mytool telemetry enable # opt in
mytool telemetry status # check current state
mytool telemetry disable # opt out (drops all pending events)
mytool telemetry reset # clear local data + request remote deletion
Related Documentation¶
- Telemetry Command — CLI commands for managing telemetry
- Props — dependency injection container (
Collectorfield) - Create a Custom Telemetry Backend — implement your own backend
- Create a Custom Deletion Requestor — GDPR deletion for custom backends
- Telemetry Specification — full design spec
- Vendor Backends Specification — Datadog and PostHog backends
In this section¶
- What's Collected — Event types, the data collected, and machine identification.
- Backends — Pluggable backends, selection precedence, delivery modes, and buffering.
- Configuration — TelemetryConfig, environment variables, and initialiser integration.
- Privacy & Consent — Two-level gating, GDPR deletion, consent withdrawal, and known limitations.
- Testing — Testing telemetry collection and backends.