Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

refactor(cdp): edit cdp filter matchers with the series picker (#126230)

Thomas Obermüller15509135d39f
diff --git a/frontend/src/scenes/hog-functions/filters/HogFunctionFilters.tsx b/frontend/src/scenes/hog-functions/filters/HogFunctionFilters.tsx
index f01adb15f067..e6c12084cc2d 100644
--- a/frontend/src/scenes/hog-functions/filters/HogFunctionFilters.tsx
+++ b/frontend/src/scenes/hog-functions/filters/HogFunctionFilters.tsx
@@ -14,18 +14,20 @@ import { LemonField } from 'lib/lemon-ui/LemonField'
import { Link } from 'lib/lemon-ui/Link'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { dataWarehouseViewsLogic } from 'scenes/data-warehouse/saved_queries/dataWarehouseViewsLogic'
-import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'
import MaxTool from 'scenes/max/MaxTool'
import { urls } from 'scenes/urls'
import { groupsModel } from '~/models/groupsModel'
-import { AnyPropertyFilter, CyclotronJobFiltersType, EntityTypes, FilterType } from '~/types'
+import { NodeKind } from '~/queries/schema/schema-general'
+import { AnyPropertyFilter, ChartDisplayCategory, CyclotronJobFiltersType } from '~/types'
import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'
import { hogFunctionConfigurationLogic } from '../configuration/hogFunctionConfigurationLogic'
import { truncateHogFunctionContext } from '../hog-function-utils'
+import { CdpFilterEntities, cdpFiltersToSeries, seriesToCdpFilters } from './cdpFilterSeries'
import { HogFunctionFiltersInternal } from './HogFunctionFiltersInternal'
const MASKING_HASH_ALL = 'all'
@@ -40,7 +42,7 @@ const CALENDAR_DAY_HASHES = [MASKING_HASH_PER_PERSON_PER_DAY, MASKING_HASH_PER_P
const CALENDAR_DAY_TTL = 24 * 60 * 60
const DEFAULT_INTERVAL_TTL = 60 * 30
-function sanitizeActionFilters(filters?: FilterType): Partial<CyclotronJobFiltersType> {
+function sanitizeActionFilters(filters?: CdpFilterEntities): Partial<CyclotronJobFiltersType> {
if (!filters) {
return {}
}
@@ -332,15 +334,16 @@ export function HogFunctionFilters({
<p className="mb-0 text-xs text-secondary">
If set, the {type} will only run if the <b>event matches any</b> of the below.
</p>
- <ActionFilter
+ <SeriesActionFilter
bordered
- filters={currentFilters ?? {} /* TODO: this is any */}
- setFilters={(payload) => {
+ series={cdpFiltersToSeries(currentFilters)}
+ onChange={(series) => {
onChange({
...currentFilters,
- ...sanitizeActionFilters(payload),
+ ...sanitizeActionFilters(seriesToCdpFilters(series)),
})
}}
+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
typeKey={isDataWarehouseView ? 'plugin-filters-view' : 'plugin-filters'}
mathAvailability={MathAvailability.None}
hideRename
@@ -360,19 +363,15 @@ export function HogFunctionFilters({
}
propertiesTaxonomicGroupTypes={taxonomicGroupTypes}
propertyFiltersPopover
- addFilterDefaultOptions={
+ newSeriesDefaults={
isDataWarehouse
? {
name: isDataWarehouseView
? 'Select a materialized view'
: 'Select a table',
- type: EntityTypes.DATA_WAREHOUSE,
- }
- : {
- id: '$pageview',
- name: '$pageview',
- type: EntityTypes.EVENTS,
+ kind: NodeKind.DataWarehouseNode,
}
+ : { kind: NodeKind.EventsNode, event: '$pageview', name: '$pageview' }
}
buttonCopy={
isDataWarehouseView
diff --git a/frontend/src/scenes/hog-functions/filters/cdpFilterSeries.test.ts b/frontend/src/scenes/hog-functions/filters/cdpFilterSeries.test.ts
new file mode 100644
index 000000000000..2847c38e0d90
--- /dev/null
+++ b/frontend/src/scenes/hog-functions/filters/cdpFilterSeries.test.ts
@@ -0,0 +1,113 @@
+import { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'
+
+import { NodeKind } from '~/queries/schema/schema-general'
+
+import { CdpFilterEntities, cdpFiltersToSeries, seriesToCdpFilters } from './cdpFilterSeries'
+
+const exampleUrl = { key: '$current_url', value: 'https://example.com', operator: 'icontains', type: 'event' }
+
+describe('cdpFilterSeries', () => {
+ test.each<[string, Partial<CdpFilterEntities>, CdpFilterEntities]>([
+ [
+ 'events, actions and warehouse tables keep their fields and come back sorted by order',
+ {
+ events: [{ id: '$pageview', type: 'events', name: '$pageview', order: 0, properties: [exampleUrl] }],
+ actions: [{ id: '9', type: 'actions', name: 'Users signed up', order: 1, properties: [] }],
+ data_warehouse: [
+ {
+ id: 'payments',
+ type: 'data_warehouse',
+ name: 'payments',
+ order: 2,
+ uuid: '0189e1f0-0000-0000-0000-000000000000',
+ table_name: 'payments',
+ timestamp_field: 'created_at',
+ distinct_id_field: 'person_id',
+ id_field: 'id',
+ properties: [],
+ },
+ ],
+ },
+ {
+ actions: [{ name: 'Users signed up', properties: [], id: 9, type: 'actions', order: 1 }],
+ events: [{ name: '$pageview', properties: [exampleUrl], id: '$pageview', type: 'events', order: 0 }],
+ data_warehouse: [
+ {
+ name: 'payments',
+ table_name: 'payments',
+ timestamp_field: 'created_at',
+ distinct_id_field: 'person_id',
+ id_field: 'id',
+ properties: [],
+ id: 'payments',
+ type: 'data_warehouse',
+ order: 2,
+ },
+ ],
+ groups: [],
+ },
+ ],
+ [
+ 'custom names stay and gaps in order close up',
+ {
+ events: [
+ { id: 'purchased', type: 'events', name: 'purchased', custom_name: 'Checkout', order: 7 },
+ { id: '$pageview', type: 'events', name: '$pageview', order: 3 },
+ ],
+ },
+ {
+ actions: [],
+ events: [
+ { name: '$pageview', id: '$pageview', type: 'events', order: 0 },
+ { name: 'purchased', custom_name: 'Checkout', id: 'purchased', type: 'events', order: 1 },
+ ],
+ data_warehouse: [],
+ groups: [],
+ },
+ ],
+ [
+ 'a group keeps its operator and nested event and action',
+ {
+ groups: [
+ {
+ type: 'groups',
+ name: 'Signed up or purchased',
+ operator: 'OR',
+ order: 0,
+ nestedFilters: [
+ { id: 'signed_up', type: 'events', name: 'signed_up', order: 0 },
+ { id: '12', type: 'actions', name: 'Purchased', order: 1, properties: [exampleUrl] },
+ ],
+ },
+ ],
+ },
+ {
+ actions: [],
+ events: [],
+ data_warehouse: [],
+ groups: [
+ {
+ name: 'Signed up or purchased',
+ operator: 'OR',
+ nestedFilters: [
+ { name: 'signed_up', id: 'signed_up', type: 'events', order: 0 },
+ { name: 'Purchased', properties: [exampleUrl], id: 12, type: 'actions', order: 1 },
+ ],
+ id: null,
+ type: 'groups',
+ order: 0,
+ },
+ ],
+ },
+ ],
+ ])('%s', (_, stored, expected) => {
+ expect(JSON.stringify(seriesToCdpFilters(cdpFiltersToSeries(stored)))).toEqual(JSON.stringify(expected))
+ })
+
+ test('a row the picker built drops its node version', () => {
+ const series = [{ kind: NodeKind.ActionsNode, id: 4, name: 'Clicked buy', version: 1 } as SeriesNode]
+ expect(JSON.stringify(seriesToCdpFilters(series).actions)).toEqual(
+ JSON.stringify([{ name: 'Clicked buy', id: 4, type: 'actions', order: 0 }])
+ )
+ })
+})
diff --git a/frontend/src/scenes/hog-functions/filters/cdpFilterSeries.ts b/frontend/src/scenes/hog-functions/filters/cdpFilterSeries.ts
new file mode 100644
index 000000000000..d32688ed42f2
--- /dev/null
+++ b/frontend/src/scenes/hog-functions/filters/cdpFilterSeries.ts
@@ -0,0 +1,120 @@
+import { convertPropertyGroupToProperties } from 'lib/components/PropertyFilters/utils'
+import {
+ SeriesNode,
+ isActionsSeriesNode,
+ isEventsSeriesNode,
+ isGroupSeriesNode,
+ isWarehouseSeriesNode,
+ seriesNodeEntityType,
+ toActionId,
+} from 'scenes/insights/filters/ActionFilter/seriesNode'
+
+import { NodeKind } from '~/queries/schema/schema-general'
+import { EntityTypes } from '~/types'
+
+export interface CdpFilterEntity {
+ id?: any
+ type?: any
+ order?: number
+ [key: string]: any
+}
+
+export interface CdpFilterEntities {
+ actions: CdpFilterEntity[]
+ events: CdpFilterEntity[]
+ data_warehouse: CdpFilterEntity[]
+ groups: CdpFilterEntity[]
+}
+
+const ENTITY_IDENTITY_KEYS = ['type', 'id', 'order', 'index', 'nestedFilters', 'uuid']
+const NODE_IDENTITY_KEYS = ['kind', 'version', 'event', 'id', 'nodes']
+
+function omitKeys(source: Record<string, any>, keys: string[]): Record<string, any> {
+ return Object.fromEntries(Object.entries(source).filter(([key]) => !keys.includes(key)))
+}
+
+// The picker replaces its rows with every new series array it receives. A parent can render again before it
+// receives the filters that hold a new row, so the same filters object must give back the same array.
+const seriesByFilters = new WeakMap<Partial<CdpFilterEntities>, SeriesNode[]>()
+
+export function cdpFiltersToSeries(filters: Partial<CdpFilterEntities> | null | undefined): SeriesNode[] {
+ if (!filters) {
+ return []
+ }
+ let series = seriesByFilters.get(filters)
+ if (!series) {
+ series = [
+ ...(filters.actions ?? []),
+ ...(filters.events ?? []),
+ ...(filters.data_warehouse ?? []),
+ ...(filters.groups ?? []),
+ ]
+ .sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
+ .map(cdpFilterEntityToSeriesNode)
+ seriesByFilters.set(filters, series)
+ }
+ return series
+}
+
+function cdpFilterEntityToSeriesNode(entity: CdpFilterEntity): SeriesNode {
+ const shared = omitKeys(entity, ENTITY_IDENTITY_KEYS)
+ if (Array.isArray(shared.properties)) {
+ shared.properties = convertPropertyGroupToProperties(shared.properties)
+ }
+
+ if (entity.type === EntityTypes.ACTIONS) {
+ return { ...shared, kind: NodeKind.ActionsNode, id: toActionId(entity.id) } as SeriesNode
+ }
+ if (entity.type === EntityTypes.GROUPS) {
+ return {
+ ...shared,
+ kind: NodeKind.GroupNode,
+ nodes: (entity.nestedFilters ?? []).map(cdpFilterEntityToSeriesNode),
+ } as SeriesNode
+ }
+ if (entity.type === EntityTypes.DATA_WAREHOUSE) {
+ const tableName = shared.table_name ?? (typeof entity.id === 'string' ? entity.id : undefined)
+ return {
+ ...shared,
+ kind: NodeKind.DataWarehouseNode,
+ table_name: tableName,
+ id: tableName ?? entity.id,
+ } as SeriesNode
+ }
+ return { ...shared, kind: NodeKind.EventsNode, event: entity.id } as SeriesNode
+}
+
+export function seriesToCdpFilters(series: SeriesNode[]): CdpFilterEntities {
+ const entities = series.map(seriesNodeToCdpFilterEntity)
+ return {
+ actions: entities.filter((entity) => entity.type === EntityTypes.ACTIONS),
+ events: entities.filter((entity) => entity.type === EntityTypes.EVENTS),
+ data_warehouse: entities.filter((entity) => entity.type === EntityTypes.DATA_WAREHOUSE),
+ groups: entities.filter((entity) => entity.type === EntityTypes.GROUPS),
+ }
+}
+
+function seriesNodeToCdpFilterEntity(node: SeriesNode, order: number): CdpFilterEntity {
+ let id: string | number | null = null
+ if (isEventsSeriesNode(node)) {
+ id = node.event ?? null
+ } else if (isActionsSeriesNode(node)) {
+ id = node.id
+ } else if (isWarehouseSeriesNode(node)) {
+ id = node.table_name
+ }
+
+ return {
+ ...omitKeys(node, NODE_IDENTITY_KEYS),
+ ...(isGroupSeriesNode(node)
+ ? {
+ nestedFilters: node.nodes.map((nested, nestedOrder) =>
+ seriesNodeToCdpFilterEntity(nested, nestedOrder)
+ ),
+ }
+ : {}),
+ id,
+ type: seriesNodeEntityType(node) ?? EntityTypes.EVENTS,
+ order,
+ }
+}
diff --git a/frontend/src/scenes/hog-functions/mapping/HogFunctionMappings.tsx b/frontend/src/scenes/hog-functions/mapping/HogFunctionMappings.tsx
index a8ad6300ac20..38aa3340392c 100644
--- a/frontend/src/scenes/hog-functions/mapping/HogFunctionMappings.tsx
+++ b/frontend/src/scenes/hog-functions/mapping/HogFunctionMappings.tsx
@@ -18,13 +18,20 @@ import {
import { CyclotronJobInputs } from 'lib/components/CyclotronJob/CyclotronJobInputs'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { LemonField } from 'lib/lemon-ui/LemonField'
-import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'
import { groupsModel } from '~/models/groupsModel'
-import { EntityTypes, HogFunctionConfigurationType, HogFunctionMappingType } from '~/types'
+import { NodeKind } from '~/queries/schema/schema-general'
+import {
+ ChartDisplayCategory,
+ CyclotronJobFiltersType,
+ HogFunctionConfigurationType,
+ HogFunctionMappingType,
+} from '~/types'
import { hogFunctionConfigurationLogic } from '../configuration/hogFunctionConfigurationLogic'
+import { cdpFiltersToSeries, seriesToCdpFilters } from '../filters/cdpFilterSeries'
export const humanize = (value: string): string => {
const fallback = typeof value === 'string' ? (value ?? '') : ''
@@ -100,9 +107,15 @@ export function HogFunctionMapping({
{!hideEventFilter && (
<>
<LemonLabel>Match events and actions</LemonLabel>
- <ActionFilter
- filters={mapping.filters ?? ({} as any)}
- setFilters={(f: any) => onChange({ ...mapping, filters: f })}
+ <SeriesActionFilter
+ series={cdpFiltersToSeries(mapping.filters)}
+ onChange={(series) =>
+ onChange({
+ ...mapping,
+ filters: seriesToCdpFilters(series) as unknown as CyclotronJobFiltersType,
+ })
+ }
+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
typeKey={`match-group-${index}`}
mathAvailability={MathAvailability.None}
hideRename
@@ -121,11 +134,7 @@ export function HogFunctionMapping({
...groupsTaxonomicTypes,
]}
propertyFiltersPopover
- addFilterDefaultOptions={{
- id: '$pageview',
- name: '$pageview',
- type: EntityTypes.EVENTS,
- }}
+ newSeriesDefaults={{ kind: NodeKind.EventsNode, event: '$pageview', name: '$pageview' }}
buttonProps={{
type: 'secondary',
}}
diff --git a/frontend/src/scenes/settings/environment/UsageMetricsConfig.tsx b/frontend/src/scenes/settings/environment/UsageMetricsConfig.tsx
index d1e8555cd0c8..6a96466d7b1e 100644
--- a/frontend/src/scenes/settings/environment/UsageMetricsConfig.tsx
+++ b/frontend/src/scenes/settings/environment/UsageMetricsConfig.tsx
@@ -24,14 +24,17 @@ import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { groupsAccessLogic } from 'lib/introductions/groupsAccessLogic'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
-import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
+import { cdpFiltersToSeries, seriesToCdpFilters } from 'scenes/hog-functions/filters/cdpFilterSeries'
+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'
-import { AnyPropertyFilter, EntityTypes, FilterType } from '~/types'
+import { NodeKind } from '~/queries/schema/schema-general'
+import { AnyPropertyFilter, ChartDisplayCategory } from '~/types'
import type { GroupUsageMetricApi } from 'products/customer_analytics/frontend/generated/api.schemas'
import {
+ UsageMetricEventFilters,
UsageMetricFiltersDataWarehouse,
UsageMetricFormData,
actionFilterValueToSavedFilters,
@@ -106,7 +109,10 @@ function UsageMetricsTable(): JSX.Element {
label: 'Edit',
onClick: () => {
openModal()
- setUsageMetricValues({ ...metric, filters: (metric.filters ?? {}) as FilterType })
+ setUsageMetricValues({
+ ...metric,
+ filters: (metric.filters ?? {}) as UsageMetricEventFilters,
+ })
reportUsageMetricsUpdateButtonClicked()
},
disabledReason: restrictedReason,
@@ -258,12 +264,15 @@ function UsageMetricsForm(): JSX.Element {
const actionFilterValue = savedFiltersToActionFilterValue(value)
return (
<>
- <ActionFilter
+ <SeriesActionFilter
bordered
- filters={actionFilterValue}
- setFilters={(payload) => {
- onChange(actionFilterValueToSavedFilters(payload, source))
+ series={cdpFiltersToSeries(actionFilterValue)}
+ onChange={(series) => {
+ onChange(
+ actionFilterValueToSavedFilters(seriesToCdpFilters(series), source)
+ )
}}
+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
typeKey="usage-metric-filters"
mathAvailability={MathAvailability.None}
hideRename
@@ -280,10 +289,10 @@ function UsageMetricsForm(): JSX.Element {
{ key: 'timestamp_field', label: 'Timestamp column', allowHogQL: true },
{ key: 'key_field', label: 'Group key column' },
]}
- addFilterDefaultOptions={{
- id: '$pageview',
+ newSeriesDefaults={{
+ kind: NodeKind.EventsNode,
+ event: '$pageview',
name: '$pageview',
- type: EntityTypes.EVENTS,
}}
buttonCopy={
(actionFilterValue?.events ?? []).length > 0
diff --git a/frontend/src/scenes/settings/environment/usageMetricsConfigLogic.ts b/frontend/src/scenes/settings/environment/usageMetricsConfigLogic.ts
index b6aa8451a75f..1be97cadae46 100644
--- a/frontend/src/scenes/settings/environment/usageMetricsConfigLogic.ts
+++ b/frontend/src/scenes/settings/environment/usageMetricsConfigLogic.ts
@@ -4,11 +4,12 @@ import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from
import { lazyLoaders } from 'kea-loaders'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
+import { CdpFilterEntities } from 'scenes/hog-functions/filters/cdpFilterSeries'
import { projectLogic } from 'scenes/projectLogic'
import { teamLogic } from 'scenes/teamLogic'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-import { FilterType } from '~/types'
+import { AnyPropertyFilter } from '~/types'
import {
groupsTypesMetricsCreate,
@@ -29,9 +30,14 @@ export type UsageMetricFiltersDataWarehouse = {
key_field?: string | null
}
+export type UsageMetricEventFilters = Partial<CdpFilterEntities> & {
+ properties?: AnyPropertyFilter[]
+ filter_test_accounts?: boolean
+}
+
export type UsageMetricFormData = Omit<GroupUsageMetricApi, 'id' | 'filters'> & {
id?: string
- filters: FilterType | UsageMetricFiltersDataWarehouse
+ filters: UsageMetricEventFilters | UsageMetricFiltersDataWarehouse
}
const NEW_USAGE_METRIC: UsageMetricFormData = {
@@ -57,10 +63,10 @@ export function getMetricSource(filters: UsageMetricFormData['filters']): UsageM
}
/**
- * Render the saved filters in the standard FilterType shape that ActionFilter expects.
+ * Render the saved filters in the matcher shape the event picker reads.
* DW metrics get hoisted into a single `data_warehouse` entry; events metrics pass through.
*/
-export function savedFiltersToActionFilterValue(filters: UsageMetricFormData['filters']): FilterType {
+export function savedFiltersToActionFilterValue(filters: UsageMetricFormData['filters']): UsageMetricEventFilters {
if (getMetricSource(filters) === 'data_warehouse') {
const dw = filters as UsageMetricFiltersDataWarehouse
return {
@@ -74,18 +80,18 @@ export function savedFiltersToActionFilterValue(filters: UsageMetricFormData['fi
key_field: dw.key_field,
},
],
- } as FilterType
+ }
}
- return (filters ?? {}) as FilterType
+ return (filters ?? {}) as UsageMetricEventFilters
}
/**
- * Translate ActionFilter's FilterType payload back into our saved shape (events shape or DW shape).
+ * Translate the event picker's matcher payload back into our saved shape (events shape or DW shape).
* If both branches are populated (the user just added an entry of the opposite type), resolve by
* switching to whichever side just received the new entry — using `prevSource` as the reference.
*/
export function actionFilterValueToSavedFilters(
- payload: FilterType,
+ payload: UsageMetricEventFilters,
prevSource: UsageMetricSource
): UsageMetricFormData['filters'] {
const dwEntries = (payload.data_warehouse ?? []) as Array<Record<string, any>>
@@ -110,7 +116,7 @@ export function actionFilterValueToSavedFilters(
actions: actionEntries,
properties: payload.properties ?? [],
filter_test_accounts: payload.filter_test_accounts,
- } as FilterType
+ }
}
// Hardcoded to 0 — the backend model is coupled to groups but will be refactored to be group-agnostic
diff --git a/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx b/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx
index 0dd780d66354..5001838bd3c6 100644
--- a/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/filters/HogFlowFilters.tsx
@@ -4,14 +4,15 @@ import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { AllowedProperties, TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { isOperatorSemver } from 'lib/utils/operators'
-import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
+import { cdpFiltersToSeries, seriesToCdpFilters } from 'scenes/hog-functions/filters/cdpFilterSeries'
+import { SeriesActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'
import { groupsModel } from '~/models/groupsModel'
import { PropValue } from '~/models/propertyDefinitionsModel'
import { defaultDataTableColumns } from '~/queries/nodes/DataTable/utils'
import { DatabaseSchemaField, NodeKind } from '~/queries/schema/schema-general'
-import { FilterType, PropertyDefinition, PropertyOperator } from '~/types'
+import { AnyPropertyFilter, ChartDisplayCategory, PropertyDefinition, PropertyOperator } from '~/types'
import { workflowLogic } from '../../workflowLogic'
import { HogFlowAction } from '../types'
@@ -89,7 +90,7 @@ export function HogFlowEventFilters({
}
// WorkflowVariables comes first so its dedicated tab renders first in the category list.
- // ActionFilter does not pipe `taxonomicFilterOptionsFromProp`, so the All/Suggestions tab
+ // SeriesActionFilter does not pipe `taxonomicFilterOptionsFromProp`, so the All/Suggestions tab
// does not aggregate variables here — variable surfacing in All/Suggestions only kicks in
// for the property-level filter (HogFlowPropertyFilters below).
const propertyTaxonomicGroupTypes = [
@@ -106,12 +107,10 @@ export function HogFlowEventFilters({
}
return (
- <ActionFilter
- filters={filters ?? {}}
- setFilters={(filters: FilterType): void => {
- // TODO: Improve the types here...
- setFilters(filters as HogFlowAction['filters'])
- }}
+ <SeriesActionFilter
+ series={cdpFiltersToSeries(filters)}
+ onChange={(series) => setFilters(seriesToCdpFilters(series))}
+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
typeKey={typeKey ?? 'hogflow-filters'}
mathAvailability={MathAvailability.None}
hideRename
@@ -169,7 +168,7 @@ export function HogFlowPropertyFilters({
return (
<PropertyFilters
propertyFilters={filters?.properties}
- onChange={(properties: FilterType['properties']): void => {
+ onChange={(properties: AnyPropertyFilter[]): void => {
setFilters({ ...filters, properties: properties ?? [] } as HogFlowAction['filters'])
}}
pageKey={`HogFlowPropertyFilters.${filtersKey}`}