← Back to Pull requests

PostHog: fix signup_completed and add qr_picks_saved #241

Open
unknown opened this pull request with 403 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 29, 2026 04:37 UTC
Author

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->

Summary

Production showed 0 signup_completed events vs 34 login_completed (PostHog SQL, last 90 days). Root causes addressed:

1. Auth events fired before posthog.identify while person_profiles is identified_only, so sign-up captures were not reliably stored as identified funnel events.
2. Email registration called captureEvent only after updateProfile; a profile update failure created the Firebase user but skipped analytics entirely.
3. Google registration relied solely on getAdditionalUserInfo().isNewUser; when Firebase omits that flag, new accounts were recorded as login_completed.
4. QR Nexus flow applied picks via useApplyPendingPicks / quick picker with no dedicated analytics event.

Changes

  • frontend/src/analytics/authCompletion.js — identify-then-capture helpers; Google new-user metadata fallback; mutually exclusive signup vs login.

  • frontend/src/analytics/qrPicksAnalytics.js + QR_PICKS_SAVED — fires after pending picks apply or signed-in quick save (pick_count, rows_written, utm_*, is_new_user via short-lived session marker after signup).

  • PostHog Data Management: registered verified event definitions for signup_completed and qr_picks_saved.
  • How to verify (hosted)

    1. Deploy Hosting (Front end only deploy workflow or npm run deploy:hosting with PostHog env).
    2. Incognito: open https://shardstash.web.app/getting-started?collect=pins&utm_source=qr&utm_campaign=nexus-2026, mark picks, sign up with Google or email.
    3. PostHog → Live events: expect signup_completed once (not paired with login_completed on that action), then qr_picks_saved with is_new_user: true when picks land within ~30 minutes of signup.
    4. Regression: existing user sign-in should emit login_completed only.

    Tests

  • npm run check

  • cd frontend && npm run test (1082 tests)

  • New unit tests: authCompletion.test.js, qrPicksAnalytics.test.js; extended AuthContext, useApplyPendingPicks, SocialLoginButtons tests.
  • Deploy steps

    Merge → run Front end only deploy on this branch (or main after merge). No Functions/Firestore changes.
    <!-- CURSOR_AGENT_PR_BODY_END -->

    <div><a href="https://cursor.com/agents/bc-f3de7933-67b5-53de-9224-f1dd399bbe2f?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/background-agent?bcId=bc-f3de7933-67b5-53de-9224-f1dd399bbe2f&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

    Diff: 403 lines (+302 / -101) across 5 files Reviewer: cursor[bot] Review duration: 26m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 403 lines diff across 5 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #241"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.4% · Safe to merge
    28.4%