Skip to content

feat(telemetry): CLI flow events - #243

Merged
LorrisSaintGenez merged 6 commits into
mainfrom
feat/events-flow
Jun 15, 2026
Merged

LorrisSaintGenez merged 6 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

Go on the CLI Segment debugger: https://app.segment.com/algolia-app/sources/segment_cli_dev/debugger

Then try the following commands. You should see the events being logged into Segment. sequence property + timestamp combo indicate the real order of events (Segment sometimes shows events in the wrong order)

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

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

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

# Signup variant
go run ./cmd/algolia auth signup

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

# Application create + plan change funnels
go run ./cmd/algolia application create
go run ./cmd/algolia application upgrade
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
Comment thread pkg/cmd/root/root.go Outdated
}()
select {
case <-done:
case <-time.After(3 * time.Second):

@8bittitan 8bittitan Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IMO we should make this a lot shorter even, like 500ms -> 1s at the worst. Or even keep it fire-and-forget as it was prior.

A healthy flush completes in tens of ms; the cap only matters when the
endpoint is unreachable, where bailing out faster keeps the CLI snappy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LorrisSaintGenez
LorrisSaintGenez merged commit 4e3114a into main Jun 15, 2026
3 checks passed
@LorrisSaintGenez
LorrisSaintGenez deleted the feat/events-flow branch June 15, 2026 21:40
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
algolia 1.11.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* feat(open): add new dashboard shortcuts by @LorrisSaintGenez in algolia/cli#225
* feat(application): update/upgrade/downgrade/plans commands by @LorrisSaintGenez in algolia/cli#224
* docs: add npm install option to README by @tkrugg in algolia/cli#223
* feat(application): add name, tos and plan selection during application creation by @LorrisSaintGenez in algolia/cli#227
* feat(identify): send user data to identify after oauth flow by @LorrisSaintGenez in algolia/cli#228
* feat(application): more precise plan upgrade/downgrade direction by @LorrisSaintGenez in algolia/cli#226
* feat(telemetry): CLI flow events by @LorrisSaintGenez in algolia/cli#243
* feat: add auth get command by @levimichael in algolia/cli#253
* chore(api client): Upgrade Algolia Go API client by @tkrugg in algolia/cli#254
* fix: update 'auth get' to support refresh by @levimichael in algolia/cli#255
* feat(auth): Add token to `auth get` command by @levimichael in algolia/cli#257

## New Contributors
* @levimichael made their first contribution in algolia/cli#253

**Full Changelog**: https://github.com/algolia/cli/compare/v1.10.5...v1.11.0</pre>
  <p>View the full release notes at <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Falgolia%2Fcli%2Fpull%2F%3Ca+href%3D"https://github.com/algolia/cli/releases/tag/v1.11.0">https://github.com/algolia/cli/releases/tag/v1.11.0</a>.</p">https://github.com/algolia/cli/releases/tag/v1.11.0">https://github.com/algolia/cli/releases/tag/v1.11.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!13019
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.

2 participants