Merge branch 'dev' of https://github.com/umami-software/umami into analytics

This commit is contained in:
Francis Cao 2025-02-12 11:42:30 -08:00
commit 5abd4e6592
5 changed files with 33 additions and 28 deletions

View file

@ -1,8 +1,8 @@
import { z } from 'zod';
import { parseRequest } from '@/lib/request';
import { unauthorized, json } from '@/lib/response';
import { canViewWebsite } from '@/lib/auth';
import { getEventDataEvents } from '@/queries/sql/events/getEventDataEvents';
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { getSessionDataValues } from '@/queries';
import { z } from 'zod';
export async function GET(
request: Request,
@ -20,7 +20,7 @@ export async function GET(
return error();
}
const { startAt, endAt, event } = query;
const { startAt, endAt, propertyName } = query;
const { websiteId } = await params;
if (!(await canViewWebsite(auth, websiteId))) {
@ -30,10 +30,10 @@ export async function GET(
const startDate = new Date(+startAt);
const endDate = new Date(+endAt);
const data = await getEventDataEvents(websiteId, {
const data = await getSessionDataValues(websiteId, {
startDate,
endDate,
event,
propertyName,
});
return json(data);

View file

@ -87,7 +87,7 @@ export function ReferrersTable({ allowFilter, ...props }: ReferrersTableProps) {
{...props}
title={formatMessage(labels.referrers)}
type="referrer"
metric={formatMessage(labels.views)}
metric={formatMessage(labels.visitors)}
dataFilter={view === 'grouped' ? groupedFilter : undefined}
renderLabel={renderLink}
>

View file

@ -62,7 +62,8 @@ async function relationalQuery(
return rawQuery(
`
select ${column} x, count(*) y
select ${column} x,
${column === 'referrer_domain' ? 'count(distinct session_id)' : 'count(*)'} as y
from website_event
${joinSession}
${entryExitQuery}
@ -119,7 +120,8 @@ async function clickhouseQuery(
}
sql = `
select ${column} x, count(*) y
select ${column} x,
${column === 'referrer_domain' ? 'uniq(session_id)' : 'count(*)'} as y
from website_event
${entryExitQuery}
where website_id = {websiteId:UUID}
@ -133,13 +135,13 @@ async function clickhouseQuery(
`;
} else {
let groupByQuery = '';
let columnQuery = `arrayJoin(${column})`;
if (column === 'referrer_domain') {
excludeDomain = `and t != hostname and hostname != ''`;
columnQuery = `session_id s, arrayJoin(${column})`;
}
let columnQuery = `arrayJoin(${column})`;
if (type === 'entry') {
columnQuery = `visit_id x, argMinMerge(entry_url)`;
}
@ -154,7 +156,7 @@ async function clickhouseQuery(
sql = `
select g.t as x,
count(*) as y
${column === 'referrer_domain' ? 'uniq(s)' : 'count(*)'} as y
from (
select ${columnQuery} as t
from website_event_stats_hourly website_event

View file

@ -25,13 +25,12 @@ async function relationalQuery(
`
select
data_key as "propertyName",
count(*) as "total"
count(distinct d.session_id) as "total"
from website_event e
left join session_data d
join session_data d
on d.session_id = e.session_id
where e.website_id = {{websiteId:uuid}}
and e.created_at between {{startDate}} and {{endDate}}
and d.data_key is not null
${filterQuery}
group by 1
order by 2 desc
@ -54,9 +53,9 @@ async function clickhouseQuery(
`
select
data_key as propertyName,
count(*) as total
count(distinct d.session_id) as total
from website_event e
left join session_data d
join session_data d final
on d.session_id = e.session_id
where e.website_id = {websiteId:UUID}
and e.created_at between {startDate:DateTime64} and {endDate:DateTime64}

View file

@ -27,11 +27,13 @@ async function relationalQuery(
when data_type = 4 then ${getDateSQL('date_value', 'hour')}
else string_value
end as "value",
count(*) as "total"
from session_data
where website_id = {{websiteId::uuid}}
and created_at between {{startDate}} and {{endDate}}
and data_key = {{propertyName}}
count(distinct d.session_id) as "total"
from website_event e
join session_data d
on d.session_id = e.session_id
where e.website_id = {{websiteId::uuid}}
and e.created_at between {{startDate}} and {{endDate}}
and d.data_key = {{propertyName}}
${filterQuery}
group by value
order by 2 desc
@ -54,11 +56,13 @@ async function clickhouseQuery(
multiIf(data_type = 2, replaceAll(string_value, '.0000', ''),
data_type = 4, toString(date_trunc('hour', date_value)),
string_value) as "value",
count(*) as "total"
from session_data final
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and data_key = {propertyName:String}
uniq(d.session_id) as "total"
from website_event e
join session_data d final
on d.session_id = e.session_id
where e.website_id = {websiteId:UUID}
and e.created_at between {startDate:DateTime64} and {endDate:DateTime64}
and d.data_key = {propertyName:String}
${filterQuery}
group by value
order by 2 desc