Skip to content

feat(telemetry): CLI flow events#243

Open
LorrisSaintGenez wants to merge 5 commits into
mainfrom
feat/events-flow
Open

feat(telemetry): CLI flow events#243
LorrisSaintGenez wants to merge 5 commits into
mainfrom
feat/events-flow

Conversation

@LorrisSaintGenez

@LorrisSaintGenez LorrisSaintGenez commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What

Foundations (#238)

  • Fixes the telemetry client lifecycle: Close() deferred in Execute() with a 3s timeout; NoOpTelemetryClient fallback on init failure.
  • Track with custom properties + monotonic sequence counter per invocation.
  • Event catalog (events.go): Flow/Step/Direction/ErrorClass enums, FlowTracker, event name constants.
  • Command Completed emitted before final flush; guard against orphan events when PersistentPreRunE never ran.

Auth flow events (#239)

  • RunOAuthFlow emits CLI Auth Started → one terminal event (Completed/Aborted/Failed) with step, duration_ms, error_class.
  • Event struct + typed constructors + nil-safe TrackEvent(ctx, Event) helper.
  • Shared telemetrytest.RecordingClient for flow event tests.

Logout flow event (#242)

  • auth logout emits CLI Auth Logout (flow: logout) before ClearToken().
  • No event when already signed out; no Identify at logout.

Application create + plan change flow events (#240)

  • application create: CLI Application Create StartedCompleted/Aborted/Failed with step, region, plan, duration_ms, reason. Dry runs not tracked.
  • application upgrade/downgrade: CLI Application Plan Change * with direction, from_plan, to_plan.
  • Every Aborted carries a reason (declined_terms/cancelled/billing_required/already_on_plan/no_candidates).

Env header (#241)

  • Every telemetry request carries X-Algolia-CLI-Env: prod (semver build) or dev (source build). Transport clones the request.
  • Fixes double slash in telemetry URL (//v1/batch).
  • Remaining outside repo: create "CLI (PROD)" Segment source; route telemetry-proxy on the header.

Test

# Foundations + Command Completed
DEBUG=1 go run ./cmd/algolia application plans

# Auth flow: Started → Completed
DEBUG=1 go run ./cmd/algolia auth login

# Abort mid-flow (Esc/Ctrl-C during app selection) → Aborted {step: app_select}
DEBUG=1 go run ./cmd/algolia auth login

# Signup variant
DEBUG=1 go run ./cmd/algolia auth signup

# Logout (signed in → event emitted; already signed out → no event)
DEBUG=1 go run ./cmd/algolia auth logout

# Application create + plan change funnels
DEBUG=1 go run ./cmd/algolia application create
DEBUG=1 go run ./cmd/algolia application upgrade
DEBUG=1 go run ./cmd/algolia application downgrade

GROUT-349
GROUT-351

LorrisSaintGenez and others added 3 commits June 11, 2026 12:45
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Jun 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 55 complexity · 35 duplication

Metric Results
Complexity 55
Duplication 35

View in Codacy

TIP This summary will be updated as you push new changes.

@LorrisSaintGenez LorrisSaintGenez marked this pull request as ready for review June 11, 2026 20:48
@LorrisSaintGenez LorrisSaintGenez marked this pull request as draft June 11, 2026 21:48
LorrisSaintGenez and others added 2 commits June 12, 2026 13:27
…ogin

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LorrisSaintGenez LorrisSaintGenez marked this pull request as ready for review June 12, 2026 20:28
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