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.

updates

Steven Tey17f0d55b7bb3
diff --git a/apps/web/lib/tinybird/index.ts b/apps/web/lib/tinybird/index.ts
index ff94fa635c..fc7b91e1d9 100644
--- a/apps/web/lib/tinybird/index.ts
+++ b/apps/web/lib/tinybird/index.ts
@@ -2,7 +2,6 @@ export * from "./client";
export * from "./get-click-event";
export * from "./get-lead-event";
export * from "./record-click";
-export * from "./record-customer";
export * from "./record-lead";
export * from "./record-link";
export * from "./record-sale";
diff --git a/packages/tinybird/pipes/v1_events.pipe b/packages/tinybird/pipes/v1_events.pipe
index 99874a5c8f..08ac85ec73 100644
--- a/packages/tinybird/pipes/v1_events.pipe
+++ b/packages/tinybird/pipes/v1_events.pipe
@@ -1,15 +1,15 @@
DESCRIPTION >
- Clicks, leads, and sales events
+ Top countries
-TOKEN "v1_events_endpoint_read_2795" READ
+TOKEN "v1_events_endpoint_read_8799" READ
NODE workspace_links
SQL >
%
SELECT link_id, domain, key
- from dub_links_metadata_latest FINAL
+ from dub_links_metadata_lambda
WHERE
workspace_id
= {{
@@ -20,7 +20,7 @@ SQL >
required=True,
)
}}
- AND deleted == 0
+ {% if defined(linkId) %} AND link_id = {{ String(linkId) }} {% end %}
{% if defined(domain) %} AND domain IN {{ Array(domain, 'String') }} {% end %}
{% if defined(tagId) %} AND has(tag_ids, {{ tagId }}) {% end %}
{% if defined(root) %}
@@ -33,14 +33,13 @@ NODE click_events
SQL >
%
- SELECT *, wl.domain, wl.key
+ SELECT *, 'click' as event
FROM dub_click_events_mv dce
- INNER JOIN workspace_links wl ON dce.link_id = wl.link_id
WHERE
timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
- {% if defined(linkId) %} AND link_id = {{ String(linkId) }}
- {% elif defined(workspaceId) %} AND link_id IN (SELECT link_id FROM workspace_links)
+ {% if defined(linkId) %} AND dce.link_id = {{ String(linkId) }}
+ {% elif defined(workspaceId) %} AND dce.link_id IN (SELECT link_id FROM workspace_links)
{% end %}
{% if defined(qr) %} AND qr = {{ Boolean(qr) }} {% end %}
{% if defined(continent) %} AND continent = {{ continent }} {% end %}
@@ -52,7 +51,7 @@ SQL >
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}
- LIMIT {{ Int32(limit, 500) }}
+ LIMIT {{ Int32(limit, 100) }}
{% if defined(offset) %} OFFSET {{ Int32(offset, 0) }} {% end %}
@@ -62,29 +61,9 @@ SQL >
%
SELECT
- dle.timestamp as timestamp,
- dle.event_id as event_id,
- dle.event_name as event_name,
- dcm.name as customer_name,
- dcm.email as customer_email,
- dcm.avatar as customer_avatar,
- dle.click_id as click_id,
- dle.link_id as link_id,
- wl.domain as domain,
- wl.key as key,
- dle.url as url,
- dle.continent as continent,
- dle.country as country,
- dle.city as city,
- dle.device as device,
- dle.browser as browser,
- dle.os as os,
- dle.referer as referer,
- dle.qr as qr,
- dle.ip as ip
- FROM dub_lead_events_mv dle
- INNER JOIN workspace_links wl ON dle.link_id = wl.link_id
- INNER JOIN dub_customers_metadata dcm ON dle.customer_id = dcm.customer_id
+ 'lead' as event,
+ *,
+ FROM dub_lead_events_mv
WHERE
timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
@@ -100,8 +79,8 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
- ORDER BY dle.timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}
- LIMIT {{ Int32(limit, 500) }}
+ ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}
+ LIMIT {{ Int32(limit, 100) }}
{% if defined(offset) %} OFFSET {{ Int32(offset, 0) }} {% end %}
@@ -111,37 +90,15 @@ SQL >
%
SELECT
- dse.timestamp as timestamp,
- dse.event_id as event_id,
- dse.event_name as event_name,
- dse.amount as amount,
- dse.payment_processor as payment_processor,
- dse.invoice_id as invoice_id,
- dcm.name as customer_name,
- dcm.email as customer_email,
- dcm.avatar as customer_avatar,
- dse.click_id as click_id,
- dse.link_id as link_id,
- wl.domain as domain,
- wl.key as key,
- dse.url as url,
- dse.continent as continent,
- dse.country as country,
- dse.city as city,
- dse.device as device,
- dse.browser as browser,
- dse.os as os,
- dse.referer as referer,
- dse.qr as qr,
- dse.ip as ip
- FROM dub_sale_events_mv dse
- INNER JOIN workspace_links wl ON dse.link_id = wl.link_id
- INNER JOIN dub_customers_metadata dcm ON dse.customer_id = dcm.customer_id
+ 'sale' as event,
+ *,
+ amount as saleAmount
+ FROM dub_sale_events_mv
WHERE
- dse.timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
- AND dse.timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
- {% if defined(linkId) %} AND dse.link_id = {{ String(linkId) }}
- {% elif defined(workspaceId) %} AND dse.link_id IN (SELECT link_id FROM workspace_links)
+ timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
+ AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
+ {% if defined(linkId) %} AND link_id = {{ String(linkId) }}
+ {% elif defined(workspaceId) %} AND link_id IN (SELECT link_id FROM workspace_links)
{% end %}
{% if defined(qr) %} AND qr = {{ Boolean(qr) }} {% end %}
{% if defined(continent) %} AND continent = {{ continent }} {% end %}
@@ -152,8 +109,8 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
- ORDER BY {% if sortBy == 'amount' %} dse.amount {% else %} dse.timestamp {% end %} {% if order == 'asc' %} ASC {% else %} DESC {% end %}
- LIMIT {{ Int32(limit, 500) }}
+ ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}
+ LIMIT {{ Int32(limit, 100) }}
{% if defined(offset) %} OFFSET {{ Int32(offset, 0) }} {% end %}