The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
incrementLinkLeads
Steven Tey3ce2c3051135
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.tsindex 1aebf8b5eb..114a6469e4 100644--- a/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts@@ -146,6 +146,7 @@ export async function checkoutSessionCompleted(if (!existingCustomer) {await recordLead(leadEvent);+ waitUntil(incrementLinkLeads(clickEvent.link_id));}linkId = clickEvent.link_id;@@ -600,17 +601,7 @@ async function attributeViaPromoCode({// record lead side effects (link stats, partner commissions, workflows, workspace webhook)waitUntil((async () => {- const linkUpdated = await prisma.link.update({- where: {- id: link.id,- },- data: {- leads: {- increment: 1,- },- lastLeadAt: new Date(),- },- });+ const linkUpdated = await incrementLinkLeads(link.id);let webhookPartner: WebhookPartner | undefined;if (link.programId && link.partnerId) {@@ -671,3 +662,17 @@ async function attributeViaPromoCode({leadEvent,};}++async function incrementLinkLeads(linkId: string) {+ return await prisma.link.update({+ where: {+ id: linkId,+ },+ data: {+ leads: {+ increment: 1,+ },+ lastLeadAt: new Date(),+ },+ });+}