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 saleAmount

Kiran K0309bdcc30df
diff --git a/apps/web/lib/zod/schemas/analytics-response.ts b/apps/web/lib/zod/schemas/analytics-response.ts
index 91904407e8..aa3bd7692c 100644
--- a/apps/web/lib/zod/schemas/analytics-response.ts
+++ b/apps/web/lib/zod/schemas/analytics-response.ts
@@ -467,6 +467,12 @@ export const analyticsResponse = {
clicks: z.number().describe("The total number of clicks").default(0),
leads: z.number().describe("The total number of leads").default(0),
sales: z.number().describe("The total number of sales").default(0),
+ saleAmount: z
+ .number()
+ .describe(
+ "The total amount of sales from this partner for this program, in cents",
+ )
+ .default(0),
})
.openapi({ ref: "AnalyticsPartners" }),
} as const;
diff --git a/packages/tinybird/pipes/v2_partners.pipe b/packages/tinybird/pipes/v2_partners.pipe
index 5c9fb156b1..8b52631505 100644
--- a/packages/tinybird/pipes/v2_partners.pipe
+++ b/packages/tinybird/pipes/v2_partners.pipe
@@ -115,7 +115,7 @@ NODE count_sales
SQL >
%
- SELECT wl.partner_id, COUNT(*) AS sales
+ SELECT wl.partner_id, COUNT(*) AS sales, sum(amount) as saleAmount
FROM dub_sale_events AS se
JOIN workspace_links AS wl ON se.link_id = wl.link_id
WHERE
@@ -160,7 +160,7 @@ SQL >
NODE count_composite
SQL >
- SELECT c.partner_id as partner_id, clicks, leads, sales
+ SELECT c.partner_id as partner_id, clicks, leads, sales, saleAmount
FROM count_clicks AS c
LEFT JOIN count_leads AS l ON c.partner_id = l.partner_id
LEFT JOIN count_sales AS s ON c.partner_id = s.partner_id