Skip to content

feat: resolve real user ID in analytics via UserStore#342

Merged
theFong merged 1 commit intomainfrom
feat/analytics-user-store
Mar 24, 2026
Merged

feat: resolve real user ID in analytics via UserStore#342
theFong merged 1 commit intomainfrom
feat/analytics-user-store

Conversation

@theFong
Copy link
Member

@theFong theFong commented Mar 24, 2026

Summary

  • Adds a UserStore interface to the analytics package with GetCurrentUserID() (string, error)
  • SetUserStore() is called once during init with noLoginCmdStore, which already implements this method
  • GetOrCreateAnalyticsID() now tries the store first for the real user ID, falling back to the anonymous UUID
  • Simplifies PersistentPostRunE — no more manual user resolution in cmd.go
  • Logout is handled naturally: once credentials are cleared, the store call fails and we fall back to the anon ID

Test plan

  • Verify brev ls still reports analytics with user ID when logged in
  • Verify analytics falls back to anonymous UUID when logged out
  • Verify brev logout followed by a command uses the anonymous ID

Instead of manually passing user IDs through callers, analytics now
accepts a UserStore interface and resolves the user ID directly.
GetOrCreateAnalyticsID prefers the real user ID when available,
falling back to the anonymous UUID.
@theFong theFong requested a review from a team as a code owner March 24, 2026 18:19
@theFong theFong merged commit 1a12fd5 into main Mar 24, 2026
9 checks passed
@theFong theFong deleted the feat/analytics-user-store branch March 24, 2026 22:56
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