Skip to content

feat(analytics): E-02 track installs and updates and open the welcome page - #59

Closed
navidshad wants to merge 2 commits into
devfrom
analytics-fixes/E-02-install-event
Closed

navidshad wants to merge 2 commits into
devfrom
analytics-fixes/E-02-install-event

Conversation

@navidshad

Copy link
Copy Markdown
Collaborator

What

  • chrome.runtime.onInstalled now sends one Mixpanel event on the install's analytics id:
    • extension_installed (reason install)
    • extension_updated with previous_version (reason update)
    • A Chrome update is ignored.
  • If the install id does not exist yet, it is created with the same key (analyticsAnonymousId) and format as src/plugins/mixpanel.ts.
  • On a first install it opens:
    https://subturtle.app/?install_id=<install id>&utm_source=extension&utm_medium=install

Why

There was no install event anywhere. The landing page could not be joined to the install that follows it. Work list: subturtle-doc docs/tech/analytics-fixes-implementation.md (row E-02).

Service worker safety

  • mixpanel-browser needs window and document. A MV3 service worker has neither. So the background sends the event with fetch to Mixpanel's /track endpoint (through MIXPANEL_API_HOST), in the same shape mixpanel-browser uses.
  • The listener is added at the top level, so Chrome finds it when it wakes the worker.
  • A failed request or a failed tab open is logged and never throws.

One change from the work list

The welcome page opens only for Web Store installs (the manifest has update_url). Unpacked builds (local dev, the CI e2e run, a dev zip) still send the event but do not open subturtle.app. This stops dev reloads and CI runs from opening the site and counting fake installs on the landing page.

How tested

  • New unit tests: tests/install-tracking.test.ts (install, update, existing id, Chrome update ignored, unpacked build, failed request, URL encoding).
  • yarn typecheck: clean.
  • yarn test: 41 files, 365 tests pass.
  • yarn build: OK.
  • The repo has no lint script.

Dependencies

🤖 Generated with Claude Code

… page

- chrome.runtime.onInstalled now tracks extension_installed (reason
  install) or extension_updated (with previous_version) on the install's
  analytics id. The id is created when missing, with the same key and
  format as plugins/mixpanel.ts (new helper common/helper/install-id.ts).
- The service worker has no window or document, so mixpanel-browser is
  not loaded there. The events go to Mixpanel's /track endpoint with
  fetch, through MIXPANEL_API_HOST, in the same shape mixpanel-browser
  sends. A failed request never throws.
- On install it opens
  https://subturtle.app/?install_id=<id>&utm_source=extension&utm_medium=install
  for the landing page (D-01). Unpacked builds (local dev, CI e2e) skip
  the tab, so they do not open the site or count fake installs.
- Tests: tests/install-tracking.test.ts.

Work list: subturtle-doc docs/tech/analytics-fixes-implementation.md
Pairs with landing D-01 (codebridger/subturtle-dashboard-app#144).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…E-01

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@navidshad

Copy link
Copy Markdown
Collaborator Author

Replaced by #62, which combines all extension rows (E-01 to E-06) into one PR.

@navidshad navidshad closed this Oct 16, 2026
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