The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update transform schema
Steven Tey7ce7ab7a786d
diff --git a/apps/web/lib/webhook/schemas.ts b/apps/web/lib/webhook/schemas.tsindex d28757d599..f5ac6f05eb 100644--- a/apps/web/lib/webhook/schemas.ts+++ b/apps/web/lib/webhook/schemas.ts@@ -39,26 +39,31 @@ export const clickEventSchema = z.object({link: linkEventSchema,});+const customerSchema = z.object({+ id: z.string(),+ name: z.string().nullable(),+ email: z.string().nullable(),+ avatar: z.string().nullable(),+});+export const leadEventSchema = z.object({eventName: z.string(),- customerId: z.string(),- customerName: z.string().nullable(),- customerEmail: z.string().nullable(),- customerAvatar: z.string().nullable(),+ customer: customerSchema,click: clickEventSchema.omit({ link: true, timestamp: true }),link: linkEventSchema,});-export const saleEventSchema = z.object({- eventName: z.string(),- customerId: z.string(),- customerName: z.string().nullable(),- customerEmail: z.string().nullable(),- customerAvatar: z.string().nullable(),+const saleSchema = z.object({amount: z.number(),paymentProcessor: z.string(),invoiceId: z.string().nullable(),currency: z.string(),+});++export const saleEventSchema = z.object({+ eventName: z.string(),+ customer: customerSchema,+ sale: saleSchema,click: clickEventSchema.omit({ link: true, timestamp: true }),link: linkEventSchema,});diff --git a/apps/web/lib/webhook/transform.ts b/apps/web/lib/webhook/transform.tsindex 7361d5e0c0..8f35611757 100644--- a/apps/web/lib/webhook/transform.ts+++ b/apps/web/lib/webhook/transform.ts@@ -59,6 +59,12 @@ export const transformLeadEventData = (data: any) => {return leadEventSchema.parse({...lead,+ customer: {+ id: lead.customerId,+ name: lead.customerName,+ email: lead.customerEmail,+ avatar: lead.customerAvatar,+ },click: {...lead,qr: lead.qr === 1,@@ -77,6 +83,18 @@ export const transformSaleEventData = (data: any) => {return saleEventSchema.parse({...sale,+ customer: {+ id: sale.customerId,+ name: sale.customerName,+ email: sale.customerEmail,+ avatar: sale.customerAvatar,+ },+ sale: {+ amount: sale.amount,+ paymentProcessor: sale.paymentProcessor,+ invoiceId: sale.invoiceId,+ currency: sale.currency,+ },click: {...sale,qr: sale.qr === 1,