Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
fix cohort queries with new multiselect
Francis Caobbf569e8bcce
diff --git a/src/lib/clickhouse.ts b/src/lib/clickhouse.tsindex 3620a04ce..bb3976c71 100644--- a/src/lib/clickhouse.ts+++ b/src/lib/clickhouse.ts@@ -178,7 +178,10 @@ function getQueryParams(filters: Record<string, any>) {return {...filters,...filtersObjectToArray(filters).reduce((obj, { name, column, operator, value }) => {- if (!column || !name || value === undefined) return obj;+ const resolvedColumn =+ column || (name?.startsWith('cohort_') && FILTER_COLUMNS[name.slice('cohort_'.length)]);++ if (!resolvedColumn || !name || value === undefined) return obj;obj[name] = ([OPERATORS.equals, OPERATORS.notEquals] as string[]).includes(operator)? Array.isArray(value)diff --git a/src/lib/prisma.ts b/src/lib/prisma.tsindex b8cb82c4d..3d31fcf9b 100644--- a/src/lib/prisma.ts+++ b/src/lib/prisma.ts@@ -182,7 +182,10 @@ function getQueryParams(filters: Record<string, any>) {return {...filters,...filtersObjectToArray(filters).reduce((obj, { name, column, operator, value }) => {- if (!column) return obj;+ const resolvedColumn =+ column || (name?.startsWith('cohort_') && FILTER_COLUMNS[name.slice('cohort_'.length)]);++ if (!resolvedColumn) return obj;if (([OPERATORS.contains, OPERATORS.doesNotContain] as Operator[]).includes(operator)) {obj[name] = `%${value}%`;diff --git a/src/lib/request.ts b/src/lib/request.tsindex 0b7c1a424..e89f5722f 100644--- a/src/lib/request.ts+++ b/src/lib/request.ts@@ -1,7 +1,7 @@import { startOfMonth, subMonths } from 'date-fns';import { z } from 'zod';import { checkAuth } from '@/lib/auth';-import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants';+import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS, OPERATORS } from '@/lib/constants';import { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';import { fetchAccount, fetchWebsite } from '@/lib/load';import { filtersArrayToObject } from '@/lib/params';@@ -130,7 +130,7 @@ export async function getQueryFilters(cohortFilters.push({name: `cohort_${cohortParams.action.type}`,- operator: 'eq',+ operator: OPERATORS.equals,value: cohortParams.action.value,});