Merge branch 'dev' of https://github.com/umami-software/umami into dev
This commit is contained in:
commit
3ad1e3ee9a
11 files changed
+151
-46
No files matched your search
@@ -7,6 +7,7 @@ services:
|
||||
environment:
|
||||
DATABASE_URL: postgresql://umami:umami@db:5432/umami
|
||||
APP_SECRET: replace-me-with-a-random-string
|
||||
# BOUNCE_THRESHOLD: 2 # OPTIONAL: set the minimum amount custom events to trigger a bounce
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export const CURRENT_VERSION = process.env.currentVersion;
|
||||
export const BOUNCE_THRESHOLD = Math.max(1, Number.parseInt(process.env.BOUNCE_THRESHOLD, 10) || 1);
|
||||
export const AUTH_TOKEN = 'umami.auth';
|
||||
export const LOCALE_CONFIG = 'umami.locale';
|
||||
export const TIMEZONE_CONFIG = 'umami.timezone';
|
||||
|
||||
@@ -22,8 +22,8 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||
});
|
||||
|
||||
const searchQuery = search
|
||||
? `and ((event_name ilike {{search}} and event_type = 2)
|
||||
or (url_path ilike {{search}} and event_type = 1))`
|
||||
? `and ((event_name ilike {{search}} and event_type = ${EVENT_TYPE.customEvent})
|
||||
or (url_path ilike {{search}} and event_type = ${EVENT_TYPE.pageView}))`
|
||||
: '';
|
||||
|
||||
return pagedRawQuery(
|
||||
@@ -77,8 +77,8 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||
});
|
||||
|
||||
const searchQuery = search
|
||||
? `and ((positionCaseInsensitive(event_name, {search:String}) > 0 and event_type = 2)
|
||||
or (positionCaseInsensitive(url_path, {search:String}) > 0 and event_type = 1))`
|
||||
? `and ((positionCaseInsensitive(event_name, {search:String}) > 0 and event_type = ${EVENT_TYPE.customEvent})
|
||||
or (positionCaseInsensitive(url_path, {search:String}) > 0 and event_type = ${EVENT_TYPE.pageView}))`
|
||||
: '';
|
||||
|
||||
return pagedRawQuery(
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import clickhouse from '@/lib/clickhouse';
|
||||
import {
|
||||
BOUNCE_THRESHOLD,
|
||||
EMAIL_DOMAINS,
|
||||
EVENT_TYPE,
|
||||
LLM_DOMAINS,
|
||||
PAID_AD_PARAMS,
|
||||
SEARCH_DOMAINS,
|
||||
@@ -120,20 +122,34 @@ async function relationalQuery(
|
||||
min(created_at) as min_time,
|
||||
max(created_at) as max_time
|
||||
from prefix
|
||||
group by session_id, visit_id),
|
||||
|
||||
visit_events as (
|
||||
select
|
||||
session_id,
|
||||
visit_id,
|
||||
count(*) as events_count
|
||||
from website_event
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
group by session_id, visit_id)
|
||||
|
||||
|
||||
select
|
||||
visit_channels.name,
|
||||
sum(visit_stats.c) as "pageviews",
|
||||
count(distinct visit_stats.session_id) as "visitors",
|
||||
count(distinct visit_stats.visit_id) as "visits",
|
||||
sum(case when visit_stats.c = 1 then 1 else 0 end) as "bounces",
|
||||
sum(case when visit_stats.c = 1 and coalesce(visit_events.events_count, 0) < ${BOUNCE_THRESHOLD} then 1 else 0 end) as "bounces",
|
||||
sum(${getTimestampDiffSQL('visit_stats.min_time', 'visit_stats.max_time')}) as "totaltime"
|
||||
from visit_stats
|
||||
join visit_channels
|
||||
on visit_channels.session_id = visit_stats.session_id
|
||||
and visit_channels.visit_id = visit_stats.visit_id
|
||||
group by visit_channels.name
|
||||
left join visit_events
|
||||
on visit_events.session_id = visit_stats.session_id
|
||||
and visit_events.visit_id = visit_stats.visit_id
|
||||
group by visit_channels.name
|
||||
order by visitors desc, visits desc
|
||||
`,
|
||||
queryParams,
|
||||
@@ -158,7 +174,7 @@ async function clickhouseQuery(
|
||||
sum(t.c) as "pageviews",
|
||||
uniq(t.session_id) as "visitors",
|
||||
uniq(t.visit_id) as "visits",
|
||||
sum(if(t.c = 1, 1, 0)) as "bounces",
|
||||
sumIf(1, t.c = 1 and ifNull(e.events_count, 0) < ${BOUNCE_THRESHOLD}) as "bounces",
|
||||
sum(max_time-min_time) as "totaltime"
|
||||
from (
|
||||
select
|
||||
@@ -213,7 +229,15 @@ async function clickhouseQuery(
|
||||
)
|
||||
group by session_id, visit_id
|
||||
) as t
|
||||
group by name
|
||||
left join (
|
||||
select session_id, visit_id, toUInt32(count()) as events_count
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
group by session_id, visit_id
|
||||
) as e using (session_id, visit_id)
|
||||
group by name
|
||||
order by visitors desc, visits desc;
|
||||
`,
|
||||
queryParams,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import clickhouse from '@/lib/clickhouse';
|
||||
import { EVENT_COLUMNS } from '@/lib/constants';
|
||||
import { BOUNCE_THRESHOLD, 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';
|
||||
@@ -35,7 +35,9 @@ async function relationalQuery(
|
||||
});
|
||||
|
||||
const { excludeBounce } = filters;
|
||||
const bounceQuery = excludeBounce ? '0' : 'coalesce(sum(case when t.c = 1 then 1 else 0 end), 0)';
|
||||
const bounceQuery = excludeBounce
|
||||
? '0'
|
||||
: `coalesce(sum(case when t.c = 1 and t.events_count < ${BOUNCE_THRESHOLD} then 1 else 0 end), 0)`;
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
@@ -51,11 +53,20 @@ async function relationalQuery(
|
||||
website_event.visit_id,
|
||||
count(*) as "c",
|
||||
min(website_event.created_at) as "min_time",
|
||||
max(website_event.created_at) as "max_time"
|
||||
max(website_event.created_at) as "max_time",
|
||||
max((
|
||||
select count(*)
|
||||
from website_event we2
|
||||
where we2.website_id = website_event.website_id
|
||||
and we2.session_id = website_event.session_id
|
||||
and we2.visit_id = website_event.visit_id
|
||||
and we2.created_at between {{startDate}} and {{endDate}}
|
||||
and we2.event_type = ${EVENT_TYPE.customEvent}
|
||||
)) as "events_count"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${excludeBounceQuery}
|
||||
${joinSessionQuery}
|
||||
${joinSessionQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and website_event.event_type NOT IN (2, 5)
|
||||
@@ -81,7 +92,9 @@ async function clickhouseQuery(
|
||||
|
||||
let sql = '';
|
||||
const { excludeBounce } = filters;
|
||||
const bounceQuery = excludeBounce ? '0' : 'sumIf(1, t.c = 1)';
|
||||
const bounceQuery = excludeBounce
|
||||
? '0'
|
||||
: `sumIf(1, t.c = 1 and ifNull(e.events_count, 0) < ${BOUNCE_THRESHOLD})`;
|
||||
|
||||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
|
||||
sql = `
|
||||
@@ -106,7 +119,15 @@ async function clickhouseQuery(
|
||||
and event_type NOT IN (2, 5)
|
||||
${filterQuery}
|
||||
group by session_id, visit_id
|
||||
) as t;
|
||||
) as t
|
||||
left join (
|
||||
select session_id, visit_id, toUInt32(count()) as events_count
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
group by session_id, visit_id
|
||||
) as e using (session_id, visit_id);
|
||||
`;
|
||||
} else {
|
||||
sql = `
|
||||
@@ -130,7 +151,14 @@ async function clickhouseQuery(
|
||||
and event_type NOT IN (2, 5)
|
||||
${filterQuery}
|
||||
group by session_id, visit_id
|
||||
) as t;
|
||||
) as t
|
||||
left join (
|
||||
select session_id, visit_id, toUInt32(sum(length(event_name))) as events_count
|
||||
from website_event_stats_hourly
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
group by session_id, visit_id
|
||||
) as e using (session_id, visit_id);
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import clickhouse from '@/lib/clickhouse';
|
||||
import { FILTER_COLUMNS, GROUPED_DOMAINS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { BOUNCE_THRESHOLD, EVENT_TYPE, FILTER_COLUMNS, GROUPED_DOMAINS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import prisma from '@/lib/prisma';
|
||||
import type { QueryFilters } from '@/lib/types';
|
||||
@@ -96,7 +96,7 @@ async function relationalQuery(
|
||||
sum(t.c) as "pageviews",
|
||||
count(distinct t.session_id) as "visitors",
|
||||
count(distinct t.visit_id) as "visits",
|
||||
sum(case when t.c = 1 then 1 else 0 end) as "bounces",
|
||||
sum(case when t.c = 1 and t.events_count < ${BOUNCE_THRESHOLD} then 1 else 0 end) as "bounces",
|
||||
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime"
|
||||
from (
|
||||
select
|
||||
@@ -105,12 +105,21 @@ async function relationalQuery(
|
||||
website_event.visit_id,
|
||||
count(*) as "c",
|
||||
min(website_event.created_at) as "min_time",
|
||||
max(website_event.created_at) as "max_time"
|
||||
max(website_event.created_at) as "max_time",
|
||||
max((
|
||||
select count(*)
|
||||
from website_event we2
|
||||
where we2.website_id = website_event.website_id
|
||||
and we2.session_id = website_event.session_id
|
||||
and we2.visit_id = website_event.visit_id
|
||||
and we2.created_at between {{startDate}} and {{endDate}}
|
||||
and we2.event_type = ${EVENT_TYPE.customEvent}
|
||||
)) as "events_count"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${excludeBounceQuery}
|
||||
${joinSessionQuery}
|
||||
${entryExitQuery}
|
||||
${joinSessionQuery}
|
||||
${entryExitQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and website_event.event_type NOT IN (2, 5)
|
||||
@@ -188,7 +197,7 @@ async function clickhouseQuery(
|
||||
sum(t.c) as "pageviews",
|
||||
uniq(t.session_id) as "visitors",
|
||||
uniq(t.visit_id) as "visits",
|
||||
sum(if(t.c = 1, 1, 0)) as "bounces",
|
||||
sumIf(1, t.c = 1 and ifNull(e.events_count, 0) < ${BOUNCE_THRESHOLD}) as "bounces",
|
||||
sum(max_time-min_time) as "totaltime"
|
||||
from (
|
||||
select
|
||||
@@ -211,6 +220,14 @@ async function clickhouseQuery(
|
||||
${filterQuery}
|
||||
group by name, session_id, visit_id
|
||||
) as t
|
||||
left join (
|
||||
select session_id, visit_id, toUInt32(count()) as events_count
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
group by session_id, visit_id
|
||||
) as e using (session_id, visit_id)
|
||||
group by name
|
||||
order by visitors desc, visits desc
|
||||
limit ${limit}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import clickhouse from '@/lib/clickhouse';
|
||||
import { EVENT_TYPE, FILTER_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { BOUNCE_THRESHOLD, EVENT_TYPE, FILTER_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import prisma from '@/lib/prisma';
|
||||
import type { QueryFilters } from '@/lib/types';
|
||||
@@ -50,7 +50,7 @@ async function relationalQuery(
|
||||
sum(t.c) as "views",
|
||||
count(distinct t.session_id) as "visitors",
|
||||
count(distinct t.visit_id) as "visits",
|
||||
sum(case when t.c = 1 then 1 else 0 end) as "bounces",
|
||||
sum(case when t.c = 1 and t.events_count < ${BOUNCE_THRESHOLD} then 1 else 0 end) as "bounces",
|
||||
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime",
|
||||
${parseFieldsByName(fields)}
|
||||
from (
|
||||
@@ -60,14 +60,23 @@ async function relationalQuery(
|
||||
website_event.visit_id,
|
||||
count(*) as "c",
|
||||
min(website_event.created_at) as "min_time",
|
||||
max(website_event.created_at) as "max_time"
|
||||
max(website_event.created_at) as "max_time",
|
||||
max((
|
||||
select count(*)
|
||||
from website_event we2
|
||||
where we2.website_id = website_event.website_id
|
||||
and we2.session_id = website_event.session_id
|
||||
and we2.visit_id = website_event.visit_id
|
||||
and we2.created_at between {{startDate}} and {{endDate}}
|
||||
and we2.event_type = ${EVENT_TYPE.customEvent}
|
||||
)) as "events_count"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
${filterQuery}
|
||||
group by ${parseFieldsByName(fields)},
|
||||
group by ${parseFieldsByName(fields)},
|
||||
website_event.session_id, website_event.visit_id
|
||||
) as t
|
||||
group by ${parseFieldsByName(fields)}
|
||||
@@ -99,7 +108,7 @@ async function clickhouseQuery(
|
||||
sum(t.c) as "views",
|
||||
count(distinct t.session_id) as "visitors",
|
||||
count(distinct t.visit_id) as "visits",
|
||||
sum(if(t.c = 1, 1, 0)) as "bounces",
|
||||
sumIf(1, t.c = 1 and ifNull(e.events_count, 0) < ${BOUNCE_THRESHOLD}) as "bounces",
|
||||
sum(max_time-min_time) as "totaltime",
|
||||
${parseFieldsByName(fields)}
|
||||
from (
|
||||
@@ -115,9 +124,17 @@ async function clickhouseQuery(
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
${filterQuery}
|
||||
group by ${parseFieldsByName(fields)},
|
||||
group by ${parseFieldsByName(fields)},
|
||||
session_id, visit_id
|
||||
) as t
|
||||
left join (
|
||||
select session_id, visit_id, toUInt32(count()) as events_count
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
group by session_id, visit_id
|
||||
) as e using (session_id, visit_id)
|
||||
group by ${parseFieldsByName(fields)}
|
||||
order by 2 desc, 1 desc
|
||||
limit 500
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import clickhouse from '@/lib/clickhouse';
|
||||
import { FILTER_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { BOUNCE_THRESHOLD, EVENT_TYPE, FILTER_COLUMNS, SESSION_COLUMNS } from '@/lib/constants';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
|
||||
import prisma from '@/lib/prisma';
|
||||
import type { QueryFilters } from '@/lib/types';
|
||||
@@ -62,7 +62,7 @@ async function relationalQuery(
|
||||
sum(t.c) as "pageviews",
|
||||
count(distinct t.session_id) as "visitors",
|
||||
count(distinct t.visit_id) as "visits",
|
||||
sum(case when t.c = 1 then 1 else 0 end) as "bounces",
|
||||
sum(case when t.c = 1 and t.events_count < ${BOUNCE_THRESHOLD} then 1 else 0 end) as "bounces",
|
||||
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime"
|
||||
from (
|
||||
select
|
||||
@@ -72,11 +72,20 @@ async function relationalQuery(
|
||||
website_event.visit_id,
|
||||
count(*) as "c",
|
||||
min(website_event.created_at) as "min_time",
|
||||
max(website_event.created_at) as "max_time"
|
||||
max(website_event.created_at) as "max_time",
|
||||
max((
|
||||
select count(*)
|
||||
from website_event we2
|
||||
where we2.website_id = website_event.website_id
|
||||
and we2.session_id = website_event.session_id
|
||||
and we2.visit_id = website_event.visit_id
|
||||
and we2.created_at between {{startDate}} and {{endDate}}
|
||||
and we2.event_type = ${EVENT_TYPE.customEvent}
|
||||
)) as "events_count"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${excludeBounceQuery}
|
||||
${joinSessionQuery}
|
||||
${joinSessionQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and website_event.event_type NOT IN (2, 5)
|
||||
@@ -122,7 +131,7 @@ async function clickhouseQuery(
|
||||
sum(t.c) as "pageviews",
|
||||
uniq(t.session_id) as "visitors",
|
||||
uniq(t.visit_id) as "visits",
|
||||
sum(if(t.c = 1, 1, 0)) as "bounces",
|
||||
sumIf(1, t.c = 1 and ifNull(e.events_count, 0) < ${BOUNCE_THRESHOLD}) as "bounces",
|
||||
sum(max_time-min_time) as "totaltime"
|
||||
from (
|
||||
select
|
||||
@@ -144,7 +153,15 @@ async function clickhouseQuery(
|
||||
group by name, session_id, visit_id
|
||||
${includeCountry ? ', country' : ''}
|
||||
) as t
|
||||
group by name
|
||||
left join (
|
||||
select session_id, visit_id, toUInt32(count()) as events_count
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
group by session_id, visit_id
|
||||
) as e using (session_id, visit_id)
|
||||
group by name
|
||||
${includeCountry ? ', country' : ''}
|
||||
order by visitors desc, visits desc
|
||||
limit ${limit}
|
||||
|
||||
@@ -49,8 +49,8 @@ async function relationalQuery(websiteId: string, sessionId: string) {
|
||||
session.city,
|
||||
min(website_event.created_at) as min_time,
|
||||
max(website_event.created_at) as max_time,
|
||||
sum(case when website_event.event_type = 1 then 1 else 0 end) as views,
|
||||
sum(case when website_event.event_type = 2 then 1 else 0 end) as events
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.pageView} then 1 else 0 end) as views,
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.customEvent} then 1 else 0 end) as events
|
||||
from session
|
||||
join website_event on website_event.session_id = session.session_id
|
||||
where session.website_id = {{websiteId::uuid}}
|
||||
|
||||
@@ -36,11 +36,11 @@ async function relationalQuery(
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
sum(case when website_event.event_type = 1 then 1 else 0 end) as "pageviews",
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.pageView} 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",
|
||||
sum(case when website_event.event_type = 2 then 1 else 0 end) as "events"
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.customEvent} then 1 else 0 end) as "events"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
join session on website_event.session_id = session.session_id
|
||||
@@ -67,11 +67,11 @@ async function clickhouseQuery(
|
||||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
|
||||
sql = `
|
||||
select
|
||||
sumIf(1, event_type = 1) as "pageviews",
|
||||
sumIf(1, event_type = ${EVENT_TYPE.pageView}) as "pageviews",
|
||||
uniq(session_id) as "visitors",
|
||||
uniq(visit_id) as "visits",
|
||||
uniq(country) as "countries",
|
||||
sumIf(1, event_type = 2) as "events"
|
||||
sumIf(1, event_type = ${EVENT_TYPE.customEvent}) as "events"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
|
||||
@@ -50,8 +50,8 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||
min(website_event.created_at) as "firstAt",
|
||||
max(website_event.created_at) as "lastAt",
|
||||
count(distinct website_event.visit_id) as "visits",
|
||||
sum(case when website_event.event_type = 1 then 1 else 0 end) as "views",
|
||||
sum(case when website_event.event_type = 2 then 1 else 0 end) as "events",
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.pageView} then 1 else 0 end) as "views",
|
||||
sum(case when website_event.event_type = ${EVENT_TYPE.customEvent} then 1 else 0 end) as "events",
|
||||
max(website_event.created_at) as "createdAt"
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
@@ -125,8 +125,8 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||
${getDateStringSQL('min(created_at)')} as firstAt,
|
||||
${getDateStringSQL('max(created_at)')} as lastAt,
|
||||
uniq(visit_id) as visits,
|
||||
sumIf(1, event_type = 1) as views,
|
||||
sumIf(1, event_type = 2) as events,
|
||||
sumIf(1, event_type = ${EVENT_TYPE.pageView}) as views,
|
||||
sumIf(1, event_type = ${EVENT_TYPE.customEvent}) as events,
|
||||
max(created_at) as createdAt
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
@@ -155,7 +155,7 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters) {
|
||||
${getDateStringSQL('min(min_time)')} as firstAt,
|
||||
${getDateStringSQL('max(max_time)')} as lastAt,
|
||||
uniq(visit_id) as visits,
|
||||
sumIf(views, event_type = 1) as views,
|
||||
sumIf(views, event_type = ${EVENT_TYPE.pageView}) as views,
|
||||
sum(length(event_name)) as events,
|
||||
max(max_time) as createdAt
|
||||
from website_event_stats_hourly as website_event
|
||||
|
||||
Reference in new issue
Block a user