The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
deduplicate first before getLeadEvent
Steven Teyc06b1c6c741d
diff --git a/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.ts b/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.tsindex 048a0cc9de..83db796fe6 100644--- a/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.ts+++ b/apps/web/app/api/stripe/connect/webhook/checkout-session-completed.ts@@ -29,12 +29,6 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {},});- // Find lead- const leadEvent = await getLeadEvent({ customerId: customer.id });- if (!leadEvent || leadEvent.data.length === 0) {- return;- }-if (invoiceId) {// Skip if invoice id is already processedconst ok = await redis.set(`dub_sale_events:invoiceId:${invoiceId}`, 1, {@@ -51,6 +45,12 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {}}+ // Find lead+ const leadEvent = await getLeadEvent({ customerId: customer.id });+ if (!leadEvent || leadEvent.data.length === 0) {+ return;+ }+await Promise.all([recordSale({...leadEvent.data[0],diff --git a/apps/web/app/api/stripe/connect/webhook/invoice-paid.ts b/apps/web/app/api/stripe/connect/webhook/invoice-paid.tsindex 4afd8bd892..a8e0c64b8d 100644--- a/apps/web/app/api/stripe/connect/webhook/invoice-paid.ts+++ b/apps/web/app/api/stripe/connect/webhook/invoice-paid.ts@@ -23,12 +23,6 @@ export async function invoicePaid(event: Stripe.Event) {return;}- // Find lead- const leadEvent = await getLeadEvent({ customerId: customer.id });- if (!leadEvent || leadEvent.data.length === 0) {- return;- }-// Skip if invoice id is already processedconst ok = await redis.set(`dub_sale_events:invoiceId:${invoiceId}`, 1, {ex: 60 * 60 * 24 * 7,@@ -43,6 +37,12 @@ export async function invoicePaid(event: Stripe.Event) {return;}+ // Find lead+ const leadEvent = await getLeadEvent({ customerId: customer.id });+ if (!leadEvent || leadEvent.data.length === 0) {+ return;+ }+await Promise.all([recordSale({...leadEvent.data[0],