-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Improve payout descriptions #2703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes update payout and transfer descriptions across several modules to dynamically include program names or relevant date information. Related data fetching and type definitions are expanded to provide access to program names where necessary. Some function signatures are updated to support these richer data structures, but no core logic or control flow is altered. Changes
Sequence Diagram(s)sequenceDiagram
participant CronJob
participant DB
participant Stripe
participant Program
CronJob->>DB: Fetch programEnrollment including program.name
CronJob->>Program: Get program.name
CronJob->>Stripe: Create payout with description "Dub Partners payout (Program Name)"
sequenceDiagram
participant Webhook
participant Utils
participant Stripe
Webhook->>Utils: formatDate(currentMonth)
Webhook->>Stripe: Create payout with description "Dub Partners auto-withdrawal (Month)"
sequenceDiagram
participant Action
participant DB
participant Stripe
Action->>DB: Fetch payouts including program.name
Action->>Stripe: Create transfer with description listing program names
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@CodeRabbit final review please |
|
@steven-tey I'll conduct a final review of the PR to improve payout descriptions. 🧠 Learnings used✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/web/app/(ee)/api/stripe/connect/webhook/balance-available.ts (1)
87-88: Fix comment to match actual implementation.The comment shows "Aug 1, 2025" but the actual code only includes the month abbreviation. The
formatDate(new Date(), { month: "short" })call returns just "Aug", not "Aug 1, 2025".Either update the comment to match the implementation:
- // example: "Dub Partners auto-withdrawal (Aug 1, 2025)" + // example: "Dub Partners auto-withdrawal (Aug)"Or update the implementation to match the comment:
- description: `Dub Partners auto-withdrawal (${formatDate(new Date(), { month: "short" })})`, + description: `Dub Partners auto-withdrawal (${formatDate(new Date(), { month: "short", day: "numeric", year: "numeric" })})`,apps/web/lib/partners/create-stripe-transfer.ts (1)
101-101: LGTM! Improved transfer descriptions with program context.The transfer description now includes meaningful program names instead of technical payout IDs, making it more readable. The use of
pluralizeensures proper grammar.Consider deduplicating program names if multiple payouts from the same program could be included:
- description: `Dub Partners payout ${pluralize("transfer", allPayouts.length)} (${allPayouts.map((p) => p.program.name).join(", ")})`, + description: `Dub Partners payout ${pluralize("transfer", allPayouts.length)} (${[...new Set(allPayouts.map((p) => p.program.name))].join(", ")})`,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/(ee)/api/cron/payouts/create-payout.ts(2 hunks)apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts(2 hunks)apps/web/app/(ee)/api/stripe/connect/webhook/balance-available.ts(2 hunks)apps/web/lib/actions/partners/update-partner-payout-settings.ts(1 hunks)apps/web/lib/partners/create-stripe-transfer.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: devkiran
PR: dubinc/dub#2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the @unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.
Learnt from: steven-tey
PR: dubinc/dub#0
File: :0-0
Timestamp: 2025-06-25T21:20:59.837Z
Learning: In the Dub codebase, payout limit validation uses a two-stage pattern: server actions perform quick sanity checks (payoutsUsage > payoutsLimit) for immediate user feedback, while the cron job (/cron/payouts) performs authoritative validation (payoutsUsage + payoutAmount > payoutsLimit) with actual calculated amounts before processing. This design provides fast user feedback while ensuring accurate limit enforcement at transaction time.
📚 Learning: in the dub codebase, multiple payout records can now share the same stripetransferid because payouts...
Learnt from: devkiran
PR: dubinc/dub#2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the @unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.
Applied to files:
apps/web/app/(ee)/api/stripe/connect/webhook/balance-available.tsapps/web/app/(ee)/api/cron/payouts/create-payout.tsapps/web/lib/actions/partners/update-partner-payout-settings.tsapps/web/app/(ee)/api/cron/payouts/process/split-payouts.tsapps/web/lib/partners/create-stripe-transfer.ts
📚 Learning: paypal webhook verification in the dub codebase is handled at the route level in `apps/web/app/(ee)/...
Learnt from: steven-tey
PR: dubinc/dub#0
File: :0-0
Timestamp: 2025-06-19T01:46:45.723Z
Learning: PayPal webhook verification in the Dub codebase is handled at the route level in `apps/web/app/(ee)/api/paypal/webhook/route.ts` using the `verifySignature` function. Individual webhook handlers like `payoutsItemFailed` don't need to re-verify signatures since they're only called after successful verification.
Applied to files:
apps/web/app/(ee)/api/stripe/connect/webhook/balance-available.ts
📚 Learning: in the dub codebase, payout limit validation uses a two-stage pattern: server actions perform quick ...
Learnt from: steven-tey
PR: dubinc/dub#0
File: :0-0
Timestamp: 2025-06-25T21:20:59.837Z
Learning: In the Dub codebase, payout limit validation uses a two-stage pattern: server actions perform quick sanity checks (payoutsUsage > payoutsLimit) for immediate user feedback, while the cron job (/cron/payouts) performs authoritative validation (payoutsUsage + payoutAmount > payoutsLimit) with actual calculated amounts before processing. This design provides fast user feedback while ensuring accurate limit enforcement at transaction time.
Applied to files:
apps/web/app/(ee)/api/cron/payouts/create-payout.tsapps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
📚 Learning: in apps/web/ui/partners/rewards/rewards-logic.tsx, when setting the entity field in a reward conditi...
Learnt from: TWilson023
PR: dubinc/dub#2673
File: apps/web/ui/partners/rewards/rewards-logic.tsx:268-275
Timestamp: 2025-07-30T15:29:54.131Z
Learning: In apps/web/ui/partners/rewards/rewards-logic.tsx, when setting the entity field in a reward condition, dependent fields (attribute, operator, value) should be reset rather than preserved because different entities (customer vs sale) have different available attributes. Maintaining existing fields when the entity changes would create invalid state combinations and confusing UX.
Applied to files:
apps/web/lib/actions/partners/update-partner-payout-settings.ts
📚 Learning: in the singular integration (apps/web/app/(ee)/api/singular/webhook/route.ts), the event names in th...
Learnt from: devkiran
PR: dubinc/dub#2637
File: apps/web/app/(ee)/api/singular/webhook/route.ts:0-0
Timestamp: 2025-07-17T06:41:45.620Z
Learning: In the Singular integration (apps/web/app/(ee)/api/singular/webhook/route.ts), the event names in the singularToDubEvent object have intentionally different casing: "Copy GAID" and "copy IDFA". This casing difference is valid and should not be changed, as these are the correct event names expected from Singular.
Applied to files:
apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (4)
apps/web/app/(ee)/api/cron/payouts/create-payout.ts (1)
24-24: LGTM! Clean implementation of dynamic payout descriptions.The program name is properly selected in the query and correctly used in the payout description. This enhances the description with meaningful context while maintaining type safety.
Also applies to: 157-157
apps/web/lib/actions/partners/update-partner-payout-settings.ts (1)
48-54: LGTM! Proper enrichment of payout data with program names.The query correctly includes program name data using Prisma's nested include pattern, supporting the improved payout descriptions throughout the system.
apps/web/app/(ee)/api/cron/payouts/process/split-payouts.ts (1)
15-15: LGTM! Consistent implementation of dynamic payout descriptions.The function signature correctly includes the
nameproperty in the program type, and the payout description properly uses this field. The implementation maintains type safety and follows the established pattern.Also applies to: 103-103
apps/web/lib/partners/create-stripe-transfer.ts (1)
10-14: LGTM! Well-defined type extension for program name enrichment.The
PayoutWithProgramNametype alias properly extends the base Payout type with program name information, supporting more descriptive transfer descriptions.
|
@CodeRabbit there was no review. Can you please do a proper final review? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@steven-tey I'll examine the actual code changes to provide a comprehensive final review. 🏁 Script executed: Length of output: 317 🏁 Script executed: Length of output: 19976 @steven-tey Here's my comprehensive final review of the payout description improvements: ✅ Overall AssessmentThe changes successfully enhance payout descriptions across all contexts, making them more informative and specific. The implementation is well-structured and maintains consistency. 📋 File-by-File Review1. create-payout.ts
2. split-payouts.ts
3. balance-available.ts
4. update-partner-payout-settings.ts
5. create-stripe-transfer.ts
🔍 Potential Considerations
🎯 Consistency Check
🚀 RecommendationThe implementation is ready for deployment. The changes provide significant value by making payout descriptions more informative for both internal tracking and external communications without introducing any risks. Final Grade: A+ - Well-executed enhancement that improves user experience and operational visibility. 🧠 Learnings used |
Summary by CodeRabbit
New Features
Enhancements