From a1b892e0ff95ec9da5c02a04cef2b28256d864ef Mon Sep 17 00:00:00 2001 From: Juraj Majerik Date: Wed, 27 Mar 2024 08:39:40 +0100 Subject: [PATCH] tweak --- .../ExperimentView/SecondaryMetricsTable.tsx | 201 +++++++++--------- 1 file changed, 101 insertions(+), 100 deletions(-) diff --git a/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx b/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx index 56195a8b9c7b3..432e40a5c9506 100644 --- a/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx +++ b/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx @@ -4,6 +4,7 @@ import { IconPencil, IconPlus } from '@posthog/icons' import { LemonBanner, LemonButton, LemonInput, LemonModal, LemonTable, LemonTableColumns } from '@posthog/lemon-ui' import { BindLogic, useActions, useValues } from 'kea' import { Form } from 'kea-forms' +import { EntityFilterInfo } from 'lib/components/EntityFilterInfo' import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { IconAreaChart } from 'lib/lemon-ui/icons' import { LemonField } from 'lib/lemon-ui/LemonField' @@ -151,34 +152,38 @@ export function SecondaryMetricsTable({ countDataForVariant, exposureCountDataForVariant, conversionRateForVariant, + experimentMathAggregationForTrends, } = useValues(experimentLogic({ experimentId })) - const columns: LemonTableColumns = [ + const columns: LemonTableColumns = [ { - key: 'variant', - title: 'Variant', - render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { - return ( -
-
- {capitalizeFirstLetter(item.variant)} -
- ) - }, + children: [ + { + title:
Variant
, + render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { + return ( +
+
+ {capitalizeFirstLetter(item.variant)} +
+ ) + }, + }, + ], }, ] experiment.secondary_metrics?.forEach((metric, idx) => { const Header = (): JSX.Element => ( -
+
{capitalizeFirstLetter(metric.name)}
@@ -203,92 +208,88 @@ export function SecondaryMetricsTable({
) + const targetResults = secondaryMetricResults?.[idx] + const targetResultFilters = targetResults?.filters + const winningVariant = findKeyWithHighestNumber(targetResults?.probability || null) + if (metric.filters.insight === InsightType.TRENDS) { columns.push({ - key: `results_${idx}`, - title: ( -
-
-
-
Count
-
Exposure
-
- Win probability + title:
, + children: [ + { + title: ( +
+ [ + {targetResults && + targetResults.insight?.[0] && + 'action' in targetResults.insight[0] && ( + + )} + ] + + {experimentMathAggregationForTrends(targetResultFilters) ? 'metric' : 'count'} +
-
-
- ), - render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { - const targetResults = secondaryMetricResults?.[idx] - - const { variant } = item - const winningVariant = findKeyWithHighestNumber(targetResults?.probability || null) - - return ( -
-
- {targetResults ? countDataForVariant(targetResults, variant) : '--'} -
-
- {targetResults ? exposureCountDataForVariant(targetResults, variant) : '--'} -
-
- - {targetResults?.probability?.[variant] != undefined - ? `${(targetResults.probability?.[variant] * 100).toFixed(1)}%` - : '--'} - -
-
- ) - }, + ), + render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { + const { variant } = item + return
{targetResults ? countDataForVariant(targetResults, variant) : '--'}
+ }, + }, + { + title: 'Exposure', + render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { + const { variant } = item + return ( +
{targetResults ? exposureCountDataForVariant(targetResults, variant) : '--'}
+ ) + }, + }, + { + title: 'Win probability', + render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { + const { variant } = item + return ( +
+ + {targetResults?.probability?.[variant] != undefined + ? `${(targetResults.probability?.[variant] * 100).toFixed(1)}%` + : '--'} + +
+ ) + }, + }, + ], }) } else { columns.push({ - key: `results_${idx}`, - title: ( -
-
-
-
- Conversion rate -
-
- Win probability -
-
-
- ), - render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { - const targetResults = secondaryMetricResults?.[idx] - - const { variant } = item - const winningVariant = findKeyWithHighestNumber(targetResults?.probability || null) - - const conversionRate = conversionRateForVariant(targetResults || null, variant) - return ( -
-
- {conversionRate === '--' ? conversionRate : `${conversionRate}%`} -
-
- - {targetResults?.probability?.[variant] != undefined - ? `${(targetResults.probability?.[variant] * 100).toFixed(1)}%` - : '--'} - -
-
- ) - }, + title:
, + children: [ + { + title: 'Conversion rate', + render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { + const { variant } = item + const conversionRate = conversionRateForVariant(targetResults || null, variant) + return
{conversionRate === '--' ? conversionRate : `${conversionRate}%`}
+ }, + }, + { + title: 'Win probability', + render: function Key(_, item: TabularSecondaryMetricResults): JSX.Element { + const { variant } = item + return ( +
+ + {targetResults?.probability?.[variant] != undefined + ? `${(targetResults.probability?.[variant] * 100).toFixed(1)}%` + : '--'} + +
+ ) + }, + }, + ], }) } })