Get properties for sessions within date range.

This commit is contained in:
Mike Cao 2025-02-11 21:28:26 -08:00
parent 22a910e818
commit 020cfdc646
2 changed files with 18 additions and 12 deletions

View file

@ -10,7 +10,7 @@ export function useSessionDataProperties(
const params = useFilterParams(websiteId);
return useQuery<any>({
queryKey: ['websites:event-data:properties', { websiteId, ...params }],
queryKey: ['websites:session-data:properties', { websiteId, ...params }],
queryFn: () => get(`/websites/${websiteId}/session-data/properties`, { ...params }),
enabled: !!websiteId,
...options,

View file

@ -24,13 +24,16 @@ async function relationalQuery(
return rawQuery(
`
select
data_key as "propertyName",
count(*) as "total"
from session_data
where website_id = {{websiteId::uuid}}
and created_at between {{startDate}} and {{endDate}}
${filterQuery}
group by data_key
data_key as "propertyName",
count(*) as "total"
from website_event e
left 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
limit 500
`,
@ -52,11 +55,14 @@ async function clickhouseQuery(
select
data_key as propertyName,
count(*) as total
from session_data final
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
from website_event e
left join session_data d
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 != ''
${filterQuery}
group by data_key
group by 1
order by 2 desc
limit 500
`,