The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Refactor event data handling in lead tracking integrations
Kiran K110f54018f3c
diff --git a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.tsindex 43d7507289..56ff85b964 100644--- a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts+++ b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts@@ -325,8 +325,8 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {workspace,data: transformLeadEventData({...clickEvent,- link: linkUpdated,eventName: "Checkout session completed",+ link: linkUpdated,customerId: customer.id,customerExternalId: customer.externalId,customerName: customer.name,diff --git a/apps/web/app/api/stripe/integration/webhook/customer-created.ts b/apps/web/app/api/stripe/integration/webhook/customer-created.tsindex 3fc4afd6f7..475132ecd1 100644--- a/apps/web/app/api/stripe/integration/webhook/customer-created.ts+++ b/apps/web/app/api/stripe/integration/webhook/customer-created.ts@@ -85,10 +85,12 @@ export async function customerCreated(event: Stripe.Event) {},});+ const eventName = "New customer";+const leadData = {...clickData,event_id: nanoid(16),- event_name: "New customer",+ event_name: eventName,customer_id: customer.id,};@@ -128,6 +130,7 @@ export async function customerCreated(event: Stripe.Event) {workspace,data: transformLeadEventData({...clickData,+ eventName,link: linkUpdated,customerId: customer.id,customerExternalId: customer.externalId,@@ -138,6 +141,7 @@ export async function customerCreated(event: Stripe.Event) {}),}),);+return `New Dub customer created: ${customer.id}. Lead event recorded: ${leadData.event_id}`;}}diff --git a/apps/web/app/api/track/lead/route.ts b/apps/web/app/api/track/lead/route.tsindex bbf9d48f77..fceff21616 100644--- a/apps/web/app/api/track/lead/route.ts+++ b/apps/web/app/api/track/lead/route.ts@@ -125,8 +125,8 @@ export const POST = withWorkspaceEdge(trigger: "lead.created",data: transformLeadEventData({...clickData,- link,eventName,+ link,customerId: customer.id,customerExternalId: customer.externalId,customerName: customer.name,diff --git a/apps/web/lib/integrations/shopify/create-lead.ts b/apps/web/lib/integrations/shopify/create-lead.tsindex 11c932b7cc..a2737399a7 100644--- a/apps/web/lib/integrations/shopify/create-lead.ts+++ b/apps/web/lib/integrations/shopify/create-lead.ts@@ -45,10 +45,12 @@ export async function createShopifyLead({},});+ const eventName = "Account created";+const leadData = leadEventSchemaTB.parse({...clickData,event_id: nanoid(16),- event_name: "Account created",+ event_name: eventName,customer_id: customer.id,});@@ -88,6 +90,7 @@ export async function createShopifyLead({workspace,data: transformLeadEventData({...clickData,+ eventName,link,customerId: customer.id,customerExternalId: customer.externalId,