The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix the endpoints
Kiran K68f80aee4220
diff --git a/apps/web/app/api/analytics/sales/[endpoint]/route.ts b/apps/web/app/api/analytics/sales/[endpoint]/route.tsindex 40481b3425..a0587faeed 100644--- a/apps/web/app/api/analytics/sales/[endpoint]/route.ts+++ b/apps/web/app/api/analytics/sales/[endpoint]/route.ts@@ -1,4 +1,4 @@-import { getLeads } from "@/lib/analytics/leads";+import { getSales } from "@/lib/analytics/sales";import { validDateRangeForPlan } from "@/lib/analytics/utils";import { withWorkspace } from "@/lib/auth";import { getDomainViaEdge } from "@/lib/planetscale";@@ -30,7 +30,7 @@ export const GET = withWorkspace(? await getDomainViaEdge(domain).then((d) => d?.id): null;- const response = await getLeads({+ const response = await getSales({...parsedParams,endpoint,...(linkId && { linkId }),diff --git a/packages/tinybird/endpoints/leads_top_urls.pipe b/packages/tinybird/endpoints/leads_top_urls.pipenew file mode 100644index 0000000000..8aa290a068--- /dev/null+++ b/packages/tinybird/endpoints/leads_top_urls.pipe@@ -0,0 +1,33 @@+DESCRIPTION >+ Top URLs for a given link++NODE endpoint+SQL >++ %+ SELECT url, COUNT(*) AS leads+ FROM dub_lead_events_mv+ WHERE+ link_id+ = {{+ String(+ linkId,+ 'clsdzhhlq0003vskwcaz6nm39',+ description="The ID of the link",+ required=True,+ )+ }}+ {% if defined(qr) %} AND qr = {{ Boolean(qr)}} {% end %}+ {% if defined(country) %} AND country = {{ country }} {% end %}+ {% if defined(city) %} AND city = {{ city }} {% end %}+ {% if defined(device) %} AND device = {{ device }} {% end %}+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}+ {% if defined(os) %} AND os = {{ os }} {% end %}+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}+ {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}+ {% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}+ GROUP BY url+ ORDER BY leads DESC++diff --git a/packages/tinybird/endpoints/sales_top_urls.pipe b/packages/tinybird/endpoints/sales_top_urls.pipenew file mode 100644index 0000000000..71cd064e1a--- /dev/null+++ b/packages/tinybird/endpoints/sales_top_urls.pipe@@ -0,0 +1,33 @@+DESCRIPTION >+ Top URLs for a given link++NODE endpoint+SQL >++ %+ SELECT url, COUNT(*) AS sales+ FROM dub_sale_events_mv+ WHERE+ link_id+ = {{+ String(+ linkId,+ 'clsdzhhlq0003vskwcaz6nm39',+ description="The ID of the link",+ required=True,+ )+ }}+ {% if defined(qr) %} AND qr = {{ Boolean(qr)}} {% end %}+ {% if defined(country) %} AND country = {{ country }} {% end %}+ {% if defined(city) %} AND city = {{ city }} {% end %}+ {% if defined(device) %} AND device = {{ device }} {% end %}+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}+ {% if defined(os) %} AND os = {{ os }} {% end %}+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}+ {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}+ {% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}+ GROUP BY url+ ORDER BY sales DESC++