: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(insights): remove the legacy filters-to-query converter (#100749)
Thomas Obermüller2547b6ddda2e
diff --git a/frontend/src/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries.test.tsnew file mode 100644index 000000000000..58226454c33b--- /dev/null+++ b/frontend/src/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries.test.ts@@ -0,0 +1,150 @@+import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'++import { NodeKind } from '~/queries/schema/schema-general'+import { ActionFilter, BaseMathType, FunnelDatawarehouseFilter, LifecycleDatawarehouseFilter } from '~/types'++import { actionsAndEventsToSeries } from './actionsAndEventsToSeries'++describe('actionsAndEventsToSeries', () => {+ it('sorts series by order', () => {+ const actions: ActionFilter[] = [{ type: 'actions', id: '1', order: 1, name: 'item2', math: 'total' }]+ const events: ActionFilter[] = [+ { id: '$pageview', type: 'events', order: 0, name: 'item1' },+ { id: '$autocapture', type: 'events', order: 2, name: 'item3' },+ ]++ const result = actionsAndEventsToSeries({ actions, events }, false, MathAvailability.None)++ expect(result[0].name).toEqual('item1')+ expect(result[1].name).toEqual('item2')+ expect(result[2].name).toEqual('item3')+ })++ it('sorts elements without order first', () => {+ const actions: ActionFilter[] = [{ type: 'actions', id: '1', name: 'itemWithOrder', math: 'total' }]+ const events: ActionFilter[] = [+ { id: '$pageview', type: 'events', order: 0, name: 'item1' },+ { id: '$autocapture', type: 'events', order: 2, name: 'item2' },+ ]++ const result = actionsAndEventsToSeries({ actions, events }, false, MathAvailability.None)++ expect(result[0].name).toEqual('itemWithOrder')+ expect(result[1].name).toEqual('item1')+ expect(result[2].name).toEqual('item2')+ })++ it('assumes typeless series is an event series', () => {+ const events: ActionFilter[] = [{ id: '$pageview', order: 0, name: 'item1' } as any]++ const result = actionsAndEventsToSeries({ events }, false, MathAvailability.None)++ expect(result[0].kind).toEqual(NodeKind.EventsNode)+ })++ it('converts funnels math types', () => {+ const actions: ActionFilter[] = [+ { type: 'actions', id: '1', order: 0, name: 'item1', math: 'total' },+ { type: 'actions', id: '1', order: 1, name: 'item2', math: 'first_time_for_user' },+ ]+ const events: ActionFilter[] = [+ { id: '$pageview', type: 'events', order: 2, name: 'item3', math: 'total' },+ { id: '$autocapture', type: 'events', order: 3, name: 'item4', math: 'first_time_for_user' },+ ]++ const result = actionsAndEventsToSeries({ events, actions }, false, MathAvailability.FunnelsOnly)++ expect(result).toEqual([+ {+ kind: NodeKind.ActionsNode,+ id: '1',+ name: 'item1',+ },+ {+ kind: NodeKind.ActionsNode,+ id: '1',+ name: 'item2',+ math: BaseMathType.FirstTimeForUser,+ },+ {+ kind: NodeKind.EventsNode,+ event: '$pageview',+ name: 'item3',+ },+ {+ kind: NodeKind.EventsNode,+ event: '$autocapture',+ name: 'item4',+ math: BaseMathType.FirstTimeForUser,+ },+ ])+ })++ it('converts lifecycle data warehouse series to lifecycle nodes', () => {+ const data_warehouse: LifecycleDatawarehouseFilter[] = [+ {+ type: 'data_warehouse',+ id: 'warehouse_orders',+ order: 0,+ name: 'Orders',+ table_name: 'warehouse_orders',+ timestamp_field: 'timestamp',+ aggregation_target_field: 'order_id',+ created_at_field: 'created_at',+ },+ ]++ const result = actionsAndEventsToSeries(+ { data_warehouse },+ true,+ MathAvailability.None,+ NodeKind.LifecycleDataWarehouseNode+ )++ expect(result).toEqual([+ {+ kind: NodeKind.LifecycleDataWarehouseNode,+ id: 'warehouse_orders',+ name: 'Orders',+ table_name: 'warehouse_orders',+ timestamp_field: 'timestamp',+ aggregation_target_field: 'order_id',+ created_at_field: 'created_at',+ },+ ])+ })++ it('converts funnels data warehouse series to funnels nodes', () => {+ const data_warehouse: FunnelDatawarehouseFilter[] = [+ {+ type: 'data_warehouse' as const,+ id: 'warehouse_orders',+ order: 0,+ name: 'Orders',+ table_name: 'warehouse_orders',+ timestamp_field: 'timestamp',+ id_field: 'id',+ aggregation_target_field: 'person_id',+ },+ ]++ const result = actionsAndEventsToSeries(+ { data_warehouse },+ true,+ MathAvailability.FunnelsOnly,+ NodeKind.FunnelsDataWarehouseNode+ )++ expect(result).toEqual([+ {+ kind: NodeKind.FunnelsDataWarehouseNode,+ id: 'warehouse_orders',+ name: 'Orders',+ table_name: 'warehouse_orders',+ timestamp_field: 'timestamp',+ id_field: 'id',+ aggregation_target_field: 'person_id',+ },+ ])+ })+})diff --git a/frontend/src/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries.ts b/frontend/src/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries.tsnew file mode 100644index 000000000000..a99dab29945e--- /dev/null+++ b/frontend/src/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries.ts@@ -0,0 +1,259 @@+import { objectCleanWithEmpty } from 'lib/utils/objects'+import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'++import {+ ActionsNode,+ AnyDataWarehouseNode,+ AnyEntityNode,+ DataWarehouseNode,+ EventsNode,+ FunnelsDataWarehouseNode,+ GroupNode,+ LifecycleDataWarehouseNode,+ MathType,+ NodeKind,+} from '~/queries/schema/schema-general'+import { setLatestVersionsOnQuery } from '~/queries/utils'+import {+ ActionFilter,+ AnyDataWarehouseFilter,+ BaseMathType,+ CalendarHeatmapMathType,+ EntityTypes,+ FunnelDatawarehouseFilter,+ FunnelMathType,+ GroupMathType,+ HogQLMathType,+ LifecycleDatawarehouseFilter,+ RetentionEntity,+ TrendsDataWarehouseFilter,+ isDataWarehouseFilter,+ isGroupFilter,+} from '~/types'++import { cleanEntityProperties } from './cleanProperties'++export const actorsOnlyMathTypes = [+ BaseMathType.UniqueUsers,+ BaseMathType.WeeklyActiveUsers,+ BaseMathType.MonthlyActiveUsers,+ GroupMathType.UniqueGroup,+ HogQLMathType.HogQL,+]++const funnelsMathTypes = [FunnelMathType.FirstTimeForUser, FunnelMathType.FirstTimeForUserWithFilters]++const calendarHeatmapMathTypes = [CalendarHeatmapMathType.TotalCount, CalendarHeatmapMathType.UniqueUsers]++export type FilterTypeActionsAndEvents = {+ events?: ActionFilter[]+ actions?: ActionFilter[]+ data_warehouse?: AnyDataWarehouseFilter[]+ new_entity?: ActionFilter[]+ groups?: ActionFilter[]+}++type DataWarehouseNodeKind =+ | NodeKind.DataWarehouseNode+ | NodeKind.FunnelsDataWarehouseNode+ | NodeKind.LifecycleDataWarehouseNode++export const legacyEntityToNode = (+ entity: ActionFilter | AnyDataWarehouseFilter,+ includeProperties: boolean,+ mathAvailability: MathAvailability,+ dataWarehouseNodeKind: DataWarehouseNodeKind = NodeKind.DataWarehouseNode+): AnyEntityNode<AnyDataWarehouseNode> | GroupNode<AnyDataWarehouseNode> => {+ let shared: Partial<+ EventsNode | ActionsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | GroupNode+ > = {+ name: entity.name || undefined,+ custom_name: entity.custom_name || undefined,+ }++ if (isDataWarehouseFilter(entity)) {+ shared = {+ ...shared,+ timestamp_field: entity.timestamp_field || undefined,+ table_name: entity.table_name || undefined,+ ...(dataWarehouseNodeKind === NodeKind.LifecycleDataWarehouseNode+ ? {+ aggregation_target_field: (entity as LifecycleDatawarehouseFilter).aggregation_target_field,+ created_at_field: (entity as LifecycleDatawarehouseFilter).created_at_field,+ }+ : dataWarehouseNodeKind === NodeKind.FunnelsDataWarehouseNode+ ? {+ id_field: (entity as FunnelDatawarehouseFilter).id_field || undefined,+ aggregation_target_field:+ (entity as FunnelDatawarehouseFilter).aggregation_target_field || undefined,+ }+ : {+ id_field: (entity as TrendsDataWarehouseFilter).id_field || undefined,+ distinct_id_field: (entity as TrendsDataWarehouseFilter).distinct_id_field || undefined,+ }),+ } as DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode+ }++ if (isGroupFilter(entity)) {+ shared = {+ ...shared,+ operator: entity.operator || undefined,+ nodes: (entity.nestedFilters || []).map((v) =>+ legacyEntityToNode(+ v as ActionFilter | AnyDataWarehouseFilter,+ includeProperties,+ mathAvailability,+ dataWarehouseNodeKind+ )+ ),+ } as GroupNode+ }++ if (includeProperties) {+ shared = { ...shared, properties: cleanEntityProperties(entity.properties) } as any+ }++ if (mathAvailability !== MathAvailability.None) {+ // only trends, funnels, and stickiness insights support math.+ // transition to then default math for stickiness, when an unsupported math type is encountered.+ if (mathAvailability === MathAvailability.ActorsOnly && !actorsOnlyMathTypes.includes(entity.math as any)) {+ shared = {+ ...shared,+ math: BaseMathType.UniqueUsers,+ }+ } else if (mathAvailability === MathAvailability.FunnelsOnly) {+ if (funnelsMathTypes.includes(entity.math as any)) {+ shared = {+ ...shared,+ math: entity.math as MathType,+ }+ }+ if (entity.optionalInFunnel) {+ shared = {+ ...shared,+ optionalInFunnel: true,+ }+ }+ } else if (mathAvailability === MathAvailability.CalendarHeatmapOnly) {+ if (calendarHeatmapMathTypes.includes(entity.math as any)) {+ shared = {+ ...shared,+ math: entity.math as MathType,+ }+ }+ } else {+ shared = {+ ...shared,+ math: entity.math || 'total',+ math_property: entity.math_property,+ math_property_type: entity.math_property_type,+ math_hogql: entity.math_hogql,+ math_group_type_index: entity.math_group_type_index,+ } as any+ }+ }++ if (entity.type === 'actions') {+ return setLatestVersionsOnQuery(+ objectCleanWithEmpty({+ kind: NodeKind.ActionsNode,+ id: entity.id,+ ...shared,+ })+ ) as any+ } else if (entity.type === 'data_warehouse') {+ return setLatestVersionsOnQuery(+ objectCleanWithEmpty({+ kind: dataWarehouseNodeKind,+ id: entity.id,+ ...shared,+ })+ ) as any+ } else if (entity.type === EntityTypes.GROUPS) {+ return setLatestVersionsOnQuery(+ objectCleanWithEmpty({+ kind: NodeKind.GroupNode,+ ...shared,+ })+ ) as any+ }+ return setLatestVersionsOnQuery(+ objectCleanWithEmpty({+ kind: NodeKind.EventsNode,+ event: entity.id,+ ...shared,+ })+ ) as any+}++type FilterTypeActionsAndEventsWithGroups = FilterTypeActionsAndEvents & { groups: ActionFilter[] }+type FilterTypeActionsAndEventsWithoutGroups = Omit<FilterTypeActionsAndEvents, 'groups'> & { groups?: undefined }++export function actionsAndEventsToSeries(+ filters: FilterTypeActionsAndEventsWithGroups,+ includeProperties: boolean,+ includeMath: MathAvailability,+ dataWarehouseNodeKind?: NodeKind.DataWarehouseNode+): (AnyEntityNode | GroupNode)[]+export function actionsAndEventsToSeries(+ filters: FilterTypeActionsAndEventsWithoutGroups,+ includeProperties: boolean,+ includeMath: MathAvailability,+ dataWarehouseNodeKind: NodeKind.LifecycleDataWarehouseNode+): AnyEntityNode<LifecycleDataWarehouseNode>[]+export function actionsAndEventsToSeries(+ filters: FilterTypeActionsAndEventsWithoutGroups,+ includeProperties: boolean,+ includeMath: MathAvailability,+ dataWarehouseNodeKind: NodeKind.FunnelsDataWarehouseNode+): AnyEntityNode<FunnelsDataWarehouseNode>[]+export function actionsAndEventsToSeries(+ filters: FilterTypeActionsAndEventsWithoutGroups,+ includeProperties: boolean,+ includeMath: MathAvailability,+ dataWarehouseNodeKind?: NodeKind.DataWarehouseNode+): AnyEntityNode[]+export function actionsAndEventsToSeries(+ { actions, events, data_warehouse, new_entity, groups }: FilterTypeActionsAndEvents,+ includeProperties: boolean,+ includeMath: MathAvailability,+ dataWarehouseNodeKind: DataWarehouseNodeKind = NodeKind.DataWarehouseNode+): (AnyEntityNode<AnyDataWarehouseNode> | GroupNode<AnyDataWarehouseNode>)[] {+ const series: (AnyEntityNode<AnyDataWarehouseNode> | GroupNode<AnyDataWarehouseNode>)[] = [+ ...(actions || []),+ ...(events || []),+ ...(data_warehouse || []),+ ...(new_entity || []),+ ...(groups || []),+ ]+ .sort((a, b) => (a.order || b.order ? (!a.order ? -1 : !b.order ? 1 : a.order - b.order) : 0))+ .map((f) => legacyEntityToNode(f, includeProperties, includeMath, dataWarehouseNodeKind))++ return series+}++export const sanitizeRetentionEntity = (entity: RetentionEntity | undefined): RetentionEntity | undefined => {+ if (!entity) {+ return undefined+ }++ const { id, kind, name, type, order, uuid, custom_name } = entity+ return {+ ...('id' in entity ? { id } : {}),+ ...('kind' in entity ? { kind } : {}),+ ...('name' in entity ? { name } : {}),+ ...('type' in entity ? { type } : {}),+ ...('order' in entity ? { order } : {}),+ ...('uuid' in entity ? { uuid } : {}),+ ...('custom_name' in entity ? { custom_name } : {}),+ }+}++/** Expand GroupNodes into individual EventsNode/ActionsNode for insight types that don't support GroupNode */+export const expandGroupNodes = (+ series: (EventsNode | ActionsNode | DataWarehouseNode | GroupNode)[]+): (EventsNode | ActionsNode | DataWarehouseNode)[] => {+ return series.flatMap((item) =>+ item.kind === NodeKind.GroupNode ? (item.nodes as (EventsNode | ActionsNode | DataWarehouseNode)[]) : [item]+ )+}diff --git a/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.test.tsindex 0b34cc662c64..3735bd8c8450 100644--- a/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.test.ts+++ b/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.test.ts@@ -1,78 +1,4 @@-import { cleanEntityProperties, cleanGlobalProperties } from './cleanProperties'--describe('cleanGlobalProperties', () => {- it('handles empty properties', () => {- const properties = {}-- const result = cleanGlobalProperties(properties)-- expect(result).toEqual(undefined)- })-- it('handles old style properties', () => {- const properties = { utm_medium__icontains: 'email' }-- const result = cleanGlobalProperties(properties)-- expect(result).toEqual({- type: 'AND',- values: [- {- type: 'AND',- values: [- {- key: 'utm_medium',- operator: 'icontains',- type: 'event',- value: 'email',- },- ],- },- ],- })- })-- it('handles property filter lists', () => {- const properties = [{ key: 'id', type: 'cohort', value: 636, operator: null }]-- const result = cleanGlobalProperties(properties)-- expect(result).toEqual({- type: 'AND',- values: [{ type: 'AND', values: [{ key: 'id', type: 'cohort', value: 636, operator: null }] }],- })- })-- it('handles property group filters', () => {- const properties = {- type: 'AND',- values: [{ type: 'AND', values: [{ key: 'id', type: 'cohort', value: 850, operator: null }] }],- }-- const result = cleanGlobalProperties(properties)-- expect(result).toEqual(properties)- })-- it('handles property group filters values', () => {- const properties = {- type: 'AND',- values: [{ key: 'id', type: 'cohort', value: 850, operator: null }],- }-- const result = cleanGlobalProperties(properties)-- expect(result).toEqual({- type: 'AND',- values: [- {- type: 'AND',- values: [{ key: 'id', type: 'cohort', value: 850, operator: null }],- },- ],- })- })-})+import { cleanEntityProperties } from './cleanProperties'describe('cleanEntityProperties', () => {it('handles empty properties', () => {diff --git a/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.ts b/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.tsindex dff537f0e50b..f2043e50b2d4 100644--- a/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.ts+++ b/frontend/src/queries/nodes/InsightQuery/utils/cleanProperties.ts@@ -1,55 +1,4 @@-import {- AnyPropertyFilter,- EventPropertyFilter,- PropertyFilterType,- PropertyGroupFilter,- PropertyGroupFilterValue,- PropertyOperator,-} from '~/types'--/** Cleans properties of insights. These are either a simple list of property filters or a property group filter. The property group filter has- * a type (AND, OR) and a list of values that are property group filter values, which are either property group filter values or a simple list of- * property filters.- */-export const cleanGlobalProperties = (- properties: Record<string, any> | Record<string, any>[] | undefined-): AnyPropertyFilter[] | PropertyGroupFilter | undefined => {- if (- properties == undefined ||- (Array.isArray(properties) && properties.length == 0) ||- Object.keys(properties).length == 0- ) {- // empty properties- return undefined- } else if (isOldStyleProperties(properties)) {- // old style properties- properties = transformOldStyleProperties(properties)- properties = {- type: 'AND',- values: [{ type: 'AND', values: properties }],- }- return cleanPropertyGroupFilter(properties)- } else if (Array.isArray(properties)) {- // list of property filters- properties = {- type: 'AND',- values: [{ type: 'AND', values: properties }],- }- return cleanPropertyGroupFilter(properties)- } else if (- (properties['type'] === 'AND' || properties['type'] === 'OR') &&- !properties['values'].some((property: any) => property['type'] === 'AND' || property['type'] === 'OR')- ) {- // property group filter value- properties = {- type: 'AND',- values: [properties],- }- return cleanPropertyGroupFilter(properties)- }- // property group filter- return cleanPropertyGroupFilter(properties)-}+import { AnyPropertyFilter, EventPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'/** Cleans properties of entities i.e. event and action nodes. These are a simple list of property filters. */export const cleanEntityProperties = (@@ -78,29 +27,6 @@ export const cleanEntityProperties = (throw new Error('Unexpected format of entity properties.')}-const cleanPropertyGroupFilter = (properties: Record<string, any>): PropertyGroupFilter => {- properties['values'] = cleanPropertyGroupFilterValues(properties.values)- return properties as PropertyGroupFilter-}--const cleanPropertyGroupFilterValues = (- properties: (AnyPropertyFilter | PropertyGroupFilterValue)[]-): (AnyPropertyFilter | PropertyGroupFilterValue)[] => {- return properties.map(cleanPropertyGroupFilterValue)-}--const cleanPropertyGroupFilterValue = (- property: AnyPropertyFilter | PropertyGroupFilterValue-): AnyPropertyFilter | PropertyGroupFilterValue => {- if (property['type'] == 'AND' || property['type'] == 'OR') {- // property group filter value- property['values'] = cleanPropertyGroupFilterValues(property['values'] as PropertyGroupFilterValue[])- return property- }- // property filter- return cleanProperty(property)-}-const cleanProperty = (property: Record<string, any>): AnyPropertyFilter => {if (Object.keys(property).length === 0) {return { type: PropertyFilterType.HogQL, key: 'true' }diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.tsdeleted file mode 100644index e0320e60640f..000000000000--- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts+++ /dev/null@@ -1,1786 +0,0 @@-import { FunnelLayout, ShownAsValue } from 'lib/constants'-import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'--import {- FunnelsQuery,- InsightQueryNode,- LifecycleQuery,- NodeKind,- PathsQuery,- RetentionQuery,- StickinessQuery,- TrendsQuery,-} from '~/queries/schema/schema-general'-import {- ActionFilter,- BaseMathType,- BreakdownAttributionType,- ChartDisplayType,- FilterLogicalOperator,- FunnelDatawarehouseFilter,- FilterType,- FunnelConversionWindowTimeUnit,- FunnelPathType,- FunnelStepReference,- FunnelVizType,- FunnelsFilterType,- GroupMathType,- InsightType,- LifecycleDatawarehouseFilter,- LifecycleFilterType,- PathType,- PathsFilterType,- PropertyFilterType,- PropertyMathType,- PropertyOperator,- RetentionFilterType,- RetentionPeriod,- StepOrderValue,- StickinessFilterType,- TrendsFilterType,-} from '~/types'--import {- actionsAndEventsToSeries,- filtersToQueryNode,- hiddenLegendKeysToBreakdowns,- hiddenLegendKeysToIndexes,-} from './filtersToQueryNode'--describe('actionsAndEventsToSeries', () => {- it('sorts series by order', () => {- const actions: ActionFilter[] = [{ type: 'actions', id: '1', order: 1, name: 'item2', math: 'total' }]- const events: ActionFilter[] = [- { id: '$pageview', type: 'events', order: 0, name: 'item1' },- { id: '$autocapture', type: 'events', order: 2, name: 'item3' },- ]-- const result = actionsAndEventsToSeries({ actions, events }, false, MathAvailability.None)-- expect(result[0].name).toEqual('item1')- expect(result[1].name).toEqual('item2')- expect(result[2].name).toEqual('item3')- })-- it('sorts elements without order first', () => {- const actions: ActionFilter[] = [{ type: 'actions', id: '1', name: 'itemWithOrder', math: 'total' }]- const events: ActionFilter[] = [- { id: '$pageview', type: 'events', order: 0, name: 'item1' },- { id: '$autocapture', type: 'events', order: 2, name: 'item2' },- ]-- const result = actionsAndEventsToSeries({ actions, events }, false, MathAvailability.None)-- expect(result[0].name).toEqual('itemWithOrder')- expect(result[1].name).toEqual('item1')- expect(result[2].name).toEqual('item2')- })-- it('assumes typeless series is an event series', () => {- const events: ActionFilter[] = [{ id: '$pageview', order: 0, name: 'item1' } as any]-- const result = actionsAndEventsToSeries({ events }, false, MathAvailability.None)-- expect(result[0].kind).toEqual(NodeKind.EventsNode)- })-- it('converts funnels math types', () => {- const actions: ActionFilter[] = [- { type: 'actions', id: '1', order: 0, name: 'item1', math: 'total' },- { type: 'actions', id: '1', order: 1, name: 'item2', math: 'first_time_for_user' },- ]- const events: ActionFilter[] = [- { id: '$pageview', type: 'events', order: 2, name: 'item3', math: 'total' },- { id: '$autocapture', type: 'events', order: 3, name: 'item4', math: 'first_time_for_user' },- ]-- const result = actionsAndEventsToSeries({ events, actions }, false, MathAvailability.FunnelsOnly)-- expect(result).toEqual([- {- kind: NodeKind.ActionsNode,- id: '1',- name: 'item1',- },- {- kind: NodeKind.ActionsNode,- id: '1',- name: 'item2',- math: BaseMathType.FirstTimeForUser,- },- {- kind: NodeKind.EventsNode,- event: '$pageview',- name: 'item3',- },- {- kind: NodeKind.EventsNode,- event: '$autocapture',- name: 'item4',- math: BaseMathType.FirstTimeForUser,- },- ])- })-- it('converts lifecycle data warehouse series to lifecycle nodes', () => {- const data_warehouse: LifecycleDatawarehouseFilter[] = [- {- type: 'data_warehouse',- id: 'warehouse_orders',- order: 0,- name: 'Orders',- table_name: 'warehouse_orders',- timestamp_field: 'timestamp',- aggregation_target_field: 'order_id',- created_at_field: 'created_at',- },- ]-- const result = actionsAndEventsToSeries(- { data_warehouse },- true,- MathAvailability.None,- NodeKind.LifecycleDataWarehouseNode- )-- expect(result).toEqual([- {- kind: NodeKind.LifecycleDataWarehouseNode,- id: 'warehouse_orders',- name: 'Orders',- table_name: 'warehouse_orders',- timestamp_field: 'timestamp',- aggregation_target_field: 'order_id',- created_at_field: 'created_at',- },- ])- })-- it('converts funnels data warehouse series to funnels nodes', () => {- const data_warehouse: FunnelDatawarehouseFilter[] = [- {- type: 'data_warehouse' as const,- id: 'warehouse_orders',- order: 0,- name: 'Orders',- table_name: 'warehouse_orders',- timestamp_field: 'timestamp',- id_field: 'id',- aggregation_target_field: 'person_id',- },- ]-- const result = actionsAndEventsToSeries(- { data_warehouse },- true,- MathAvailability.FunnelsOnly,- NodeKind.FunnelsDataWarehouseNode- )-- expect(result).toEqual([- {- kind: NodeKind.FunnelsDataWarehouseNode,- id: 'warehouse_orders',- name: 'Orders',- table_name: 'warehouse_orders',- timestamp_field: 'timestamp',- id_field: 'id',- aggregation_target_field: 'person_id',- },- ])- })-})--describe('hiddenLegendKeysToIndexes', () => {- it('converts legend keys', () => {- const keys: Record<string, boolean | undefined> = {- 1: true,- 2: false,- 3: undefined,- }-- const result = hiddenLegendKeysToIndexes(keys)-- expect(result).toEqual([1])- })-- it('handles undefined legend keys', () => {- const keys = undefined-- const result = hiddenLegendKeysToIndexes(keys)-- expect(result).toEqual(undefined)- })-- it('ignores invalid keys', () => {- const keys: Record<string, boolean | undefined> = {- Opera: true,- 'events/$pageview/0/Baseline': true,- 1: true,- }-- const result = hiddenLegendKeysToIndexes(keys)-- expect(result).toEqual([1])- })-})--describe('hiddenLegendKeysToBreakdowns', () => {- it('converts legend keys', () => {- const keys: Record<string, boolean | undefined> = {- Chrome: true,- 'Chrome iOS': true,- Firefox: false,- Safari: undefined,- }-- const result = hiddenLegendKeysToBreakdowns(keys)-- expect(result).toEqual(['Chrome', 'Chrome iOS'])- })-- it('handles undefined legend keys', () => {- const keys = undefined-- const result = hiddenLegendKeysToBreakdowns(keys)-- expect(result).toEqual(undefined)- })-- it('converts legacy format', () => {- const keys: Record<string, boolean | undefined> = {- Opera: true,- 'events/$pageview/0/Baseline': true,- 1: true,- }-- const result = hiddenLegendKeysToBreakdowns(keys)-- expect(result).toEqual(['Opera', 'Baseline'])- })-- it('ignores digit-only keys', () => {- const keys: Record<string, boolean | undefined> = {- Opera: true,- 1: true,- }-- const result = hiddenLegendKeysToBreakdowns(keys)-- expect(result).toEqual(['Opera'])- })-})--describe('filtersToQueryNode', () => {- describe('global filters', () => {- it('converts test account filter', () => {- const filters: Partial<FilterType> = {- insight: InsightType.RETENTION,- filter_test_accounts: true,- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.RetentionQuery,- filterTestAccounts: true,- retentionFilter: {- meanRetentionCalculation: 'simple',- },- } as InsightQueryNode- expect(result).toEqual(query)- })-- it('converts properties', () => {- const filters: Partial<FilterType> = {- insight: InsightType.RETENTION,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'email',- type: PropertyFilterType.Person,- value: 'is_set',- operator: PropertyOperator.IsSet,- },- ],- },- ],- },- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.RetentionQuery,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'email',- type: PropertyFilterType.Person,- value: 'is_set',- operator: PropertyOperator.IsSet,- },- ],- },- ],- },- retentionFilter: {- meanRetentionCalculation: 'simple',- },- } as InsightQueryNode- expect(result).toEqual(query)- })-- it('converts broken grouped properties', () => {- const filters: Partial<FilterType> = {- insight: InsightType.RETENTION,- properties: {- type: FilterLogicalOperator.And,- values: [- {- key: 'email',- type: PropertyFilterType.Person,- value: 'is_set',- operator: PropertyOperator.IsSet,- },- ] as any,- },- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.RetentionQuery,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'email',- type: PropertyFilterType.Person,- value: 'is_set',- operator: PropertyOperator.IsSet,- },- ],- },- ],- },- retentionFilter: {- meanRetentionCalculation: 'simple',- },- } as InsightQueryNode- expect(result).toEqual(query)- })-- it('converts date range', () => {- const filters: Partial<FilterType> = {- insight: InsightType.RETENTION,- date_to: '2021-12-08',- date_from: '2021-12-08',- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.RetentionQuery,- dateRange: {- date_to: '2021-12-08',- date_from: '2021-12-08',- },- retentionFilter: {- meanRetentionCalculation: 'simple',- },- } as InsightQueryNode- expect(result).toEqual(query)- })-- it('converts date range with explicit date setting', () => {- const filters: Partial<FilterType> = {- insight: InsightType.RETENTION,- date_to: '2021-12-08',- date_from: '2021-12-08',- explicit_date: 'y',- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.RetentionQuery,- dateRange: {- date_to: '2021-12-08',- date_from: '2021-12-08',- explicitDate: true,- },- retentionFilter: {- meanRetentionCalculation: 'simple',- },- } as InsightQueryNode- expect(result).toEqual(query)- })- })-- describe('filter with series', () => {- it('converts series', () => {- const filters: Partial<FilterType> = {- insight: InsightType.TRENDS,- events: [- { id: '$pageview', type: 'events', order: 0, name: 'item1' },- { id: '$autocapture', type: 'events', order: 2, name: 'item3' },- ],- actions: [{ type: 'actions', id: 1, order: 1, name: 'item2', math: 'total' }],- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: '$pageview',- name: 'item1',- math: BaseMathType.TotalCount,- },- {- kind: NodeKind.ActionsNode,- id: 1,- math: BaseMathType.TotalCount,- name: 'item2',- },- {- kind: NodeKind.EventsNode,- event: '$autocapture',- name: 'item3',- math: BaseMathType.TotalCount,- },- ],- }- expect(result).toEqual(query)- })-- it('converts interval', () => {- const filters: Partial<FilterType> = {- insight: InsightType.TRENDS,- interval: 'day',- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- interval: 'day',- series: [],- }- expect(result).toEqual(query)- })- })-- describe('trends filter', () => {- it('converts all properties', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- smoothing_intervals: 1,- show_legend: true,- hidden_legend_keys: { 0: true, 10: true },- compare: true,- compare_to: '-4d',- aggregation_axis_format: 'numeric',- aggregation_axis_prefix: '£',- aggregation_axis_postfix: '%',- decimal_places: 8,- x_axis_label: 'Signup date',- y_axis_label: 'Unique users',- breakdown_histogram_bin_count: 1,- formula: 'A+B',- shown_as: ShownAsValue.VOLUME,- display: ChartDisplayType.ActionsAreaGraph,- show_percent_stack_view: true,- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- trendsFilter: {- smoothingIntervals: 1,- showLegend: true,- hiddenLegendIndexes: [0, 10],- aggregationAxisFormat: 'numeric',- aggregationAxisPrefix: '£',- aggregationAxisPostfix: '%',- decimalPlaces: 8,- xAxisLabel: 'Signup date',- yAxisLabel: 'Unique users',- formula: 'A+B',- display: ChartDisplayType.ActionsAreaGraph,- showPercentStackView: true,- },- breakdownFilter: {- breakdown_histogram_bin_count: 1,- },- compareFilter: {- compare: true,- compare_to: '-4d',- },- series: [],- }- expect(result).toEqual(query)- })-- it('converts multiple breakdowns', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- breakdowns: [- {- type: 'event',- property: '$pathname',- normalize_url: true,- },- {- type: 'group',- property: '$num',- group_type_index: 0,- histogram_bin_count: 10,- },- ],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- breakdownFilter: {- breakdowns: [- {- type: 'event',- property: '$pathname',- normalize_url: true,- },- {- type: 'group',- property: '$num',- group_type_index: 0,- histogram_bin_count: 10,- },- ],- },- series: [],- }- expect(result).toEqual(query)- })-- it('converts legacy funnel breakdowns', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- breakdowns: [- {- type: 'event',- property: '$current_url',- },- {- property: '$pathname',- } as any,- ],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- breakdownFilter: {- breakdowns: [- {- type: 'event',- property: '$current_url',- },- {- type: 'event',- property: '$pathname',- },- ],- },- series: [],- }- expect(result).toEqual(query)- })-- it('does not add breakdown_type for multiple breakdowns', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- breakdowns: [- {- type: 'person',- property: '$browser',- },- ],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- breakdownFilter: {- breakdowns: [- {- type: 'person',- property: '$browser',- },- ],- breakdown_type: undefined,- },- series: [],- }- expect(result).toEqual(query)- })- })-- describe('funnels filter', () => {- it('converts all properties', () => {- const filters: Partial<FunnelsFilterType> = {- insight: InsightType.FUNNELS,- funnel_viz_type: FunnelVizType.Steps,- funnel_from_step: 1,- funnel_to_step: 2,- funnel_step_reference: FunnelStepReference.total,- funnel_step_breakdown: 1,- breakdown_attribution_type: BreakdownAttributionType.AllSteps,- breakdown_attribution_value: 1,- bin_count: 'auto',- funnel_window_interval_unit: FunnelConversionWindowTimeUnit.Day,- funnel_window_interval: 7,- funnel_order_type: StepOrderValue.ORDERED,- exclusions: [- {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- funnel_from_step: 1,- funnel_to_step: 2,- },- {- id: 3,- type: 'actions',- order: 1,- name: 'Some action',- funnel_from_step: 1,- funnel_to_step: 2,- },- ],- funnel_correlation_person_entity: { a: 1 },- funnel_correlation_person_converted: 'true',- funnel_custom_steps: [1, 2, 3],- layout: FunnelLayout.horizontal,- funnel_step: 1,- entrance_period_start: 'abc',- drop_off: true,- hidden_legend_keys: { Chrome: true, Safari: true },- }-- const result = filtersToQueryNode(filters)-- const query: FunnelsQuery = {- kind: NodeKind.FunnelsQuery,- funnelsFilter: {- funnelVizType: FunnelVizType.Steps,- funnelFromStep: 1,- funnelToStep: 2,- funnelStepReference: FunnelStepReference.total,- breakdownAttributionType: BreakdownAttributionType.AllSteps,- breakdownAttributionValue: 1,- binCount: 'auto',- funnelWindowIntervalUnit: FunnelConversionWindowTimeUnit.Day,- funnelWindowInterval: 7,- funnelOrderType: StepOrderValue.ORDERED,- exclusions: [- {- event: '$pageview',- kind: NodeKind.EventsNode,- name: '$pageview',- funnelFromStep: 1,- funnelToStep: 2,- },- {- id: 3,- kind: NodeKind.ActionsNode,- name: 'Some action',- funnelFromStep: 1,- funnelToStep: 2,- },- ],- layout: FunnelLayout.horizontal,- hiddenLegendBreakdowns: ['Chrome', 'Safari'],- },- series: [],- }- expect(result).toEqual(query)- })-- it('converts math type', () => {- const filters: Partial<FunnelsFilterType> = {- events: [{ id: '$pageview', type: 'events', order: 0, math: BaseMathType.FirstTimeForUser }],- insight: InsightType.FUNNELS,- }-- const result = filtersToQueryNode(filters)-- const query: FunnelsQuery = {- kind: NodeKind.FunnelsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: '$pageview',- math: BaseMathType.FirstTimeForUser,- },- ],- }- expect(result).toEqual(query)- })- })-- describe('retention filter', () => {- it('converts all properties', () => {- const filters: Partial<RetentionFilterType> = {- insight: InsightType.RETENTION,- retention_type: 'retention_first_time',- retention_reference: 'total',- total_intervals: 2,- returning_entity: { id: '1' },- target_entity: { id: '1' },- period: RetentionPeriod.Day,- show_mean: true,- }-- const result = filtersToQueryNode(filters)-- const query: RetentionQuery = {- kind: NodeKind.RetentionQuery,- retentionFilter: {- retentionType: 'retention_first_time',- retentionReference: 'total',- totalIntervals: 2,- returningEntity: { id: '1' },- targetEntity: { id: '1' },- period: RetentionPeriod.Day,- meanRetentionCalculation: 'simple',- },- }- expect(result).toEqual(query)- })- })-- describe('paths filter', () => {- it('converts all properties', () => {- const filters: Partial<PathsFilterType> = {- insight: InsightType.PATHS,- include_event_types: [PathType.Screen, PathType.PageView],- start_point: 'a',- end_point: 'b',- path_groupings: ['c', 'd'],- funnel_paths: FunnelPathType.between,- funnel_filter: {- events: [- {- id: '$pageview',- name: '$pageview',- order: 0,- type: 'events',- },- {- id: null,- order: 1,- type: 'events',- },- ],- exclusions: [],- funnel_step: 1,- funnel_viz_type: 'steps',- insight: 'FUNNELS',- },- exclude_events: ['e', 'f'],- step_limit: 1,- path_start_key: 'g',- path_end_key: 'h',- path_dropoff_key: 'i',- path_replacements: true,- local_path_cleaning_filters: [{ alias: 'home' }],- edge_limit: 1,- min_edge_weight: 1,- max_edge_weight: 1,- }-- const result = filtersToQueryNode(filters)-- const query: PathsQuery = {- kind: NodeKind.PathsQuery,- pathsFilter: {- includeEventTypes: [PathType.Screen, PathType.PageView],- startPoint: 'a',- endPoint: 'b',- pathGroupings: ['c', 'd'],- excludeEvents: ['e', 'f'],- stepLimit: 1,- pathReplacements: true,- localPathCleaningFilters: [{ alias: 'home' }],- edgeLimit: 1,- minEdgeWeight: 1,- maxEdgeWeight: 1,- },- funnelPathsFilter: {- funnelPathType: FunnelPathType.between,- funnelStep: 1,- funnelSource: {- funnelsFilter: {- funnelVizType: FunnelVizType.Steps,- },- kind: NodeKind.FunnelsQuery,- series: [- {- event: '$pageview',- kind: NodeKind.EventsNode,- name: '$pageview',- },- {- event: null,- kind: NodeKind.EventsNode,- },- ],- },- },- }- expect(result).toEqual(query)- })- })-- describe('stickiness filter', () => {- it('converts all properties', () => {- const filters: Partial<StickinessFilterType> = {- insight: InsightType.STICKINESS,- compare: true,- compare_to: '-4d',- show_legend: true,- hidden_legend_keys: { 0: true, 10: true },- shown_as: ShownAsValue.STICKINESS,- display: ChartDisplayType.ActionsLineGraph,- }-- const result = filtersToQueryNode(filters)-- const query: StickinessQuery = {- kind: NodeKind.StickinessQuery,- stickinessFilter: {- showLegend: true,- hiddenLegendIndexes: [0, 10],- display: ChartDisplayType.ActionsLineGraph,- },- compareFilter: {- compare: true,- compare_to: '-4d',- },- series: [],- }- expect(result).toEqual(query)- })- })-- describe('lifecycle filter', () => {- it('converts all properties', () => {- const filters: Partial<LifecycleFilterType> = {- insight: InsightType.LIFECYCLE,- shown_as: ShownAsValue.LIFECYCLE,- toggledLifecycles: ['new', 'dormant'],- }-- const result = filtersToQueryNode(filters)-- const query: LifecycleQuery = {- kind: NodeKind.LifecycleQuery,- lifecycleFilter: {- toggledLifecycles: ['new', 'dormant'],- },- series: [],- }- expect(result).toEqual(query)- })- })-- describe('malformed properties', () => {- it('converts properties', () => {- const properties: any = {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'event',- type: PropertyFilterType.Event,- value: 'value',- },- ],- },- ],- }-- const filters: Partial<FilterType> = {- insight: InsightType.TRENDS,- properties,- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.TrendsQuery,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'event',- type: PropertyFilterType.Event,- value: 'value',- operator: PropertyOperator.Exact,- },- ],- },- ],- },- series: [],- }- expect(result).toEqual(query)- })-- it('converts properties with the correct cohort structure', () => {- const properties: any = {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'id',- type: PropertyFilterType.Cohort,- value: 6,- operator: 'in',- },- ],- },- ],- }-- const filters: Partial<FilterType> = {- insight: InsightType.TRENDS,- properties,- }-- const result = filtersToQueryNode(filters)-- const query: InsightQueryNode = {- kind: NodeKind.TrendsQuery,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'id',- type: PropertyFilterType.Cohort,- operator: PropertyOperator.In,- value: 6,- },- ],- },- ],- },- series: [],- }- expect(result).toEqual(query)- })- })-- describe('example insights', () => {- it('converts `New user retention` insight', () => {- const filters: Partial<RetentionFilterType> = {- insight: InsightType.RETENTION,- period: RetentionPeriod.Week,- // TODO: why does the original example have a display here?- // display: ChartDisplayType.ActionsTable,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'email',- type: PropertyFilterType.Person,- value: 'is_set',- operator: PropertyOperator.IsSet,- },- ],- },- ],- },- target_entity: {- id: 'signed_up',- name: 'signed_up',- type: 'events',- order: 0,- },- retention_type: 'retention_first_time',- total_intervals: 9,- returning_entity: {- id: 1,- name: 'Interacted with file',- type: 'actions',- order: 0,- },- date_from: '-7d',- }-- const result = filtersToQueryNode(filters)-- const query: RetentionQuery = {- kind: NodeKind.RetentionQuery,- dateRange: {- date_from: '-7d',- },- retentionFilter: {- meanRetentionCalculation: 'simple',- period: RetentionPeriod.Week,- targetEntity: {- id: 'signed_up',- name: 'signed_up',- type: 'events',- order: 0,- },- retentionType: 'retention_first_time',- totalIntervals: 9,- returningEntity: {- id: 1,- name: 'Interacted with file',- type: 'actions',- order: 0,- },- },- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: 'email',- type: PropertyFilterType.Person,- value: 'is_set',- operator: PropertyOperator.IsSet,- },- ],- },- ],- },- }- expect(result).toEqual(query)- })-- it('converts `Active user lifecycle` insight', () => {- const filters: Partial<LifecycleFilterType> = {- insight: InsightType.LIFECYCLE,- properties: {- type: FilterLogicalOperator.And,- values: [],- },- filter_test_accounts: true,- date_from: '-8w',- entity_type: 'events', // TODO: what does this do?- actions: [- {- type: 'actions',- id: 1,- name: 'Interacted with file',- math: 'total',- },- ],- events: [],- interval: 'day',- shown_as: ShownAsValue.LIFECYCLE,- }-- const result = filtersToQueryNode(filters)-- const query: LifecycleQuery = {- kind: NodeKind.LifecycleQuery,- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [],- },- ],- },- filterTestAccounts: true,- dateRange: {- date_from: '-8w',- },- series: [- {- kind: NodeKind.ActionsNode,- id: 1,- name: 'Interacted with file',- },- ],- interval: 'day',- }- expect(result).toEqual(query)- })-- it('converts `Monthly app revenue` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: 'paid_bill',- math: 'sum',- type: 'events',- order: 0,- math_property: 'amount_usd',- },- ],- actions: [],- date_from: '-6m',- interval: 'month',- display: ChartDisplayType.ActionsLineGraph,- properties: [],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: 'paid_bill',- math: PropertyMathType.Sum,- math_property: 'amount_usd',- },- ],- dateRange: {- date_from: '-6m',- },- interval: 'month',- trendsFilter: {- display: ChartDisplayType.ActionsLineGraph,- },- }- expect(result).toEqual(query)- })-- it('converts `Bills paid` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: 'paid_bill',- math: 'unique_group',- name: 'paid_bill',- type: 'events',- order: 0,- math_group_type_index: 0,- },- ],- actions: [],- compare: true,- date_to: null,- display: ChartDisplayType.BoldNumber,- date_from: '-30d',- properties: [],- filter_test_accounts: true,- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: 'paid_bill',- name: 'paid_bill',- math: GroupMathType.UniqueGroup,- math_group_type_index: 0,- },- ],- dateRange: {- date_to: null,- date_from: '-30d',- },- filterTestAccounts: true,- trendsFilter: {- display: ChartDisplayType.BoldNumber,- },- compareFilter: {- compare: true,- },- }- expect(result).toEqual(query)- })-- it('converts `Daily unique visitors over time` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: '$pageview',- math: 'dau',- type: 'events',- order: 0,- },- ],- actions: [],- display: ChartDisplayType.ActionsLineGraph,- interval: 'day',- date_from: '-6m',- properties: [],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: '$pageview',- math: BaseMathType.UniqueUsers,- },- ],- dateRange: {- date_from: '-6m',- },- interval: 'day',- trendsFilter: {- display: ChartDisplayType.ActionsLineGraph,- },- }- expect(result).toEqual(query)- })-- it('converts `Most popular pages` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: '$pageview',- math: 'total',- type: 'events',- order: 0,- },- ],- actions: [],- display: ChartDisplayType.ActionsTable,- date_from: '-6m',- new_entity: [],- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: '$current_url',- type: PropertyFilterType.Event,- value: '/files/',- operator: PropertyOperator.NotIContains,- },- ],- },- ],- },- breakdown: '$current_url',- breakdown_type: 'event',- breakdown_normalize_url: true,- breakdown_hide_other_aggregation: true,- breakdown_limit: 1,- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: '$pageview',- math: BaseMathType.TotalCount,- },- ],- trendsFilter: {- display: ChartDisplayType.ActionsTable,- },- breakdownFilter: {- breakdown: '$current_url',- breakdown_type: 'event',- breakdown_normalize_url: true,- breakdown_hide_other_aggregation: true,- breakdown_limit: 1,- },- dateRange: {- date_from: '-6m',- },- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [- {- key: '$current_url',- type: PropertyFilterType.Event,- value: '/files/',- operator: PropertyOperator.NotIContains,- },- ],- },- ],- },- }- expect(result).toEqual(query)- })-- it('converts `Weekly signups` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: 'signed_up',- type: 'events',- order: 0,- },- ],- actions: [],- display: ChartDisplayType.ActionsLineGraph,- interval: 'week',- date_from: '-8w',- properties: [],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: 'signed_up',- math: BaseMathType.TotalCount,- },- ],- trendsFilter: {- display: ChartDisplayType.ActionsLineGraph,- },- interval: 'week',- dateRange: {- date_from: '-8w',- },- }- expect(result).toEqual(query)- })-- it('converts `Homepage view to signup conversion` insight', () => {- const filters: Partial<FunnelsFilterType> = {- insight: InsightType.FUNNELS,- date_from: '-1m',- actions: [],- events: [- {- id: '$pageview',- name: '$pageview',- type: 'events',- order: 0,- properties: [- {- key: '$current_url',- type: 'event',- value: 'https://hedgebox.net/',- operator: 'exact',- },- ],- custom_name: 'Viewed homepage',- },- {- id: '$pageview',- name: '$pageview',- type: 'events',- order: 1,- properties: [- {- key: '$current_url',- type: 'event',- value: 'https://hedgebox.net/signup/',- operator: 'regex',- },- ],- custom_name: 'Viewed signup page',- },- {- id: 'signed_up',- name: 'signed_up',- type: 'events',- order: 2,- custom_name: 'Signed up',- },- ],- filter_test_accounts: true,- funnel_viz_type: FunnelVizType.Steps,- exclusions: [],- }-- const result = filtersToQueryNode(filters)-- const query: FunnelsQuery = {- kind: NodeKind.FunnelsQuery,- dateRange: {- date_from: '-1m',- },- series: [- {- kind: NodeKind.EventsNode,- event: '$pageview',- name: '$pageview',- properties: [- {- key: '$current_url',- type: PropertyFilterType.Event,- value: 'https://hedgebox.net/',- operator: PropertyOperator.Exact,- },- ],- custom_name: 'Viewed homepage',- },- {- kind: NodeKind.EventsNode,- event: '$pageview',- name: '$pageview',- properties: [- {- key: '$current_url',- type: PropertyFilterType.Event,- value: 'https://hedgebox.net/signup/',- operator: PropertyOperator.Regex,- },- ],- custom_name: 'Viewed signup page',- },- {- kind: NodeKind.EventsNode,- event: 'signed_up',- name: 'signed_up',- custom_name: 'Signed up',- },- ],- filterTestAccounts: true,- funnelsFilter: {- funnelVizType: FunnelVizType.Steps,- },- }- expect(result).toEqual(query)- })-- it('converts `Activation` insight', () => {- const filters: Partial<FunnelsFilterType> = {- insight: InsightType.FUNNELS,- date_from: '-1m',- actions: [- {- id: 1,- name: 'Interacted with file',- type: 'actions',- order: 3,- },- ],- events: [- {- id: 'signed_up',- name: 'signed_up',- type: 'events',- order: 2,- custom_name: 'Signed up',- },- {- id: 'upgraded_plan',- name: 'upgraded_plan',- type: 'events',- order: 4,- custom_name: 'Upgraded plan',- },- ],- filter_test_accounts: true,- funnel_viz_type: FunnelVizType.Steps,- exclusions: [],- }-- const result = filtersToQueryNode(filters)-- const query: FunnelsQuery = {- kind: NodeKind.FunnelsQuery,- dateRange: {- date_from: '-1m',- },- series: [- {- kind: NodeKind.EventsNode,- event: 'signed_up',- name: 'signed_up',- custom_name: 'Signed up',- },- {- kind: NodeKind.ActionsNode,- id: 1,- name: 'Interacted with file',- },- {- kind: NodeKind.EventsNode,- event: 'upgraded_plan',- name: 'upgraded_plan',- custom_name: 'Upgraded plan',- },- ],- filterTestAccounts: true,- funnelsFilter: {- funnelVizType: FunnelVizType.Steps,- },- }- expect(result).toEqual(query)- })-- it('converts `Weekly file volume` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: 'uploaded_file',- math: 'sum',- name: 'uploaded_file',- type: 'events',- order: 0,- custom_name: 'Uploaded bytes',- math_property: 'file_size_b',- },- {- id: 'deleted_file',- math: 'sum',- name: 'deleted_file',- type: 'events',- order: 1,- custom_name: 'Deleted bytes',- math_property: 'file_size_b',- },- ],- actions: [],- display: ChartDisplayType.ActionsLineGraph,- interval: 'week',- date_from: '-8w',- new_entity: [],- properties: [],- filter_test_accounts: true,- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: 'uploaded_file',- name: 'uploaded_file',- custom_name: 'Uploaded bytes',- math: PropertyMathType.Sum,- math_property: 'file_size_b',- },- {- kind: NodeKind.EventsNode,- event: 'deleted_file',- name: 'deleted_file',- custom_name: 'Deleted bytes',- math: PropertyMathType.Sum,- math_property: 'file_size_b',- },- ],- interval: 'week',- trendsFilter: {- display: ChartDisplayType.ActionsLineGraph,- },- dateRange: {- date_from: '-8w',- },- filterTestAccounts: true,- }- expect(result).toEqual(query)- })-- it('converts `File interactions` insight', () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: 'uploaded_file',- type: 'events',- order: 0,- },- {- id: 'deleted_file',- type: 'events',- order: 2,- },- {- id: 'downloaded_file',- type: 'events',- order: 1,- },- ],- actions: [],- display: ChartDisplayType.ActionsLineGraph,- interval: 'day',- date_from: '-30d',- properties: [],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: 'uploaded_file',- math: BaseMathType.TotalCount,- },- {- kind: NodeKind.EventsNode,- event: 'downloaded_file',- math: BaseMathType.TotalCount,- },- {- kind: NodeKind.EventsNode,- event: 'deleted_file',- math: BaseMathType.TotalCount,- },- ],- interval: 'day',- trendsFilter: {- display: ChartDisplayType.ActionsLineGraph,- },- dateRange: {- date_from: '-30d',- },- }- expect(result).toEqual(query)- })-- it('converts `User paths starting at homepage` insight', () => {- const filters: Partial<PathsFilterType> = {- insight: InsightType.PATHS,- properties: {- type: FilterLogicalOperator.And,- values: [],- },- start_point: 'https://hedgebox.net/',- step_limit: 5,- include_event_types: [PathType.PageView],- path_groupings: ['/files/*'],- exclude_events: [],- date_from: '-30d',- date_to: null,- funnel_filter: {},- local_path_cleaning_filters: [],- edge_limit: 50,- }-- const result = filtersToQueryNode(filters)-- const query: PathsQuery = {- kind: NodeKind.PathsQuery,- dateRange: {- date_from: '-30d',- date_to: null,- },- pathsFilter: {- startPoint: 'https://hedgebox.net/',- stepLimit: 5,- includeEventTypes: [PathType.PageView],- pathGroupings: ['/files/*'],- edgeLimit: 50,- },- properties: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [],- },- ],- },- }- expect(result).toEqual(query)- })-- it("converts `Last month's signups by country` insight", () => {- const filters: Partial<TrendsFilterType> = {- insight: InsightType.TRENDS,- events: [- {- id: 'signed_up',- type: 'events',- order: 0,- },- ],- actions: [],- display: ChartDisplayType.WorldMap,- breakdown: '$geoip_country_code',- date_from: '-1m',- breakdown_type: 'event',- properties: [],- }-- const result = filtersToQueryNode(filters)-- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: 'signed_up',- math: BaseMathType.TotalCount,- },- ],- trendsFilter: {- display: ChartDisplayType.WorldMap,- },- breakdownFilter: {- breakdown: '$geoip_country_code',- breakdown_type: 'event',- },- dateRange: {- date_from: '-1m',- },- }- expect(result).toEqual(query)- })- })-})diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.tsdeleted file mode 100644index a97f62f71c29..000000000000--- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts+++ /dev/null@@ -1,678 +0,0 @@-import posthog from 'posthog-js'--import { isKeyOf } from 'lib/utils/guards'-import { objectCleanWithEmpty } from 'lib/utils/objects'-import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'-import {- isFunnelsFilter,- isLifecycleFilter,- isPathsFilter,- isRetentionFilter,- isStickinessFilter,- isTrendsFilter,-} from 'scenes/insights/sharedUtils'--import { ProductAnalyticsInsightNodeKind } from '~/queries/nodes/InsightQuery/defaults'-import {- ActionsNode,- AnalyticsQueryResponseBase,- AnyEntityNode,- BreakdownFilter,- CompareFilter,- DataWarehouseNode,- EventsNode,- FunnelExclusionActionsNode,- FunnelExclusionEventsNode,- FunnelPathsFilter,- FunnelsDataWarehouseNode,- FunnelsFilter,- FunnelsQuery,- GroupNode,- InsightQueryNode,- InsightsQueryBase,- LifecycleFilter,- LifecycleDataWarehouseNode,- MathType,- NodeKind,- PathsFilter,- RetentionFilter,- StickinessFilter,- TrendsFilter,- AnyDataWarehouseNode,-} from '~/queries/schema/schema-general'-import {- isFunnelsQuery,- isInsightQueryWithBreakdown,- isInsightQueryWithCompare,- isInsightQueryWithSeries,- isLifecycleQuery,- isPathsQuery,- isRetentionQuery,- isStickinessQuery,- isTrendsQuery,- setLatestVersionsOnQuery,-} from '~/queries/utils'-import {- ActionFilter,- BaseMathType,- CalendarHeatmapMathType,- AnyDataWarehouseFilter,- EntityTypes,- FilterType,- FunnelDatawarehouseFilter,- LifecycleDatawarehouseFilter,- FunnelExclusionLegacy,- FunnelMathType,- FunnelsFilterType,- GroupMathType,- HogQLMathType,- InsightType,- PathsFilterType,- RetentionEntity,- RetentionFilterType,- TrendsDataWarehouseFilter,- TrendsFilterType,- isDataWarehouseFilter,- isGroupFilter,-} from '~/types'--import { transformLegacyHiddenLegendKeys } from 'products/product_analytics/frontend/insights/funnels/funnelUtils'--import { cleanEntityProperties, cleanGlobalProperties } from './cleanProperties'--const insightTypeToNodeKind: Record<- // Journeys insights are query-native and never come from legacy filters- Exclude<- InsightType,- InsightType.JSON | InsightType.SQL | InsightType.HOG | InsightType.WEB_ANALYTICS | InsightType.JOURNEYS- >,- ProductAnalyticsInsightNodeKind-> = {- [InsightType.TRENDS]: NodeKind.TrendsQuery,- [InsightType.FUNNELS]: NodeKind.FunnelsQuery,- [InsightType.RETENTION]: NodeKind.RetentionQuery,- [InsightType.PATHS]: NodeKind.PathsQuery,- [InsightType.STICKINESS]: NodeKind.StickinessQuery,- [InsightType.LIFECYCLE]: NodeKind.LifecycleQuery,-}--export const actorsOnlyMathTypes = [- BaseMathType.UniqueUsers,- BaseMathType.WeeklyActiveUsers,- BaseMathType.MonthlyActiveUsers,- GroupMathType.UniqueGroup,- HogQLMathType.HogQL,-]--const funnelsMathTypes = [FunnelMathType.FirstTimeForUser, FunnelMathType.FirstTimeForUserWithFilters]--const calendarHeatmapMathTypes = [CalendarHeatmapMathType.TotalCount, CalendarHeatmapMathType.UniqueUsers]--export type FilterTypeActionsAndEvents = {- events?: ActionFilter[]- actions?: ActionFilter[]- data_warehouse?: AnyDataWarehouseFilter[]- new_entity?: ActionFilter[]- groups?: ActionFilter[]-}--type DataWarehouseNodeKind =- | NodeKind.DataWarehouseNode- | NodeKind.FunnelsDataWarehouseNode- | NodeKind.LifecycleDataWarehouseNode--export const legacyEntityToNode = (- entity: ActionFilter | AnyDataWarehouseFilter,- includeProperties: boolean,- mathAvailability: MathAvailability,- dataWarehouseNodeKind: DataWarehouseNodeKind = NodeKind.DataWarehouseNode-): AnyEntityNode<AnyDataWarehouseNode> | GroupNode<AnyDataWarehouseNode> => {- let shared: Partial<- EventsNode | ActionsNode | DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode | GroupNode- > = {- name: entity.name || undefined,- custom_name: entity.custom_name || undefined,- }-- if (isDataWarehouseFilter(entity)) {- shared = {- ...shared,- timestamp_field: entity.timestamp_field || undefined,- table_name: entity.table_name || undefined,- ...(dataWarehouseNodeKind === NodeKind.LifecycleDataWarehouseNode- ? {- aggregation_target_field: (entity as LifecycleDatawarehouseFilter).aggregation_target_field,- created_at_field: (entity as LifecycleDatawarehouseFilter).created_at_field,- }- : dataWarehouseNodeKind === NodeKind.FunnelsDataWarehouseNode- ? {- id_field: (entity as FunnelDatawarehouseFilter).id_field || undefined,- aggregation_target_field:- (entity as FunnelDatawarehouseFilter).aggregation_target_field || undefined,- }- : {- id_field: (entity as TrendsDataWarehouseFilter).id_field || undefined,- distinct_id_field: (entity as TrendsDataWarehouseFilter).distinct_id_field || undefined,- }),- } as DataWarehouseNode | FunnelsDataWarehouseNode | LifecycleDataWarehouseNode- }-- if (isGroupFilter(entity)) {- shared = {- ...shared,- operator: entity.operator || undefined,- nodes: (entity.nestedFilters || []).map((v) =>- legacyEntityToNode(- v as ActionFilter | AnyDataWarehouseFilter,- includeProperties,- mathAvailability,- dataWarehouseNodeKind- )- ),- } as GroupNode- }-- if (includeProperties) {- shared = { ...shared, properties: cleanEntityProperties(entity.properties) } as any- }-- if (mathAvailability !== MathAvailability.None) {- // only trends, funnels, and stickiness insights support math.- // transition to then default math for stickiness, when an unsupported math type is encountered.- if (mathAvailability === MathAvailability.ActorsOnly && !actorsOnlyMathTypes.includes(entity.math as any)) {- shared = {- ...shared,- math: BaseMathType.UniqueUsers,- }- } else if (mathAvailability === MathAvailability.FunnelsOnly) {- if (funnelsMathTypes.includes(entity.math as any)) {- shared = {- ...shared,- math: entity.math as MathType,- }- }- if (entity.optionalInFunnel) {- shared = {- ...shared,- optionalInFunnel: true,- }- }- } else if (mathAvailability === MathAvailability.CalendarHeatmapOnly) {- if (calendarHeatmapMathTypes.includes(entity.math as any)) {- shared = {- ...shared,- math: entity.math as MathType,- }- }- } else {- shared = {- ...shared,- math: entity.math || 'total',- math_property: entity.math_property,- math_property_type: entity.math_property_type,- math_hogql: entity.math_hogql,- math_group_type_index: entity.math_group_type_index,- } as any- }- }-- if (entity.type === 'actions') {- return setLatestVersionsOnQuery(- objectCleanWithEmpty({- kind: NodeKind.ActionsNode,- id: entity.id,- ...shared,- })- ) as any- } else if (entity.type === 'data_warehouse') {- return setLatestVersionsOnQuery(- objectCleanWithEmpty({- kind: dataWarehouseNodeKind,- id: entity.id,- ...shared,- })- ) as any- } else if (entity.type === EntityTypes.GROUPS) {- return setLatestVersionsOnQuery(- objectCleanWithEmpty({- kind: NodeKind.GroupNode,- ...shared,- })- ) as any- }- return setLatestVersionsOnQuery(- objectCleanWithEmpty({- kind: NodeKind.EventsNode,- event: entity.id,- ...shared,- })- ) as any-}--const exlusionEntityToNode = (- entity: FunnelExclusionLegacy-): FunnelExclusionEventsNode | FunnelExclusionActionsNode => {- const baseEntity = legacyEntityToNode(entity as ActionFilter, false, MathAvailability.None) as- | EventsNode- | ActionsNode- return {- ...baseEntity,- funnelFromStep: entity.funnel_from_step,- funnelToStep: entity.funnel_to_step,- }-}--type FilterTypeActionsAndEventsWithGroups = FilterTypeActionsAndEvents & { groups: ActionFilter[] }-type FilterTypeActionsAndEventsWithoutGroups = Omit<FilterTypeActionsAndEvents, 'groups'> & { groups?: undefined }--export function actionsAndEventsToSeries(- filters: FilterTypeActionsAndEventsWithGroups,- includeProperties: boolean,- includeMath: MathAvailability,- dataWarehouseNodeKind?: NodeKind.DataWarehouseNode-): (AnyEntityNode | GroupNode)[]-export function actionsAndEventsToSeries(- filters: FilterTypeActionsAndEventsWithoutGroups,- includeProperties: boolean,- includeMath: MathAvailability,- dataWarehouseNodeKind: NodeKind.LifecycleDataWarehouseNode-): AnyEntityNode<LifecycleDataWarehouseNode>[]-export function actionsAndEventsToSeries(- filters: FilterTypeActionsAndEventsWithoutGroups,- includeProperties: boolean,- includeMath: MathAvailability,- dataWarehouseNodeKind: NodeKind.FunnelsDataWarehouseNode-): AnyEntityNode<FunnelsDataWarehouseNode>[]-export function actionsAndEventsToSeries(- filters: FilterTypeActionsAndEventsWithoutGroups,- includeProperties: boolean,- includeMath: MathAvailability,- dataWarehouseNodeKind?: NodeKind.DataWarehouseNode-): AnyEntityNode[]-export function actionsAndEventsToSeries(- { actions, events, data_warehouse, new_entity, groups }: FilterTypeActionsAndEvents,- includeProperties: boolean,- includeMath: MathAvailability,- dataWarehouseNodeKind: DataWarehouseNodeKind = NodeKind.DataWarehouseNode-): (AnyEntityNode<AnyDataWarehouseNode> | GroupNode<AnyDataWarehouseNode>)[] {- const series: (AnyEntityNode<AnyDataWarehouseNode> | GroupNode<AnyDataWarehouseNode>)[] = [- ...(actions || []),- ...(events || []),- ...(data_warehouse || []),- ...(new_entity || []),- ...(groups || []),- ]- .sort((a, b) => (a.order || b.order ? (!a.order ? -1 : !b.order ? 1 : a.order - b.order) : 0))- .map((f) => legacyEntityToNode(f, includeProperties, includeMath, dataWarehouseNodeKind))-- return series-}--/**- * Converts `hidden_legend_keys` in trends and stickiness insights to an array of hidden indexes.- * Example: `{1: true, 2: false}` will become `[1]`.- *- * Note: `hidden_legend_keys` in funnel insights follow a different format.- */-export const hiddenLegendKeysToIndexes = (- hidden_legend_keys: Record<string, boolean | undefined> | undefined-): number[] | undefined => {- return hidden_legend_keys- ? Object.entries(hidden_legend_keys)- .filter(([k, v]) => /^\d+$/.test(k) && v === true)- .map(([k]) => Number(k))- : undefined-}--/**- * Converts `hidden_legend_keys` in funnel insights to an array of hidden breakdowns.- * Example: `{Chrome: true, Firefox: false}` will become: `["Chrome"]`.- *- * Also handles pre-#12123 legacy format.- * Example: {`events/$pageview/0/Baseline`: true} will become `['Baseline']`.- *- * Note: `hidden_legend_keys` in trends and stickiness insights follow a different format.- */-export const hiddenLegendKeysToBreakdowns = (- hidden_legend_keys: Record<string, boolean | undefined> | undefined-): string[] | undefined => {- return hidden_legend_keys- ? Object.entries(transformLegacyHiddenLegendKeys(hidden_legend_keys))- .filter(([k, v]) => !/^\d+$/.test(k) && v === true)- .map(([k]) => k)- : undefined-}--export const sanitizeRetentionEntity = (entity: RetentionEntity | undefined): RetentionEntity | undefined => {- if (!entity) {- return undefined- }-- const { id, kind, name, type, order, uuid, custom_name } = entity- return {- ...('id' in entity ? { id } : {}),- ...('kind' in entity ? { kind } : {}),- ...('name' in entity ? { name } : {}),- ...('type' in entity ? { type } : {}),- ...('order' in entity ? { order } : {}),- ...('uuid' in entity ? { uuid } : {}),- ...('custom_name' in entity ? { custom_name } : {}),- }-}--const processBool = (value: string | boolean | null | undefined): boolean | undefined => {- if (value == null) {- return undefined- } else if (typeof value === 'boolean') {- return value- } else if (typeof value == 'string') {- return strToBool(value)- }- return false-}--const strToBool = (value: any): boolean | undefined => {- if (value == null) {- return undefined- }- return ['y', 'yes', 't', 'true', 'on', '1'].includes(String(value).toLowerCase())-}--export type FiltersToQueryNodeTrackingContext = {- source: string-}--export const filtersToQueryNode = (- filters: Partial<FilterType>,- trackingContext?: FiltersToQueryNodeTrackingContext-): InsightQueryNode => {- const captureException = (message: string): void => {- posthog.captureException(new Error(message), { filters, DataExploration: true })- }- if (trackingContext) {- posthog.capture('legacy_filters_to_query_node_called', {- source: trackingContext.source,- insight: filters.insight,- })- }-- // A stored filter object can omit `insight`. The server's converter reads that as trends- // (`_insight_type` in filter_to_query.py), so this reads it the same way rather than throwing on- // a shape the server accepts.- const insightType = filters.insight ?? InsightType.TRENDS- if (!isKeyOf(insightType, insightTypeToNodeKind)) {- throw new Error(`insightTypeToNodeKind has no key ${insightType}`)- }-- const query: InsightsQueryBase<AnalyticsQueryResponseBase> = {- kind: insightTypeToNodeKind[insightType],- properties: cleanGlobalProperties(filters.properties),- filterTestAccounts: filters.filter_test_accounts,- }- if (filters.sampling_factor) {- query.samplingFactor = filters.sampling_factor- }-- // date range- query.dateRange = objectCleanWithEmpty({- date_to: filters.date_to,- date_from: filters.date_from,- explicitDate: processBool(filters.explicit_date),- })-- // series + interval- if (isInsightQueryWithSeries(query)) {- let includeMath = MathAvailability.None- const includeProperties = true- if (isTrendsQuery(query)) {- includeMath = MathAvailability.All- } else if (isStickinessQuery(query)) {- includeMath = MathAvailability.ActorsOnly- } else if (isFunnelsQuery(query)) {- includeMath = MathAvailability.FunnelsOnly- }-- const { events, actions, data_warehouse, groups } = filters- if (isLifecycleQuery(query)) {- query.series = actionsAndEventsToSeries(- { actions, events, data_warehouse, groups } as any,- includeProperties,- includeMath,- NodeKind.LifecycleDataWarehouseNode- )- } else if (isFunnelsQuery(query)) {- query.series = actionsAndEventsToSeries(- { actions, events, data_warehouse, groups } as any,- includeProperties,- includeMath,- NodeKind.FunnelsDataWarehouseNode- )- } else {- query.series = actionsAndEventsToSeries(- { actions, events, data_warehouse, groups } as any,- includeProperties,- includeMath,- NodeKind.DataWarehouseNode- )- }- query.interval = filters.interval- }-- // breakdown- if (isInsightQueryWithBreakdown(query)) {- // not undefined or null- if (filters.breakdowns != null) {- /* handle multi-breakdowns for funnels */- if (isFunnelsFilter(filters)) {- if (filters.breakdowns.length === 1) {- filters.breakdown_type = filters.breakdowns[0].type || 'event'- filters.breakdown = filters.breakdowns[0].property as string- } else {- captureException(- 'Could not convert multi-breakdown property `breakdowns` - found more than one breakdown'- )- }- }-- /* handle multi-breakdowns for trends */- if (isTrendsFilter(filters)) {- filters.breakdowns = filters.breakdowns.map((b) => ({- ...b,- // Compatibility with legacy funnel breakdowns when someone switches a view from funnels to trends- type: b.type || filters.breakdown_type || 'event',- }))- }- } else if (- /* handle missing breakdown_type */- // check for undefined and null values- filters.breakdown != null &&- filters.breakdown_type == null- ) {- filters.breakdown_type = 'event'- }-- query.breakdownFilter = breakdownFilterToQuery(filters, isTrendsFilter(filters))- }-- // compare filter- if (isInsightQueryWithCompare(query)) {- query.compareFilter = compareFilterToQuery(filters)- }-- // group aggregation- if (filters.aggregation_group_type_index != null) {- query.aggregation_group_type_index = filters.aggregation_group_type_index- }-- // trends filter- if (isTrendsFilter(filters) && isTrendsQuery(query)) {- query.trendsFilter = trendsFilterToQuery(filters)- }-- // funnels filter- if (isFunnelsFilter(filters) && isFunnelsQuery(query)) {- query.funnelsFilter = funnelsFilterToQuery(filters)- }-- // retention filter- if (isRetentionFilter(filters) && isRetentionQuery(query)) {- query.retentionFilter = retentionFilterToQuery(filters)- }-- // paths filter- if (isPathsFilter(filters) && isPathsQuery(query)) {- query.pathsFilter = pathsFilterToQuery(filters)- query.funnelPathsFilter = filtersToFunnelPathsQuery(filters)- }-- // stickiness filter- if (isStickinessFilter(filters) && isStickinessQuery(query)) {- query.stickinessFilter = stickinessFilterToQuery(filters)- }-- // lifecycle filter- if (isLifecycleFilter(filters) && isLifecycleQuery(query)) {- query.lifecycleFilter = lifecycleFilterToQuery(filters)- }-- // remove undefined and empty array/objects and return- return objectCleanWithEmpty(query as Record<string, any>, ['series']) as InsightQueryNode-}--const trendsFilterToQuery = (filters: Partial<TrendsFilterType>): TrendsFilter => {- return objectCleanWithEmpty({- smoothingIntervals: filters.smoothing_intervals,- showLegend: filters.show_legend,- showAlertThresholdLines: filters.show_alert_threshold_lines,- hiddenLegendIndexes: hiddenLegendKeysToIndexes(filters.hidden_legend_keys),- aggregationAxisFormat: filters.aggregation_axis_format,- aggregationAxisPrefix: filters.aggregation_axis_prefix,- aggregationAxisPostfix: filters.aggregation_axis_postfix,- decimalPlaces: filters.decimal_places,- xAxisLabel: filters.x_axis_label,- yAxisLabel: filters.y_axis_label,- formula: filters.formula,- display: filters.display,- showValuesOnSeries: filters.show_values_on_series,- showPercentStackView: filters.show_percent_stack_view,- showLabelsOnSeries: filters.show_labels_on_series,- yAxisScaleType: filters.y_axis_scale_type,- showMultipleYAxes: filters.show_multiple_y_axes,- })-}--const funnelsFilterToQuery = (filters: Partial<FunnelsFilterType>): FunnelsFilter => {- return objectCleanWithEmpty({- funnelVizType: filters.funnel_viz_type,- funnelFromStep: filters.funnel_from_step,- funnelToStep: filters.funnel_to_step,- funnelStepReference: filters.funnel_step_reference,- breakdownAttributionType: filters.breakdown_attribution_type,- breakdownAttributionValue: filters.breakdown_attribution_value,- binCount: filters.bin_count,- funnelWindowIntervalUnit: filters.funnel_window_interval_unit,- funnelWindowInterval: filters.funnel_window_interval,- funnelOrderType: filters.funnel_order_type,- exclusions:- filters.exclusions !== undefined- ? filters.exclusions.map((entity) => exlusionEntityToNode(entity))- : undefined,- layout: filters.layout,- hiddenLegendBreakdowns: hiddenLegendKeysToBreakdowns(filters.hidden_legend_keys),- funnelAggregateByHogQL: filters.funnel_aggregate_by_hogql,- })-}--const retentionFilterToQuery = (filters: Partial<RetentionFilterType>): RetentionFilter => {- return objectCleanWithEmpty({- retentionType: filters.retention_type,- retentionReference: filters.retention_reference,- totalIntervals: filters.total_intervals,- returningEntity: sanitizeRetentionEntity(filters.returning_entity),- targetEntity: sanitizeRetentionEntity(filters.target_entity),- period: filters.period,- meanRetentionCalculation: filters.mean_retention_calculation || 'simple',- cumulative: filters.cumulative,- })- // TODO: query.aggregation_group_type_index-}--const pathsFilterToQuery = (filters: Partial<PathsFilterType>): PathsFilter => {- return objectCleanWithEmpty({- pathsHogQLExpression: filters.paths_hogql_expression,- includeEventTypes: filters.include_event_types,- startPoint: filters.start_point,- endPoint: filters.end_point,- pathGroupings: filters.path_groupings,- excludeEvents: filters.exclude_events,- stepLimit: filters.step_limit,- pathReplacements: filters.path_replacements,- localPathCleaningFilters: filters.local_path_cleaning_filters,- edgeLimit: filters.edge_limit,- minEdgeWeight: filters.min_edge_weight,- maxEdgeWeight: filters.max_edge_weight,- })-}--export const filtersToFunnelPathsQuery = (filters: Partial<PathsFilterType>): FunnelPathsFilter | undefined => {- if (filters.funnel_paths === undefined || filters.funnel_filter === undefined) {- return undefined- }-- return {- funnelPathType: filters.funnel_paths,- funnelSource: filtersToQueryNode(filters.funnel_filter) as FunnelsQuery,- funnelStep: filters.funnel_filter?.funnel_step,- }-}--const stickinessFilterToQuery = (filters: Record<string, any>): StickinessFilter => {- return objectCleanWithEmpty({- display: filters.display,- showLegend: filters.show_legend,- hiddenLegendIndexes: hiddenLegendKeysToIndexes(filters.hidden_legend_keys),- showValuesOnSeries: filters.show_values_on_series,- computedAs: filters.computed_as,- })-}--const lifecycleFilterToQuery = (filters: Record<string, any>): LifecycleFilter => {- return objectCleanWithEmpty({- showLegend: filters.show_legend,- toggledLifecycles: filters.toggledLifecycles,- showValuesOnSeries: filters.show_values_on_series,- })-}--const breakdownFilterToQuery = (filters: Record<string, any>, isTrends: boolean): BreakdownFilter => {- return objectCleanWithEmpty({- breakdown_type: filters.breakdown_type,- breakdown: filters.breakdown,- breakdown_normalize_url: filters.breakdown_normalize_url,- breakdowns: filters.breakdowns,- breakdown_group_type_index: filters.breakdown_group_type_index,- breakdown_limit: filters.breakdown_limit,- ...(isTrends- ? {- breakdown_histogram_bin_count: filters.breakdown_histogram_bin_count,- breakdown_hide_other_aggregation: filters.breakdown_hide_other_aggregation,- }- : {}),- })-}--const compareFilterToQuery = (filters: Record<string, any>): CompareFilter => {- return objectCleanWithEmpty({- compare: filters.compare,- compare_to: filters.compare_to,- })-}--/** Expand GroupNodes into individual EventsNode/ActionsNode for insight types that don't support GroupNode */-export const expandGroupNodes = (- series: (EventsNode | ActionsNode | DataWarehouseNode | GroupNode)[]-): (EventsNode | ActionsNode | DataWarehouseNode)[] => {- return series.flatMap((item) =>- item.kind === NodeKind.GroupNode ? (item.nodes as (EventsNode | ActionsNode | DataWarehouseNode)[]) : [item]- )-}diff --git a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.tsindex c1e2a968c6a2..cd7f1c5be0e8 100644--- a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts+++ b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts@@ -1,6 +1,5 @@import { FunnelLayout } from 'lib/constants'-import { filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'import { hiddenLegendItemsToKeys, queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import {FunnelsQuery,@@ -148,20 +147,6 @@ describe('queryNodeToFilter', () => {expect(result).toEqual(filters)})- test('round-trips axis labels through legacy trends filters', () => {- const query: TrendsQuery = {- kind: NodeKind.TrendsQuery,- series: [],- trendsFilter: {- display: ChartDisplayType.ActionsLineGraph,- xAxisLabel: 'Signup date',- yAxisLabel: 'Unique users',- },- }-- expect(filtersToQueryNode(queryNodeToFilter(query))).toEqual(query)- })-test('converts a funnelsFilter into filter properties', () => {const query: FunnelsQuery = {kind: NodeKind.FunnelsQuery,diff --git a/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx b/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsxindex a057f850e8b9..0298a29ca139 100644--- a/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx+++ b/frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx@@ -18,7 +18,7 @@ import { LifecycleQuery, NodeKind, StickinessQuery, TrendsQuery } from '~/querieimport { isInsightQueryNode } from '~/queries/utils'import { ChartDisplayType, FilterType } from '~/types'-import { actionsAndEventsToSeries } from '../InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '../InsightQuery/utils/actionsAndEventsToSeries'import { queryNodeToFilter } from '../InsightQuery/utils/queryNodeToFilter'import { LifecycleSeriesHeader } from './LifecycleSeriesHeader'import { TrendsFormula } from './TrendsFormula'diff --git a/frontend/src/scenes/dashboard/newDashboardLogic.ts b/frontend/src/scenes/dashboard/newDashboardLogic.tsindex cc9f7506b28f..5dc124bb18af 100644--- a/frontend/src/scenes/dashboard/newDashboardLogic.ts+++ b/frontend/src/scenes/dashboard/newDashboardLogic.ts@@ -26,7 +26,10 @@ import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import { dashboardsModel } from '~/models/dashboardsModel'-import { legacyEntityToNode, sanitizeRetentionEntity } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import {+ legacyEntityToNode,+ sanitizeRetentionEntity,+} from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { getQueryBasedDashboard } from '~/queries/nodes/InsightViz/utils'import { NodeKind } from '~/queries/schema/schema-general'import { isInsightVizNode } from '~/queries/utils'diff --git a/frontend/src/scenes/experiments/metricQueryUtils.ts b/frontend/src/scenes/experiments/metricQueryUtils.tsindex 1671d63e2526..e1b1a2fe090e 100644--- a/frontend/src/scenes/experiments/metricQueryUtils.ts+++ b/frontend/src/scenes/experiments/metricQueryUtils.ts@@ -5,7 +5,7 @@ import { dayjs } from 'lib/dayjs'import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import type {ActionsNode,BreakdownFilter,diff --git a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsxindex b97fa0e21c38..0194a81fa3fb 100644--- a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx+++ b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx@@ -40,7 +40,7 @@ import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { seriesToActionsAndEvents } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { FunnelsQuery, Node, NodeKind, QueryStatus } from '~/queries/schema/schema-general'import { isFunnelsDataWarehouseNode } from '~/queries/utils'diff --git a/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx b/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsxindex 9f7b664f6500..2eb2bfc89738 100644--- a/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx+++ b/frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx@@ -10,7 +10,7 @@ import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'import { filterTestAccountsDefaultsLogic } from 'scenes/settings/environment/filterTestAccountDefaultsLogic'import { urls } from 'scenes/urls'-import { actorsOnlyMathTypes, expandGroupNodes } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actorsOnlyMathTypes, expandGroupNodes } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { nodeKindToInsightType } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { getDefaultQuery } from '~/queries/nodes/InsightViz/utils'import {diff --git a/frontend/src/scenes/settings/environment/CoreEventsSettings.tsx b/frontend/src/scenes/settings/environment/CoreEventsSettings.tsxindex f3ea80d50944..1135c0b554af 100644--- a/frontend/src/scenes/settings/environment/CoreEventsSettings.tsx+++ b/frontend/src/scenes/settings/environment/CoreEventsSettings.tsx@@ -10,7 +10,7 @@ import { uuid } from 'lib/utils/dom'import { ActionFilter as ActionFilterComponent } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import {ActionsNode,CoreEvent,diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsx b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsxindex e27c27a9773b..81d4c0a7f47f 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsx+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/common/ConversionGoalDropdown.tsx@@ -4,7 +4,7 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { ActionFilter as ActionFilterComponent } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import {ActionsNode,ConversionGoalFilter,diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsxindex bab0517c5e2c..4a97e867653d 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsx+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/CustomerAnalyticsDashboardEvents.tsx@@ -14,7 +14,7 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilimport { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import { EntityTypes, FilterType } from '~/types'diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.tsindex 0336506c1b1a..aff09db263ad 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.ts+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic.ts@@ -5,7 +5,7 @@ import { urlToAction } from 'kea-router'import { isEmptyObject } from 'lib/utils/guards'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { seriesToActionsAndEvents } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { ActionsNode, DataWarehouseNode, EventsNode, GroupNode } from '~/queries/schema/schema-general'import { FilterType, InsightType } from '~/types'diff --git a/products/experiments/frontend/legacy/metrics/FunnelsMetricForm.tsx b/products/experiments/frontend/legacy/metrics/FunnelsMetricForm.tsxindex 66eff5323dc1..f6375a240e90 100644--- a/products/experiments/frontend/legacy/metrics/FunnelsMetricForm.tsx+++ b/products/experiments/frontend/legacy/metrics/FunnelsMetricForm.tsx@@ -12,7 +12,7 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilimport { getHogQLValue } from 'scenes/insights/filters/AggregationSelect'import { teamLogic } from 'scenes/teamLogic'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { Query } from '~/queries/Query/Query'import { AnyEntityNode, ExperimentFunnelsQuery, NodeKind } from '~/queries/schema/schema-general'diff --git a/products/experiments/frontend/legacy/metrics/TrendsMetricForm.tsx b/products/experiments/frontend/legacy/metrics/TrendsMetricForm.tsxindex dd05fe0f3b45..1ab07300f18c 100644--- a/products/experiments/frontend/legacy/metrics/TrendsMetricForm.tsx+++ b/products/experiments/frontend/legacy/metrics/TrendsMetricForm.tsx@@ -13,7 +13,7 @@ import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'import { teamLogic } from 'scenes/teamLogic'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { Query } from '~/queries/Query/Query'import { AnyEntityNode, ExperimentTrendsQuery, InsightQueryNode, NodeKind } from '~/queries/schema/schema-general'diff --git a/products/experiments/frontend/legacy/sharedMetrics/LegacySharedFunnelsMetricForm.tsx b/products/experiments/frontend/legacy/sharedMetrics/LegacySharedFunnelsMetricForm.tsxindex a3575a0f2bb7..4b55988efb4a 100644--- a/products/experiments/frontend/legacy/sharedMetrics/LegacySharedFunnelsMetricForm.tsx+++ b/products/experiments/frontend/legacy/sharedMetrics/LegacySharedFunnelsMetricForm.tsx@@ -10,7 +10,7 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilimport { getHogQLValue } from 'scenes/insights/filters/AggregationSelect'import { teamLogic } from 'scenes/teamLogic'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { Query } from '~/queries/Query/Query'import { ExperimentFunnelsQuery, NodeKind } from '~/queries/schema/schema-general'diff --git a/products/experiments/frontend/legacy/sharedMetrics/LegacySharedTrendsMetricForm.tsx b/products/experiments/frontend/legacy/sharedMetrics/LegacySharedTrendsMetricForm.tsxindex 7bfe2c7a570f..71f656735326 100644--- a/products/experiments/frontend/legacy/sharedMetrics/LegacySharedTrendsMetricForm.tsx+++ b/products/experiments/frontend/legacy/sharedMetrics/LegacySharedTrendsMetricForm.tsx@@ -11,7 +11,7 @@ import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/types'import { teamLogic } from 'scenes/teamLogic'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { Query } from '~/queries/Query/Query'import { ExperimentTrendsQuery, InsightQueryNode, NodeKind } from '~/queries/schema/schema-general'diff --git a/products/product_analytics/frontend/insights/funnels/editor/FunnelsQuerySteps.tsx b/products/product_analytics/frontend/insights/funnels/editor/FunnelsQuerySteps.tsxindex 7d479a605284..e93deee258fd 100644--- a/products/product_analytics/frontend/insights/funnels/editor/FunnelsQuerySteps.tsx+++ b/products/product_analytics/frontend/insights/funnels/editor/FunnelsQuerySteps.tsx@@ -11,7 +11,7 @@ import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'import { getInsightPropertyFilterGroupTypes } from 'scenes/insights/utils/propertyTaxonomicGroupTypes'import { groupsModel } from '~/models/groupsModel'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { FunnelsQuery, NodeKind } from '~/queries/schema/schema-general'import { isInsightQueryNode } from '~/queries/utils'diff --git a/products/product_analytics/frontend/insights/funnels/filters/FunnelExclusionsFilter/FunnelExclusionsFilter.tsx b/products/product_analytics/frontend/insights/funnels/filters/FunnelExclusionsFilter/FunnelExclusionsFilter.tsxindex 9d2fe34b1b78..2b19074cc1aa 100644--- a/products/product_analytics/frontend/insights/funnels/filters/FunnelExclusionsFilter/FunnelExclusionsFilter.tsx+++ b/products/product_analytics/frontend/insights/funnels/filters/FunnelExclusionsFilter/FunnelExclusionsFilter.tsx@@ -7,7 +7,7 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilimport { insightLogic } from 'scenes/insights/insightLogic'import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'-import { legacyEntityToNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { legacyEntityToNode } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { ActionsNode, EventsNode } from '~/queries/schema/schema-general'import { ActionFilter as ActionFilterType, EntityTypes, FilterType } from '~/types'diff --git a/products/product_analytics/frontend/insights/funnels/funnelUtils.tsx b/products/product_analytics/frontend/insights/funnels/funnelUtils.tsxindex f415915d8858..5b9013e34318 100644--- a/products/product_analytics/frontend/insights/funnels/funnelUtils.tsx+++ b/products/product_analytics/frontend/insights/funnels/funnelUtils.tsx@@ -815,34 +815,6 @@ export function flattenedStepsByBreakdownCompare(return rows}-/**- * Transform pre-#12113 funnel series keys to the current more reliable format.- *- * Old: `${step.type}/${step.action_id}/${step.order}/${breakdownValues.join('_')}`- * New: `breakdownValues.join('::')`- *- * If you squint you'll notice this doesn't actually handle the .join() part, but that's fine,- * because that's only relevant for funnels with multiple breakdowns, and that hasn't been- * released to users at the point of the format change.- */-export const transformLegacyHiddenLegendKeys = (- hidden_legend_keys: Record<string, boolean | undefined>-): Record<string, boolean | undefined> => {- const hiddenLegendKeys: Record<string, boolean | undefined> = {}- for (const [key, value] of Object.entries(hidden_legend_keys)) {- const oldFormatMatch = key.match(/\w+\/.+\/\d+\/(.+)/)- if (oldFormatMatch) {- // Don't override values for series if already set from a previously-seen old-format key- if (!(oldFormatMatch[1] in hiddenLegendKeys)) {- hiddenLegendKeys[oldFormatMatch[1]] = value- }- } else {- hiddenLegendKeys[key] = value- }- }- return hiddenLegendKeys-}-export const parseBreakdownValue = (item: string): {diff --git a/products/product_analytics/frontend/insights/paths/pathsDataLogic.ts b/products/product_analytics/frontend/insights/paths/pathsDataLogic.tsindex 1e424b2e2bb7..c6cd525179f6 100644--- a/products/product_analytics/frontend/insights/paths/pathsDataLogic.ts+++ b/products/product_analytics/frontend/insights/paths/pathsDataLogic.ts@@ -13,7 +13,7 @@ import { pathsTitle } from 'scenes/trends/persons-modal/persons-modal-utils'import { OpenPersonsModalProps, openPersonsModal } from 'scenes/trends/persons-modal/PersonsModal'import { urls } from 'scenes/urls'-import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'+import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/actionsAndEventsToSeries'import { InsightActorsQuery, InsightVizNode, NodeKind, PathsLink, PathsQuery } from '~/queries/schema/schema-general'import type {DataNode,