← Back to Pull requests

Admin report: retention cohorts (signup week, weeks 1/4/12) #239

Closed
unknown closed this pull request without merging on Nov 29, 2026 04:51 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 04:20 UTC
Author

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->

Summary

Adds an admin Retention cohorts report under Admin → Reports, registered in the existing reports registry.

  • Cohorts: UTC Monday signup weeks from Firebase Auth account creation time.

  • Return: Share of each cohort with at least one collections.updatedAt in weeks 1, 4, and 12 after that cohort week (windows are seven days each, starting at cohort week + N×7 days).

  • Data path: Admin-only callable getAdminRetentionCohorts (reuses assertSiteAdmin / admin: true claim). One-shot load plus Refresh in the UI.
  • Not tracked yet

    | Metric | Reason |
    |--------|--------|
    | Site visits / page views | PostHog captures $pageview and funnel events client-side, but there is no server-side PostHog query (no personal API key in Cloud Functions), so visit-based “return” cannot be shown safely from the admin UI. |
    | Sign-in-only return | Firebase Auth exposes lastSignInTime only as the latest sign-in, not per-week history, so it cannot power week-1/4/12 retention. |

    The report UI lists these gaps explicitly in a Not tracked yet callout.

    Return signal caveat

    Percentages reflect collection entry updates, not passive browsing. Users who only view the site without touching their collection count as non-returned in this report.

    Setup / deploy

    1. Functions: Deploy Cloud Functions so getAdminRetentionCohorts is available (firebase deploy --only functions or full project deploy).
    2. Firestore rules: No change in this PR (data is not client-readable).
    3. Indexes: None required (admin SDK pagination only).
    4. Config: No new env vars. Existing PostHog build-time keys are unchanged and are not used by this report.

    Tests

  • functions/retentionCohorts.test.js — cohort grouping, week windows, admin gate, handler merge.

  • frontend/src/pages/Admin/reports/useRetentionCohortsReport.test.js — callable hook.

  • frontend/src/pages/Admin/reports/RetentionCohortsReport.test.jsx — UI render.
  • Demo

    Retention cohorts report

    <sub>To show artifacts inline, <a href="https://cursor.com/dashboard/cloud-agents#my-pull-requests">enable</a> in settings.</sub>
    <!-- CURSOR_AGENT_PR_BODY_END -->

    <div><a href="https://cursor.com/agents/bc-557b1c8a-a53f-5030-b945-2f06410dc72b?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-557b1c8a-a53f-5030-b945-2f06410dc72b&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: 422 lines (+316 / -106) across 5 files Reviewer: cursor[bot] Review duration: 31m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 422 lines diff across 5 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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.362
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #239"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 50% (MEDIUM) · Higher = larger blast radius
    50%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 21.6% · Safe to merge
    21.6%