Skip to content

fix(analytics): E-01 to E-06 to main (cherry-picked, without the rest of dev) - #64

Merged
navidshad merged 5 commits into
mainfrom
hotfix/analytics-fixes-to-main
Oct 16, 2026
Merged

navidshad merged 5 commits into
mainfrom
hotfix/analytics-fixes-to-main

Conversation

@navidshad

Copy link
Copy Markdown
Collaborator

Brings only the analytics fixes from #62 to main. The rest of dev (multilingual work) is not ready for production, so these five commits are cherry-picked (-x) onto main.

What is in it

  • E-01 / E-05 — the install id (deviceId) and the trigger go with translation calls; deviceId also goes with createPhrase.
  • E-02 — extension_installed / extension_updated, and the welcome page on first install.
  • E-03 — "Login to save" prompt events, user_logged-in source, login_failed.
  • E-04 / E-06 — shared in-flight translations, one call per caption.

Conflicts resolved (dev-only code left out)

  • translate.service.ts: kept main's language code; took only the install-id import, the TranslationTrigger type and deviceId. The multilingual imports and translationLanguageArg() stay on dev.
  • SaveWordSectionV2.vue: kept main's createPhrase args and added only deviceId.
  • CLAUDE.md test map: kept only the E-02 / E-03 test lines.

How tested

  • yarn typecheck: clean (with the sibling dashboard-app checked out, as in CI).
  • yarn test: 36 files, 298 tests pass.
  • yarn build: passes.

After merge

The main release builds a zip; the Chrome Web Store upload is still manual. The later main → dev back-merge meets the same changes already on dev; keep the dev side in the three files above.

Work list: subturtle-docs docs/tech/analytics-fixes-implementation.md.

🤖 Generated with Claude Code

navidshad and others added 5 commits October 16, 2026 19:52
… 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>
(cherry picked from commit b7ddfd6)
…te each caption once

- E-04: TranslateService keeps a map of requests in flight by cache key.
  An identical call made before the first one answers waits for it and
  gets the same answer, so only one request goes out. The entry is removed
  when the request settles; a failure reaches every waiting caller and is
  never cached.
- E-06: new src/subtitle/helpers/caption-translation-gate.ts. With
  "translate whole caption" on, the Netflix and support-template caption
  components wait about 150 ms for the caption to settle, then send it
  only when the joined text differs from the caption already translated
  on screen. A failed caption can be sent again. Turning the option on
  still translates at once.
- Tests: in-flight cases in tests/translate.service.test.ts, new
  tests/caption-translation-gate.test.ts.

Work list: subturtle-doc docs/tech/analytics-fixes-implementation.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7c0a3b2)
- Word card: save-login-prompt_viewed fires once per word view when
  "Login to save this phrase" shows (a new word or a new view resets it).
  Clicking it sends save-login-prompt_clicked.
- OpenLoginWindowMessage carries a source (save_prompt, practice, popup).
  The background puts it on the login window URL
  (popup.html#/login?source=...), and LoginView reads it. No source means
  the toolbar popup.
- user_logged-in gains source. New login_failed with source and reason:
  window_closed (Google consent window closed), google_error (no Google
  token), server_error (our server failed or sent no token, or the
  password login was rejected).
- The Google flow no longer stores an empty token when the server reply
  has none; it counts as a failed login.
- practice-now_login-clicked is kept.
- Tests: tests/save-login-prompt.test.ts, tests/login-analytics.test.ts.

Work list: subturtle-doc docs/tech/analytics-fixes-implementation.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit efec688)
…E-01

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3658d71)
…ation calls

- New helper src/common/helper/install-id.ts reads the install's analytics
  id (analyticsAnonymousId in chrome.storage.local), or creates it with the
  same key and format as plugins/mixpanel.ts. It waits for storage, so a
  call never sends an empty id, and it reads on each call, so it follows
  the new id after logout.
- translateWithContext (simple and detailed), translationAdvice and
  createPhrase now send deviceId. userId stays for old servers.
- Each translation caller sends trigger: caption (both caption
  components), word (marker store, hovered caption word), selection
  (selection popup), detail (word detail). "definition" is in the type for
  the server contract; no caller uses it today (Definition.vue is gone).
- Tests: tests/translate-analytics-args.test.ts.

Work list: subturtle-doc docs/tech/analytics-fixes-implementation.md
Pairs with server B-01 / B-03. The server ignores unknown args today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1466a8f)
@navidshad
navidshad merged commit 5e19e08 into main Oct 16, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.18.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant