feat(card): proof-of-address upload on stuck Rain applications#2446
Conversation
Hotfix port to main of peanut-ui#2438 (branch was dev-based; every touched file is byte-identical between dev and main, so this is the same reviewed content squashed onto main). Pairs with peanut-api-ts hotfix/rain-poa-selfheal — deploy the API first. When the rain rail carries the sumsub:proof_of_address next-action, the card status screens (requires-info / rejected) render a primary "Upload proof of address" CTA driving a dedicated lightweight flow: resubmit action -> second SumsubKycWrapper -> inline initiation errors -> optimistic "we received your document" banner (auto-reset when the backend state takes over). Double-click guard; analytics tagged source: poa-self-heal. Full review trail on #2438.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds a Rain proof-of-address self-heal flow with token-based Sumsub submission, upload controls and inline errors on supported status screens, optimistic reviewing messaging, and refreshed card data after completion. ChangesProof-of-address self-heal
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CardUser
participant ApplicationStatusScreen
participant CardPage
participant initiateSelfHealResubmission
participant SumsubKycWrapper
participant CardOverview
CardUser->>ApplicationStatusScreen: Selects Upload proof of address
ApplicationStatusScreen->>CardPage: Calls onUploadProofOfAddress
CardPage->>initiateSelfHealResubmission: Requests RAIN token
initiateSelfHealResubmission-->>CardPage: Returns PoA action token
CardPage->>SumsubKycWrapper: Opens PoA submission with token
SumsubKycWrapper-->>CardPage: Completes PoA submission
CardPage->>CardOverview: Invalidates overview and refetches user
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: dependency version conflict. Check your lock file or package.json. Comment |
Code-analysis diffPainscore total: 6207.05 → 6208.86 (+1.81) 🆕 New findings (13)
✅ Resolved (12)
📈 Painscore deltas (top movers)
|
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/app/`(mobile-ui)/card/page.tsx:
- Around line 244-257: Move the posthog.capture call for CARD_SUMSUB_OPENED in
startPoaUpload to after initiateSelfHealResubmission returns a valid token and
setPoaToken is prepared. Do not record the event when the response contains an
error or no token.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d938d83c-af27-4c85-93f0-95e80171c044
📒 Files selected for processing (4)
src/app/(mobile-ui)/card/page.tsxsrc/app/actions/sumsub.tssrc/components/Card/ApplicationStatusScreen.tsxsrc/components/Card/__tests__/ApplicationStatusScreen.test.tsx
| const startPoaUpload = useCallback(async () => { | ||
| if (poaStartingRef.current) return | ||
| poaStartingRef.current = true | ||
| posthog.capture(ANALYTICS_EVENTS.CARD_SUMSUB_OPENED, { source: 'poa-self-heal' }) | ||
| setPoaError(null) | ||
| try { | ||
| const response = await initiateSelfHealResubmission('RAIN') | ||
| if (response.error || !response.data?.token) { | ||
| // Surfaced inline on the status screen — a silent primary CTA on | ||
| // a stuck-application screen is worse than no CTA. | ||
| setPoaError(response.error ?? 'Could not start the upload. Please try again.') | ||
| return | ||
| } | ||
| setPoaToken(response.data.token) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Record CARD_SUMSUB_OPENED only after token creation succeeds.
Initiation failures currently count as opened sessions even though the SDK never launches, skewing the PoA funnel.
Proposed fix
if (poaStartingRef.current) return
poaStartingRef.current = true
- posthog.capture(ANALYTICS_EVENTS.CARD_SUMSUB_OPENED, { source: 'poa-self-heal' })
setPoaError(null)
try {
const response = await initiateSelfHealResubmission('RAIN')
if (response.error || !response.data?.token) {
setPoaError(response.error ?? 'Could not start the upload. Please try again.')
return
}
+ posthog.capture(ANALYTICS_EVENTS.CARD_SUMSUB_OPENED, { source: 'poa-self-heal' })
setPoaToken(response.data.token)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const startPoaUpload = useCallback(async () => { | |
| if (poaStartingRef.current) return | |
| poaStartingRef.current = true | |
| posthog.capture(ANALYTICS_EVENTS.CARD_SUMSUB_OPENED, { source: 'poa-self-heal' }) | |
| setPoaError(null) | |
| try { | |
| const response = await initiateSelfHealResubmission('RAIN') | |
| if (response.error || !response.data?.token) { | |
| // Surfaced inline on the status screen — a silent primary CTA on | |
| // a stuck-application screen is worse than no CTA. | |
| setPoaError(response.error ?? 'Could not start the upload. Please try again.') | |
| return | |
| } | |
| setPoaToken(response.data.token) | |
| const startPoaUpload = useCallback(async () => { | |
| if (poaStartingRef.current) return | |
| poaStartingRef.current = true | |
| setPoaError(null) | |
| try { | |
| const response = await initiateSelfHealResubmission('RAIN') | |
| if (response.error || !response.data?.token) { | |
| // Surfaced inline on the status screen — a silent primary CTA on | |
| // a stuck-application screen is worse than no CTA. | |
| setPoaError(response.error ?? 'Could not start the upload. Please try again.') | |
| return | |
| } | |
| posthog.capture(ANALYTICS_EVENTS.CARD_SUMSUB_OPENED, { source: 'poa-self-heal' }) | |
| setPoaToken(response.data.token) |
🤖 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/app/`(mobile-ui)/card/page.tsx around lines 244 - 257, Move the
posthog.capture call for CARD_SUMSUB_OPENED in startPoaUpload to after
initiateSelfHealResubmission returns a valid token and setPoaToken is prepared.
Do not record the event when the response contains an error or no token.
Hotfix port of #2438 to
mainper Jota — same reviewed content, squashed ontomain(every touched file is byte-identical betweendevandmain, verified). Full description and review trail on #2438.Deploy order: peanut-api-ts
hotfix/rain-poa-selfhealmust be live first (fails closed otherwise — the CTA simply doesn't render).Back-merge debt: standard main→dev back-merge after merge.
Summary by CodeRabbit
New Features
Bug Fixes
Tests