Skip to content

feat(analytics): E-03 track the save-login prompt and login results - #60

Closed
navidshad wants to merge 1 commit into
devfrom
analytics-fixes/E-03-save-login-prompt-events
Closed

navidshad wants to merge 1 commit into
devfrom
analytics-fixes/E-03-save-login-prompt-events

Conversation

@navidshad

Copy link
Copy Markdown
Collaborator

What

New and changed events for the "Login to save this phrase" path:

Event When Properties
save-login-prompt_viewed The button shows on the word card. Once per word view (a new word or a new view resets it). —
save-login-prompt_clicked The button is clicked. —
user_logged-in A login from the login window works. new: source
login_failed (new) A login from the login window fails. source, reason
  • source: save_prompt (word card), practice (practice page), popup (toolbar popup, or no source).
  • reason:
    • window_closed: the user closed the Google consent window.
    • google_error: Google gave no token (also the "Current Chrome User" button when Chrome has no token).
    • server_error: our server failed or sent no token, or the email/password login was rejected.
  • practice-now_login-clicked is kept.

How the source reaches the login window

The login runs in a separate window (popup.html#/login), opened by the background. So OpenLoginWindowMessage now carries an optional source. The background adds it to the URL (#/login?source=save_prompt). LoginView reads it from the route.

Why

94% of people who look up a word are not logged in. They see this button instead of Save, but we could not tell if they ignore it, click it, or click it and fail. Work list: subturtle-doc docs/tech/analytics-fixes-implementation.md (row E-03). The funnel viewed → clicked → user_logged-in (source save_prompt) → phrase_saved now works in Mixpanel.

Small fix on the way

In the Google flow, a server reply with no token used to be stored as a login (an empty token). Now it counts as login_failed with server_error, and nothing is stored.

How tested

  • New unit tests: tests/save-login-prompt.test.ts (viewed once, again for a new word, not for a logged-in user, clicked + source) and tests/login-analytics.test.ts (helpers, source on user_logged-in, each failure reason).
  • yarn typecheck: clean.
  • yarn test: 42 files, 370 tests pass.
  • yarn build: OK.
  • npx playwright test tests/e2e/password-login.spec.ts: 4 passed (this spec drives LoginView).
  • The repo has no lint script.

Dependencies

🤖 Generated with Claude Code

- 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>
@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