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
use pivot table for hasData column.
Francis Cao8a438e10ae8c
diff --git a/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx b/src/app/(main)/websites/[websiteId]/events/EventsTable.tsxindex 5035f0e4c..54b4fc139 100644--- a/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx+++ b/src/app/(main)/websites/[websiteId]/events/EventsTable.tsx@@ -114,7 +114,7 @@ const PropertiesButton = props => {</Icon></Row></Button>- <Popover side="right">+ <Popover side="right" sideOffset={8}><Dialog><EventData {...props} /></Dialog>diff --git a/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx b/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsxindex 7512769bc..1697b9e5c 100644--- a/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx+++ b/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx@@ -98,7 +98,7 @@ const PropertiesButton = props => {</Icon></Row></Button>- <Popover side="right">+ <Popover side="right" sideOffset={8}><Dialog><EventData {...props} /></Dialog>diff --git a/src/queries/sql/events/getWebsiteEvents.test.ts b/src/queries/sql/events/getWebsiteEvents.test.tsindex 906d64be8..d48dfb362 100644--- a/src/queries/sql/events/getWebsiteEvents.test.ts+++ b/src/queries/sql/events/getWebsiteEvents.test.ts@@ -124,10 +124,10 @@ describe('getWebsiteEvents', () => {expect(dataQuery).toContain('website_id as websiteId');expect(dataQuery).toContain('paged_event_data as (');expect(dataQuery).toContain('where website_id = {websiteId:UUID}');- expect(dataQuery).toContain('from event_data');- expect(dataQuery).toContain('inner join paged_events on paged_events.id = event_data.event_id');+ expect(dataQuery).toContain('from umami.event_data_pivot');+ expect(dataQuery).toContain('inner join paged_events on paged_events.id = event_data_pivot.event_id');expect(dataQuery).toContain(- 'and event_data.created_at between {startDate:DateTime64} and {endDate:DateTime64}',+ 'and event_data_pivot.created_at between {startDate:DateTime64} and {endDate:DateTime64}',);expect(dataQuery).toContain('from paged_events');expect(dataQuery).toContain('left join paged_event_data on paged_event_data.event_id = paged_events.id');@@ -185,7 +185,7 @@ describe('getWebsiteEvents', () => {const [dataQuery] = clickhouseRawQuery.mock.calls[1];expect(dataQuery).toContain(- 'and event_data.created_at between toTimezone({startDate:DateTime64},{timezone:String}) and toTimezone({endDate:DateTime64},{timezone:String})',+ 'and event_data_pivot.created_at between toTimezone({startDate:DateTime64},{timezone:String}) and toTimezone({endDate:DateTime64},{timezone:String})',);expect(dataQuery).not.toContain('and created_at between {startDate:DateTime64} and {endDate:DateTime64}',diff --git a/src/queries/sql/events/getWebsiteEvents.ts b/src/queries/sql/events/getWebsiteEvents.tsindex 2680d608e..bf1450e74 100644--- a/src/queries/sql/events/getWebsiteEvents.ts+++ b/src/queries/sql/events/getWebsiteEvents.ts@@ -114,7 +114,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {...filters,websiteId,});- const hasDataDateQuery = dateQuery.replaceAll('created_at', 'event_data.created_at');+ const hasDataDateQuery = dateQuery.replaceAll('created_at', 'event_data_pivot.created_at');const searchQuery = search? `and ((positionCaseInsensitive(event_name, {search:String}) > 0 and event_type = ${EVENT_TYPE.customEvent})@@ -176,8 +176,8 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {selectevent_id,toUInt8(1) as has_data- from event_data- inner join paged_events on paged_events.id = event_data.event_id+ from umami.event_data_pivot+ inner join paged_events on paged_events.id = event_data_pivot.event_idwhere website_id = {websiteId:UUID}${hasDataDateQuery}group by event_id