Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
improve revenue joins and event_data joins to website_event
Francis Caocd6a28ea4a7f
diff --git a/src/queries/sql/events/getEventDataEvents.ts b/src/queries/sql/events/getEventDataEvents.tsindex 6c8f12c19..8ed6633ea 100644--- a/src/queries/sql/events/getEventDataEvents.ts+++ b/src/queries/sql/events/getEventDataEvents.ts@@ -93,11 +93,15 @@ async function clickhouseQuery(string_value as propertyValue,count(*) as totalfrom event_data- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.event_id = event_data.event_id+ and website_event.session_id = event_data.session_idand website_event.website_id = event_data.website_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where event_data.website_id = {websiteId:UUID}and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}@@ -120,11 +124,15 @@ async function clickhouseQuery(data_type as dataType,count(*) as totalfrom event_data- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.event_id = event_data.event_id+ and website_event.session_id = event_data.session_idand website_event.website_id = event_data.website_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where event_data.website_id = {websiteId:UUID}and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}diff --git a/src/queries/sql/events/getEventDataFields.ts b/src/queries/sql/events/getEventDataFields.tsindex 933776909..709454929 100644--- a/src/queries/sql/events/getEventDataFields.ts+++ b/src/queries/sql/events/getEventDataFields.ts@@ -65,11 +65,15 @@ async function clickhouseQuery(string_value) as "value",count(*) as "total"from event_data- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.event_id = event_data.event_id+ and website_event.session_id = event_data.session_idand website_event.website_id = event_data.website_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where event_data.website_id = {websiteId:UUID}and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}diff --git a/src/queries/sql/events/getEventDataProperties.ts b/src/queries/sql/events/getEventDataProperties.tsindex 82c078f8d..82d0b6b62 100644--- a/src/queries/sql/events/getEventDataProperties.ts+++ b/src/queries/sql/events/getEventDataProperties.ts@@ -69,11 +69,15 @@ async function clickhouseQuery(data_key as propertyName,count(*) as totalfrom event_data- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.event_id = event_data.event_id+ and website_event.session_id = event_data.session_idand website_event.website_id = event_data.website_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where event_data.website_id = {websiteId:UUID}and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}diff --git a/src/queries/sql/events/getEventDataStats.ts b/src/queries/sql/events/getEventDataStats.tsindex 89e135828..9d178f676 100644--- a/src/queries/sql/events/getEventDataStats.ts+++ b/src/queries/sql/events/getEventDataStats.ts@@ -72,11 +72,15 @@ async function clickhouseQuery(data_key,count(*) as "total"from event_data- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.event_id = event_data.event_id+ and website_event.session_id = event_data.session_idand website_event.website_id = event_data.website_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where event_data.website_id = {websiteId:UUID}and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}diff --git a/src/queries/sql/events/getEventDataValues.ts b/src/queries/sql/events/getEventDataValues.tsindex 0426e646e..7c1ae282e 100644--- a/src/queries/sql/events/getEventDataValues.ts+++ b/src/queries/sql/events/getEventDataValues.ts@@ -72,11 +72,15 @@ async function clickhouseQuery(string_value) as "value",count(*) as "total"from event_data- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.event_id = event_data.event_id+ and website_event.session_id = event_data.session_idand website_event.website_id = event_data.website_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where event_data.website_id = {websiteId:UUID}and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}diff --git a/src/queries/sql/reports/getRevenue.ts b/src/queries/sql/reports/getRevenue.tsindex 2a4604fec..d3bff6c9a 100644--- a/src/queries/sql/reports/getRevenue.ts+++ b/src/queries/sql/reports/getRevenue.ts@@ -43,12 +43,14 @@ async function relationalQuery(const joinQuery =filterQuery || cohortQuery- ? `join website_event- on website_event.website_id = revenue.website_id- and website_event.session_id = revenue.session_id- and website_event.event_id = revenue.event_id- and website_event.website_id = {{websiteId::uuid}}- and website_event.created_at between {{startDate}} and {{endDate}}`+ ? `join (select *+ from website_event+ where website_id = {{websiteId::uuid}}+ and created_at between {{startDate}} and {{endDate}}+ and event_type = 2) website_event+ on website_event.website_id = revenue.website_id+ and website_event.session_id = revenue.session_id+ and website_event.event_id = revenue.event_id`: '';const chart = await rawQuery(@@ -130,12 +132,15 @@ async function clickhouseQuery(});const joinQuery = filterQuery- ? `join website_event- on website_event.website_id = website_revenue.website_id- and website_event.session_id = website_revenue.session_id- and website_event.event_id = website_revenue.event_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}`+ ? `any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_event+ on website_event.website_id = website_revenue.website_id+ and website_event.session_id = website_revenue.session_id+ and website_event.event_id = website_revenue.event_id`: '';const chart = await rawQuery<@@ -174,12 +179,15 @@ async function clickhouseQuery(website_event.country as name,sum(website_revenue.revenue) as valuefrom website_revenue- join website_event+ any left join (+ select *+ from website_event+ where website_id = {websiteId:UUID}+ and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type = 2) website_eventon website_event.website_id = website_revenue.website_idand website_event.session_id = website_revenue.session_idand website_event.event_id = website_revenue.event_id- and website_event.website_id = {websiteId:UUID}- and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}${cohortQuery}where website_revenue.website_id = {websiteId:UUID}and website_revenue.created_at between {startDate:DateTime64} and {endDate:DateTime64}