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
exclude performance events from non-performance metrics/lists
Francis Cao17e7a4a63aee
diff --git a/src/queries/sql/events/getWebsiteEvents.ts b/src/queries/sql/events/getWebsiteEvents.tsindex f11d3ff13..d7a8ecb63 100644--- a/src/queries/sql/events/getWebsiteEvents.ts+++ b/src/queries/sql/events/getWebsiteEvents.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -55,6 +56,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {join session on session.session_id = website_event.session_idand session.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}+ and website_event.event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}@@ -107,6 +109,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {from website_event${cohortQuery}where website_id = {websiteId:UUID}+ and event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}diff --git a/src/queries/sql/getRealtimeActivity.ts b/src/queries/sql/getRealtimeActivity.tsindex c847b6f7d..f328d6488 100644--- a/src/queries/sql/getRealtimeActivity.ts+++ b/src/queries/sql/getRealtimeActivity.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -38,6 +39,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {on session.session_id = website_event.session_idand session.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${dateQuery}order by website_event.created_at desc@@ -71,6 +73,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters): Promisfrom website_event${cohortQuery}where website_id = {websiteId:UUID}+ and event_type != ${EVENT_TYPE.performance}${filterQuery}${dateQuery}order by createdAt descdiff --git a/src/queries/sql/reports/getRevenueSessions.ts b/src/queries/sql/reports/getRevenueSessions.tsindex 3f30a79ab..f7aa70dd0 100644--- a/src/queries/sql/reports/getRevenueSessions.ts+++ b/src/queries/sql/reports/getRevenueSessions.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -64,6 +65,7 @@ async function relationalQuery(websiteId: string, currency: string, filters: Queand upper(currency) = {{currency}}) rev on rev.session_id = website_event.session_idwhere website_event.website_id = {{websiteId::uuid}}+ and website_event.event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}@@ -126,6 +128,7 @@ async function clickhouseQuery(websiteId: string, currency: string, filters: Quefrom website_event${cohortQuery}where website_id = {websiteId:UUID}+ and event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}diff --git a/src/queries/sql/sessions/getSessionActivity.ts b/src/queries/sql/sessions/getSessionActivity.tsindex 1ac7e6ff8..f8cff7f39 100644--- a/src/queries/sql/sessions/getSessionActivity.ts+++ b/src/queries/sql/sessions/getSessionActivity.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -37,6 +38,7 @@ async function relationalQuery(websiteId: string, sessionId: string, filters: Qufrom website_eventwhere website_id = {{websiteId::uuid}}and session_id = {{sessionId::uuid}}+ and event_type != ${EVENT_TYPE.performance}and created_at between {{startDate}} and {{endDate}}order by created_at desclimit 500@@ -70,6 +72,7 @@ async function clickhouseQuery(websiteId: string, sessionId: string, filters: Qufrom website_eventwhere website_id = {websiteId:UUID}and session_id = {sessionId:UUID}+ and event_type != ${EVENT_TYPE.performance}and created_at between {startDate:DateTime64} and {endDate:DateTime64}order by created_at desclimit 500diff --git a/src/queries/sql/sessions/getSessionDataActivityStats.ts b/src/queries/sql/sessions/getSessionDataActivityStats.tsindex c8bb0a277..939f437c0 100644--- a/src/queries/sql/sessions/getSessionDataActivityStats.ts+++ b/src/queries/sql/sessions/getSessionDataActivityStats.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { DATA_TYPE } from '@/lib/constants';+import { DATA_TYPE, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { PropertyFilter, PropertyLeaderboardRow, QueryFilters } from '@/lib/types';@@ -39,6 +39,7 @@ async function relationalQuery(${joinSessionQuery}where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL}),@@ -57,6 +58,7 @@ async function relationalQuery(and filtered_sessions.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}group by website_event.session_id, website_event.visit_id),session_stats as (@@ -119,6 +121,7 @@ async function clickhouseQuery(${cohortQuery}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL}),@@ -135,6 +138,7 @@ async function clickhouseQuery(join filtered_sessions on filtered_sessions.session_id = website_event.session_idwhere website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}group by website_event.session_id, website_event.visit_id),session_stats as (diff --git a/src/queries/sql/sessions/getSessionDataArraySeries.ts b/src/queries/sql/sessions/getSessionDataArraySeries.tsindex a4b81ecb1..89e876d45 100644--- a/src/queries/sql/sessions/getSessionDataArraySeries.ts+++ b/src/queries/sql/sessions/getSessionDataArraySeries.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { DATA_TYPE } from '@/lib/constants';+import { DATA_TYPE, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { EventDataSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';@@ -50,6 +50,7 @@ async function relationalQuery(cross join lateral jsonb_array_elements_text(coalesce(session_data.string_value, '[]')::jsonb) as array_item(value)where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {{propertyName}}and session_data.data_type = ${DATA_TYPE.array}${filterQuery}@@ -86,6 +87,7 @@ async function clickhouseQuery(and session_data.website_id = {websiteId:UUID}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {propertyName:String}and session_data.data_type = ${DATA_TYPE.array}${filterQuery}diff --git a/src/queries/sql/sessions/getSessionDataDateSeries.ts b/src/queries/sql/sessions/getSessionDataDateSeries.tsindex d74b5e8a8..15b762959 100644--- a/src/queries/sql/sessions/getSessionDataDateSeries.ts+++ b/src/queries/sql/sessions/getSessionDataDateSeries.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { DATA_TYPE } from '@/lib/constants';+import { DATA_TYPE, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { EventDataDateSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';@@ -48,6 +48,7 @@ async function relationalQuery(and session_data.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {{propertyName}}and session_data.data_type = ${DATA_TYPE.date}${filterQuery}@@ -83,6 +84,7 @@ async function clickhouseQuery(and session_data.website_id = {websiteId:UUID}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {propertyName:String}and session_data.data_type = ${DATA_TYPE.date}${filterQuery}diff --git a/src/queries/sql/sessions/getSessionDataNumericSeries.ts b/src/queries/sql/sessions/getSessionDataNumericSeries.tsindex 03d660f02..e74ac8f56 100644--- a/src/queries/sql/sessions/getSessionDataNumericSeries.ts+++ b/src/queries/sql/sessions/getSessionDataNumericSeries.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { PropertyFilter, QueryFilters } from '@/lib/types';@@ -51,6 +52,7 @@ async function relationalQuery(${joinSessionQuery}where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL})@@ -98,6 +100,7 @@ async function clickhouseQuery(${cohortQuery}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL})diff --git a/src/queries/sql/sessions/getSessionDataNumericStats.ts b/src/queries/sql/sessions/getSessionDataNumericStats.tsindex a7dcd7df0..7f6ee775f 100644--- a/src/queries/sql/sessions/getSessionDataNumericStats.ts+++ b/src/queries/sql/sessions/getSessionDataNumericStats.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { EventDataNumericStats, PropertyFilter, QueryFilters } from '@/lib/types';@@ -43,6 +44,7 @@ async function relationalQuery(${joinSessionQuery}where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL})@@ -84,6 +86,7 @@ async function clickhouseQuery(${cohortQuery}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL})diff --git a/src/queries/sql/sessions/getSessionDataPivot.ts b/src/queries/sql/sessions/getSessionDataPivot.tsindex c4e460b0e..9e9445853 100644--- a/src/queries/sql/sessions/getSessionDataPivot.ts+++ b/src/queries/sql/sessions/getSessionDataPivot.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { PageResult, PropertyFilter, QueryFilters, SessionDataPivotRow } from '@/lib/types';@@ -48,6 +49,7 @@ async function relationalQuery(${joinSessionQuery}where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL}),@@ -141,6 +143,7 @@ async function clickhouseQuery(${cohortQuery}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL}),diff --git a/src/queries/sql/sessions/getSessionDataProperties.ts b/src/queries/sql/sessions/getSessionDataProperties.tsindex 2cae98b2c..38708b116 100644--- a/src/queries/sql/sessions/getSessionDataProperties.ts+++ b/src/queries/sql/sessions/getSessionDataProperties.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { PropertyFilter, QueryFilters } from '@/lib/types';@@ -47,6 +48,7 @@ async function relationalQuery(${joinSessionQuery}where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL}),@@ -98,6 +100,7 @@ async function clickhouseQuery(${cohortQuery}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}${pfSQL}),diff --git a/src/queries/sql/sessions/getSessionDataPropertySeries.ts b/src/queries/sql/sessions/getSessionDataPropertySeries.tsindex fdffab423..f66620b1e 100644--- a/src/queries/sql/sessions/getSessionDataPropertySeries.ts+++ b/src/queries/sql/sessions/getSessionDataPropertySeries.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { DATA_TYPE } from '@/lib/constants';+import { DATA_TYPE, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { EventDataSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';@@ -49,6 +49,7 @@ async function relationalQuery(and session_data.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {{propertyName}}and session_data.data_type in (${DATA_TYPE.string}, ${DATA_TYPE.boolean})${filterQuery}@@ -85,6 +86,7 @@ async function clickhouseQuery(and session_data.website_id = {websiteId:UUID}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {propertyName:String}and session_data.data_type in (${DATA_TYPE.string}, ${DATA_TYPE.boolean})${filterQuery}diff --git a/src/queries/sql/sessions/getSessionDataValues.ts b/src/queries/sql/sessions/getSessionDataValues.tsindex 1c7434768..d862fa66a 100644--- a/src/queries/sql/sessions/getSessionDataValues.ts+++ b/src/queries/sql/sessions/getSessionDataValues.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { DATA_TYPE } from '@/lib/constants';+import { DATA_TYPE, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -41,6 +41,7 @@ async function relationalQuery(cross join lateral jsonb_array_elements_text(coalesce(session_data.string_value, '[]')::jsonb) as array_item(value)where website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {{propertyName}}and session_data.data_type = ${DATA_TYPE.array}${filterQuery}@@ -70,6 +71,7 @@ async function relationalQuery(and session_data.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {{propertyName}}${dataType ? `and session_data.data_type = ${dataType}` : ''}${filterQuery}@@ -103,6 +105,7 @@ async function clickhouseQuery(and session_data.website_id = {websiteId:UUID}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {propertyName:String}and session_data.data_type = ${DATA_TYPE.array}${filterQuery}@@ -129,6 +132,7 @@ async function clickhouseQuery(and session_data.website_id = {websiteId:UUID}where website_event.website_id = {websiteId:UUID}and website_event.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and website_event.event_type != ${EVENT_TYPE.performance}and session_data.data_key = {propertyName:String}${dataType ? `and session_data.data_type = ${dataType}` : ''}${filterQuery}diff --git a/src/queries/sql/sessions/getWebsiteSession.ts b/src/queries/sql/sessions/getWebsiteSession.tsindex 3c1608713..28a85f969 100644--- a/src/queries/sql/sessions/getWebsiteSession.ts+++ b/src/queries/sql/sessions/getWebsiteSession.ts@@ -1,4 +1,5 @@import clickhouse from '@/lib/clickhouse';+import { EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';@@ -54,6 +55,7 @@ async function relationalQuery(websiteId: string, sessionId: string) {join website_event on website_event.session_id = session.session_idwhere session.website_id = {{websiteId::uuid}}and session.session_id = {{sessionId::uuid}}+ and website_event.event_type != ${EVENT_TYPE.performance}group by session.session_id, session.distinct_id, visit_id, session.website_id, session.browser, session.os, session.device, session.screen, session.language, session.country, session.region, session.city) tgroup by id, distinct_id, website_id, browser, os, device, screen, language, country, region, city;`,@@ -104,6 +106,7 @@ async function clickhouseQuery(websiteId: string, sessionId: string) {from website_event_stats_hourlywhere website_id = {websiteId:UUID}and session_id = {sessionId:UUID}+ and event_type != ${EVENT_TYPE.performance}group by session_id, distinct_id, visit_id, website_id, browser, os, device, screen, language, country, region, city) tgroup by id, websiteId, distinctId, browser, os, device, screen, language, country, region, city;`,diff --git a/src/queries/sql/sessions/getWebsiteSessionStats.ts b/src/queries/sql/sessions/getWebsiteSessionStats.tsindex a4615ee40..a14fbc5f3 100644--- a/src/queries/sql/sessions/getWebsiteSessionStats.ts+++ b/src/queries/sql/sessions/getWebsiteSessionStats.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { EVENT_COLUMNS } from '@/lib/constants';+import { EVENT_COLUMNS, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -36,7 +36,7 @@ async function relationalQuery(return rawQuery(`select- count(*) as "pageviews",+ sum(case when website_event.event_type = 1 then 1 else 0 end) as "pageviews",count(distinct website_event.session_id) as "visitors",count(distinct website_event.visit_id) as "visits",count(distinct session.country) as "countries",@@ -47,6 +47,7 @@ async function relationalQuery(and website_event.website_id = session.website_idwhere website_event.website_id = {{websiteId::uuid}}and website_event.created_at between {{startDate}} and {{endDate}}+ and website_event.event_type != ${EVENT_TYPE.performance}${filterQuery}`,queryParams,@@ -75,6 +76,7 @@ async function clickhouseQuery(${cohortQuery}where website_id = {websiteId:UUID}and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type != ${EVENT_TYPE.performance}${filterQuery}`;} else {@@ -89,6 +91,7 @@ async function clickhouseQuery(${cohortQuery}where website_id = {websiteId:UUID}and created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and event_type != ${EVENT_TYPE.performance}${filterQuery}`;}diff --git a/src/queries/sql/sessions/getWebsiteSessions.ts b/src/queries/sql/sessions/getWebsiteSessions.tsindex 8efea80df..ffa3271b6 100644--- a/src/queries/sql/sessions/getWebsiteSessions.ts+++ b/src/queries/sql/sessions/getWebsiteSessions.ts@@ -1,5 +1,5 @@import clickhouse from '@/lib/clickhouse';-import { EVENT_COLUMNS } from '@/lib/constants';+import { EVENT_COLUMNS, EVENT_TYPE } from '@/lib/constants';import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';import prisma from '@/lib/prisma';import type { QueryFilters } from '@/lib/types';@@ -55,6 +55,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {join session on session.session_id = website_event.session_idand session.website_id = website_event.website_idwhere website_event.website_id = {{websiteId::uuid}}+ and website_event.event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}@@ -118,6 +119,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {from website_event${cohortQuery}where website_id = {websiteId:UUID}+ and event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}@@ -147,6 +149,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {from website_event_stats_hourly as website_event${cohortQuery}where website_id = {websiteId:UUID}+ and event_type != ${EVENT_TYPE.performance}${dateQuery}${filterQuery}${searchQuery}