Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add click timestamp to webhooks

Steven Teydb48c4f768c4
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.ts
index b1012bc8c5..43d7507289 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
@@ -343,6 +343,7 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
workspace,
data: transformSaleEventData({
...saleData,
+ clickedAt: customer.clickedAt || customer.createdAt,
link: linkUpdated,
customerId: customer.id,
customerExternalId: customer.externalId,
diff --git a/apps/web/lib/webhook/transform.ts b/apps/web/lib/webhook/transform.ts
index 90b4fddb37..913052da4b 100644
--- a/apps/web/lib/webhook/transform.ts
+++ b/apps/web/lib/webhook/transform.ts
@@ -98,6 +98,7 @@ export const transformSaleEventData = (data: any) => {
click: {
...sale,
id: sale.clickId,
+ timestamp: sale.clickedAt,
qr: sale.qr === 1,
bot: sale.bot === 1,
},
diff --git a/apps/web/lib/zod/schemas/clicks.ts b/apps/web/lib/zod/schemas/clicks.ts
index a32da5d565..f31cc1de28 100644
--- a/apps/web/lib/zod/schemas/clicks.ts
+++ b/apps/web/lib/zod/schemas/clicks.ts
@@ -54,6 +54,7 @@ export const clickEventSchemaTBEndpoint = z.object({
export const clickEventSchema = z.object({
id: z.string(),
+ timestamp: z.string(),
url: z.string(),
country: z.string(),
city: z.string(),