Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

final comments / changes

Steven Teyf93760e9673e
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
index d32391f3f0..0cf33c7c79 100644
--- a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts
@@ -107,7 +107,8 @@ export async function processPayouts({
`Updated ${res.count} payouts to invoice ${invoiceId} and "processing" status`,
);
- //
+ // if hybrid mode, we need to update payouts for partners with payoutsEnabledAt = null to external mode
+ // here we don't need to filter if they have tenantId cause getPayoutEligibilityFilter above already takes care of that
if (program.payoutMode === "hybrid") {
await prisma.payout.updateMany({
where: {
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts b/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts
index 5109a145d2..11e5afe1b0 100644
--- a/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts
+++ b/apps/web/app/(ee)/api/cron/payouts/process/updates/route.ts
@@ -61,25 +61,27 @@ export async function POST(req: Request) {
}
const auditLogResponse = await recordAuditLog(
- payouts.map((payout) => ({
- workspaceId: payout.program.workspaceId,
- programId: payout.program.id,
- action: "payout.confirmed",
- description: `Payout ${payout.id} confirmed`,
- actor: {
- id: payout.userId!,
- },
- targets: [
- {
- type: "payout",
- id: payout.id,
- metadata: payout,
+ payouts.map((p) => {
+ const { program, partner, invoice, ...payout } = p;
+ return {
+ workspaceId: program.workspaceId,
+ programId: program.id,
+ action: "payout.confirmed",
+ description: `Payout ${payout.id} confirmed`,
+ actor: {
+ id: payout.userId ?? "system",
},
- ],
- })),
+ targets: [
+ {
+ type: "payout",
+ id: payout.id,
+ metadata: payout,
+ },
+ ],
+ };
+ }),
);
-
- console.log({ auditLogResponse });
+ console.log(JSON.stringify({ auditLogResponse }, null, 2));
const invoice = payouts[0].invoice;
const internalPayouts = payouts.filter(
@@ -114,7 +116,7 @@ export async function POST(req: Request) {
}),
})),
);
- console.log({ batchEmailResponse });
+ console.log(JSON.stringify({ batchEmailResponse }, null, 2));
}
if (payouts.length === BATCH_SIZE) {
diff --git a/apps/web/lib/actions/partners/confirm-payouts.ts b/apps/web/lib/actions/partners/confirm-payouts.ts
index f2783c1a7c..6d65921682 100644
--- a/apps/web/lib/actions/partners/confirm-payouts.ts
+++ b/apps/web/lib/actions/partners/confirm-payouts.ts
@@ -88,6 +88,7 @@ export const confirmPayoutsAction = authActionClient
programId,
});
+ // TODO: Remove this once we can support cutoff periods for invoices with > 1,000 payouts
if (cutoffPeriod) {
const totalEligiblePayouts = await prisma.payout.aggregate({
where: {
diff --git a/apps/web/lib/api/audit-logs/record-audit-log.ts b/apps/web/lib/api/audit-logs/record-audit-log.ts
index 6a7b533ced..1d291bc681 100644
--- a/apps/web/lib/api/audit-logs/record-audit-log.ts
+++ b/apps/web/lib/api/audit-logs/record-audit-log.ts
@@ -57,7 +57,7 @@ export const recordAuditLog = async (data: AuditLogInput | AuditLogInput[]) => {
try {
waitUntil(recordAuditLogTBOld(auditLogs));
- await recordAuditLogTB(auditLogs);
+ return await recordAuditLogTB(auditLogs);
} catch (error) {
console.error(
"Failed to record audit log",