exclude performance events from non-performance metrics/lists
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
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_id
|
join session on session.session_id = website_event.session_id
|
||||||
and session.website_id = website_event.website_id
|
and session.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
@@ -107,6 +109,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
import type { QueryFilters } from '@/lib/types';
|
||||||
@@ -38,6 +39,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
on session.session_id = website_event.session_id
|
on session.session_id = website_event.session_id
|
||||||
and session.website_id = website_event.website_id
|
and session.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
order by website_event.created_at desc
|
order by website_event.created_at desc
|
||||||
@@ -71,6 +73,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters): Promis
|
|||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
order by createdAt desc
|
order by createdAt desc
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
import type { QueryFilters } from '@/lib/types';
|
||||||
@@ -64,6 +65,7 @@ async function relationalQuery(websiteId: string, currency: string, filters: Que
|
|||||||
and upper(currency) = {{currency}}
|
and upper(currency) = {{currency}}
|
||||||
) rev on rev.session_id = website_event.session_id
|
) rev on rev.session_id = website_event.session_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
@@ -126,6 +128,7 @@ async function clickhouseQuery(websiteId: string, currency: string, filters: Que
|
|||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
import type { QueryFilters } from '@/lib/types';
|
||||||
@@ -37,6 +38,7 @@ async function relationalQuery(websiteId: string, sessionId: string, filters: Qu
|
|||||||
from website_event
|
from website_event
|
||||||
where website_id = {{websiteId::uuid}}
|
where website_id = {{websiteId::uuid}}
|
||||||
and session_id = {{sessionId::uuid}}
|
and session_id = {{sessionId::uuid}}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
and created_at between {{startDate}} and {{endDate}}
|
and created_at between {{startDate}} and {{endDate}}
|
||||||
order by created_at desc
|
order by created_at desc
|
||||||
limit 500
|
limit 500
|
||||||
@@ -70,6 +72,7 @@ async function clickhouseQuery(websiteId: string, sessionId: string, filters: Qu
|
|||||||
from website_event
|
from website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and session_id = {sessionId:UUID}
|
and session_id = {sessionId:UUID}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
order by created_at desc
|
order by created_at desc
|
||||||
limit 500
|
limit 500
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { PropertyFilter, PropertyLeaderboardRow, QueryFilters } from '@/lib/types';
|
import type { PropertyFilter, PropertyLeaderboardRow, QueryFilters } from '@/lib/types';
|
||||||
@@ -39,6 +39,7 @@ async function relationalQuery(
|
|||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
),
|
),
|
||||||
@@ -57,6 +58,7 @@ async function relationalQuery(
|
|||||||
and filtered_sessions.website_id = website_event.website_id
|
and filtered_sessions.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
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
|
group by website_event.session_id, website_event.visit_id
|
||||||
),
|
),
|
||||||
session_stats as (
|
session_stats as (
|
||||||
@@ -119,6 +121,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_event.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.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
),
|
),
|
||||||
@@ -135,6 +138,7 @@ async function clickhouseQuery(
|
|||||||
join filtered_sessions on filtered_sessions.session_id = website_event.session_id
|
join filtered_sessions on filtered_sessions.session_id = website_event.session_id
|
||||||
where website_event.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.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
|
group by website_event.session_id, website_event.visit_id
|
||||||
),
|
),
|
||||||
session_stats as (
|
session_stats as (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { EventDataSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';
|
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)
|
cross join lateral jsonb_array_elements_text(coalesce(session_data.string_value, '[]')::jsonb) as array_item(value)
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
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_key = {{propertyName}}
|
||||||
and session_data.data_type = ${DATA_TYPE.array}
|
and session_data.data_type = ${DATA_TYPE.array}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
@@ -86,6 +87,7 @@ async function clickhouseQuery(
|
|||||||
and session_data.website_id = {websiteId:UUID}
|
and session_data.website_id = {websiteId:UUID}
|
||||||
where website_event.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.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_key = {propertyName:String}
|
||||||
and session_data.data_type = ${DATA_TYPE.array}
|
and session_data.data_type = ${DATA_TYPE.array}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { EventDataDateSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';
|
import type { EventDataDateSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';
|
||||||
@@ -48,6 +48,7 @@ async function relationalQuery(
|
|||||||
and session_data.website_id = website_event.website_id
|
and session_data.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
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_key = {{propertyName}}
|
||||||
and session_data.data_type = ${DATA_TYPE.date}
|
and session_data.data_type = ${DATA_TYPE.date}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
@@ -83,6 +84,7 @@ async function clickhouseQuery(
|
|||||||
and session_data.website_id = {websiteId:UUID}
|
and session_data.website_id = {websiteId:UUID}
|
||||||
where website_event.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.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_key = {propertyName:String}
|
||||||
and session_data.data_type = ${DATA_TYPE.date}
|
and session_data.data_type = ${DATA_TYPE.date}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { PropertyFilter, QueryFilters } from '@/lib/types';
|
import type { PropertyFilter, QueryFilters } from '@/lib/types';
|
||||||
@@ -51,6 +52,7 @@ async function relationalQuery(
|
|||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
)
|
)
|
||||||
@@ -98,6 +100,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_event.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.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { EventDataNumericStats, PropertyFilter, QueryFilters } from '@/lib/types';
|
import type { EventDataNumericStats, PropertyFilter, QueryFilters } from '@/lib/types';
|
||||||
@@ -43,6 +44,7 @@ async function relationalQuery(
|
|||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
)
|
)
|
||||||
@@ -84,6 +86,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_event.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.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { PageResult, PropertyFilter, QueryFilters, SessionDataPivotRow } from '@/lib/types';
|
import type { PageResult, PropertyFilter, QueryFilters, SessionDataPivotRow } from '@/lib/types';
|
||||||
@@ -48,6 +49,7 @@ async function relationalQuery(
|
|||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
),
|
),
|
||||||
@@ -141,6 +143,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_event.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.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { PropertyFilter, QueryFilters } from '@/lib/types';
|
import type { PropertyFilter, QueryFilters } from '@/lib/types';
|
||||||
@@ -47,6 +48,7 @@ async function relationalQuery(
|
|||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
),
|
),
|
||||||
@@ -98,6 +100,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_event.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.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${pfSQL}
|
${pfSQL}
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { EventDataSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';
|
import type { EventDataSeriesPoint, PropertyFilter, QueryFilters } from '@/lib/types';
|
||||||
@@ -49,6 +49,7 @@ async function relationalQuery(
|
|||||||
and session_data.website_id = website_event.website_id
|
and session_data.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
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_key = {{propertyName}}
|
||||||
and session_data.data_type in (${DATA_TYPE.string}, ${DATA_TYPE.boolean})
|
and session_data.data_type in (${DATA_TYPE.string}, ${DATA_TYPE.boolean})
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
@@ -85,6 +86,7 @@ async function clickhouseQuery(
|
|||||||
and session_data.website_id = {websiteId:UUID}
|
and session_data.website_id = {websiteId:UUID}
|
||||||
where website_event.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.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_key = {propertyName:String}
|
||||||
and session_data.data_type in (${DATA_TYPE.string}, ${DATA_TYPE.boolean})
|
and session_data.data_type in (${DATA_TYPE.string}, ${DATA_TYPE.boolean})
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
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)
|
cross join lateral jsonb_array_elements_text(coalesce(session_data.string_value, '[]')::jsonb) as array_item(value)
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
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_key = {{propertyName}}
|
||||||
and session_data.data_type = ${DATA_TYPE.array}
|
and session_data.data_type = ${DATA_TYPE.array}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
@@ -70,6 +71,7 @@ async function relationalQuery(
|
|||||||
and session_data.website_id = website_event.website_id
|
and session_data.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
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_key = {{propertyName}}
|
||||||
${dataType ? `and session_data.data_type = ${dataType}` : ''}
|
${dataType ? `and session_data.data_type = ${dataType}` : ''}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
@@ -103,6 +105,7 @@ async function clickhouseQuery(
|
|||||||
and session_data.website_id = {websiteId:UUID}
|
and session_data.website_id = {websiteId:UUID}
|
||||||
where website_event.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.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_key = {propertyName:String}
|
||||||
and session_data.data_type = ${DATA_TYPE.array}
|
and session_data.data_type = ${DATA_TYPE.array}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
@@ -129,6 +132,7 @@ async function clickhouseQuery(
|
|||||||
and session_data.website_id = {websiteId:UUID}
|
and session_data.website_id = {websiteId:UUID}
|
||||||
where website_event.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.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_key = {propertyName:String}
|
||||||
${dataType ? `and session_data.data_type = ${dataType}` : ''}
|
${dataType ? `and session_data.data_type = ${dataType}` : ''}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
import clickhouse from '@/lib/clickhouse';
|
||||||
|
import { EVENT_TYPE } from '@/lib/constants';
|
||||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
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_id
|
join website_event on website_event.session_id = session.session_id
|
||||||
where session.website_id = {{websiteId::uuid}}
|
where session.website_id = {{websiteId::uuid}}
|
||||||
and session.session_id = {{sessionId::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) t
|
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) t
|
||||||
group by id, distinct_id, website_id, browser, os, device, screen, language, country, region, city;
|
group 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_hourly
|
from website_event_stats_hourly
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and session_id = {sessionId: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) t
|
group by session_id, distinct_id, visit_id, website_id, browser, os, device, screen, language, country, region, city) t
|
||||||
group by id, websiteId, distinctId, browser, os, device, screen, language, country, region, city;
|
group by id, websiteId, distinctId, browser, os, device, screen, language, country, region, city;
|
||||||
`,
|
`,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
import type { QueryFilters } from '@/lib/types';
|
||||||
@@ -36,7 +36,7 @@ async function relationalQuery(
|
|||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
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.session_id) as "visitors",
|
||||||
count(distinct website_event.visit_id) as "visits",
|
count(distinct website_event.visit_id) as "visits",
|
||||||
count(distinct session.country) as "countries",
|
count(distinct session.country) as "countries",
|
||||||
@@ -47,6 +47,7 @@ async function relationalQuery(
|
|||||||
and website_event.website_id = session.website_id
|
and website_event.website_id = session.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
`,
|
`,
|
||||||
queryParams,
|
queryParams,
|
||||||
@@ -75,6 +76,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
@@ -89,6 +91,7 @@ async function clickhouseQuery(
|
|||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import clickhouse from '@/lib/clickhouse';
|
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 { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
import type { QueryFilters } from '@/lib/types';
|
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_id
|
join session on session.session_id = website_event.session_id
|
||||||
and session.website_id = website_event.website_id
|
and session.website_id = website_event.website_id
|
||||||
where website_event.website_id = {{websiteId::uuid}}
|
where website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
@@ -118,6 +119,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
@@ -147,6 +149,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
|||||||
from website_event_stats_hourly as website_event
|
from website_event_stats_hourly as website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
|
and event_type != ${EVENT_TYPE.performance}
|
||||||
${dateQuery}
|
${dateQuery}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
${searchQuery}
|
${searchQuery}
|
||||||
|
|||||||
Reference in New Issue
Block a user