remove event from website stats. doesnt work with view

This commit is contained in:
Francis Cao 2024-08-09 18:20:26 -07:00
parent 136dd6794e
commit 22333a1e9a
3 changed files with 7 additions and 19 deletions

View File

@ -28,11 +28,6 @@ export function EventsMetricsBar({ websiteId }: { websiteId: string }) {
label={formatMessage(labels.views)} label={formatMessage(labels.views)}
formatValue={formatLongNumber} formatValue={formatLongNumber}
/> />
<MetricCard
value={data?.events?.value}
label={formatMessage(labels.events)}
formatValue={formatLongNumber}
/>
</MetricsBar> </MetricsBar>
<WebsiteDateFilter websiteId={websiteId} /> <WebsiteDateFilter websiteId={websiteId} />
</Flexbox> </Flexbox>

View File

@ -33,15 +33,12 @@ async function relationalQuery(
count(distinct t.session_id) as "visitors", count(distinct t.session_id) as "visitors",
count(distinct t.visit_id) as "visits", count(distinct t.visit_id) as "visits",
count(distinct t.country) as "countries", count(distinct t.country) as "countries",
count(t.event_name) as "countries",
sum(case when t.event_type = 2 then 1 else 0 end) as "events",
sum(case when t.c = 1 then 1 else 0 end) as "bounces", sum(case when t.c = 1 then 1 else 0 end) as "bounces",
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime", sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime",
from ( from (
select select
website_event.session_id, website_event.session_id,
website_event.visit_id, website_event.visit_id,
website_event.event_type,
session.country, session.country,
count(*) as "c", count(*) as "c",
min(website_event.created_at) as "min_time", min(website_event.created_at) as "min_time",
@ -51,7 +48,7 @@ async function relationalQuery(
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}}
${filterQuery} ${filterQuery}
group by 1, 2, 3, 4 group by 1, 2, 3
) as t ) as t
`, `,
params, params,
@ -78,14 +75,12 @@ async function clickhouseQuery(
uniq(t.session_id) as "visitors", uniq(t.session_id) as "visitors",
uniq(t.visit_id) as "visits", uniq(t.visit_id) as "visits",
uniq(t.country) as "countries", uniq(t.country) as "countries",
sumIf(1, t.event_type = 2) as "events",
sumIf(1, t.c = 1) as "bounces", sumIf(1, t.c = 1) as "bounces",
sum(max_time-min_time) as "totaltime" sum(max_time-min_time) as "totaltime"
from ( from (
select select
session_id, session_id,
visit_id, visit_id,
event_type,
country, country,
count(*) c, count(*) c,
min(created_at) min_time, min(created_at) min_time,
@ -94,7 +89,7 @@ async function clickhouseQuery(
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}
${filterQuery} ${filterQuery}
group by session_id, visit_id, event_type, country group by session_id, visit_id, country
) as t; ) as t;
`; `;
} else { } else {
@ -104,14 +99,12 @@ async function clickhouseQuery(
uniq(session_id) as "visitors", uniq(session_id) as "visitors",
uniq(visit_id) as "visits", uniq(visit_id) as "visits",
uniq(country) as "countries", uniq(country) as "countries",
sumIf(1, t.event_type = 2) as "events",
sumIf(1, t.c = 1) as "bounces", sumIf(1, t.c = 1) as "bounces",
sum(max_time-min_time) as "totaltime" sum(max_time-min_time) as "totaltime"
from ( from (
select select
session_id, session_id,
visit_id, visit_id,
event_type,
country, country,
sum(views) c, sum(views) c,
min(min_time) min_time, min(min_time) min_time,
@ -120,7 +113,7 @@ async function clickhouseQuery(
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}
${filterQuery} ${filterQuery}
group by session_id, visit_id, event_type, country group by session_id, visit_id, country
) as t; ) as t;
`; `;
} }

View File

@ -44,11 +44,11 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters, pagePar
country, country,
subdivision1, subdivision1,
city, city,
min(created_at) as firstAt, min(min_time) as firstAt,
max(created_at) as lastAt, max(max_time) as lastAt,
uniq(visit_id) as visits, uniq(visit_id) as visits,
sumIf(1, event_type = 1) as views sumIf(views, event_type = 1) as views
from website_event from website_event_stats_hourly
where website_id = {websiteId:UUID} where website_id = {websiteId:UUID}
${dateQuery} ${dateQuery}
${filterQuery} ${filterQuery}