fix(analytics): attribute manteca KYC lifecycle events to the initiated intent - #2478
Conversation
…ed intent
Manteca entry points (MantecaAddMoney, qr-pay, withdraw/manteca,
MantecaFlowManager) instantiate useMultiPhaseKycFlow({}) and pass 'LATAM'
only as an override to handleInitiateKyc, so completion/abandon captures
read the undefined hook-level regionIntent: LATAM successes fired as
kyc_approved with region_intent None and abandons as kyc_abandoned. That
made manteca_kyc_completed undercount and paged a false 'Funnel dead:
manteca-kyc' alert (2026-07-22). Track the last initiated intent in a ref
and let it win over the prop for all lifecycle captures.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthrough
ChangesKYC intent analytics
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code-analysis diffPainscore total: 6233.55 → 6233.75 (+0.2) 🆕 New findings (3)
✅ Resolved (4)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/hooks/useMultiPhaseKycFlow.ts (1)
159-162: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for override-only intent attribution.
Test a hook with no
regionIntent, initiate with'LATAM', and assert completion capturesMANTECA_KYC_COMPLETEDwithregion_intent: 'LATAM'.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/hooks/useMultiPhaseKycFlow.ts` around lines 159 - 162, Add regression coverage for the completion path in useMultiPhaseKycFlow: render the hook without regionIntent, initiate the flow with 'LATAM', and assert PostHog captures ANALYTICS_EVENTS.MANTECA_KYC_COMPLETED with region_intent set to 'LATAM'.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/hooks/useMultiPhaseKycFlow.ts`:
- Around line 159-162: Add regression coverage for the completion path in
useMultiPhaseKycFlow: render the hook without regionIntent, initiate the flow
with 'LATAM', and assert PostHog captures ANALYTICS_EVENTS.MANTECA_KYC_COMPLETED
with region_intent set to 'LATAM'.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f20d6493-9226-4a1a-9d02-94f31de14013
📒 Files selected for processing (1)
src/hooks/useMultiPhaseKycFlow.ts
Summary
LATAM (Manteca) KYC completions were being logged as
kyc_approvedwithregion_intent: Noneinstead ofmanteca_kyc_completed(same for abandons →kyc_abandoned). The Manteca entry points (MantecaAddMoney,qr-pay,withdraw/manteca,MantecaFlowManager) instantiateuseMultiPhaseKycFlow({})and pass'LATAM'only as a call-time override tohandleInitiateKyc, while the completion/abandon/rejected/submitted captures read the (undefined) hook-levelregionIntent.Impact:
manteca_kyc_initiated→manteca_kyc_completedfunnels systematically undercount successes. This paged a false "🔴 Funnel dead: manteca-kyc — 25 attempts, 0 successes" alert on 2026-07-22 while both affected users were in fact ACTIVE in the backend (one success visible in PostHog askyc_approved region_intent: Noneon/add-money/argentinaat 16:54 UTC).Fix: track the effective intent in a ref set inside
handleInitiateKyc(which already computesoverrideIntent ?? regionIntent) and let it win over the prop in all lifecycle captures.Risks / breaking changes
crispy): the funnel-pulse sentinel switches to distinct-person counting.QA
npm run typecheckclean; jest 2008 passed (1 pre-existing failure inadd-money-states.test.tsx"loaded EVM deposit shows QR code and address", also red on cleandev— unrelated)./add-money/*LATAM flows emitmanteca_kyc_completedwithregion_intent: LATAM(previously only/profile/identity-verificationdid).Summary by CodeRabbit