The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update v2_events.pipe
Steven Teya8c747ff755a
diff --git a/packages/tinybird/pipes/v2_events.pipe b/packages/tinybird/pipes/v2_events.pipeindex 00f9808f94..f5cbd568e5 100644--- a/packages/tinybird/pipes/v2_events.pipe+++ b/packages/tinybird/pipes/v2_events.pipe@@ -2,8 +2,6 @@ DESCRIPTION >Top countries-TOKEN "v2_events_endpoint_read_6623" READ-TAGS "Dub Endpoints"NODE workspace_links@@ -11,16 +9,23 @@ SQL >%SELECT link_id, domain, key- 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 %} FINALWHEREdeleted == 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 %}@@ -54,21 +59,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 %}ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}LIMIT {{ Int32(limit, 100) }}@@ -85,10 +80,10 @@ SQL >splitByString('?', referer_url)[1] as referer_url_processed,CONCAT(country, '-', region) as region_processed,'lead' as event- FROM dub_lead_events_mv+ FROM dub_lead_events_mv_newWHERE- timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}- AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}+ timestamp >= {{ DateTime(start, '2024-01-01 00:00:00') }}+ AND timestamp < {{ DateTime(end, '2025-12-31 00:00:00') }}{% if defined(linkId) %} AND link_id = {{ String(linkId) }}{% elif defined(workspaceId) or defined(partnerId) or defined(programId) %}AND link_id IN (SELECT link_id FROM workspace_links)@@ -104,11 +99,22 @@ 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 %}ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}LIMIT {{ Int32(limit, 100) }}@@ -126,7 +132,7 @@ SQL >CONCAT(country, '-', region) as region_processed,splitByString('?', referer_url)[1] as referer_url_processed,'sale' as event- FROM dub_sale_events_mv+ FROM dub_sale_events_mv_newWHEREtimestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}@@ -145,11 +151,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 %}ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}LIMIT {{ Int32(limit, 100) }}