The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
address coderabbit feedback
Kiran K1404d5baa7e5
diff --git a/apps/web/app/(ee)/api/cron/links/create-promotion-codes/route.ts b/apps/web/app/(ee)/api/cron/links/create-promotion-codes/route.tsindex 3ef8c1f4a4..2978f226f0 100644--- a/apps/web/app/(ee)/api/cron/links/create-promotion-codes/route.ts+++ b/apps/web/app/(ee)/api/cron/links/create-promotion-codes/route.ts@@ -95,6 +95,7 @@ export async function POST(req: Request) {partnerId: {in: enrollments.map(({ partnerId }) => partnerId),},+ couponCode: null,},select: {id: true,@@ -104,6 +105,8 @@ export async function POST(req: Request) {if (links.length === 0) {console.log("No more links found.");+ currentPage++;+ processedBatches++;continue;}diff --git a/apps/web/app/(ee)/api/cron/links/invalidate-for-discounts/route.ts b/apps/web/app/(ee)/api/cron/links/invalidate-for-discounts/route.tsindex 0ee4495212..56be60c920 100644--- a/apps/web/app/(ee)/api/cron/links/invalidate-for-discounts/route.ts+++ b/apps/web/app/(ee)/api/cron/links/invalidate-for-discounts/route.ts@@ -17,7 +17,7 @@ const schema = z.object({.boolean().optional().describe("Must be passed for discount-deleted action"),- action: z.enum(["discount-created", "discount-updated", "discount-deleted"]),+ action: z.enum(["discount-created", "discount-deleted"]),});// This route is used to invalidate the partnerlink cache when a discount is created/updated/deleted.@@ -30,7 +30,7 @@ export async function POST(req: Request) {const body = schema.parse(JSON.parse(rawBody));const { programId, discountId, isDefault, action } = body;- if (action === "discount-created" || action === "discount-updated") {+ if (action === "discount-created") {const discount = await prisma.discount.findUnique({where: {id: discountId,@@ -69,9 +69,7 @@ export async function POST(req: Request) {}return new Response(`Invalidated ${total} links.`);- }-- if (action === "discount-deleted") {+ } else if (action === "discount-deleted") {let page = 0;let total = 0;const take = 1000;diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.tsindex b320aac2d1..253207de71 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts@@ -73,7 +73,7 @@ export async function couponDeleted(event: Stripe.Event) {if (workspaceUsers) {const { user } = workspaceUsers;- sendEmail({+ await sendEmail({subject: `${process.env.NEXT_PUBLIC_APP_NAME}: Discount has been deleted`,email: user.email!,react: DiscountDeleted({diff --git a/apps/web/lib/api/links/bulk-delete-links.ts b/apps/web/lib/api/links/bulk-delete-links.tsindex 775dbf935b..5bba04e53c 100644--- a/apps/web/lib/api/links/bulk-delete-links.ts+++ b/apps/web/lib/api/links/bulk-delete-links.ts@@ -45,7 +45,7 @@ export async function bulkDeleteLinks({},}),- links+ ...links.filter((link) => link.couponCode).map((link) =>disableStripePromotionCode({diff --git a/apps/web/lib/stripe/disable-stripe-promotion-code.ts b/apps/web/lib/stripe/disable-stripe-promotion-code.tsindex 457cfabf3b..ab3bf99bd8 100644--- a/apps/web/lib/stripe/disable-stripe-promotion-code.ts+++ b/apps/web/lib/stripe/disable-stripe-promotion-code.ts@@ -15,10 +15,15 @@ export async function disableStripePromotionCode({return;}- const promotionCodes = await stripe.promotionCodes.list({- code: couponCode,- limit: 1,- });+ const promotionCodes = await stripe.promotionCodes.list(+ {+ code: couponCode,+ limit: 1,+ },+ {+ stripeAccount: stripeConnectId,+ },+ );if (promotionCodes.data.length === 0) {return;