The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Improve `recordLead`
Kiran K6e6c8a0269ea
diff --git a/apps/web/app/api/stripe/integration/webhook/customer-created.ts b/apps/web/app/api/stripe/integration/webhook/customer-created.tsindex 34489ca745..b1daa4928e 100644--- a/apps/web/app/api/stripe/integration/webhook/customer-created.ts+++ b/apps/web/app/api/stripe/integration/webhook/customer-created.ts@@ -73,10 +73,8 @@ export async function customerCreated(event: Stripe.Event) {},});- const { timestamp, ...rest } = clickData;-const leadData = {- ...rest, // remove timestamp from lead data because tinybird will generate its own at ingestion time+ ...clickData,event_id: nanoid(16),event_name: "New customer",customer_id: customer.id,diff --git a/apps/web/app/api/track/lead/route.ts b/apps/web/app/api/track/lead/route.tsindex 8d3bf6ee84..5ea37cbae9 100644--- a/apps/web/app/api/track/lead/route.ts+++ b/apps/web/app/api/track/lead/route.ts@@ -85,12 +85,9 @@ export const POST = withWorkspaceEdge(},});- // remove timestamp from lead data because tinybird will generate its own at ingestion time- const { timestamp, ...rest } = clickData;-const [_lead, link, _project] = await Promise.all([recordLead({- ...rest,+ ...clickData,event_id: nanoid(16),event_name: eventName,customer_id: customer.id,diff --git a/apps/web/lib/zod/schemas/leads.ts b/apps/web/lib/zod/schemas/leads.tsindex 9544ba3955..62c3be27a4 100644--- a/apps/web/lib/zod/schemas/leads.ts+++ b/apps/web/lib/zod/schemas/leads.ts@@ -75,7 +75,7 @@ export const trackLeadResponseSchema = z.object({});export const leadEventSchemaTB = clickEventSchemaTB- .omit({ timestamp: true })+ .omit({ timestamp: true }) // remove timestamp from lead data because tinybird will generate its own at ingestion time.and(z.object({event_id: z.string(),