Skip to content

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

chore(insights): delete reader-free legacy filter types and fields (#127282)

Thomas Obermüllerd8cbc31f144d
diff --git a/frontend/src/lib/components/heatmaps/types.ts b/frontend/src/lib/components/heatmaps/types.ts
index a086fb20b1e9..a113ea61e8a5 100644
--- a/frontend/src/lib/components/heatmaps/types.ts
+++ b/frontend/src/lib/components/heatmaps/types.ts
@@ -3,8 +3,7 @@ export type CommonFilters = {
date_to?: string | null
filter_test_accounts?: boolean
cohort_ids?: number[]
- // A subset of FilterType['events'], spelled out because ~/types imports this file. Each entry is an
- // event name plus optional property filters, matching what the heatmap event picker emits.
+ // Each entry is an event name plus optional property filters, matching what the heatmap event picker emits.
events?: HeatmapEventFilter[]
}
diff --git a/frontend/src/lib/insights/entityFilterNames.test.ts b/frontend/src/lib/insights/entityFilterNames.test.ts
index bc188c8d7e83..0700722da7bd 100644
--- a/frontend/src/lib/insights/entityFilterNames.test.ts
+++ b/frontend/src/lib/insights/entityFilterNames.test.ts
@@ -1,8 +1,8 @@
-import { Entity, EntityFilter } from '~/types'
+import { EntityFilter } from '~/types'
import { getDisplayNameFromEntityFilter } from './entityFilterNames'
-const createFilter = (id?: Entity['id'], name?: string, custom_name?: string): EntityFilter => {
+const createFilter = (id?: EntityFilter['id'], name?: string, custom_name?: string): EntityFilter => {
return {
custom_name,
name: name ?? null,
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 60a09416ea51..488faf16ac37 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -31,7 +31,6 @@ import {
ExperimentStatsMethod,
FileSystemIconColor,
FilterLogicalOperator,
- FilterType,
FunnelConversionWindowTimeUnit,
FunnelMathType,
FunnelPathType,
@@ -827,8 +826,8 @@ export interface RecordingsQuery extends DataNode<RecordingsQueryResponse> {
* */
date_from?: string | null
date_to?: string | null
- events?: FilterType['events']
- actions?: FilterType['actions']
+ events?: Record<string, any>[]
+ actions?: Record<string, any>[]
properties?: AnyPropertyFilter[]
console_log_filters?: LogEntryPropertyFilter[]
having_predicates?: AnyPropertyFilter[] // duration and snapshot_source filters
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/seriesNode.ts b/frontend/src/scenes/insights/filters/ActionFilter/seriesNode.ts
index d9b3134d931b..2591c4a79ef9 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/seriesNode.ts
+++ b/frontend/src/scenes/insights/filters/ActionFilter/seriesNode.ts
@@ -99,22 +99,6 @@ export function seriesNodeEntityType(node: SeriesNode | null | undefined): Entit
return node ? ENTITY_TYPE_BY_SERIES_NODE_KIND[node.kind] : undefined
}
-export function seriesNodeKindForEntityType(
- type: EntityType | null | undefined,
- warehouseKind: WarehouseSeriesNodeKind
-): SeriesNode['kind'] {
- switch (type) {
- case EntityTypes.ACTIONS:
- return NodeKind.ActionsNode
- case EntityTypes.DATA_WAREHOUSE:
- return warehouseKind
- case EntityTypes.GROUPS:
- return NodeKind.GroupNode
- default:
- return NodeKind.EventsNode
- }
-}
-
/**
* An action id reaches the editor as a string from the taxonomic picker, while the schema types
* `ActionsNode.id` as an integer. Coerce once, here, so no consumer has to repair it later.
diff --git a/frontend/src/scenes/insights/insightLogic.test.ts b/frontend/src/scenes/insights/insightLogic.test.ts
index 7badd9d19567..be12b44e92b5 100644
--- a/frontend/src/scenes/insights/insightLogic.test.ts
+++ b/frontend/src/scenes/insights/insightLogic.test.ts
@@ -45,7 +45,6 @@ import { insightsApi } from './utils/api'
const API_FILTERS: Partial<FilterType> = {
insight: InsightType.TRENDS as InsightType,
- events: [{ id: 3 }],
properties: [{ value: 'a', operator: PropertyOperator.Exact, key: 'a', type: 'a' } as any as AnyPropertyFilter],
}
diff --git a/frontend/src/scenes/insights/utils.test.ts b/frontend/src/scenes/insights/utils.test.ts
index 62509ce094e1..b0d21e63fce7 100644
--- a/frontend/src/scenes/insights/utils.test.ts
+++ b/frontend/src/scenes/insights/utils.test.ts
@@ -1,7 +1,6 @@
import { formatAggregationAxisValue } from 'lib/insights/aggregationAxisFormat'
import {
compareInsightTopLevelSections,
- extractObjectDiffKeys,
formatAggregationValue,
formatBreakdownLabel,
formatBreakdownType,
@@ -22,11 +21,11 @@ import {
TrendsQuery,
} from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import { BaseMathType, CompareLabelType, Entity, FilterType, InsightType, TeamType } from '~/types'
+import { BaseMathType, CompareLabelType, TeamType } from '~/types'
import { IndexedTrendResult } from 'products/product_analytics/frontend/insights/trends/types'
-const createEventsNode = (id?: Entity['id'], name?: string, custom_name?: string): EventsNode => {
+const createEventsNode = (id?: string | number | null, name?: string, custom_name?: string): EventsNode => {
return {
kind: NodeKind.EventsNode,
custom_name,
@@ -35,7 +34,7 @@ const createEventsNode = (id?: Entity['id'], name?: string, custom_name?: string
}
}
-const createActionsNode = (id?: Entity['id'], name?: string, custom_name?: string): ActionsNode => {
+const createActionsNode = (id?: string | number | null, name?: string, custom_name?: string): ActionsNode => {
return {
kind: NodeKind.ActionsNode,
custom_name,
@@ -89,78 +88,6 @@ describe('getDisplayNameFromEntityNode()', () => {
})
})
-describe('extractObjectDiffKeys()', () => {
- const testCases: [string, FilterType, FilterType, string, Record<string, any>][] = [
- [
- 'one value',
- { insight: InsightType.TRENDS },
- { insight: InsightType.FUNNELS },
- '',
- { changed_insight: InsightType.TRENDS },
- ],
- [
- 'multiple values',
- { insight: InsightType.TRENDS, date_from: '-7d' },
- { insight: InsightType.FUNNELS, date_from: '-7d' },
- '',
- { changed_insight: InsightType.TRENDS },
- ],
- [
- 'nested event',
- { insight: InsightType.TRENDS, events: [{ name: 'pageview', math: 'total' }] },
- { insight: InsightType.TRENDS, events: [{ name: 'pageview', math: 'dau' }] },
- '',
- { changed_event_0_math: 'total' },
- ],
- [
- 'nested event multiple',
- {
- insight: InsightType.TRENDS,
- events: [
- { name: 'pageview', math: 'dau' },
- { name: 'pageview', math: 'total' },
- ],
- },
- {
- insight: InsightType.TRENDS,
- events: [
- { name: 'pageview', math: 'dau' },
- { name: 'pageview', math: 'dau' },
- ],
- },
- '',
- { changed_event_1_math: 'total' },
- ],
- [
- 'nested action',
- { insight: InsightType.TRENDS, actions: [{ name: 'pageview', math: 'total' }] },
- { insight: InsightType.TRENDS, actions: [{ name: 'pageview', math: 'dau' }] },
- '',
- { changed_action_0_math: 'total' },
- ],
- [
- 'nested action',
- { insight: InsightType.TRENDS, actions: undefined, events: [] },
- { insight: InsightType.TRENDS, actions: [], events: undefined },
- '',
- {},
- ],
- [
- 'nested action',
- { insight: InsightType.TRENDS, actions: undefined, events: [] },
- { insight: InsightType.TRENDS, actions: [{ name: 'pageview', math: 'dau ' }], events: undefined },
- '',
- { changed_actions_length: 0 },
- ],
- ]
-
- testCases.forEach(([testName, oldFilter, newFilter, prefix, expected]) => {
- it(`expect ${JSON.stringify(expected)} for ${testName}`, () => {
- expect(extractObjectDiffKeys(oldFilter, newFilter, prefix)).toEqual(expected)
- })
- })
-})
-
describe('formatAggregationValue', () => {
it('safely handles null', () => {
const fakeRenderCount = (x: number): string => String(x)
diff --git a/frontend/src/scenes/insights/utils.tsx b/frontend/src/scenes/insights/utils.tsx
index 98027bf22261..06c9a2577ec8 100644
--- a/frontend/src/scenes/insights/utils.tsx
+++ b/frontend/src/scenes/insights/utils.tsx
@@ -55,7 +55,6 @@ import {
import { getResultSeriesIndex } from '~/scenes/insights/utils/resultSeries'
import { CORE_FILTER_DEFINITIONS_BY_GROUP } from '~/taxonomy/taxonomy'
import {
- AnyPartialFilterType,
BreakdownKeyType,
ChartDisplayType,
CohortType,
@@ -106,47 +105,6 @@ export const getDisplayNameFromEntityNode = (
return (isCustom ? customName : null) ?? name ?? (id ? `${id}` : null)
}
-export function extractObjectDiffKeys(
- oldObj: AnyPartialFilterType,
- newObj: AnyPartialFilterType,
- prefix: string = ''
-): Record<string, any> {
- if (Object.keys(oldObj).length === 0) {
- return []
- }
-
- let changedKeys: Record<string, any> = {}
- for (const [key, value] of Object.entries(newObj)) {
- const valueOrArray = value || []
- const oldValue = (oldObj as Record<string, any>)[key] || []
- if (!objectsEqual(value, oldValue)) {
- if (key === 'events') {
- const events = valueOrArray as Record<string, any>[]
- if (events.length !== oldValue.length) {
- changedKeys['changed_events_length'] = oldValue?.length
- } else {
- events.forEach((event, idx) => {
- Object.assign(changedKeys, extractObjectDiffKeys(oldValue[idx], event, `event_${idx}_`))
- })
- }
- } else if (key === 'actions') {
- const actions = valueOrArray as Record<string, any>[]
- if (actions.length !== oldValue.length) {
- changedKeys['changed_actions_length'] = oldValue.length
- } else {
- actions.forEach((action, idx) => {
- Object.assign(changedKeys, extractObjectDiffKeys(oldValue[idx], action, `action_${idx}_`))
- })
- }
- } else {
- changedKeys[`changed_${prefix}${key}`] = oldValue
- }
- }
- }
-
- return changedKeys
-}
-
export function humanizePathsEventTypes(includeEventTypes: PathsFilter['includeEventTypes']): string[] {
let humanEventTypes: string[] = []
if (includeEventTypes) {
diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
index 20db7149f9ff..e0e5ede6a8bb 100644
--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
@@ -46,7 +46,6 @@ import {
import {
AnyPropertyFilter,
FilterLogicalOperator,
- FilterType,
LegacyRecordingFilters,
LogEntryPropertyFilter,
MatchedRecordingEvent,
@@ -1151,7 +1150,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic
loadEventsHaveSessionId: async () => {
const filters = filtersFromUniversalFilterGroups(values.filters)
// "All events" (id == null) matches any event, so it can always filter recordings
- const events: FilterType['events'] = filters
+ const events: Record<string, any>[] = filters
.filter(isEventFilter)
.filter((event) => event.id != null)
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 67ef514f7bee..441b9bd4a126 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -1633,8 +1633,8 @@ export type FilterableLogLevel = 'info' | 'warn' | 'error'
export interface LegacyRecordingFilters {
date_from?: string | null
date_to?: string | null
- events?: FilterType['events']
- actions?: FilterType['actions']
+ events?: Record<string, any>[]
+ actions?: Record<string, any>[]
properties?: AnyPropertyFilter[]
session_recording_duration?: RecordingDurationFilter
duration_type_filter?: DurationType
@@ -1687,14 +1687,6 @@ export type ErrorClusterResponse = ErrorCluster[] | null
export type EntityType = 'actions' | 'events' | 'data_warehouse' | 'new_entity' | 'groups'
-export interface Entity {
- id: string | number | null
- name: string
- custom_name?: string
- order: number
- type: EntityType
-}
-
export enum EntityTypes {
ACTIONS = 'actions',
EVENTS = 'events',
@@ -1704,7 +1696,7 @@ export enum EntityTypes {
export type EntityFilter = {
type?: EntityType
- id: Entity['id'] | null
+ id: string | number | null
name?: string | null
custom_name?: string | null
index?: number
@@ -1758,11 +1750,6 @@ export interface LifecycleDatawarehouseFilter extends ActionFilter {
export const isDataWarehouseFilter = (filter: EntityFilter): filter is AnyDataWarehouseFilter =>
filter.type === EntityTypes.DATA_WAREHOUSE
-export interface FunnelExclusionLegacy extends Partial<EntityFilter> {
- funnel_from_step: number
- funnel_to_step: number
-}
-
export interface PersonType {
id?: string
uuid?: string
@@ -3278,17 +3265,6 @@ export interface FilterType {
*/
explicit_date?: boolean | string | null
- events?: Record<string, any>[]
- actions?: Record<string, any>[]
- data_warehouse?: Record<string, any>[]
- new_entity?: Record<string, any>[]
- groups?: Record<string, any>[]
-
- // persons modal
- entity_id?: string | number
- entity_type?: EntityType
- entity_math?: string
-
// used by trends and stickiness
interval?: IntervalType
// TODO: extract into TrendsFunnelsCommonFilterType
@@ -3375,7 +3351,6 @@ export interface FunnelsFilterType extends FilterType {
funnel_window_interval_unit?: FunnelConversionWindowTimeUnit // minutes, days, weeks, etc. for conversion window
funnel_window_interval?: number | undefined // length of conversion window
funnel_order_type?: StepOrderValue
- exclusions?: FunnelExclusionLegacy[] // used in funnel exclusion filters
funnel_aggregate_by_hogql?: string | null
// frontend only
@@ -3398,7 +3373,6 @@ export interface PathsFilterType extends FilterType {
end_point?: string
path_groupings?: string[]
funnel_paths?: FunnelPathType
- funnel_filter?: Record<string, any> // Funnel Filter used in Paths
exclude_events?: string[] // Paths Exclusion type
/** @asType integer */
step_limit?: number // Paths Step Limit
@@ -3452,8 +3426,6 @@ export interface RetentionFilterType extends FilterType {
* @asType integer
*/
total_intervals?: number
- returning_entity?: RetentionEntity
- target_entity?: RetentionEntity
period?: RetentionPeriod
cumulative?: boolean
@@ -3472,15 +3444,6 @@ export interface LifecycleFilterType extends FilterType {
}
export type LifecycleToggle = 'new' | 'resurrecting' | 'returning' | 'dormant'
-export type AnyFilterType =
- | TrendsFilterType
- | StickinessFilterType
- | FunnelsFilterType
- | PathsFilterType
- | RetentionFilterType
- | LifecycleFilterType
- | FilterType
-
export type AnyPartialFilterType =
| Partial<TrendsFilterType>
| Partial<StickinessFilterType>