Skip to content

Commit

Permalink
Use current_domain from each line (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfernandez authored Feb 6, 2025
1 parent 7d6a06b commit 4b633f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tinybird/pipes/analytics_hits.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SQL >
JSONExtractString(payload, 'referrer') as referrer,
JSONExtractString(payload, 'pathname') as pathname,
JSONExtractString(payload, 'href') as href,
domainWithoutWWW(href) as current_domain,
lower(JSONExtractString(payload, 'user-agent')) as user_agent
FROM analytics_events
where action = 'page_hit'
Expand All @@ -33,6 +34,7 @@ SQL >
referrer,
pathname,
href,
current_domain,
case
when match(user_agent, 'wget|ahrefsbot|curl|urllib|bitdiscovery|\+https://|googlebot')
then 'bot'
Expand Down
3 changes: 1 addition & 2 deletions tinybird/pipes/analytics_sources.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ DESCRIPTION >
Aggregate by referral and calculate session and hits

SQL >
WITH (SELECT domainWithoutWWW(href) FROM analytics_hits LIMIT 1) AS currenct_domain
SELECT
toDate(timestamp) AS date,
device,
Expand All @@ -13,7 +12,7 @@ SQL >
uniqState(session_id) AS visits,
countState() AS hits
FROM analytics_hits
WHERE domainWithoutWWW(referrer) != currenct_domain
WHERE domainWithoutWWW(referrer) != current_domain
GROUP BY date, device, browser, location, referrer

TYPE MATERIALIZED
Expand Down

0 comments on commit 4b633f3

Please sign in to comment.