From 4db9b9fbf102f859f9c015f026bcda5b2c70dc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Oberm=C3=BCller?= Date: Fri, 29 Nov 2024 13:18:07 +0100 Subject: [PATCH] fix(retention): fix retention actors with dashboard overrides (#26503) --- frontend/src/queries/schema.json | 110 ++++++++++++++---- frontend/src/queries/schema.ts | 2 +- .../EditorFilters/FunnelsAdvanced.tsx | 2 +- .../insights/filters/AggregationSelect.tsx | 4 +- frontend/src/scenes/retention/queries.ts | 2 +- frontend/src/scenes/trends/trendsDataLogic.ts | 2 +- 6 files changed, 96 insertions(+), 26 deletions(-) diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json index a83a40dad42a1..640b17a507df8 100644 --- a/frontend/src/queries/schema.json +++ b/frontend/src/queries/schema.json @@ -6957,8 +6957,15 @@ "additionalProperties": false, "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "breakdownFilter": { "$ref": "#/definitions/BreakdownFilter", @@ -8047,8 +8054,15 @@ "description": "Base class for insight query nodes. Should not be used directly.", "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -8097,8 +8111,15 @@ "description": "Base class for insight query nodes. Should not be used directly.", "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -8147,8 +8168,15 @@ "description": "Base class for insight query nodes. Should not be used directly.", "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -8197,8 +8225,15 @@ "description": "Base class for insight query nodes. Should not be used directly.", "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -8247,8 +8282,15 @@ "description": "Base class for insight query nodes. Should not be used directly.", "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -8350,8 +8392,15 @@ "additionalProperties": false, "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -8753,8 +8802,15 @@ "additionalProperties": false, "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -11598,8 +11654,15 @@ "additionalProperties": false, "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "dateRange": { "$ref": "#/definitions/InsightDateRange", @@ -12795,8 +12858,15 @@ "additionalProperties": false, "properties": { "aggregation_group_type_index": { - "description": "Groups aggregation", - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "description": "Groups aggregation" }, "breakdownFilter": { "$ref": "#/definitions/BreakdownFilter", diff --git a/frontend/src/queries/schema.ts b/frontend/src/queries/schema.ts index 5f106dfab26c8..b033a9150a2a7 100644 --- a/frontend/src/queries/schema.ts +++ b/frontend/src/queries/schema.ts @@ -829,7 +829,7 @@ export interface InsightsQueryBase> ex /** * Groups aggregation */ - aggregation_group_type_index?: integer + aggregation_group_type_index?: integer | null /** Sampling rate */ samplingFactor?: number | null /** Modifiers used when performing the query */ diff --git a/frontend/src/scenes/insights/EditorFilters/FunnelsAdvanced.tsx b/frontend/src/scenes/insights/EditorFilters/FunnelsAdvanced.tsx index 6d34791efaf1c..4917ec9a5612c 100644 --- a/frontend/src/scenes/insights/EditorFilters/FunnelsAdvanced.tsx +++ b/frontend/src/scenes/insights/EditorFilters/FunnelsAdvanced.tsx @@ -73,7 +73,7 @@ function StepOrderInfo(): JSX.Element { type ExclusionStepsInfoProps = { aggregationTargetLabel: Noun - aggregation_group_type_index?: number + aggregation_group_type_index?: number | null } function ExclusionStepsInfo({ diff --git a/frontend/src/scenes/insights/filters/AggregationSelect.tsx b/frontend/src/scenes/insights/filters/AggregationSelect.tsx index 4086bc02831b4..4d576309fe002 100644 --- a/frontend/src/scenes/insights/filters/AggregationSelect.tsx +++ b/frontend/src/scenes/insights/filters/AggregationSelect.tsx @@ -10,8 +10,8 @@ import { FunnelsQuery } from '~/queries/schema' import { isFunnelsQuery, isInsightQueryNode, isStickinessQuery } from '~/queries/utils' import { InsightLogicProps } from '~/types' -export function getHogQLValue(groupIndex?: number, aggregationQuery?: string): string { - if (groupIndex !== undefined) { +export function getHogQLValue(groupIndex?: number | null, aggregationQuery?: string): string { + if (groupIndex != undefined) { return `$group_${groupIndex}` } else if (aggregationQuery) { return aggregationQuery diff --git a/frontend/src/scenes/retention/queries.ts b/frontend/src/scenes/retention/queries.ts index 4fa5ef2956221..21995ed55a421 100644 --- a/frontend/src/scenes/retention/queries.ts +++ b/frontend/src/scenes/retention/queries.ts @@ -4,7 +4,7 @@ import { performQuery } from '~/queries/query' import { ActorsQuery, NodeKind, RetentionQuery } from '~/queries/schema' export function retentionToActorsQuery(query: RetentionQuery, selectedInterval: number, offset = 0): ActorsQuery { - const group = query.aggregation_group_type_index !== undefined + const group = query.aggregation_group_type_index != null const selectActor = group ? 'group' : 'person' const totalIntervals = (query.retentionFilter.totalIntervals || 11) - selectedInterval const periodName = query.retentionFilter.period?.toLowerCase() ?? 'day' diff --git a/frontend/src/scenes/trends/trendsDataLogic.ts b/frontend/src/scenes/trends/trendsDataLogic.ts index 0b2bea5c105ed..12c59197f3c84 100644 --- a/frontend/src/scenes/trends/trendsDataLogic.ts +++ b/frontend/src/scenes/trends/trendsDataLogic.ts @@ -199,7 +199,7 @@ export const trendsDataLogic = kea([ (s) => [s.series, s.querySource, s.isLifecycle], (series, querySource, isLifecycle): 'people' | 'none' | number => { // Find the commonly shared aggregation group index if there is one. - let firstAggregationGroupTypeIndex: 'people' | 'none' | number | undefined + let firstAggregationGroupTypeIndex: 'people' | 'none' | number | undefined | null if (isLifecycle) { firstAggregationGroupTypeIndex = (querySource as LifecycleQuery)?.aggregation_group_type_index } else {