fix(api): filter empty values when using sum and average, added min and max
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import {
|
||||
chartSegments,
|
||||
chartTypes,
|
||||
intervals,
|
||||
lineTypes,
|
||||
@@ -29,6 +30,11 @@ export const zChartEventFilter = z.object({
|
||||
.describe('The values to filter on'),
|
||||
});
|
||||
|
||||
export const zChartEventSegment = z
|
||||
.enum(objectToZodEnums(chartSegments))
|
||||
.default('event')
|
||||
.describe('Defines how the event data should be segmented or aggregated');
|
||||
|
||||
export const zChartEvent = z.object({
|
||||
id: z
|
||||
.string()
|
||||
@@ -45,18 +51,7 @@ export const zChartEvent = z.object({
|
||||
.describe(
|
||||
'Optional property of the event used for specific segment calculations (e.g., value for property_sum/average)',
|
||||
),
|
||||
segment: z
|
||||
.enum([
|
||||
'event',
|
||||
'user',
|
||||
'session',
|
||||
'user_average',
|
||||
'one_event_per_user',
|
||||
'property_sum',
|
||||
'property_average',
|
||||
])
|
||||
.default('event')
|
||||
.describe('Defines how the event data should be segmented or aggregated'),
|
||||
segment: zChartEventSegment,
|
||||
filters: z
|
||||
.array(zChartEventFilter)
|
||||
.default([])
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { z } from 'zod';
|
||||
import type {
|
||||
zChartBreakdown,
|
||||
zChartEvent,
|
||||
zChartEventSegment,
|
||||
zChartInput,
|
||||
zChartInputAI,
|
||||
zChartType,
|
||||
@@ -23,6 +24,7 @@ export type IChartProps = z.infer<typeof zReportInput> & {
|
||||
previousIndicatorInverted?: boolean;
|
||||
};
|
||||
export type IChartEvent = z.infer<typeof zChartEvent>;
|
||||
export type IChartEventSegment = z.infer<typeof zChartEventSegment>;
|
||||
export type IChartEventFilter = IChartEvent['filters'][number];
|
||||
export type IChartEventFilterValue =
|
||||
IChartEvent['filters'][number]['value'][number];
|
||||
|
||||
Reference in New Issue
Block a user