From 9700a2bad2e87206675fd5bd3fc6885a8d3512bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Oberm=C3=BCller?= Date: Tue, 16 Jan 2024 11:20:15 +0100 Subject: [PATCH] chore(query-nodes): camel case decimal places, aggregation axis, show label/percent stack view (#19759) --- .../components/UnitPicker/CustomUnitModal.tsx | 4 +-- .../lib/components/UnitPicker/UnitPicker.tsx | 28 +++++++++---------- .../utils/filtersToQueryNode.test.ts | 10 ++++--- .../InsightQuery/utils/filtersToQueryNode.ts | 11 ++++---- .../utils/queryNodeToFilter.test.ts | 18 ++++++++---- .../InsightQuery/utils/queryNodeToFilter.ts | 12 ++++++++ .../nodes/InsightViz/InsightDisplayConfig.tsx | 10 +++---- .../src/queries/nodes/InsightViz/utils.ts | 4 +-- frontend/src/queries/schema.json | 14 +++++----- frontend/src/queries/schema.ts | 14 +++++----- .../src/scenes/funnels/FunnelLineGraph.tsx | 2 +- .../EditorFilters/PercentStackViewFilter.tsx | 2 +- .../scenes/insights/aggregationAxisFormat.ts | 23 +++++++++++---- .../insights/aggregationAxisFormats.test.ts | 10 +++++++ frontend/src/scenes/insights/utils.test.ts | 4 +-- .../insights/utils/compareInsightQuery.ts | 11 ++++---- .../scenes/retention/RetentionLineGraph.tsx | 2 +- .../scenes/web-analytics/webAnalyticsLogic.ts | 2 +- .../legacy_compatibility/filter_to_query.py | 11 ++++---- .../test/test_filter_to_query.py | 8 +++--- posthog/schema.py | 12 ++++---- 21 files changed, 128 insertions(+), 84 deletions(-) diff --git a/frontend/src/lib/components/UnitPicker/CustomUnitModal.tsx b/frontend/src/lib/components/UnitPicker/CustomUnitModal.tsx index 8491aafb0c61d..e3e4226744377 100644 --- a/frontend/src/lib/components/UnitPicker/CustomUnitModal.tsx +++ b/frontend/src/lib/components/UnitPicker/CustomUnitModal.tsx @@ -13,11 +13,11 @@ function chooseFormativeElementValue( trendsFilter: TrendsFilter | null | undefined ): string { if (formativeElement === 'prefix') { - return trendsFilter?.aggregation_axis_prefix || '' + return trendsFilter?.aggregationAxisPrefix || '' } if (formativeElement === 'postfix') { - return trendsFilter?.aggregation_axis_postfix || '' + return trendsFilter?.aggregationAxisPostfix || '' } return '' diff --git a/frontend/src/lib/components/UnitPicker/UnitPicker.tsx b/frontend/src/lib/components/UnitPicker/UnitPicker.tsx index 675aa251add3b..7a35b1d357269 100644 --- a/frontend/src/lib/components/UnitPicker/UnitPicker.tsx +++ b/frontend/src/lib/components/UnitPicker/UnitPicker.tsx @@ -29,7 +29,7 @@ export function UnitPicker(): JSX.Element { const { reportAxisUnitsChanged } = useActions(eventUsageLogic) const [isVisible, setIsVisible] = useState(false) - const [localAxisFormat, setLocalAxisFormat] = useState(trendsFilter?.aggregation_axis_format || undefined) + const [localAxisFormat, setLocalAxisFormat] = useState(trendsFilter?.aggregationAxisFormat || undefined) const [customUnitModal, setCustomUnitModal] = useState<'prefix' | 'postfix' | null>(null) const customUnitModalRef = useRef(null) @@ -50,9 +50,9 @@ export function UnitPicker(): JSX.Element { setLocalAxisFormat(format) updateInsightFilter({ - aggregation_axis_format: format, - aggregation_axis_prefix: prefix, - aggregation_axis_postfix: postfix, + aggregationAxisFormat: format, + aggregationAxisPrefix: prefix, + aggregationAxisPostfix: postfix, }) reportAxisUnitsChanged({ @@ -72,11 +72,11 @@ export function UnitPicker(): JSX.Element { if (localAxisFormat) { displayValue = aggregationDisplayMap[localAxisFormat] } - if (trendsFilter?.aggregation_axis_prefix?.length) { - displayValue = `Prefix: ${trendsFilter?.aggregation_axis_prefix}` + if (trendsFilter?.aggregationAxisPrefix?.length) { + displayValue = `Prefix: ${trendsFilter?.aggregationAxisPrefix}` } - if (trendsFilter?.aggregation_axis_postfix?.length) { - displayValue = `Postfix: ${trendsFilter?.aggregation_axis_postfix}` + if (trendsFilter?.aggregationAxisPostfix?.length) { + displayValue = `Postfix: ${trendsFilter?.aggregationAxisPostfix}` } return displayValue }, [localAxisFormat, trendsFilter]) @@ -118,22 +118,22 @@ export function UnitPicker(): JSX.Element { setCustomUnitModal('prefix')} - active={!!trendsFilter?.aggregation_axis_prefix} + active={!!trendsFilter?.aggregationAxisPrefix} fullWidth > Custom prefix - {trendsFilter?.aggregation_axis_prefix - ? `: ${trendsFilter?.aggregation_axis_prefix}...` + {trendsFilter?.aggregationAxisPrefix + ? `: ${trendsFilter?.aggregationAxisPrefix}...` : '...'} setCustomUnitModal('postfix')} - active={!!trendsFilter?.aggregation_axis_postfix} + active={!!trendsFilter?.aggregationAxisPostfix} fullWidth > Custom postfix - {trendsFilter?.aggregation_axis_postfix - ? `: ${trendsFilter?.aggregation_axis_postfix}...` + {trendsFilter?.aggregationAxisPostfix + ? `: ${trendsFilter?.aggregationAxisPostfix}...` : '...'} diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts index abceb32d1c9b7..a75fed5d2247f 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.test.ts @@ -316,6 +316,7 @@ describe('filtersToQueryNode', () => { formula: 'A+B', shown_as: ShownAsValue.VOLUME, display: ChartDisplayType.ActionsAreaGraph, + show_percent_stack_view: true, } const result = filtersToQueryNode(filters) @@ -327,12 +328,13 @@ describe('filtersToQueryNode', () => { show_legend: true, hidden_legend_indexes: [0, 10], compare: true, - aggregation_axis_format: 'numeric', - aggregation_axis_prefix: '£', - aggregation_axis_postfix: '%', - decimal_places: 8, + aggregationAxisFormat: 'numeric', + aggregationAxisPrefix: '£', + aggregationAxisPostfix: '%', + decimalPlaces: 8, formula: 'A+B', display: ChartDisplayType.ActionsAreaGraph, + showPercentStackView: true, }, breakdownFilter: { breakdown_histogram_bin_count: 1, diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts index 73f3b26e274e0..3a05c8a856448 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts @@ -254,14 +254,15 @@ export const filtersToQueryNode = (filters: Partial): InsightQueryNo show_legend: filters.show_legend, hidden_legend_indexes: cleanHiddenLegendIndexes(filters.hidden_legend_keys), compare: filters.compare, - aggregation_axis_format: filters.aggregation_axis_format, - aggregation_axis_prefix: filters.aggregation_axis_prefix, - aggregation_axis_postfix: filters.aggregation_axis_postfix, - decimal_places: filters.decimal_places, + aggregationAxisFormat: filters.aggregation_axis_format, + aggregationAxisPrefix: filters.aggregation_axis_prefix, + aggregationAxisPostfix: filters.aggregation_axis_postfix, + decimalPlaces: filters.decimal_places, formula: filters.formula, display: filters.display, show_values_on_series: filters.show_values_on_series, - show_percent_stack_view: filters.show_percent_stack_view, + showPercentStackView: filters.show_percent_stack_view, + showLabelsOnSeries: filters.show_labels_on_series, }) } diff --git a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts index 81386be669a3e..a935c910522d5 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts @@ -56,13 +56,13 @@ describe('queryNodeToFilter', () => { display: ChartDisplayType.ActionsBar, // breakdown_histogram_bin_count?: TrendsFilterLegacy['breakdown_histogram_bin_count'] // show_legend?: TrendsFilterLegacy['show_legend'] - // aggregation_axis_format?: TrendsFilterLegacy['aggregation_axis_format'] - // aggregation_axis_prefix?: TrendsFilterLegacy['aggregation_axis_prefix'] - // aggregation_axis_postfix?: TrendsFilterLegacy['aggregation_axis_postfix'] - // decimal_places?: TrendsFilterLegacy['decimal_places'] + aggregationAxisFormat: 'numeric', + aggregationAxisPrefix: 'M', + aggregationAxisPostfix: '$', + decimalPlaces: 5, // show_values_on_series?: TrendsFilterLegacy['show_values_on_series'] - // show_labels_on_series?: TrendsFilterLegacy['show_labels_on_series'] - // show_percent_stack_view?: TrendsFilterLegacy['show_percent_stack_view'] + showLabelsOnSeries: true, + showPercentStackView: true, // hidden_legend_indexes?: TrendsFilterLegacy['hidden_legend_indexes'] }, } @@ -78,6 +78,12 @@ describe('queryNodeToFilter', () => { display: ChartDisplayType.ActionsBar, formula: 'A + B', compare: true, + decimal_places: 5, + aggregation_axis_format: 'numeric', + aggregation_axis_prefix: 'M', + aggregation_axis_postfix: '$', + show_labels_on_series: true, + show_percent_stack_view: true, } expect(result).toEqual(filters) }) diff --git a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts index 7ea157508b39d..c4fa3b175e67c 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts @@ -151,7 +151,19 @@ export const queryNodeToFilter = (query: InsightQueryNode): Partial const legacyProps: TrendsFilterLegacy = {} if (isTrendsQuery(query)) { legacyProps.smoothing_intervals = insightFilter.smoothingIntervals + legacyProps.decimal_places = insightFilter.decimalPlaces + legacyProps.aggregation_axis_format = insightFilter.aggregationAxisFormat + legacyProps.aggregation_axis_postfix = insightFilter.aggregationAxisPostfix + legacyProps.aggregation_axis_prefix = insightFilter.aggregationAxisPrefix + legacyProps.show_labels_on_series = insightFilter.showLabelsOnSeries + legacyProps.show_percent_stack_view = insightFilter.showPercentStackView delete insightFilter.smoothingIntervals + delete insightFilter.decimalPlaces + delete insightFilter.aggregationAxisFormat + delete insightFilter.aggregationAxisPostfix + delete insightFilter.aggregationAxisPrefix + delete insightFilter.showLabelsOnSeries + delete insightFilter.showPercentStackView } Object.assign(filters, insightFilter) Object.assign(filters, legacyProps) diff --git a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx index 4cbe9e56b4cbb..68869cf4e6c78 100644 --- a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx +++ b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx @@ -106,8 +106,8 @@ export function InsightDisplayConfig(): JSX.Element { (showPercentStackView && isPercentStackViewOn ? 1 : 0) + (!isPercentStackViewOn && isTrends && - trendsFilter?.aggregation_axis_format && - trendsFilter.aggregation_axis_format !== 'numeric' + trendsFilter?.aggregationAxisFormat && + trendsFilter.aggregationAxisFormat !== 'numeric' ? 1 : 0) + (hasLegend && showLegend ? 1 : 0) @@ -199,7 +199,7 @@ function DecimalPrecisionInput(): JSX.Element { const reportChange = useDebouncedCallback(() => { posthog.capture('decimal places changed', { - decimal_places: trendsFilter?.decimal_places, + decimal_places: trendsFilter?.decimalPlaces, }) }, 500) @@ -211,10 +211,10 @@ function DecimalPrecisionInput(): JSX.Element { min={0} max={9} defaultValue={DEFAULT_DECIMAL_PLACES} - value={trendsFilter?.decimal_places} + value={trendsFilter?.decimalPlaces} onChange={(value) => { updateInsightFilter({ - decimal_places: value, + decimalPlaces: value, }) reportChange() }} diff --git a/frontend/src/queries/nodes/InsightViz/utils.ts b/frontend/src/queries/nodes/InsightViz/utils.ts index 55a6aa99f640f..a7fa870d8b355 100644 --- a/frontend/src/queries/nodes/InsightViz/utils.ts +++ b/frontend/src/queries/nodes/InsightViz/utils.ts @@ -107,7 +107,7 @@ export const getShowValueOnSeries = (query: InsightQueryNode): boolean | undefin export const getShowLabelsOnSeries = (query: InsightQueryNode): boolean | undefined => { if (isTrendsQuery(query)) { - return query.trendsFilter?.show_labels_on_series + return query.trendsFilter?.showLabelsOnSeries } else { return undefined } @@ -115,7 +115,7 @@ export const getShowLabelsOnSeries = (query: InsightQueryNode): boolean | undefi export const getShowPercentStackView = (query: InsightQueryNode): boolean | undefined => { if (isTrendsQuery(query)) { - return query.trendsFilter?.show_percent_stack_view + return query.trendsFilter?.showPercentStackView } else { return undefined } diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json index 87c95f8f3f52f..e41bf1a843171 100644 --- a/frontend/src/queries/schema.json +++ b/frontend/src/queries/schema.json @@ -3741,13 +3741,13 @@ "TrendsFilter": { "additionalProperties": false, "properties": { - "aggregation_axis_format": { + "aggregationAxisFormat": { "$ref": "#/definitions/AggregationAxisFormat" }, - "aggregation_axis_postfix": { + "aggregationAxisPostfix": { "type": "string" }, - "aggregation_axis_prefix": { + "aggregationAxisPrefix": { "type": "string" }, "breakdown_histogram_bin_count": { @@ -3756,7 +3756,7 @@ "compare": { "type": "boolean" }, - "decimal_places": { + "decimalPlaces": { "type": "number" }, "display": { @@ -3771,13 +3771,13 @@ }, "type": "array" }, - "show_labels_on_series": { + "showLabelsOnSeries": { "type": "boolean" }, - "show_legend": { + "showPercentStackView": { "type": "boolean" }, - "show_percent_stack_view": { + "show_legend": { "type": "boolean" }, "show_values_on_series": { diff --git a/frontend/src/queries/schema.ts b/frontend/src/queries/schema.ts index a3896933b2295..d769a559e7394 100644 --- a/frontend/src/queries/schema.ts +++ b/frontend/src/queries/schema.ts @@ -513,15 +513,15 @@ export type TrendsFilter = { compare?: TrendsFilterLegacy['compare'] formula?: TrendsFilterLegacy['formula'] display?: TrendsFilterLegacy['display'] - breakdown_histogram_bin_count?: TrendsFilterLegacy['breakdown_histogram_bin_count'] show_legend?: TrendsFilterLegacy['show_legend'] - aggregation_axis_format?: TrendsFilterLegacy['aggregation_axis_format'] - aggregation_axis_prefix?: TrendsFilterLegacy['aggregation_axis_prefix'] - aggregation_axis_postfix?: TrendsFilterLegacy['aggregation_axis_postfix'] - decimal_places?: TrendsFilterLegacy['decimal_places'] + breakdown_histogram_bin_count?: TrendsFilterLegacy['breakdown_histogram_bin_count'] // TODO: fully move into BreakdownFilter + aggregationAxisFormat?: TrendsFilterLegacy['aggregation_axis_format'] + aggregationAxisPrefix?: TrendsFilterLegacy['aggregation_axis_prefix'] + aggregationAxisPostfix?: TrendsFilterLegacy['aggregation_axis_postfix'] + decimalPlaces?: TrendsFilterLegacy['decimal_places'] show_values_on_series?: TrendsFilterLegacy['show_values_on_series'] - show_labels_on_series?: TrendsFilterLegacy['show_labels_on_series'] - show_percent_stack_view?: TrendsFilterLegacy['show_percent_stack_view'] + showLabelsOnSeries?: TrendsFilterLegacy['show_labels_on_series'] + showPercentStackView?: TrendsFilterLegacy['show_percent_stack_view'] hidden_legend_indexes?: TrendsFilterLegacy['hidden_legend_indexes'] } diff --git a/frontend/src/scenes/funnels/FunnelLineGraph.tsx b/frontend/src/scenes/funnels/FunnelLineGraph.tsx index 56b54bb71b8f3..9efaa3e6741a5 100644 --- a/frontend/src/scenes/funnels/FunnelLineGraph.tsx +++ b/frontend/src/scenes/funnels/FunnelLineGraph.tsx @@ -64,7 +64,7 @@ export function FunnelLineGraph({ return `${count}%` }, }} - trendsFilter={{ aggregation_axis_format: 'percentage' } as TrendsFilter} + trendsFilter={{ aggregationAxisFormat: 'percentage' } as TrendsFilter} labelGroupType={aggregationGroupTypeIndex ?? 'people'} incompletenessOffsetFromEnd={incompletenessOffsetFromEnd} onClick={ diff --git a/frontend/src/scenes/insights/EditorFilters/PercentStackViewFilter.tsx b/frontend/src/scenes/insights/EditorFilters/PercentStackViewFilter.tsx index 9e31687ef2971..88a4a688a553a 100644 --- a/frontend/src/scenes/insights/EditorFilters/PercentStackViewFilter.tsx +++ b/frontend/src/scenes/insights/EditorFilters/PercentStackViewFilter.tsx @@ -14,7 +14,7 @@ export function PercentStackViewFilter(): JSX.Element { className="p-1 px-2" checked={!!showPercentStackView} onChange={(checked) => { - updateInsightFilter({ show_percent_stack_view: checked }) + updateInsightFilter({ showPercentStackView: checked }) }} label={Show as % of total} size="small" diff --git a/frontend/src/scenes/insights/aggregationAxisFormat.ts b/frontend/src/scenes/insights/aggregationAxisFormat.ts index 4696d3e92e471..68d4d9ed245e8 100644 --- a/frontend/src/scenes/insights/aggregationAxisFormat.ts +++ b/frontend/src/scenes/insights/aggregationAxisFormat.ts @@ -15,14 +15,27 @@ export const INSIGHT_UNIT_OPTIONS: LemonSelectOptionLeaf[ { value: 'percentage_scaled', label: 'Percent (0-1)' }, ] +// this function needs to support a trendsFilter as part of an insight query and +// legacy trend filters, as we still return these as part of a data response export const formatAggregationAxisValue = ( trendsFilter: TrendsFilter | null | undefined | Partial, value: number | string ): string => { value = Number(value) - let formattedValue = humanFriendlyNumber(value, trendsFilter?.decimal_places) - if (trendsFilter?.aggregation_axis_format) { - switch (trendsFilter?.aggregation_axis_format) { + const decimalPlaces = + (trendsFilter as TrendsFilter)?.decimalPlaces || (trendsFilter as Partial)?.decimal_places + const aggregationAxisFormat = + (trendsFilter as TrendsFilter)?.aggregationAxisFormat || + (trendsFilter as Partial)?.aggregation_axis_format + const aggregationAxisPrefix = + (trendsFilter as TrendsFilter)?.aggregationAxisPrefix || + (trendsFilter as Partial)?.aggregation_axis_prefix + const aggregationAxisPostfix = + (trendsFilter as TrendsFilter)?.aggregationAxisPostfix || + (trendsFilter as Partial)?.aggregation_axis_postfix + let formattedValue = humanFriendlyNumber(value, decimalPlaces) + if (aggregationAxisFormat) { + switch (aggregationAxisFormat) { case 'duration': formattedValue = humanFriendlyDuration(value) break @@ -40,9 +53,7 @@ export const formatAggregationAxisValue = ( break } } - return `${trendsFilter?.aggregation_axis_prefix || ''}${formattedValue}${ - trendsFilter?.aggregation_axis_postfix || '' - }` + return `${aggregationAxisPrefix || ''}${formattedValue}${aggregationAxisPostfix || ''}` } export const formatPercentStackAxisValue = ( diff --git a/frontend/src/scenes/insights/aggregationAxisFormats.test.ts b/frontend/src/scenes/insights/aggregationAxisFormats.test.ts index a86aa1bcc2c44..8f6a479739c42 100644 --- a/frontend/src/scenes/insights/aggregationAxisFormats.test.ts +++ b/frontend/src/scenes/insights/aggregationAxisFormats.test.ts @@ -24,9 +24,19 @@ describe('formatAggregationAxisValue', () => { }, expected: '£3,940💖', }, + { + candidate: 3940, + filters: { + aggregationAxisFormat: 'numeric', + aggregationAxisPrefix: '£', + aggregationAxisPostfix: '💖', + }, + expected: '£3,940💖', + }, { candidate: 0.8709423, filters: {}, expected: '0.87' }, { candidate: 0.8709423, filters: { decimal_places: 2 }, expected: '0.87' }, { candidate: 0.8709423, filters: { decimal_places: 3 }, expected: '0.871' }, + { candidate: 0.8709423, filters: { decimalPlaces: 3 }, expected: '0.871' }, { candidate: 0.8709423, filters: { decimal_places: 9 }, expected: '0.8709423' }, { candidate: 0.8709423, filters: { decimal_places: -1 }, expected: '0.87' }, // Fall back to default for unsupported values ] diff --git a/frontend/src/scenes/insights/utils.test.ts b/frontend/src/scenes/insights/utils.test.ts index 94bad45af4386..9306f43c34db7 100644 --- a/frontend/src/scenes/insights/utils.test.ts +++ b/frontend/src/scenes/insights/utils.test.ts @@ -181,7 +181,7 @@ describe('formatAggregationValue', () => { it('uses render count when there is a value and property format is a no-op', () => { const fakeRenderCount = (x: number): string => - formatAggregationAxisValue({ aggregation_axis_format: 'duration' }, x) + formatAggregationAxisValue({ aggregationAxisFormat: 'duration' }, x) const noOpFormatProperty = jest.fn((_, y) => y) const actual = formatAggregationValue('some name', 500, fakeRenderCount, noOpFormatProperty) expect(actual).toEqual('8m 20s') @@ -189,7 +189,7 @@ describe('formatAggregationValue', () => { it('uses render count when there is a value and property format converts number to string', () => { const fakeRenderCount = (x: number): string => - formatAggregationAxisValue({ aggregation_axis_format: 'duration' }, x) + formatAggregationAxisValue({ aggregationAxisFormat: 'duration' }, x) const noOpFormatProperty = jest.fn((_, y) => String(y)) const actual = formatAggregationValue('some name', 500, fakeRenderCount, noOpFormatProperty) expect(actual).toEqual('8m 20s') diff --git a/frontend/src/scenes/insights/utils/compareInsightQuery.ts b/frontend/src/scenes/insights/utils/compareInsightQuery.ts index 682512f12127c..2fc863e4a7bcc 100644 --- a/frontend/src/scenes/insights/utils/compareInsightQuery.ts +++ b/frontend/src/scenes/insights/utils/compareInsightQuery.ts @@ -49,14 +49,15 @@ const cleanInsightQuery = (query: InsightQueryNode, ignoreVisualizationOnlyChang cleanedQuery[insightFilterKey] = { ...insightFilter, show_legend: undefined, - show_percent_stack_view: undefined, + showPercentStackView: undefined, show_values_on_series: undefined, - aggregation_axis_format: undefined, - aggregation_axis_prefix: undefined, - aggregation_axis_postfix: undefined, - decimal_places: undefined, + aggregationAxisFormat: undefined, + aggregationAxisPrefix: undefined, + aggregationAxisPostfix: undefined, + decimalPlaces: undefined, layout: undefined, toggledLifecycles: undefined, + showLabelsOnSeries: undefined, } if (isInsightQueryWithDisplay(cleanedQuery)) { diff --git a/frontend/src/scenes/retention/RetentionLineGraph.tsx b/frontend/src/scenes/retention/RetentionLineGraph.tsx index f9ddce22272e6..4bdee944c6403 100644 --- a/frontend/src/scenes/retention/RetentionLineGraph.tsx +++ b/frontend/src/scenes/retention/RetentionLineGraph.tsx @@ -35,7 +35,7 @@ export function RetentionLineGraph({ inSharedMode = false }: RetentionLineGraphP inSharedMode={!!inSharedMode} showPersonsModal={false} labelGroupType={aggregationGroupTypeIndex} - trendsFilter={{ aggregation_axis_format: 'percentage' } as TrendsFilter} + trendsFilter={{ aggregationAxisFormat: 'percentage' } as TrendsFilter} tooltip={{ rowCutoff: 11, // 11 time units is hardcoded into retention insights renderSeries: function _renderCohortPrefix(value) { diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.ts b/frontend/src/scenes/web-analytics/webAnalyticsLogic.ts index fd9fd99e661b2..98df4dd8c5fc0 100644 --- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.ts +++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.ts @@ -624,7 +624,7 @@ export const webAnalyticsLogic = kea([ ], trendsFilter: { display: ChartDisplayType.ActionsPie, - show_labels_on_series: true, + showLabelsOnSeries: true, }, filterTestAccounts: true, properties: webAnalyticsFilters, diff --git a/posthog/hogql_queries/legacy_compatibility/filter_to_query.py b/posthog/hogql_queries/legacy_compatibility/filter_to_query.py index 64914418df817..1b3c1213d77ea 100644 --- a/posthog/hogql_queries/legacy_compatibility/filter_to_query.py +++ b/posthog/hogql_queries/legacy_compatibility/filter_to_query.py @@ -318,14 +318,15 @@ def _insight_filter(filter: Dict): # show_legend=filter.get('show_legend'), # hidden_legend_indexes=cleanHiddenLegendIndexes(filter.get('hidden_legend_keys')), compare=filter.get("compare"), - aggregation_axis_format=filter.get("aggregation_axis_format"), - aggregation_axis_prefix=filter.get("aggregation_axis_prefix"), - aggregation_axis_postfix=filter.get("aggregation_axis_postfix"), - decimal_places=filter.get("decimal_places"), + aggregationAxisFormat=filter.get("aggregation_axis_format"), + aggregationAxisPrefix=filter.get("aggregation_axis_prefix"), + aggregationAxisPostfix=filter.get("aggregation_axis_postfix"), + decimalPlaces=filter.get("decimal_places"), formula=filter.get("formula"), display=clean_display(filter.get("display")), show_values_on_series=filter.get("show_values_on_series"), - show_percent_stack_view=filter.get("show_percent_stack_view"), + showPercentStackView=filter.get("show_percent_stack_view"), + showLabelsOnSeries=filter.get("show_label_on_series"), ) } elif _insight_type(filter) == "FUNNELS": diff --git a/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py b/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py index f466eeee28af7..6fdf7d838fd3d 100644 --- a/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py +++ b/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py @@ -1295,12 +1295,12 @@ def test_trends_filter(self): TrendsFilter( smoothingIntervals=2, compare=True, - aggregation_axis_format=AggregationAxisFormat.duration_ms, - aggregation_axis_prefix="pre", - aggregation_axis_postfix="post", + aggregationAxisFormat=AggregationAxisFormat.duration_ms, + aggregationAxisPrefix="pre", + aggregationAxisPostfix="post", formula="A + B", display=ChartDisplayType.ActionsAreaGraph, - decimal_places=5, + decimalPlaces=5, ), ) diff --git a/posthog/schema.py b/posthog/schema.py index 6ab56dbed4f6f..ddee598cbd80b 100644 --- a/posthog/schema.py +++ b/posthog/schema.py @@ -642,18 +642,18 @@ class TrendsFilter(BaseModel): model_config = ConfigDict( extra="forbid", ) - aggregation_axis_format: Optional[AggregationAxisFormat] = None - aggregation_axis_postfix: Optional[str] = None - aggregation_axis_prefix: Optional[str] = None + aggregationAxisFormat: Optional[AggregationAxisFormat] = None + aggregationAxisPostfix: Optional[str] = None + aggregationAxisPrefix: Optional[str] = None breakdown_histogram_bin_count: Optional[float] = None compare: Optional[bool] = None - decimal_places: Optional[float] = None + decimalPlaces: Optional[float] = None display: Optional[ChartDisplayType] = None formula: Optional[str] = None hidden_legend_indexes: Optional[List[float]] = None - show_labels_on_series: Optional[bool] = None + showLabelsOnSeries: Optional[bool] = None + showPercentStackView: Optional[bool] = None show_legend: Optional[bool] = None - show_percent_stack_view: Optional[bool] = None show_values_on_series: Optional[bool] = None smoothingIntervals: Optional[float] = None