Skip to content

telemetry: add best-effort usage telemetry recorder - #1378

Open
BolajiOlajide wants to merge 1 commit into
mainfrom
src-cli-usage-telemetry
Open

BolajiOlajide wants to merge 1 commit into
mainfrom
src-cli-usage-telemetry

Conversation

@BolajiOlajide

Copy link
Copy Markdown
Contributor

Adds the internal/telemetry package: a Recorder that records src-cli usage events to the authenticated Sourcegraph instance via the Telemetry V2 recordEvents GraphQL mutation. Recording is strictly best-effort — validation, network, GraphQL, timeout, and old-instance (<5.2) failures are all swallowed (optionally surfaced via WithDebug for -v) and never affect the command the user ran. Command identity is carried in feature/action with numeric-only, PII-free metadata (no privateMetadata), feature/action names are validated against Sourcegraph's server-side naming rules, and each Record applies a short 2s timeout since events are sent synchronously before process exit. This is the foundational package only; wiring it into cmd/src/main.go and the opt-out/suppression logic land in follow-up changes.

Test plan

  • go test ./internal/telemetry/... — unit tests cover a well-formed mutation, empty metadata, pre-send validation, and swallowed network/GraphQL/nil-client failures plus timeout application.
  • go vet ./internal/telemetry/... passes.

Add the internal/telemetry package: a Recorder that records src-cli usage
events to the authenticated Sourcegraph instance via the Telemetry V2
recordEvents GraphQL mutation. Recording is strictly best-effort — network,
GraphQL, timeout, and old-instance (<5.2) failures are all swallowed and never
affect the command the user ran. Command identity is encoded in feature/action
with numeric-only metadata (no user content, no privateMetadata), and names are
validated against Sourcegraph's server-side naming rules.
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.

1 participant