Repository navigation
fix(analytics): E-01 to E-06 install id, install event, login prompt events, translation dedupe - #62
Merged
Conversation
… 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>
…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>
- 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>
…E-01 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
This was referenced Oct 16, 2026
|
🎉 This PR is included in version 1.17.0-dev.8 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All extension rows of the analytics fixes in one PR, to cut deploy time. It replaces #58, #59, #60 and #61 (same commits, cherry-picked onto the latest
dev).Why: subturtle-doc
docs/tech/analytics-fixes-implementation.md(rows E-01 to E-06; E-07 is not in this round).E-01: send the install id with server calls
translateWithContext(simple and detailed),translationAdviceandcreatePhrasenow senddeviceId. This is the install's analytics id (analyticsAnonymousIdinchrome.storage.local).userIdis still sent for old servers.src/common/helper/install-id.tsreads the id, or creates it with the same key and format asmixpanel.ts. Each call waits for the stored id, so it never sends an empty value. It reads the id on every call, so after logout it sends the new one.E-05: send the trigger with each translation
caption: whole-caption translation (Netflix and the support template)word: a hovered caption wordselection: the Nibble selection popupdetail: the word detail paneldefinitionis in the type for the server contract, but no caller uses it (Definition.vueno longer exists).E-02: install and update events, welcome page
chrome.runtime.onInstalledsendsextension_installedorextension_updated(withprevious_version) on the install id.https://subturtle.app/?install_id=<id>&utm_source=extension&utm_medium=install.window, so it sends the event withfetchto Mixpanel's/track(throughMIXPANEL_API_HOST). A failure never throws.E-03: "Login to save" prompt and login results
save-login-prompt_viewed(once per word view when the button shows) andsave-login-prompt_clicked.user_logged-ingainssource(save_prompt,practice,popup).login_failedwithsourceandreason(window_closed,google_error,server_error).#/login?source=…).practice-now_login-clickedis kept.login_failed(server_error).E-04: share translations already in flight
E-06: translate each caption once
src/subtitle/helpers/caption-translation-gate.ts, used by both caption components. With "translate whole caption" on, it waits about 150 ms for the caption to settle and skips a caption that is already translated on screen. A failed caption can be sent again.How tested
translate-analytics-args,install-tracking,save-login-prompt,login-analytics,caption-translation-gate, plus in-flight cases intranslate.service.yarn typecheck: clean.yarn test: 45 files, 398 tests pass.yarn build: OK.yarn test:e2e: 22 of 22 pass with CI's Mixpanel stub settings. (With a real Mixpanel host in the local env, one analytics test cannot see its stub requests; that is a local setup issue, not a bug.)Dependencies
install_id, which D-01 reads.🤖 Generated with Claude Code