Merge branch 'analytics' of https://github.com/umami-software/umami into dev
Some checks are pending
Node.js CI / build (push) Waiting to run

This commit is contained in:
Francis Cao 2026-02-09 17:52:00 -08:00
commit 02d28a9c53
11 changed files with 37 additions and 35 deletions

View file

@ -23,6 +23,25 @@ export const dateRangeParams = {
compare: z.enum(['prev', 'yoy']).optional(),
};
export function withDateRange<T extends z.ZodRawShape>(shape?: T) {
return z
.object({
...dateRangeParams,
...shape,
})
.superRefine((data: Record<string, unknown>, ctx) => {
const hasTimestamps = data.startAt != null && data.endAt != null;
const hasDates = data.startDate != null && data.endDate != null;
if (!hasTimestamps && !hasDates) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Either startAt+endAt or startDate+endDate must be provided',
});
}
});
}
export const filterParams = {
path: z.string().optional(),
referrer: z.string().optional(),