diff --git a/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx b/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx index 8f7f5fe17df4b..7226758067a2d 100644 --- a/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx +++ b/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx @@ -11,7 +11,7 @@ import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/fil import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' import { Query } from '~/queries/Query/Query' import { ExperimentTrendsQuery, NodeKind } from '~/queries/schema' -import { FilterType } from '~/types' +import { FilterType, PropertyMathType } from '~/types' import { experimentLogic } from '../experimentLogic' import { commonActionFilterProps } from './Selectors' @@ -63,6 +63,7 @@ export function PrimaryGoalTrends(): JSX.Element { showSeriesIndicator={true} entitiesLimit={1} showNumericalPropsOnly={true} + onlyPropertyMathDefinitions={[PropertyMathType.Average]} {...commonActionFilterProps} />
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx index 91d3c1fcf260d..03be753ff14ce 100644 --- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx +++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilter.tsx @@ -86,6 +86,8 @@ export interface ActionFilterProps { deleteButton, orLabel, }: Record) => JSX.Element + /** Only show these property math definitions */ + onlyPropertyMathDefinitions?: Array | null } export const ActionFilter = React.forwardRef(function ActionFilter( @@ -116,6 +118,7 @@ export const ActionFilter = React.forwardRef( buttonType = 'tertiary', readOnly = false, bordered = false, + onlyPropertyMathDefinitions = null, }, ref ): JSX.Element { @@ -174,6 +177,7 @@ export const ActionFilter = React.forwardRef( onRenameClick: showModal, sortable, showNumericalPropsOnly, + onlyPropertyMathDefinitions, } const reachedLimit: boolean = Boolean(entitiesLimit && localFilters.length >= entitiesLimit) diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx index 15586e766a310..8bebbb42608a7 100644 --- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx +++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx @@ -126,6 +126,8 @@ export interface ActionFilterRowProps { trendsDisplayCategory: ChartDisplayCategory | null /** Whether properties shown should be limited to just numerical types */ showNumericalPropsOnly?: boolean + /** Only show these property math definitions */ + onlyPropertyMathDefinitions?: Array | null } export function ActionFilterRow({ @@ -155,6 +157,7 @@ export function ActionFilterRow({ renderRow, trendsDisplayCategory, showNumericalPropsOnly, + onlyPropertyMathDefinitions = null, }: ActionFilterRowProps): JSX.Element { const { entityFilterVisible } = useValues(logic) const { @@ -425,6 +428,7 @@ export function ActionFilterRow({ style={{ maxWidth: '100%', width: 'initial' }} mathAvailability={mathAvailability} trendsDisplayCategory={trendsDisplayCategory} + onlyPropertyMathDefinitions={onlyPropertyMathDefinitions} /> {mathDefinitions[math || BaseMathType.TotalCount]?.category === MathCategory.PropertyValue && ( @@ -642,6 +646,7 @@ interface MathSelectorProps { onMathSelect: (index: number, value: any) => any trendsDisplayCategory: ChartDisplayCategory | null style?: React.CSSProperties + onlyPropertyMathDefinitions?: Array | null } function isPropertyValueMath(math: string | undefined): math is PropertyMathType { @@ -660,6 +665,7 @@ function useMathSelectorOptions({ mathAvailability, onMathSelect, trendsDisplayCategory, + onlyPropertyMathDefinitions = null, }: MathSelectorProps): LemonSelectOptions { const mountedInsightDataLogic = insightDataLogic.findMounted() const query = mountedInsightDataLogic?.values?.query @@ -758,12 +764,19 @@ function useMathSelectorOptions({ setPropertyMathTypeShown(value as PropertyMathType) onMathSelect(index, value) }} - options={Object.entries(PROPERTY_MATH_DEFINITIONS).map(([key, definition]) => ({ - value: key, - label: definition.shortName, - tooltip: definition.description, - 'data-attr': `math-${key}-${index}`, - }))} + options={Object.entries(PROPERTY_MATH_DEFINITIONS) + .filter(([key]) => { + if (null === onlyPropertyMathDefinitions) { + return true + } + return onlyPropertyMathDefinitions.includes(key) + }) + .map(([key, definition]) => ({ + value: key, + label: definition.shortName, + tooltip: definition.description, + 'data-attr': `math-${key}-${index}`, + }))} onClick={(e) => e.stopPropagation()} size="small" dropdownMatchSelectWidth={false}