Add anonymous usage telemetry via Segment#357
Draft
schurchleycci wants to merge 3 commits into
Draft
Conversation
Instruments all commands with a Segment-backed telemetry client that records which command ran, which flags were set, and whether it succeeded. No arguments, flag values, file paths, or PII are collected. Implementation: - internal/telemetry: Segment client with Mode enum (NOOP/Send/Log), noop and logging backends, never returns a nil client - Delegation pattern: a lazily-populated delegatingTelemetry is created at startup; PersistentPreRunE resolves the mode and sets the real client, then recordTelemetryForSubcommands wraps each RunE without needing per-command changes - Opt-out: --no-telemetry flag, CHUNK_NO_TELEMETRY / NO_ANALYTICS / DO_NOT_TRACK / CI env vars, and NoTelemetry field in user config all switch the client to ModeNOOP - Instance ID: a stable UUID is generated on first run and stored in ~/.config/chunk/config.json; used as the anonymous device identifier - Build: Segment write key injected at release time via -ldflags Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds sender, team_name, action, and organization_id (when available via CIRCLECI_ORG_ID) to every track event to meet CCI Segment standards. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
go mod tidy moves pflag from indirect to direct since it's now explicitly imported by the telemetry code via cobra's flag types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
@schurchleycci is there a reason this is still in draft? |
Contributor
Author
Yeah, I'm waiting to hear back from the data team on how they want to handle Segment / event tracking generally for chunk CLI. |
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
Adds anonymous usage telemetry to chunk via Segment. All events are opt-out and no PII is collected.
Events
`command_invocation`
Fired after every CLI command completes.
`identify` (one-time)
Fired once on first run when the `instanceID` UUID is generated. Associates the device with the anonymous ID for Segment/Amplitude. No additional properties beyond the `anonymous_id`.
What is NOT collected
Opt-out
Telemetry is automatically disabled in any of these conditions:
--no-telemetryflag on any commandCHUNK_NO_TELEMETRY=1environment variableNO_ANALYTICSenvironment variable setDO_NOT_TRACKenvironment variable setCIenvironment variable set (all CI systems)noTelemetry: truein~/.config/chunk/config.jsonImplementation
internal/telemetrypackage with three modes:ModeSend(production),ModeNOOP(disabled),ModeLog(debug/stderr)-ldflagsin.goreleaser.yaml; empty key = no-op, so no events are ever sent from development buildsinstanceIDUUID persisted in~/.config/chunk/config.jsonon first runrecordTelemetryForSubcommandsin root command setupTest plan
task testpassestask lintpassesCHUNK_TELEMETRY_LOG=1(ModeLog) and verify[telemetry] track command_invocationon stderr with correct propertiesCHUNK_NO_TELEMETRY=1and confirm no events are emitted🤖 Generated with Claude Code