chore(events): add cli-emitted events#230
Closed
LorrisSaintGenez wants to merge 7 commits into
Closed
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 46 |
| Duplication | 33 |
TIP This summary will be updated as you push new changes.
CI only enforces gofumpt via golangci-lint; golines (run by 'task format') rewrapped untouched code and added noise to the diff. AGENTS.md: avoid unrelated formatting churn. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Started carried an ignored plan param; the other events mixed the raw --plan input with the resolved template id under one 'plan' property. Now: requested_plan (raw --plan, omitted when picked interactively) on Started, and a from_plan/to_plan pair (plan ids, 'unknown' fallback) on the accepted/declined/failed/completed events. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
version (semver for releases, 'main' for source builds) lets Segment destinations route dev vs prod traffic to the right Amplitude project. event_index is the per-invocation emit order: a deterministic ordering key that doesn't depend on Amplitude's undocumented same-millisecond tie-breaking, complementing the spaced timestamps. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AuthStepBrowser was never emitted (browser failures have their own non-fatal event); root.go now goes through the CommandInvoked constructor like every other catalog event; and the error_class fallback maps Go's generic error types to 'unknown' instead of letting *errors.errorString dominate the dimension with no signal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
EnsureAuthenticated and ReauthenticateIfExpired ran the OAuth flow with context.Background(), silently dropping every CLI Auth * event on the most common auth path (running any command while logged out, or with an expired session). Thread the command context down so lazy logins emit the same flow events, attributed to the command that triggered them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Adds the CLI-emitted flow events for GROUT-349 on top of the existing
Command Invoked: command lifecycle, OAuth auth flow, application create, and plan upgrade/downgrade funnels.Event catalog (
pkg/telemetry/events.go)All event names and property schemas live in one catalog; call sites go through typed constructors so names and keys can't drift.
Command Invoked/Command Completed(duration_ms,succeeded,exit_code) /Command Failed(error_class,error_source,http_status)CLI Auth Started / Browser Opened / Browser Failed / Callback Received / Completed / Failed, withflow(login|signup) andstepon failuresCLI Application Create Started / Completed / Failed / Aborted, withtriggered_from(auth_flow|explicit_command)CLI Application Upgrade|Downgrade Started / Accepted Terms / Declined Terms / Failed / Completed, withrequested_planon Started (raw--plan, omitted when picked interactively) and a consistentfrom_plan/to_planpair (plan ids,unknownfallback)Every tracked event also carries:
version— semver for released binaries,mainfor source builds, so Segment destinations can route dev vs prod traffic to separate Amplitude projectsevent_index— per-invocation emit order; the deterministic ordering ground truthDelivery and ordering
Execute, instead of the library's 5s periodic flushes — fixes events being split across requests and dropped at exitevent_timeto ms and same-ms ordering is undocumented);event_indexcomplements this deterministicallyEnsureAuthenticated, session expiry) now thread the command context, so auth flow events are also emitted on the most common auth path, attributed to the triggering commandError classification (
pkg/cmdutil/classify.go)ClassifyErrormaps errors to a stable, low-cardinalityerror_class+error_source(+http_statuswhen carried). Dashboard non-2xx responses now return a typeddashboard.APIErrorcarrying the status. Genericerrors.New/fmt.Errorfroot causes classify asunknown.Beyond telemetry
root.goerror handling is restructured: exit-code resolution is extracted toexitCodeForErrorsoCommand Completedcan carry it. Printing behavior is unchanged.event_index, plan-change funnel events by direction, classifier table.Follow-ups (not in this PR)
version, millisecond resolution on the Amplitude project