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 invoice ID

Steven Tey4119167728ad
diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.ts
index fb93c72348..1135dd08c7 100644
--- a/apps/web/app/api/track/sale/route.ts
+++ b/apps/web/app/api/track/sale/route.ts
@@ -15,6 +15,7 @@ export const POST = withWorkspaceEdge(
customerId,
paymentProcessor,
productId,
+ invoiceId,
amount,
currency,
recurring,
@@ -29,6 +30,7 @@ export const POST = withWorkspaceEdge(
const leadEvent = await getLeadEvent({ customer_id: customerId });
if (!leadEvent || leadEvent.data.length === 0) {
+ console.log("No lead event found for customer_id:", customerId);
return;
}
@@ -42,6 +44,7 @@ export const POST = withWorkspaceEdge(
event_id: nanoid(16),
payment_processor: paymentProcessor,
product_id: productId,
+ invoice_id: invoiceId,
amount,
currency,
recurring: recurring ? 1 : 0,
diff --git a/apps/web/lib/zod/schemas/sales.ts b/apps/web/lib/zod/schemas/sales.ts
index cab408a0b6..d837efdd9f 100644
--- a/apps/web/lib/zod/schemas/sales.ts
+++ b/apps/web/lib/zod/schemas/sales.ts
@@ -5,6 +5,7 @@ export const trackSaleRequestSchema = z.object({
customerId: z.string(),
paymentProcessor: z.enum(["stripe", "shopify", "paddle"]),
productId: z.string(),
+ invoiceId: z.string(),
amount: z.number().int().positive().default(0),
currency: z.string().default("usd"),
recurring: z.boolean().default(false),
@@ -22,6 +23,7 @@ export const saleEventSchemaTB = clickEventSchemaTB
customer_id: z.string(),
payment_processor: z.string(),
product_id: z.string().default(""),
+ invoice_id: z.string().default(""),
amount: z.number().int().positive(),
currency: z.string(),
recurring: z.number(),