fix(sso): redesign auth analytics for login/register parity and outcome tracking - #3632
fix(sso): redesign auth analytics for login/register parity and outcome tracking#3632YishaiGlasner wants to merge 3 commits into
Conversation
…me tracking The sign-up funnel analytics shipped alongside SSO were built for register only and reused as-is for login, causing login attempts to fire method_chosen/ process_started/process_ended events with a null flow_id and no bookending flow_started/flow_ended. Rename the whole sign_up_* vocabulary to the spec's auth_* events, track login and register as equally first-class flows (a direct register<->login transition now correctly ends the old flow and starts a new one), add flow_intent and outcome fields, and fix LoginView never calling endProcess at all. Getting `outcome` (created_new_account vs existing_user_login) for Google/Apple SSO required backend support: a new Sefaria-owned /api/auth/google/callback endpoint (mirroring the existing Apple one) replaces a direct call to allauth's stock headless endpoint, which had no hook to report it. Redirect-mode SSO (mobile web) gets the same signal via a new sefaria_sso_outcome cookie, set by extending get_login_redirect_url/get_signup_redirect_url and the existing ClearSsoNextCookieMiddleware. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
📊 Code Quality Score: 52/100
Was this score accurate? 👍 Yes · 👎 No Scored by GitVelocity · How are scores calculated? |
| PROCESS_ENDED: 'sign_up_process_ended', | ||
| FLOW_ENDED: 'sign_up_flow_ended', | ||
| export const AUTH_EVENT = { | ||
| FLOW_STARTED: 'auth_flow_started', |
There was a problem hiding this comment.
[claude] Context for reviewers: this rename isn't unilateral — it ships the web half of the cross-platform event contract the team already documented, which mobile shipped on 2026-08-11, and that doc carries its own dashboard-impact note.
grep -rn "sign_up_" on master shows no remaining consumers in the repo, so the rename is clean internally. The open item is external: confirm the GA4/BigQuery saved queries and audiences keyed to sign_up_* are repointed, since this PR is what triggers that for web.
|
|
||
| export function fireFlowStarted(flowId, source) { | ||
| sendEvent(SIGNUP_EVENT.FLOW_STARTED, { flow_id: flowId, source }); | ||
| export function fireFlowStarted(flowId, source, flowIntent) { |
There was a problem hiding this comment.
[claude] flow_intent is emitted only here on flow_started, and outcome only on process_ended/flow_ended (lines 41-45) — which matches the spec in the file header. The PR description says both are added "across all five events"; the description is what's off, not the code.
…values QA found two bugs in the new auth analytics: (1) startProcess()/endProcess() each had a one-shot guard, so retrying an email login/register submission after a failure fired no further process_started, and a later successful retry's endProcess call was silently dropped, leaving auth_flow_ended stuck reporting the earlier failure; (2) several login entry points never set data-signup-source, so auth_flow_started fired with source: null for the register->login crosslink, the LA/chatbot banner, and the shared SignUpModal's "Sign In" link (Save/AddToSheet interstitials). startProcess() now only no-ops while an attempt is genuinely still in flight, and re-arms (same attempt_id, fresh process_started) once the prior attempt has concluded; LoginView/RegisterView call it on every submit rather than only once. sourceForModalKind() takes a prefix so the modal's Sign In link can use login_modal_* alongside its existing signup_modal_* Sign Up link. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary
sign_up_*events/constants/files) to the spec'dauth_*events, and fixes login attempts firing tracking events with a nullflow_idand no bookendingflow_started/flow_ended(the tracking hook was gated toflow === 'register'only).flow_intent(registration/login/one_tap_login) andoutcome(created_new_account/existing_user_login) fields across all five events, and fixesLoginView.jsx, which never calledendProcessat all.outcomeis accurate for Google/Apple SSO too: a new/api/auth/google/callbackendpoint (mirroring the existing Apple one) replaces a direct call to allauth's stock headless endpoint, which had no hook to report it; redirect-mode (mobile web) SSO gets the same signal via a newsefaria_sso_outcomecookie set throughget_login_redirect_url/get_signup_redirect_urland the existingClearSsoNextCookieMiddleware.Test plan
npx jest static/js/auth— 102 tests passing across 7 suitespython manage.py test sso.tests.adapters_test sso.tests.middleware_test sso.tests.views_test— 67 tests passing/loginand/registerfor email, Google (popup), Google One Tap, and Apple (popup), confirming a consistentflow_id/attempt_idsequence with correctflow_intent/outcomeon success🤖 Generated with Claude Code