Improve net-new revenue bounty logic - #3986
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 (6)
📝 WalkthroughWalkthroughThis PR extends the workflow identity system to track customer identity and enforces eligibility constraints on performance bounties. A ChangesCustomer Identity and Bounty Eligibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
|
@coderabbitai full review, any breaking changes? does the logic changes look good? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== execute-complete-bounty-workflow.ts ==="
cat apps/web/lib/api/workflows/execute-complete-bounty-workflow.ts
echo ""
echo "=== types.ts (WorkflowIdentity section) ==="
rg -n "WorkflowIdentity|customerId|customerFirstSaleAt" apps/web/lib/types.ts -A 2 -B 2
echo ""
echo "=== track-sale.ts (executeWorkflows call) ==="
rg -n "executeWorkflows|customerFirstSaleAt|customerId|identity" apps/web/lib/api/conversions/track-sale.ts -A 3 -B 3
echo ""
echo "=== checkout-session-completed.ts (executeWorkflows call) ==="
rg -n "executeWorkflows|customerFirstSaleAt|customerId|identity" "apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts" -A 3 -B 3
echo ""
echo "=== invoice-paid.ts (executeWorkflows call) ==="
rg -n "executeWorkflows|customerFirstSaleAt|customerId|identity" "apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts" -A 3 -B 3
echo ""
echo "=== shopify/create-sale.ts ==="
rg -n "executeWorkflows|customerFirstSaleAt|customerId|identity" apps/web/lib/integrations/shopify/create-sale.ts -A 3 -B 3
echo ""
echo "=== bounty performanceScope schema/type ==="
rg -n "performanceScope" --type ts -A 2 -B 2
echo ""
echo "=== startsAt on bounty ==="
rg -n "startsAt" --type ts -A 2 -B 2 | head -80
echo ""
echo "=== AwardBounty action ==="
rg -n "AwardBounty" --type ts -A 3 -B 3
echo ""
echo "=== customer.firstSaleAt usage ==="
rg -n "firstSaleAt" --type ts -A 2 -B 2Length of output: 68737
Breaking ChangesNo breaking changes. Here's why:
Logic Assessment ✅The core gate in if (
bounty.performanceScope === "new" &&
customerFirstSaleAt &&
customerFirstSaleAt < bounty.startsAt
) {
console.log(`Bounty ... is for net-new revenue only and partner ... referred customer ... before the bounty started, skipping...`);
return;
}This is semantically correct: a "new" scope bounty should only reward revenue from customers whose first ever purchase happened after the bounty started. The comparison of The
Call site coverage is complete — all four sale recording entry points are updated:
Consistency with existing logic: Minor Observations
Overall: The changes are well-scoped, non-breaking, and the logic correctly implements net-new revenue bounty gating. LGTM! 🐇 🧠 Learnings used |
Summary by CodeRabbit
New Features
Improvements