Skip to content

fix(cli): send analytics without a person profile when logged out - #3724

Merged
proksh merged 3 commits into
mainfrom
ma-4381
Nov 2, 2026
Merged

proksh merged 3 commits into
mainfrom
ma-4381

Conversation

@proksh

@proksh proksh commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

The CLI creates a PostHog person profile for every machine that runs it, even for people who never logged in and have no user data to attach. Logged-out usage is now counted without creating a profile. Fixes MA-4381.

Approach

  • Logged out (no token): events are sent with $process_person_profile: false and without $groups, including when old user or org data is still cached after maestro logout.
  • Logged in: unchanged, with $identify and identified events.
  • Token timing: the token is read when an event is tracked, so events from maestro logout still count as logged in after it deletes the token.
  • Shutdown: Analytics.close() now waits for tracked events before flushing, so a slow identify no longer loses them.
  • Tests: the maestro-cli test task, e2e/run_tests and the test-e2e.yaml and test-e2e-ios-intel.yaml workflows now set MAESTRO_CLI_NO_ANALYTICS, so test runs stop sending real events.

To make this testable, the trackEvent logic moved into a new EventDispatcher class, so most of the Analytics.kt diff is moved code.

Verification

  • Added EventDispatcherTest. ./gradlew :maestro-cli:test passes.
  • Ran the built CLI against PostHog on a fresh analytics ID:
    • Logged out: person_mode = propertyless.
    • Logged in: $identify sent, person_mode = full, with $groups.
  • Analytics.close() and the Analytics wiring have no unit tests, because Analytics is a singleton with a hardcoded client. I checked those with the runs above.

@linear-code

linear-code Bot commented Nov 2, 2026

Copy link
Copy Markdown

MA-4381

@Fishbowler Fishbowler left a comment

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.

the maestro-cli test task now sets MAESTRO_CLI_NO_ANALYTICS, so test runs stop sending real events

This already exists for e2e/cli but perhaps e2e/run_tests needs this too? Also in .github/workflows/test-e2e.yaml ?

@proksh

proksh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

the maestro-cli test task now sets MAESTRO_CLI_NO_ANALYTICS, so test runs stop sending real events

This already exists for e2e/cli but perhaps e2e/run_tests needs this too? Also in .github/workflows/test-e2e.yaml ?

Good catch.

e2e/run_tests now sets MAESTRO_CLI_NO_ANALYTICS=1. I also set it at the top level of test-e2e.yaml and test-e2e-ios-intel.yaml.

@proksh
proksh merged commit b80bd24 into main Nov 2, 2026
18 checks passed
@proksh
proksh deleted the ma-4381 branch November 2, 2026 14:26
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