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 count

Tim Wilsonb932cd3832fb
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/customers/[customerId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/customers/[customerId]/page-client.tsx
index a2b298e5cf..8b9c2a6c62 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/customers/[customerId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/customers/[customerId]/page-client.tsx
@@ -115,7 +115,7 @@ export function CustomerPageClient() {
<h2 className="text-lg font-semibold text-neutral-900">Activity</h2>
<CustomerActivityList
activity={customerActivity}
- isLoading={isCustomerActivityLoading}
+ isLoading={!customer || isCustomerActivityLoading}
/>
</section>
</div>
@@ -138,7 +138,7 @@ export function CustomerPageClient() {
</span>
)
) : (
- <div className="h-5 w-24 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-5 w-24 animate-pulse rounded-md bg-neutral-100" />
)}
{click
? [
diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.ts
index f079766d06..c60a97c573 100644
--- a/apps/web/lib/analytics/get-analytics.ts
+++ b/apps/web/lib/analytics/get-analytics.ts
@@ -36,6 +36,8 @@ export const getAnalytics = async (params: AnalyticsFilters) => {
const tagIds = combineTagIds(params);
+ console.log("!!! GETTING ANALYTICS", { linkId, groupBy, interval });
+
// get all-time clicks count if:
// 1. linkId is defined
// 2. type is count
diff --git a/apps/web/ui/customers/customer-activity-list.tsx b/apps/web/ui/customers/customer-activity-list.tsx
index e2de849d63..a24d8a412a 100644
--- a/apps/web/ui/customers/customer-activity-list.tsx
+++ b/apps/web/ui/customers/customer-activity-list.tsx
@@ -50,7 +50,7 @@ export function CustomerActivityList({
}) {
return isLoading ? (
<div className="flex h-32 w-full animate-pulse rounded-lg border border-transparent bg-neutral-100" />
- ) : !activity?.events.length ? (
+ ) : !activity?.events?.length ? (
<div className="text-sm text-neutral-500">
{activity?.events ? "No activity" : "Failed to load activity"}
</div>
diff --git a/packages/tinybird/datasources/dub_regular_links_metadata_latest.datasource b/packages/tinybird/datasources/dub_regular_links_metadata_latest.datasource
new file mode 100644
index 0000000000..7a2e1afa7c
--- /dev/null
+++ b/packages/tinybird/datasources/dub_regular_links_metadata_latest.datasource
@@ -0,0 +1,20 @@
+# Data Source created from Pipe 'dub_regular_links_metadata_pipe'
+
+SCHEMA >
+ `timestamp` DateTime,
+ `link_id` String,
+ `domain` String,
+ `key` String,
+ `url` String,
+ `tag_ids` Array(String),
+ `workspace_id` String,
+ `created_at` DateTime64(3),
+ `deleted` UInt8,
+ `program_id` String,
+ `tenant_id` String,
+ `partner_id` String,
+ `folder_id` String
+
+ENGINE "ReplacingMergeTree"
+ENGINE_PARTITION_KEY "toYYYYMM(timestamp)"
+ENGINE_SORTING_KEY "link_id"
diff --git a/packages/tinybird/pipes/dub_regular_links_metadata_pipe.pipe b/packages/tinybird/pipes/dub_regular_links_metadata_pipe.pipe
new file mode 100644
index 0000000000..06d69fadf7
--- /dev/null
+++ b/packages/tinybird/pipes/dub_regular_links_metadata_pipe.pipe
@@ -0,0 +1,11 @@
+TAGS "Dub MV Pipes"
+
+NODE mv
+SQL >
+
+ SELECT * FROM dub_links_metadata WHERE domain not in ['buff.ly', 'sms.cal.com']
+
+TYPE materialized
+DATASOURCE dub_regular_links_metadata_latest
+
+
diff --git a/packages/tinybird/pipes/v2_count.pipe b/packages/tinybird/pipes/v2_count.pipe
index 87d1223ff9..7df39f6c8a 100644
--- a/packages/tinybird/pipes/v2_count.pipe
+++ b/packages/tinybird/pipes/v2_count.pipe
@@ -2,8 +2,6 @@ DESCRIPTION >
Top countries
-TOKEN "v2_count_endpoint_read_0115" READ
-
TAGS "Dub Endpoints"
NODE workspace_links
@@ -11,16 +9,23 @@ SQL >
%
SELECT link_id
- from dub_links_metadata_latest FINAL
+ FROM
+ {% if defined(isMegaFolder) and Boolean(isMegaFolder) == 1 %} dub_links_metadata_latest
+ {% else %} dub_regular_links_metadata_latest
+ {% end %} FINAL
WHERE
deleted == 0
{% if defined(workspaceId) %} AND workspace_id = {{ workspaceId }} {% end %}
{% if defined(programId) %} AND program_id = {{ programId }} {% end %}
{% if defined(partnerId) %} AND partner_id = {{ partnerId }} {% end %}
{% if defined(tenantId) %} AND tenant_id = {{ tenantId }} {% end %}
- {% if defined(folderId) %} AND folder_id = {{ folderId }} {% end %}
+ {% if defined(folderIds) %} AND folder_id IN {{ Array(folderIds, 'String') }}
+ {% elif defined(folderId) %} AND folder_id = {{ folderId }}
+ {% end %}
{% if defined(domain) %} AND domain IN {{ Array(domain, 'String') }} {% end %}
- {% if defined(tagIds) %} AND arrayIntersect(tag_ids, {{ Array(tagIds, 'String') }}) != [] {% end %}
+ {% if defined(tagIds) %}
+ AND arrayIntersect(tag_ids, {{ Array(tagIds, 'String') }}) != []
+ {% end %}
{% if defined(root) %}
{% if Boolean(root) == 1 %} AND key = '_root' {% else %} AND key != '_root' {% end %}
{% end %}
@@ -40,6 +45,7 @@ SQL >
WHERE
true
{% if defined(linkId) %} AND link_id = {{ String(linkId) }} {% end %}
+ {% if defined(customerId) %} AND customer_id = {{ String(customerId) }} {% end %}
{% if defined(qr) %} AND qr = {{ Boolean(qr) }} {% end %}
{% if defined(continent) %} AND continent = {{ continent }} {% end %}
{% if defined(country) %} AND country = {{ country }} {% end %}
@@ -50,11 +56,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
- {% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
- {% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
- {% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
- {% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
- {% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
+ {% if defined(utm_source) %} AND url LIKE concat('%utm_source=', encodeURLFormComponent({{ String(utm_source) }}), '%') {% end %}
+ {% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', encodeURLFormComponent({{ String(utm_medium) }}), '%') {% end %}
+ {% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', encodeURLFormComponent({{ String(utm_campaign) }}), '%') {% end %}
+ {% if defined(utm_term) %} AND url LIKE concat('%utm_term=', encodeURLFormComponent({{ String(utm_term) }}), '%') {% end %}
+ {% if defined(utm_content) %} AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
@@ -74,6 +80,7 @@ SQL >
WHERE
true
{% if defined(linkId) %} AND link_id = {{ String(linkId) }} {% end %}
+ {% if defined(customerId) %} AND customer_id = {{ String(customerId) }} {% end %}
{% if defined(qr) %} AND qr = {{ Boolean(qr) }} {% end %}
{% if defined(continent) %} AND continent = {{ continent }} {% end %}
{% if defined(country) %} AND country = {{ country }} {% end %}
@@ -84,11 +91,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
- {% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
- {% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
- {% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
- {% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
- {% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
+ {% if defined(utm_source) %} AND url LIKE concat('%utm_source=', encodeURLFormComponent({{ String(utm_source) }}), '%') {% end %}
+ {% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', encodeURLFormComponent({{ String(utm_medium) }}), '%') {% end %}
+ {% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', encodeURLFormComponent({{ String(utm_campaign) }}), '%') {% end %}
+ {% if defined(utm_term) %} AND url LIKE concat('%utm_term=', encodeURLFormComponent({{ String(utm_term) }}), '%') {% end %}
+ {% if defined(utm_content) %} AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
@@ -113,6 +120,7 @@ SQL >
WHERE
true
{% if defined(linkId) %} AND link_id = {{ String(linkId) }} {% end %}
+ {% if defined(customerId) %} AND customer_id = {{ String(customerId) }} {% end %}
{% if defined(qr) %} AND qr = {{ Boolean(qr) }} {% end %}
{% if defined(continent) %} AND continent = {{ continent }} {% end %}
{% if defined(country) %} AND country = {{ country }} {% end %}
@@ -123,11 +131,11 @@ SQL >
{% if defined(os) %} AND os = {{ os }} {% end %}
{% if defined(referer) %} AND referer = {{ referer }} {% end %}
{% if defined(refererUrl) %} AND splitByString('?', referer_url)[1] = {{ refererUrl }} {% end %}
- {% if defined(utm_source) %} AND url LIKE concat('%utm_source=', {{ String(utm_source) }}, '%') {% end %}
- {% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', {{ String(utm_medium) }}, '%') {% end %}
- {% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', {{ String(utm_campaign) }}, '%') {% end %}
- {% if defined(utm_term) %} AND url LIKE concat('%utm_term=', {{ String(utm_term) }}, '%') {% end %}
- {% if defined(utm_content) %} AND url LIKE concat('%utm_content=', {{ String(utm_content) }}, '%') {% end %}
+ {% if defined(utm_source) %} AND url LIKE concat('%utm_source=', encodeURLFormComponent({{ String(utm_source) }}), '%') {% end %}
+ {% if defined(utm_medium) %} AND url LIKE concat('%utm_medium=', encodeURLFormComponent({{ String(utm_medium) }}), '%') {% end %}
+ {% if defined(utm_campaign) %} AND url LIKE concat('%utm_campaign=', encodeURLFormComponent({{ String(utm_campaign) }}), '%') {% end %}
+ {% if defined(utm_term) %} AND url LIKE concat('%utm_term=', encodeURLFormComponent({{ String(utm_term) }}), '%') {% end %}
+ {% if defined(utm_content) %} AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%') {% end %}
{% if defined(url) %} AND url = {{ url }} {% end %}
{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}
{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}
@@ -154,3 +162,4 @@ SQL >
{% else %} count_composite
{% end %}
+