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.

fix schemas

Steven Teye82c92523b23
diff --git a/apps/web/app/api/track/lead/route.ts b/apps/web/app/api/track/lead/route.ts
index 11893cc313..b4dad8166b 100644
--- a/apps/web/app/api/track/lead/route.ts
+++ b/apps/web/app/api/track/lead/route.ts
@@ -32,7 +32,7 @@ export const POST = withWorkspaceEdge(
metadata,
} = trackLeadRequestSchema.parse(await parseRequestBody(req));
- const customerExternalId = externalId || customerId;
+ const customerExternalId = customerId || externalId;
if (!customerExternalId) {
throw new DubApiError({
@@ -153,10 +153,10 @@ export const POST = withWorkspaceEdge(
id: clickId,
},
customer: {
- id: customerExternalId,
name: finalCustomerName,
email: customerEmail,
avatar: customerAvatar,
+ externalId: customerExternalId,
},
});
diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.ts
index 0cfa295a63..e49e3999d1 100644
--- a/apps/web/app/api/track/sale/route.ts
+++ b/apps/web/app/api/track/sale/route.ts
@@ -30,7 +30,7 @@ export const POST = withWorkspaceEdge(
eventName,
} = trackSaleRequestSchema.parse(await parseRequestBody(req));
- const customerExternalId = externalId || customerId;
+ const customerExternalId = customerId || externalId;
if (!customerExternalId) {
throw new DubApiError({
@@ -140,12 +140,7 @@ export const POST = withWorkspaceEdge(
const sale = trackSaleResponseSchema.parse({
eventName,
- customer: {
- id: customer.externalId,
- name: customer.name,
- email: customer.email,
- avatar: customer.avatar,
- },
+ customer,
sale: {
amount,
currency,
diff --git a/apps/web/lib/zod/schemas/leads.ts b/apps/web/lib/zod/schemas/leads.ts
index 8b78b6cf12..210f051ac7 100644
--- a/apps/web/lib/zod/schemas/leads.ts
+++ b/apps/web/lib/zod/schemas/leads.ts
@@ -68,10 +68,10 @@ export const trackLeadResponseSchema = z.object({
id: z.string(),
}),
customer: z.object({
- id: z.string(),
name: z.string().nullable(),
email: z.string().nullable(),
avatar: z.string().nullable(),
+ externalId: z.string().nullable(),
}),
});
diff --git a/apps/web/lib/zod/schemas/sales.ts b/apps/web/lib/zod/schemas/sales.ts
index 00f58a5d4d..d77ac288ee 100644
--- a/apps/web/lib/zod/schemas/sales.ts
+++ b/apps/web/lib/zod/schemas/sales.ts
@@ -63,6 +63,7 @@ export const trackSaleResponseSchema = z.object({
name: z.string().nullable(),
email: z.string().nullable(),
avatar: z.string().nullable(),
+ externalId: z.string().nullable(),
}),
sale: z.object({
amount: z.number(),