The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
simplify the customer object
Kiran K772337dc3e38
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 56ff85b964..2ac167ee92 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@@ -327,12 +327,7 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {...clickEvent,eventName: "Checkout session completed",link: linkUpdated,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),});}@@ -345,12 +340,7 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {...saleData,clickedAt: customer.clickedAt || customer.createdAt,link: linkUpdated,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),});})(),diff --git a/apps/web/app/api/stripe/integration/webhook/customer-created.ts b/apps/web/app/api/stripe/integration/webhook/customer-created.tsindex 475132ecd1..c922abfc0e 100644--- a/apps/web/app/api/stripe/integration/webhook/customer-created.ts+++ b/apps/web/app/api/stripe/integration/webhook/customer-created.ts@@ -132,12 +132,7 @@ export async function customerCreated(event: Stripe.Event) {...clickData,eventName,link: linkUpdated,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),}),);diff --git a/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/api/stripe/integration/webhook/invoice-paid.tsindex b9a778822a..4d2935cd28 100644--- a/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts+++ b/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts@@ -179,12 +179,7 @@ export async function invoicePaid(event: Stripe.Event) {...saleData,clickedAt: customer.clickedAt || customer.createdAt,link: linkUpdated,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),}),);diff --git a/apps/web/app/api/track/lead/route.ts b/apps/web/app/api/track/lead/route.tsindex fceff21616..6377e93ccd 100644--- a/apps/web/app/api/track/lead/route.ts+++ b/apps/web/app/api/track/lead/route.ts@@ -127,12 +127,7 @@ export const POST = withWorkspaceEdge(...clickData,eventName,link,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),workspace,});diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.tsindex 9b3d10b8a1..582ab642f8 100644--- a/apps/web/app/api/track/sale/route.ts+++ b/apps/web/app/api/track/sale/route.ts@@ -186,12 +186,7 @@ export const POST = withWorkspaceEdge(...saleData,clickedAt: customer.clickedAt || customer.createdAt,link,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,});await sendWorkspaceWebhookOnEdge({diff --git a/apps/web/lib/integrations/shopify/create-lead.ts b/apps/web/lib/integrations/shopify/create-lead.tsindex a2737399a7..2ac3507f94 100644--- a/apps/web/lib/integrations/shopify/create-lead.ts+++ b/apps/web/lib/integrations/shopify/create-lead.ts@@ -92,12 +92,7 @@ export async function createShopifyLead({...clickData,eventName,link,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),}),);diff --git a/apps/web/lib/integrations/shopify/create-sale.ts b/apps/web/lib/integrations/shopify/create-sale.tsindex 0b50f1dae0..e5f00e2304 100644--- a/apps/web/lib/integrations/shopify/create-sale.ts+++ b/apps/web/lib/integrations/shopify/create-sale.ts@@ -114,12 +114,7 @@ export async function createShopifySale({...saleData,link,clickedAt: customer.clickedAt || customer.createdAt,- customerId: customer.id,- customerExternalId: customer.externalId,- customerName: customer.name,- customerEmail: customer.email,- customerAvatar: customer.avatar,- customerCreatedAt: customer.createdAt,+ customer,}),}),);diff --git a/apps/web/lib/webhook/transform.ts b/apps/web/lib/webhook/transform.tsindex 11e96fa36b..eb9fb50c84 100644--- a/apps/web/lib/webhook/transform.ts+++ b/apps/web/lib/webhook/transform.ts@@ -52,17 +52,15 @@ export const transformLeadEventData = (data: any) => {Object.entries(data).map(([key, value]) => [toCamelCase(key), value]),);+ const { customer } = data;+return leadWebhookEventSchema.parse({...lead,customer: {- id: lead.customerId,- externalId: lead.customerExternalId,- name: lead.customerName,- email: lead.customerEmail,+ ...customer,avatar:- lead.customerAvatar ||- `https://api.dicebear.com/9.x/micah/svg?seed=${lead.customerId}`,- createdAt: lead.customerCreatedAt,+ customer.avatar ||+ `https://api.dicebear.com/9.x/micah/svg?seed=${customer.id}`,},click: {...lead,@@ -79,17 +77,15 @@ export const transformSaleEventData = (data: any) => {Object.entries(data).map(([key, value]) => [toCamelCase(key), value]),);+ const { customer } = data;+return saleWebhookEventSchema.parse({...sale,customer: {- id: sale.customerId,- name: sale.customerName,- email: sale.customerEmail,+ ...customer,avatar:- sale.customerAvatar ||- `https://api.dicebear.com/9.x/micah/svg?seed=${sale.customerId}`,- externalId: sale.customerExternalId,- createdAt: sale.customerCreatedAt,+ customer.avatar ||+ `https://api.dicebear.com/9.x/micah/svg?seed=${customer.id}`,},sale: {amount: sale.amount,diff --git a/packages/ui/src/icons/card-amex.tsx b/packages/ui/src/icons/card-amex.tsxindex 659f21984e..1832e31f9a 100644--- a/packages/ui/src/icons/card-amex.tsx+++ b/packages/ui/src/icons/card-amex.tsx@@ -10,11 +10,28 @@ export function CardAmex(props: SVGProps<SVGSVGElement>) {viewBox="0 0 24 20"{...props}>- <path d="M0 10.6879L4.47134 0.598724H8.82803L9.89809 2.8535V0.598724H15.2484L16.1274 2.96815L17.0446 0.598724H22.7006V10.6891L19.1083 14.3185L24 19.4013H17.2357L15.8599 17.7962L14.4459 19.4013H3.63057V10.6879H0Z" fill="#306FC5"/>- <path fill-rule="evenodd" clip-rule="evenodd" d="M5.5378 2.01274L2.25117 9.38854H4.42952L4.96455 7.93631H8.51869L9.09194 9.38854H11.2321L7.94544 2.01274H5.5378ZM7.90723 6.40765L6.72251 3.57962L5.5378 6.40765H7.90723Z" fill="white"/>- <path d="M21.0919 9.38854V2.01274H17.9964L16.162 6.78981L14.3276 2.01274H11.2703V9.38854H13.1047V3.69427L15.2448 9.38854H17.041L19.1811 3.69427V9.38854H21.0919Z" fill="white"/>- <path d="M5.11742 17.949V10.6879H11.2321V12.293H6.95181V13.5924H11.1174V15.121H6.95181V16.4586H11.2321V17.949H5.11742Z" fill="white"/>- <path d="M20.4805 10.6879L17.0792 14.3185L20.4805 17.949H17.9964L15.8563 15.6178L13.6779 17.949H11.3085L14.6716 14.3185L11.2703 10.6879H13.6779L15.8563 13.0573L18.0728 10.6879H20.4805Z" fill="white"/>+ <path+ d="M0 10.6879L4.47134 0.598724H8.82803L9.89809 2.8535V0.598724H15.2484L16.1274 2.96815L17.0446 0.598724H22.7006V10.6891L19.1083 14.3185L24 19.4013H17.2357L15.8599 17.7962L14.4459 19.4013H3.63057V10.6879H0Z"+ fill="#306FC5"+ />+ <path+ fill-rule="evenodd"+ clip-rule="evenodd"+ d="M5.5378 2.01274L2.25117 9.38854H4.42952L4.96455 7.93631H8.51869L9.09194 9.38854H11.2321L7.94544 2.01274H5.5378ZM7.90723 6.40765L6.72251 3.57962L5.5378 6.40765H7.90723Z"+ fill="white"+ />+ <path+ d="M21.0919 9.38854V2.01274H17.9964L16.162 6.78981L14.3276 2.01274H11.2703V9.38854H13.1047V3.69427L15.2448 9.38854H17.041L19.1811 3.69427V9.38854H21.0919Z"+ fill="white"+ />+ <path+ d="M5.11742 17.949V10.6879H11.2321V12.293H6.95181V13.5924H11.1174V15.121H6.95181V16.4586H11.2321V17.949H5.11742Z"+ fill="white"+ />+ <path+ d="M20.4805 10.6879L17.0792 14.3185L20.4805 17.949H17.9964L15.8563 15.6178L13.6779 17.949H11.3085L14.6716 14.3185L11.2703 10.6879H13.6779L15.8563 13.0573L18.0728 10.6879H20.4805Z"+ fill="white"+ /></svg>);-}\ No newline at end of file+}diff --git a/packages/ui/src/icons/card-discover.tsx b/packages/ui/src/icons/card-discover.tsxindex 53b59bd912..5cda5bf021 100644--- a/packages/ui/src/icons/card-discover.tsx+++ b/packages/ui/src/icons/card-discover.tsx@@ -10,29 +10,62 @@ export function CardDiscover(props: SVGProps<SVGSVGElement>) {viewBox="0 0 22 22"{...props}>- <g filter="url(#filter0_i_3233_2334)">- <circle cx="11" cy="11" r="10.1145" fill="url(#paint0_linear_3233_2334)"/>- </g>- <defs>- <filter id="filter0_i_3233_2334" x="0.885498" y="0.885483" width="22.229" height="22.229" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">- <feFlood flood-opacity="0" result="BackgroundImageFix"/>- <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>- <feOffset dx="2" dy="2"/>- <feGaussianBlur stdDeviation="1"/>- <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>- <feColorMatrix type="matrix" values="0 0 0 0 0.675732 0 0 0 0 0.189457 0 0 0 0 0.144011 0 0 0 1 0"/>- <feBlend mode="normal" in2="shape" result="effect1_innerShadow_3233_2334"/>+ <g filter="url(#filter0_i_3233_2334)">+ <circle+ cx="11"+ cy="11"+ r="10.1145"+ fill="url(#paint0_linear_3233_2334)"+ />+ </g>+ <defs>+ <filter+ id="filter0_i_3233_2334"+ x="0.885498"+ y="0.885483"+ width="22.229"+ height="22.229"+ filterUnits="userSpaceOnUse"+ color-interpolation-filters="sRGB"+ >+ <feFlood flood-opacity="0" result="BackgroundImageFix" />+ <feBlend+ mode="normal"+ in="SourceGraphic"+ in2="BackgroundImageFix"+ result="shape"+ />+ <feColorMatrix+ in="SourceAlpha"+ type="matrix"+ values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"+ result="hardAlpha"+ />+ <feOffset dx="2" dy="2" />+ <feGaussianBlur stdDeviation="1" />+ <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1" />+ <feColorMatrix+ type="matrix"+ values="0 0 0 0 0.675732 0 0 0 0 0.189457 0 0 0 0 0.144011 0 0 0 1 0"+ />+ <feBlend+ mode="normal"+ in2="shape"+ result="effect1_innerShadow_3233_2334"+ /></filter>- <linearGradient id="paint0_linear_3233_2334" x1="0.885498" y1="0.885483" x2="21.1145" y2="21.1145" gradientUnits="userSpaceOnUse">- <stop offset="0.28" stop-color="#E0481E"/>- <stop offset="0.765" stop-color="#F59214"/>+ <linearGradient+ id="paint0_linear_3233_2334"+ x1="0.885498"+ y1="0.885483"+ x2="21.1145"+ y2="21.1145"+ gradientUnits="userSpaceOnUse"+ >+ <stop offset="0.28" stop-color="#E0481E" />+ <stop offset="0.765" stop-color="#F59214" /></linearGradient>- </defs>+ </defs></svg>);}----diff --git a/packages/ui/src/icons/card-mastercard.tsx b/packages/ui/src/icons/card-mastercard.tsxindex c6658afdf9..8a172278ce 100644--- a/packages/ui/src/icons/card-mastercard.tsx+++ b/packages/ui/src/icons/card-mastercard.tsx@@ -10,9 +10,15 @@ export function CardMastercard(props: SVGProps<SVGSVGElement>) {viewBox="0 0 26 16"{...props}>- <path d="M16.4812 1.71H9.48193V14.2895H16.4812V1.71Z" fill="#FF5F00"/>- <path d="M9.94376 7.99989C9.94267 6.78836 10.2173 5.59245 10.7467 4.50275C11.2762 3.41304 12.0467 2.45811 12.9999 1.71025C11.8197 0.782666 10.4024 0.205831 8.90991 0.045672C7.41742 -0.114488 5.90998 0.148487 4.55988 0.804545C3.20979 1.4606 2.07151 2.48327 1.27514 3.75566C0.478777 5.02805 0.0564575 6.49883 0.0564575 7.99989C0.0564575 9.50095 0.478777 10.9717 1.27514 12.2441C2.07151 13.5165 3.20979 14.5392 4.55988 15.1952C5.90998 15.8513 7.41742 16.1143 8.90991 15.9541C10.4024 15.7939 11.8197 15.2171 12.9999 14.2895C12.0467 13.5417 11.2762 12.5867 10.7467 11.497C10.2173 10.4073 9.94267 9.21142 9.94376 7.99989Z" fill="#EB001B"/>- <path d="M17.9436 9.58141e-06C16.1501 -0.00277122 14.4081 0.599824 12.9997 1.71025C13.952 2.45885 14.7219 3.41394 15.2513 4.50348C15.7808 5.59301 16.0558 6.78855 16.0558 7.99989C16.0558 9.21124 15.7808 10.4068 15.2513 11.4963C14.7219 12.5858 13.952 13.5409 12.9997 14.2895C14.0023 15.0776 15.1788 15.6146 16.4311 15.8557C17.6833 16.0968 18.9751 16.0351 20.1987 15.6756C21.4222 15.3161 22.5421 14.6693 23.465 13.7891C24.3878 12.909 25.0869 11.8209 25.5038 10.6157C25.9208 9.41056 26.0436 8.12316 25.862 6.86088C25.6804 5.5986 25.1997 4.39802 24.4599 3.35924C23.7201 2.32047 22.7427 1.4736 21.6092 0.889259C20.4757 0.304914 19.2189 2.34802e-05 17.9436 9.58141e-06Z" fill="#F79E1B"/>+ <path d="M16.4812 1.71H9.48193V14.2895H16.4812V1.71Z" fill="#FF5F00" />+ <path+ d="M9.94376 7.99989C9.94267 6.78836 10.2173 5.59245 10.7467 4.50275C11.2762 3.41304 12.0467 2.45811 12.9999 1.71025C11.8197 0.782666 10.4024 0.205831 8.90991 0.045672C7.41742 -0.114488 5.90998 0.148487 4.55988 0.804545C3.20979 1.4606 2.07151 2.48327 1.27514 3.75566C0.478777 5.02805 0.0564575 6.49883 0.0564575 7.99989C0.0564575 9.50095 0.478777 10.9717 1.27514 12.2441C2.07151 13.5165 3.20979 14.5392 4.55988 15.1952C5.90998 15.8513 7.41742 16.1143 8.90991 15.9541C10.4024 15.7939 11.8197 15.2171 12.9999 14.2895C12.0467 13.5417 11.2762 12.5867 10.7467 11.497C10.2173 10.4073 9.94267 9.21142 9.94376 7.99989Z"+ fill="#EB001B"+ />+ <path+ d="M17.9436 9.58141e-06C16.1501 -0.00277122 14.4081 0.599824 12.9997 1.71025C13.952 2.45885 14.7219 3.41394 15.2513 4.50348C15.7808 5.59301 16.0558 6.78855 16.0558 7.99989C16.0558 9.21124 15.7808 10.4068 15.2513 11.4963C14.7219 12.5858 13.952 13.5409 12.9997 14.2895C14.0023 15.0776 15.1788 15.6146 16.4311 15.8557C17.6833 16.0968 18.9751 16.0351 20.1987 15.6756C21.4222 15.3161 22.5421 14.6693 23.465 13.7891C24.3878 12.909 25.0869 11.8209 25.5038 10.6157C25.9208 9.41056 26.0436 8.12316 25.862 6.86088C25.6804 5.5986 25.1997 4.39802 24.4599 3.35924C23.7201 2.32047 22.7427 1.4736 21.6092 0.889259C20.4757 0.304914 19.2189 2.34802e-05 17.9436 9.58141e-06Z"+ fill="#F79E1B"+ /></svg>);-}\ No newline at end of file+}diff --git a/packages/ui/src/icons/card-visa.tsx b/packages/ui/src/icons/card-visa.tsxindex 22801b7365..f90b62cde2 100644--- a/packages/ui/src/icons/card-visa.tsx+++ b/packages/ui/src/icons/card-visa.tsx@@ -10,8 +10,8 @@ export function CardVisa(props: SVGProps<SVGSVGElement>) {viewBox="0 0 20 16"{...props}>- <path- d="M0.367215 0.000510312L0.279083 0.510302C0.279083 0.510302 1.80807 0.788926 3.18539 1.34516C4.95879 1.98252 5.08484 2.35402 5.38357 3.50628L8.63779 16H13.0003L19.7209 0.000510312H15.3686L11.0501 10.8786L9.28802 1.65746C9.12662 0.602156 8.30781 0 7.30608 0H0.367728L0.367215 0.000510312Z"+ <path+ d="M0.367215 0.000510312L0.279083 0.510302C0.279083 0.510302 1.80807 0.788926 3.18539 1.34516C4.95879 1.98252 5.08484 2.35402 5.38357 3.50628L8.63779 16H13.0003L19.7209 0.000510312H15.3686L11.0501 10.8786L9.28802 1.65746C9.12662 0.602156 8.30781 0 7.30608 0H0.367728L0.367215 0.000510312Z"fill="#1434CB"/></svg>