Include partner info in "New customer" lead webhook#3875
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Stripe webhook handler enriches customer creation with improved naming and enhances lead.created webhook dispatch by attaching partner context from program enrollments, enabling richer event payloads for postback delivery. ChangesWebhook Handler and Customer Creation Enhancement
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/web/lib/partners/create-partner-commission.ts (1)
48-62: ⚡ Quick winExtract
constructWebhookPartnerinto a standalone helper.Making this mapper public from
create-partner-commission.tsmeans the Stripe webhook path now depends on the entire commission-creation module. A small shared helper file would avoid pulling audit/workflow/commission-only imports into that path and keep the boundary cleaner.🤖 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 `@apps/web/lib/partners/create-partner-commission.ts` around lines 48 - 62, The constructWebhookPartner mapper is currently exported from create-partner-commission.ts which pulls heavy commission/audit/workflow imports into the Stripe webhook path; extract constructWebhookPartner into a small standalone helper module (e.g., a new file exporting a named function constructWebhookPartner) that only depends on ProgramEnrollment, Partner, Link, aggregatePartnerLinksStats and toCentsNumber types/utilities, move the implementation there, export it, then update all callers (including the Stripe webhook handler) to import constructWebhookPartner from the new helper instead of create-partner-commission; preserve the exact function signature and behavior (including totalCommissionsParam handling) and ensure the helper has no commission/audit/workflow imports so the webhook path no longer pulls those modules.
🤖 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
`@apps/web/app/`(ee)/api/stripe/integration/webhook/utils/create-new-customer.ts:
- Around line 149-168: The prisma.programEnrollment.findUnique lookup used to
build webhookPartner can reject and block the Promise.allSettled that runs
sendWorkspaceWebhook and sendPartnerPostback; change the programEnrollment fetch
(the call to prisma.programEnrollment.findUnique) to handle errors (e.g., append
.catch(() => null) or try/catch) so it returns null on failure, then pass the
possibly-null result into constructWebhookPartner as before; this ensures
webhookPartner resolution won't throw and allows Promise.allSettled (which calls
sendWorkspaceWebhook and sendPartnerPostback) to run regardless of enrichment
failures.
---
Nitpick comments:
In `@apps/web/lib/partners/create-partner-commission.ts`:
- Around line 48-62: The constructWebhookPartner mapper is currently exported
from create-partner-commission.ts which pulls heavy commission/audit/workflow
imports into the Stripe webhook path; extract constructWebhookPartner into a
small standalone helper module (e.g., a new file exporting a named function
constructWebhookPartner) that only depends on ProgramEnrollment, Partner, Link,
aggregatePartnerLinksStats and toCentsNumber types/utilities, move the
implementation there, export it, then update all callers (including the Stripe
webhook handler) to import constructWebhookPartner from the new helper instead
of create-partner-commission; preserve the exact function signature and behavior
(including totalCommissionsParam handling) and ensure the helper has no
commission/audit/workflow imports so the webhook path no longer pulls those
modules.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 025e982c-ccd2-4c9f-b2f7-60a2e989ecc3
📒 Files selected for processing (2)
apps/web/app/(ee)/api/stripe/integration/webhook/utils/create-new-customer.tsapps/web/lib/partners/create-partner-commission.ts
Summary by CodeRabbit