Skip to content

feat(analytics): add anonymous Mixpanel product analytics - #85

Merged
lauridskern merged 2 commits into
mainfrom
feat/mixpanel-analytics
Nov 3, 2026
Merged

lauridskern merged 2 commits into
mainfrom
feat/mixpanel-analytics

Conversation

@lauridskern

@lauridskern lauridskern commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Adds basic product analytics so we can see how many installations use Mobile Dev and which tools they use most.

What's tracked

  • Session Started: once each time a host connects. Mixpanel's unique-user count on this event gives installations per host.
  • Tool Called: the tool name and a success or error outcome. Tools that poll or send input many times a second are skipped.
  • Each event also carries host, plugin_version, os, a timestamp, an insert ID, and the existing installation ID as distinct_id.

Privacy

  • Sent from the server only, through instrumentProductAnalytics in packages/core/src/analytics.ts, which wraps the tools/call handler. Requests go to api-eu.mixpanel.com/track?ip=0&verbose=1, so no IPs are stored and no locations are derived; verbose=1 makes Mixpanel report rejected batches, which analytics.flush counts as failed.
  • No user profiles, tool arguments or results, device details, paths or account data.
  • Release builds only. MOBILE_DEV_TELEMETRY=off turns analytics off along with Sentry. MOBILE_DEV_ANALYTICS=off or DO_NOT_TRACK=1 turns off only analytics.
  • PRIVACY.md and the website privacy page now cover what Mixpanel receives, Mixpanel as a recipient, retention and the opt-out. docs/telemetry.md has a new "Product analytics" section.

Telemetry

  • New Sentry counter analytics.flush by outcome, so Mixpanel delivery failures show up. Existing Sentry coverage is unchanged.

Tests

  • New packages/core/test/analytics.test.ts passes, along with the existing telemetry tests.
  • npm test: 962 passed, 5 failed. All 5 are in agent-device-catalog.test.ts and fail the same way on main.

Before release

  • Confirm the Mixpanel project uses EU data residency. If it doesn't, the EU endpoint rejects events.
  • Configure or confirm the 24-month retention stated in the policy.
  • Make sure a DPA with Mixpanel is in place.
  • Legal check: analytics is on by default with an opt-out, on the basis of legitimate interest, like the current Sentry usage counters. A strict reading of ePrivacy could require asking for consent first.

…ation

- Install analytics through instrumentProductAnalytics, which wraps only the
  typed tools/call handler; telemetry.ts no longer imports or calls analytics.
- Report sessions explicitly from the plugin's oninitialized instead of as a
  side effect of setServerTelemetryHost.
- Decide once at startup whether analytics is on; off servers install nothing.
- Count a batch as delivered only when Mixpanel's verbose reply accepts it.
- Stop dropping mobile_repair_input and other *_input feature tools.
- Move the Mixpanel token and endpoint next to the Sentry constants and the
  flush counter next to the other server metrics.
@lauridskern
lauridskern merged commit 8930365 into main Nov 3, 2026
12 checks passed
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