mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
This commit is contained in:
parent
4a3190b2da
commit
ee698b636a
21 changed files with 189 additions and 69 deletions
|
|
@ -131,6 +131,25 @@ function getCohortQuery(filters: Record<string, any>) {
|
|||
`;
|
||||
}
|
||||
|
||||
function getExcludeBounceQuery(filters: Record<string, any>) {
|
||||
if (!filters.excludeBounce === true) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return `join
|
||||
(select distinct session_id, visit_id
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = 1
|
||||
group by session_id, visit_id
|
||||
having count(*) > 1
|
||||
) excludeBounce
|
||||
on excludeBounce.session_id = website_event.session_id
|
||||
and excludeBounce.visit_id = website_event.visit_id
|
||||
`;
|
||||
}
|
||||
|
||||
function getDateQuery(filters: Record<string, any>) {
|
||||
const { startDate, endDate, timezone } = filters;
|
||||
|
||||
|
|
@ -174,6 +193,7 @@ function parseFilters(filters: Record<string, any>, options?: QueryOptions) {
|
|||
dateQuery: getDateQuery(filters),
|
||||
queryParams: getQueryParams(filters),
|
||||
cohortQuery: getCohortQuery(cohortFilters),
|
||||
excludeBounceQuery: getExcludeBounceQuery(filters),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,25 @@ function getCohortQuery(filters: QueryFilters = {}) {
|
|||
`;
|
||||
}
|
||||
|
||||
function getExcludeBounceQuery(filters: Record<string, any>) {
|
||||
if (!filters.excludeBounce === true) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return `join
|
||||
(select distinct session_id, visit_id
|
||||
from website_event
|
||||
where website_id = {{websiteId}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and event_type = 1
|
||||
group by session_id, visit_id
|
||||
having count(*) > 1
|
||||
) excludeBounce
|
||||
on excludeBounce.session_id = website_event.session_id
|
||||
and excludeBounce.visit_id = website_event.visit_id
|
||||
`;
|
||||
}
|
||||
|
||||
function getDateQuery(filters: Record<string, any>) {
|
||||
const { startDate, endDate } = filters;
|
||||
|
||||
|
|
@ -186,6 +205,7 @@ function parseFilters(filters: Record<string, any>, options?: QueryOptions) {
|
|||
filterQuery: getFilterQuery(filters, options),
|
||||
queryParams: getQueryParams(filters),
|
||||
cohortQuery: getCohortQuery(cohortFilters),
|
||||
excludeBounceQuery: getExcludeBounceQuery(filters),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ export async function getQueryFilters(
|
|||
cohort_endDate: endDate,
|
||||
});
|
||||
}
|
||||
|
||||
if (params.excludeBounce) {
|
||||
Object.assign(filters, { excludeBounce: true });
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export const filterParams = {
|
|||
segment: z.uuid().optional(),
|
||||
cohort: z.uuid().optional(),
|
||||
eventType: z.coerce.number().int().positive().optional(),
|
||||
excludeBounce: z.string().optional(),
|
||||
};
|
||||
|
||||
export const searchParams = {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ export interface FilterParams {
|
|||
segment?: string;
|
||||
cohort?: string;
|
||||
compare?: string;
|
||||
excludeBounce?: boolean;
|
||||
}
|
||||
|
||||
export interface SortParams {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue