diff --git a/frontend/src/scenes/experiments/ExperimentView/CumulativeExposuresChart.tsx b/frontend/src/scenes/experiments/ExperimentView/CumulativeExposuresChart.tsx index 575eb84c527083..7f4378a7ec5efe 100644 --- a/frontend/src/scenes/experiments/ExperimentView/CumulativeExposuresChart.tsx +++ b/frontend/src/scenes/experiments/ExperimentView/CumulativeExposuresChart.tsx @@ -1,28 +1,16 @@ import { IconInfo } from '@posthog/icons' import { Tooltip } from '@posthog/lemon-ui' import { useValues } from 'kea' -import { FEATURE_FLAGS } from 'lib/constants' -import { featureFlagLogic } from 'lib/logic/featureFlagLogic' import { InsightEmptyState } from 'scenes/insights/EmptyStates' import { InsightViz } from '~/queries/nodes/InsightViz/InsightViz' -import { queryFromFilters } from '~/queries/nodes/InsightViz/utils' import { CachedExperimentTrendsQueryResponse, InsightQueryNode, InsightVizNode, NodeKind } from '~/queries/schema' -import { - _TrendsExperimentResults, - BaseMathType, - ChartDisplayType, - InsightType, - PropertyFilterType, - PropertyOperator, -} from '~/types' +import { BaseMathType, ChartDisplayType, InsightType, PropertyFilterType, PropertyOperator } from '~/types' import { experimentLogic } from '../experimentLogic' -import { transformResultFilters } from '../utils' export function CumulativeExposuresChart(): JSX.Element { const { experiment, experimentResults, getMetricType } = useValues(experimentLogic) - const { featureFlags } = useValues(featureFlagLogic) const metricIdx = 0 const metricType = getMetricType(metricIdx) @@ -32,99 +20,52 @@ export function CumulativeExposuresChart(): JSX.Element { variants.push(`holdout-${experiment.holdout.id}`) } - let query + let query: InsightVizNode - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - if (metricType === InsightType.TRENDS) { - query = { - kind: NodeKind.InsightVizNode, - source: (experimentResults as CachedExperimentTrendsQueryResponse).exposure_query, - } - } else { - query = { - kind: NodeKind.InsightVizNode, - source: { - kind: NodeKind.TrendsQuery, - dateRange: { - date_from: experiment.start_date, - date_to: experiment.end_date, - }, - interval: 'day', - trendsFilter: { - display: ChartDisplayType.ActionsLineGraphCumulative, - showLegend: false, - smoothingIntervals: 1, - }, - series: [ - { - kind: NodeKind.EventsNode, - event: experiment.filters?.events?.[0]?.name, - math: BaseMathType.UniqueUsers, - properties: [ - { - key: `$feature/${experiment.feature_flag_key}`, - value: variants, - operator: PropertyOperator.Exact, - type: PropertyFilterType.Event, - }, - ], - }, - ], - breakdownFilter: { - breakdown: `$feature/${experiment.feature_flag_key}`, - breakdown_type: 'event', - }, - }, - } + if (metricType === InsightType.TRENDS) { + query = { + kind: NodeKind.InsightVizNode, + source: (experimentResults as CachedExperimentTrendsQueryResponse)?.exposure_query || { + kind: NodeKind.TrendsQuery, + series: [], + interval: 'day', + }, } } else { - if (metricType === InsightType.TRENDS && experiment.parameters?.custom_exposure_filter) { - const trendResults = experimentResults as _TrendsExperimentResults - const queryFilters = { - ...trendResults.exposure_filters, - display: ChartDisplayType.ActionsLineGraphCumulative, - } as _TrendsExperimentResults['exposure_filters'] - query = queryFromFilters(transformResultFilters(queryFilters)) - } else { - query = { - kind: NodeKind.InsightVizNode, - source: { - kind: NodeKind.TrendsQuery, - dateRange: { - date_from: experiment.start_date, - date_to: experiment.end_date, - }, - interval: 'day', - trendsFilter: { - display: ChartDisplayType.ActionsLineGraphCumulative, - showLegend: false, - smoothingIntervals: 1, - }, - series: [ - { - kind: NodeKind.EventsNode, - event: - metricType === InsightType.TRENDS - ? '$feature_flag_called' - : experiment.filters?.events?.[0]?.name, - math: BaseMathType.UniqueUsers, - properties: [ - { - key: `$feature/${experiment.feature_flag_key}`, - value: variants, - operator: PropertyOperator.Exact, - type: PropertyFilterType.Event, - }, - ], - }, - ], - breakdownFilter: { - breakdown: `$feature/${experiment.feature_flag_key}`, - breakdown_type: 'event', + query = { + kind: NodeKind.InsightVizNode, + source: { + kind: NodeKind.TrendsQuery, + dateRange: { + date_from: experiment.start_date, + date_to: experiment.end_date, + }, + interval: 'day', + trendsFilter: { + display: ChartDisplayType.ActionsLineGraphCumulative, + showLegend: false, + smoothingIntervals: 1, + }, + series: [ + { + kind: NodeKind.EventsNode, + event: experiment.filters?.events?.[0]?.name, + math: BaseMathType.UniqueUsers, + properties: [ + { + key: `$feature/${experiment.feature_flag_key}`, + value: variants, + operator: PropertyOperator.Exact, + type: PropertyFilterType.Event, + }, + ], }, + ], + breakdownFilter: { + breakdown: `$feature/${experiment.feature_flag_key}`, + breakdown_type: 'event', }, - } + }, } } @@ -139,7 +80,7 @@ export function CumulativeExposuresChart(): JSX.Element { {experiment.start_date ? ( ), + ...query, showTable: true, }} setQuery={() => {}} diff --git a/frontend/src/scenes/experiments/ExperimentView/Goal.tsx b/frontend/src/scenes/experiments/ExperimentView/Goal.tsx index 867d82bc83a375..3b76be6da4a003 100644 --- a/frontend/src/scenes/experiments/ExperimentView/Goal.tsx +++ b/frontend/src/scenes/experiments/ExperimentView/Goal.tsx @@ -3,14 +3,14 @@ import { LemonButton, LemonDivider, Tooltip } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { InsightLabel } from 'lib/components/InsightLabel' import { PropertyFilterButton } from 'lib/components/PropertyFilters/components/PropertyFilterButton' -import { EXPERIMENT_DEFAULT_DURATION, FEATURE_FLAGS } from 'lib/constants' +import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { dayjs } from 'lib/dayjs' import { useState } from 'react' import { ExperimentFunnelsQuery, ExperimentTrendsQuery, FunnelsQuery, NodeKind, TrendsQuery } from '~/queries/schema' -import { ActionFilter, AnyPropertyFilter, ChartDisplayType, Experiment, FilterType, InsightType } from '~/types' +import { ActionFilter, AnyPropertyFilter, ChartDisplayType, Experiment, InsightType } from '~/types' -import { experimentLogic, getDefaultFilters, getDefaultFunnelsMetric } from '../experimentLogic' +import { experimentLogic, getDefaultFunnelsMetric } from '../experimentLogic' import { PrimaryMetricModal } from '../Metrics/PrimaryMetricModal' import { PrimaryTrendsExposureModal } from '../Metrics/PrimaryTrendsExposureModal' @@ -67,66 +67,15 @@ export function MetricDisplayFunnels({ query }: { query: FunnelsQuery }): JSX.El ) } -// :FLAG: CLEAN UP AFTER MIGRATION -export function MetricDisplayOld({ filters }: { filters?: FilterType }): JSX.Element { - const metricType = filters?.insight || InsightType.TRENDS - - return ( - <> - {( - [ - ...(filters?.events || []), - ...(filters?.actions || []), - ...(filters?.data_warehouse || []), - ] as ActionFilter[] - ) - .sort((a, b) => (a.order || 0) - (b.order || 0)) - .map((event: ActionFilter, idx: number) => ( -
-
- {metricType === InsightType.FUNNELS && ( -
- {(event.order || 0) + 1} -
- )} - - - -
-
- {event.properties?.map((prop: AnyPropertyFilter) => ( - - ))} -
-
- ))} - - ) -} - export function ExposureMetric({ experimentId }: { experimentId: Experiment['id'] }): JSX.Element { - const { experiment, featureFlags } = useValues(experimentLogic({ experimentId })) + const { experiment } = useValues(experimentLogic({ experimentId })) const { updateExperimentExposure, loadExperiment, setExperiment } = useActions(experimentLogic({ experimentId })) const [isModalOpen, setIsModalOpen] = useState(false) const metricIdx = 0 // :FLAG: CLEAN UP AFTER MIGRATION - let hasCustomExposure = false - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - hasCustomExposure = !!(experiment.metrics[metricIdx] as ExperimentTrendsQuery).exposure_query - } else { - hasCustomExposure = !!experiment.parameters?.custom_exposure_filter - } + const hasCustomExposure = !!(experiment.metrics[metricIdx] as ExperimentTrendsQuery).exposure_query return ( <> @@ -139,14 +88,8 @@ export function ExposureMetric({ experimentId }: { experimentId: Experiment['id' {/* :FLAG: CLEAN UP AFTER MIGRATION */} - {featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL] ? ( - hasCustomExposure ? ( - - ) : ( - Default via $feature_flag_called events - ) - ) : hasCustomExposure ? ( - + {hasCustomExposure ? ( + ) : ( Default via $feature_flag_called events )} @@ -156,51 +99,39 @@ export function ExposureMetric({ experimentId }: { experimentId: Experiment['id' type="secondary" size="xsmall" onClick={() => { - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - if (!hasCustomExposure) { - setExperiment({ - ...experiment, - metrics: experiment.metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - exposure_query: { - kind: NodeKind.TrendsQuery, - series: [ - { - kind: NodeKind.EventsNode, - name: '$pageview', - event: '$pageview', - }, - ], - interval: 'day', - dateRange: { - date_from: dayjs() - .subtract(EXPERIMENT_DEFAULT_DURATION, 'day') - .format('YYYY-MM-DDTHH:mm'), - date_to: dayjs().endOf('d').format('YYYY-MM-DDTHH:mm'), - explicitDate: true, - }, - trendsFilter: { - display: ChartDisplayType.ActionsLineGraph, + if (!hasCustomExposure) { + setExperiment({ + ...experiment, + metrics: experiment.metrics.map((metric, idx) => + idx === metricIdx + ? { + ...metric, + exposure_query: { + kind: NodeKind.TrendsQuery, + series: [ + { + kind: NodeKind.EventsNode, + name: '$pageview', + event: '$pageview', }, - filterTestAccounts: true, + ], + interval: 'day', + dateRange: { + date_from: dayjs() + .subtract(EXPERIMENT_DEFAULT_DURATION, 'day') + .format('YYYY-MM-DDTHH:mm'), + date_to: dayjs().endOf('d').format('YYYY-MM-DDTHH:mm'), + explicitDate: true, + }, + trendsFilter: { + display: ChartDisplayType.ActionsLineGraph, }, - } - : metric - ), - }) - } - } else { - if (!hasCustomExposure) { - setExperiment({ - ...experiment, - parameters: { - ...experiment.parameters, - custom_exposure_filter: getDefaultFilters(InsightType.TRENDS, undefined), - }, - }) - } + filterTestAccounts: true, + }, + } + : metric + ), + }) } setIsModalOpen(true) }} @@ -215,14 +146,12 @@ export function ExposureMetric({ experimentId }: { experimentId: Experiment['id' size="xsmall" onClick={() => { // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setExperiment({ - ...experiment, - metrics: experiment.metrics.map((metric, idx) => - idx === metricIdx ? { ...metric, exposure_query: undefined } : metric - ), - }) - } + setExperiment({ + ...experiment, + metrics: experiment.metrics.map((metric, idx) => + idx === metricIdx ? { ...metric, exposure_query: undefined } : metric + ), + }) updateExperimentExposure(null) }} > @@ -244,7 +173,7 @@ export function ExposureMetric({ experimentId }: { experimentId: Experiment['id' } export function Goal(): JSX.Element { - const { experiment, experimentId, getMetricType, experimentMathAggregationForTrends, hasGoalSet, featureFlags } = + const { experiment, experimentId, getMetricType, experimentMathAggregationForTrends, hasGoalSet } = useValues(experimentLogic) const { setExperiment, loadExperiment } = useActions(experimentLogic) const [isModalOpen, setIsModalOpen] = useState(false) @@ -281,17 +210,10 @@ export function Goal(): JSX.Element { size="small" data-attr="add-experiment-goal" onClick={() => { - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setExperiment({ - ...experiment, - metrics: [getDefaultFunnelsMetric()], - }) - } else { - setExperiment({ - ...experiment, - filters: getDefaultFilters(InsightType.FUNNELS, undefined), - }) - } + setExperiment({ + ...experiment, + metrics: [getDefaultFunnelsMetric()], + }) setIsModalOpen(true) }} > @@ -304,19 +226,12 @@ export function Goal(): JSX.Element {
{metricType === InsightType.FUNNELS ? 'Conversion goal steps' : 'Trend goal'}
- {/* :FLAG: CLEAN UP AFTER MIGRATION */} - {featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL] ? ( - metricType === InsightType.FUNNELS ? ( - - ) : ( - - ) + {metricType === InsightType.FUNNELS ? ( + ) : ( - + )} setIsModalOpen(true)}> Change goal diff --git a/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx b/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx index 52a189c4c324ab..5474962ec738b7 100644 --- a/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx +++ b/frontend/src/scenes/experiments/ExperimentView/SecondaryMetricsTable.tsx @@ -2,19 +2,13 @@ import { IconInfo, IconPencil, IconPlus } from '@posthog/icons' import { LemonButton, LemonTable, LemonTableColumns, Tooltip } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { EntityFilterInfo } from 'lib/components/EntityFilterInfo' -import { FEATURE_FLAGS } from 'lib/constants' import { IconAreaChart } from 'lib/lemon-ui/icons' import { capitalizeFirstLetter, humanFriendlyNumber } from 'lib/utils' import { useState } from 'react' import { Experiment, InsightType } from '~/types' -import { - experimentLogic, - getDefaultFilters, - getDefaultFunnelsMetric, - TabularSecondaryMetricResults, -} from '../experimentLogic' +import { experimentLogic, getDefaultFunnelsMetric, TabularSecondaryMetricResults } from '../experimentLogic' import { SecondaryMetricChartModal } from '../Metrics/SecondaryMetricChartModal' import { SecondaryMetricModal } from '../Metrics/SecondaryMetricModal' import { VariantTag } from './components' @@ -39,7 +33,6 @@ export function SecondaryMetricsTable({ experimentId }: { experimentId: Experime credibleIntervalForVariant, experimentMathAggregationForTrends, getHighestProbabilityVariant, - featureFlags, } = useValues(experimentLogic({ experimentId })) const { loadExperiment } = useActions(experimentLogic({ experimentId })) @@ -64,13 +57,7 @@ export function SecondaryMetricsTable({ experimentId }: { experimentId: Experime setModalMetricIdx(null) } - // :FLAG: CLEAN UP AFTER MIGRATION - let metrics - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - metrics = experiment.metrics_secondary - } else { - metrics = experiment.secondary_metrics - } + const metrics = experiment.metrics_secondary const columns: LemonTableColumns = [ { @@ -339,7 +326,7 @@ const AddSecondaryMetricButton = ({ metrics: any openEditModal: (metricIdx: number) => void }): JSX.Element => { - const { experiment, featureFlags } = useValues(experimentLogic({ experimentId })) + const { experiment } = useValues(experimentLogic({ experimentId })) const { setExperiment } = useActions(experimentLogic({ experimentId })) return ( { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const newMetricsSecondary = [...experiment.metrics_secondary, getDefaultFunnelsMetric()] - setExperiment({ - metrics_secondary: newMetricsSecondary, - }) - openEditModal(newMetricsSecondary.length - 1) - } else { - const newSecondaryMetrics = [ - ...experiment.secondary_metrics, - { - name: '', - filters: getDefaultFilters(InsightType.FUNNELS, undefined), - }, - ] - setExperiment({ - secondary_metrics: newSecondaryMetrics, - }) - openEditModal(newSecondaryMetrics.length - 1) - } + const newMetricsSecondary = [...experiment.metrics_secondary, getDefaultFunnelsMetric()] + setExperiment({ + metrics_secondary: newMetricsSecondary, + }) + openEditModal(newMetricsSecondary.length - 1) }} disabledReason={ metrics.length >= MAX_SECONDARY_METRICS diff --git a/frontend/src/scenes/experiments/Metrics/PrimaryGoalFunnels.tsx b/frontend/src/scenes/experiments/Metrics/PrimaryGoalFunnels.tsx index 50468541a0d9b4..4628982ab5bbeb 100644 --- a/frontend/src/scenes/experiments/Metrics/PrimaryGoalFunnels.tsx +++ b/frontend/src/scenes/experiments/Metrics/PrimaryGoalFunnels.tsx @@ -3,14 +3,14 @@ import { LemonInput } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types' import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch' -import { EXPERIMENT_DEFAULT_DURATION, FEATURE_FLAGS } from 'lib/constants' +import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { LemonBanner } from 'lib/lemon-ui/LemonBanner' import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter' import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow' import { getHogQLValue } from 'scenes/insights/filters/AggregationSelect' import { teamLogic } from 'scenes/teamLogic' -import { actionsAndEventsToSeries, filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' +import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' import { Query } from '~/queries/Query/Query' import { ExperimentFunnelsQuery, NodeKind } from '~/queries/schema' @@ -25,7 +25,7 @@ import { } from './Selectors' export function PrimaryGoalFunnels(): JSX.Element { const { currentTeam } = useValues(teamLogic) - const { experiment, isExperimentRunning, featureFlags } = useValues(experimentLogic) + const { experiment, isExperimentRunning } = useValues(experimentLogic) const { setExperiment, setFunnelsMetric } = useActions(experimentLogic) const hasFilters = (currentTeam?.test_account_filters || []).length > 0 @@ -42,70 +42,30 @@ export function PrimaryGoalFunnels(): JSX.Element { <>
Name (optional) - {featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL] && ( - { - setFunnelsMetric({ - metricIdx, - name: newName, - }) - }} - /> - )} + { + setFunnelsMetric({ + metricIdx, + name: newName, + }) + }} + />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return queryNodeToFilter(currentMetric.funnels_query) - } - return experiment.filters - })()} + filters={queryNodeToFilter(currentMetric.funnels_query)} setFilters={({ actions, events, data_warehouse }: Partial): void => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const series = actionsAndEventsToSeries( - { actions, events, data_warehouse } as any, - true, - MathAvailability.None - ) + const series = actionsAndEventsToSeries( + { actions, events, data_warehouse } as any, + true, + MathAvailability.None + ) - setFunnelsMetric({ - metricIdx, - series, - }) - } else { - if (actions?.length) { - setExperiment({ - filters: { - ...experiment.filters, - actions, - events: undefined, - data_warehouse: undefined, - }, - }) - } else if (events?.length) { - setExperiment({ - filters: { - ...experiment.filters, - events, - actions: undefined, - data_warehouse: undefined, - }, - }) - } else if (data_warehouse?.length) { - setExperiment({ - filters: { - ...experiment.filters, - data_warehouse, - actions: undefined, - events: undefined, - }, - }) - } - } + setFunnelsMetric({ + metricIdx, + series, + }) }} typeKey="experiment-metric" mathAvailability={MathAvailability.None} @@ -118,66 +78,25 @@ export function PrimaryGoalFunnels(): JSX.Element { />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return getHogQLValue( - currentMetric.funnels_query.aggregation_group_type_index ?? undefined, - currentMetric.funnels_query.funnelsFilter?.funnelAggregateByHogQL ?? undefined - ) - } - return getHogQLValue( - experiment.filters.aggregation_group_type_index, - (experiment.filters as FunnelsFilterType).funnel_aggregate_by_hogql - ) - })()} + value={getHogQLValue( + currentMetric.funnels_query.aggregation_group_type_index ?? undefined, + currentMetric.funnels_query.funnelsFilter?.funnelAggregateByHogQL ?? undefined + )} onChange={(value) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - funnelAggregateByHogQL: value, - }) - } else { - setExperiment({ - filters: { - ...experiment.filters, - funnel_aggregate_by_hogql: value, - }, - }) - } + setFunnelsMetric({ + metricIdx, + funnelAggregateByHogQL: value, + }) }} /> { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.funnels_query?.funnelsFilter?.funnelWindowInterval - } - return (experiment.filters as FunnelsFilterType).funnel_window_interval - })()} - funnelWindowIntervalUnit={(() => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.funnels_query?.funnelsFilter?.funnelWindowIntervalUnit - } - return (experiment.filters as FunnelsFilterType).funnel_window_interval_unit - })()} + funnelWindowInterval={currentMetric.funnels_query?.funnelsFilter?.funnelWindowInterval} + funnelWindowIntervalUnit={currentMetric.funnels_query?.funnelsFilter?.funnelWindowIntervalUnit} onFunnelWindowIntervalChange={(funnelWindowInterval) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - funnelWindowInterval: funnelWindowInterval, - }) - } else { - setExperiment({ - filters: { - ...experiment.filters, - funnel_window_interval: funnelWindowInterval, - }, - }) - } + setFunnelsMetric({ + metricIdx, + funnelWindowInterval: funnelWindowInterval, + }) }} onFunnelWindowIntervalUnitChange={(funnelWindowIntervalUnit) => { // :FLAG: CLEAN UP AFTER MIGRATION @@ -258,30 +177,12 @@ export function PrimaryGoalFunnels(): JSX.Element { })()} /> { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const val = (experiment.metrics[0] as ExperimentFunnelsQuery).funnels_query - ?.filterTestAccounts - return hasFilters ? !!val : false - } - return hasFilters ? !!experiment.filters.filter_test_accounts : false - })()} + checked={hasFilters ? !!currentMetric.funnels_query?.filterTestAccounts : false} onChange={(checked: boolean) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - filterTestAccounts: checked, - }) - } else { - setExperiment({ - filters: { - ...experiment.filters, - filter_test_accounts: checked, - }, - }) - } + setFunnelsMetric({ + metricIdx, + filterTestAccounts: checked, + }) }} fullWidth /> @@ -293,17 +194,10 @@ export function PrimaryGoalFunnels(): JSX.Element { )}
- {/* :FLAG: CLEAN UP AFTER MIGRATION */} { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.funnels_query - } - return filtersToQueryNode(experiment.filters) - })(), + source: currentMetric.funnels_query, showTable: false, showLastComputation: true, showLastComputationRefresh: false, diff --git a/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx b/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx index 0ce1cb72e33daf..2a673a9fc8c066 100644 --- a/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx +++ b/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrends.tsx @@ -1,13 +1,13 @@ import { LemonInput, LemonLabel } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch' -import { EXPERIMENT_DEFAULT_DURATION, FEATURE_FLAGS } from 'lib/constants' +import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { LemonBanner } from 'lib/lemon-ui/LemonBanner' import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter' import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow' import { teamLogic } from 'scenes/teamLogic' -import { actionsAndEventsToSeries, filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' +import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' import { Query } from '~/queries/Query/Query' import { ExperimentTrendsQuery, NodeKind } from '~/queries/schema' @@ -17,8 +17,8 @@ import { experimentLogic } from '../experimentLogic' import { commonActionFilterProps } from './Selectors' export function PrimaryGoalTrends(): JSX.Element { - const { experiment, isExperimentRunning, featureFlags } = useValues(experimentLogic) - const { setExperiment, setTrendsMetric } = useActions(experimentLogic) + const { experiment, isExperimentRunning } = useValues(experimentLogic) + const { setTrendsMetric } = useActions(experimentLogic) const { currentTeam } = useValues(teamLogic) const hasFilters = (currentTeam?.test_account_filters || []).length > 0 @@ -29,70 +29,30 @@ export function PrimaryGoalTrends(): JSX.Element { <>
Name (optional) - {featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL] && ( - { - setTrendsMetric({ - metricIdx, - name: newName, - }) - }} - /> - )} + { + setTrendsMetric({ + metricIdx, + name: newName, + }) + }} + />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return queryNodeToFilter(currentMetric.count_query) - } - return experiment.filters - })()} + filters={queryNodeToFilter(currentMetric.count_query)} setFilters={({ actions, events, data_warehouse }: Partial): void => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const series = actionsAndEventsToSeries( - { actions, events, data_warehouse } as any, - true, - MathAvailability.All - ) + const series = actionsAndEventsToSeries( + { actions, events, data_warehouse } as any, + true, + MathAvailability.All + ) - setTrendsMetric({ - metricIdx, - series, - }) - } else { - if (actions?.length) { - setExperiment({ - filters: { - ...experiment.filters, - actions, - events: undefined, - data_warehouse: undefined, - }, - }) - } else if (events?.length) { - setExperiment({ - filters: { - ...experiment.filters, - events, - actions: undefined, - data_warehouse: undefined, - }, - }) - } else if (data_warehouse?.length) { - setExperiment({ - filters: { - ...experiment.filters, - data_warehouse, - actions: undefined, - events: undefined, - }, - }) - } - } + setTrendsMetric({ + metricIdx, + series, + }) }} typeKey="experiment-metric" buttonCopy="Add graph series" @@ -103,29 +63,12 @@ export function PrimaryGoalTrends(): JSX.Element { />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const val = currentMetric.count_query?.filterTestAccounts - return hasFilters ? !!val : false - } - return hasFilters ? !!experiment.filters.filter_test_accounts : false - })()} + checked={hasFilters ? !!currentMetric.count_query?.filterTestAccounts : false} onChange={(checked: boolean) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setTrendsMetric({ - metricIdx, - filterTestAccounts: checked, - }) - } else { - setExperiment({ - filters: { - ...experiment.filters, - filter_test_accounts: checked, - }, - }) - } + setTrendsMetric({ + metricIdx, + filterTestAccounts: checked, + }) }} fullWidth /> @@ -137,17 +80,10 @@ export function PrimaryGoalTrends(): JSX.Element { )}
- {/* :FLAG: CLEAN UP AFTER MIGRATION */} { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.count_query - } - return filtersToQueryNode(experiment.filters) - })(), + source: currentMetric.count_query, showTable: false, showLastComputation: true, showLastComputationRefresh: false, diff --git a/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrendsExposure.tsx b/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrendsExposure.tsx index 4ebe43c30e9282..e55e8b5b91a865 100644 --- a/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrendsExposure.tsx +++ b/frontend/src/scenes/experiments/Metrics/PrimaryGoalTrendsExposure.tsx @@ -1,12 +1,12 @@ import { useActions, useValues } from 'kea' import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch' -import { EXPERIMENT_DEFAULT_DURATION, FEATURE_FLAGS } from 'lib/constants' +import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { LemonBanner } from 'lib/lemon-ui/LemonBanner' import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter' import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow' import { teamLogic } from 'scenes/teamLogic' -import { actionsAndEventsToSeries, filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' +import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' import { Query } from '~/queries/Query/Query' import { ExperimentTrendsQuery, InsightQueryNode, NodeKind } from '~/queries/schema' @@ -16,8 +16,8 @@ import { experimentLogic } from '../experimentLogic' import { commonActionFilterProps } from './Selectors' export function PrimaryGoalTrendsExposure(): JSX.Element { - const { experiment, isExperimentRunning, featureFlags } = useValues(experimentLogic) - const { setExperiment, setTrendsExposureMetric } = useActions(experimentLogic) + const { experiment, isExperimentRunning } = useValues(experimentLogic) + const { setTrendsExposureMetric } = useActions(experimentLogic) const { currentTeam } = useValues(teamLogic) const hasFilters = (currentTeam?.test_account_filters || []).length > 0 const currentMetric = experiment.metrics[0] as ExperimentTrendsQuery @@ -26,65 +26,18 @@ export function PrimaryGoalTrendsExposure(): JSX.Element { <> { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return queryNodeToFilter(currentMetric.exposure_query as InsightQueryNode) - } - return experiment.parameters.custom_exposure_filter as FilterType - })()} + filters={queryNodeToFilter(currentMetric.exposure_query as InsightQueryNode)} setFilters={({ actions, events, data_warehouse }: Partial): void => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const series = actionsAndEventsToSeries( - { actions, events, data_warehouse } as any, - true, - MathAvailability.All - ) + const series = actionsAndEventsToSeries( + { actions, events, data_warehouse } as any, + true, + MathAvailability.All + ) - setTrendsExposureMetric({ - metricIdx: 0, - series, - }) - } else { - if (actions?.length) { - setExperiment({ - parameters: { - ...experiment.parameters, - custom_exposure_filter: { - ...experiment.parameters.custom_exposure_filter, - actions, - events: undefined, - data_warehouse: undefined, - }, - }, - }) - } else if (events?.length) { - setExperiment({ - parameters: { - ...experiment.parameters, - custom_exposure_filter: { - ...experiment.parameters.custom_exposure_filter, - events, - actions: undefined, - data_warehouse: undefined, - }, - }, - }) - } else if (data_warehouse?.length) { - setExperiment({ - parameters: { - ...experiment.parameters, - custom_exposure_filter: { - ...experiment.parameters.custom_exposure_filter, - data_warehouse, - actions: undefined, - events: undefined, - }, - }, - }) - } - } + setTrendsExposureMetric({ + metricIdx: 0, + series, + }) }} typeKey="experiment-metric" buttonCopy="Add graph series" @@ -95,34 +48,12 @@ export function PrimaryGoalTrendsExposure(): JSX.Element { />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const val = currentMetric.exposure_query?.filterTestAccounts - return hasFilters ? !!val : false - } - return hasFilters - ? !!(experiment.parameters.custom_exposure_filter as FilterType).filter_test_accounts - : false - })()} + checked={hasFilters ? !!currentMetric.exposure_query?.filterTestAccounts : false} onChange={(checked: boolean) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setTrendsExposureMetric({ - metricIdx: 0, - filterTestAccounts: checked, - }) - } else { - setExperiment({ - parameters: { - ...experiment.parameters, - custom_exposure_filter: { - ...experiment.parameters.custom_exposure_filter, - filter_test_accounts: checked, - }, - }, - }) - } + setTrendsExposureMetric({ + metricIdx: 0, + filterTestAccounts: checked, + }) }} fullWidth /> @@ -134,17 +65,10 @@ export function PrimaryGoalTrendsExposure(): JSX.Element { )}
- {/* :FLAG: CLEAN UP AFTER MIGRATION */} { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.exposure_query - } - return filtersToQueryNode(experiment.parameters.custom_exposure_filter as FilterType) - })(), + source: currentMetric.exposure_query, showTable: false, showLastComputation: true, showLastComputationRefresh: false, diff --git a/frontend/src/scenes/experiments/Metrics/PrimaryTrendsExposureModal.tsx b/frontend/src/scenes/experiments/Metrics/PrimaryTrendsExposureModal.tsx index 7c4f49c114a73c..a7d410258d662d 100644 --- a/frontend/src/scenes/experiments/Metrics/PrimaryTrendsExposureModal.tsx +++ b/frontend/src/scenes/experiments/Metrics/PrimaryTrendsExposureModal.tsx @@ -1,6 +1,5 @@ import { LemonButton, LemonModal } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' -import { FEATURE_FLAGS } from 'lib/constants' import { Experiment } from '~/types' @@ -16,8 +15,8 @@ export function PrimaryTrendsExposureModal({ isOpen: boolean onClose: () => void }): JSX.Element { - const { experiment, experimentLoading, featureFlags } = useValues(experimentLogic({ experimentId })) - const { updateExperimentExposure, updateExperiment } = useActions(experimentLogic({ experimentId })) + const { experiment, experimentLoading } = useValues(experimentLogic({ experimentId })) + const { updateExperiment } = useActions(experimentLogic({ experimentId })) return ( { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - updateExperiment({ - metrics: experiment.metrics, - }) - } else { - updateExperimentExposure(experiment.parameters.custom_exposure_filter ?? null) - } + updateExperiment({ + metrics: experiment.metrics, + }) }} type="primary" loading={experimentLoading} diff --git a/frontend/src/scenes/experiments/Metrics/SecondaryGoalFunnels.tsx b/frontend/src/scenes/experiments/Metrics/SecondaryGoalFunnels.tsx index a0e903fdeab840..c0ec31dad31da7 100644 --- a/frontend/src/scenes/experiments/Metrics/SecondaryGoalFunnels.tsx +++ b/frontend/src/scenes/experiments/Metrics/SecondaryGoalFunnels.tsx @@ -2,14 +2,14 @@ import { LemonLabel } from '@posthog/lemon-ui' import { LemonInput } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch' -import { EXPERIMENT_DEFAULT_DURATION, FEATURE_FLAGS } from 'lib/constants' +import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { LemonBanner } from 'lib/lemon-ui/LemonBanner' import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter' import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow' import { getHogQLValue } from 'scenes/insights/filters/AggregationSelect' import { teamLogic } from 'scenes/teamLogic' -import { actionsAndEventsToSeries, filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' +import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' import { Query } from '~/queries/Query/Query' import { ExperimentFunnelsQuery, NodeKind } from '~/queries/schema' @@ -25,7 +25,7 @@ import { export function SecondaryGoalFunnels({ metricIdx }: { metricIdx: number }): JSX.Element { const { currentTeam } = useValues(teamLogic) - const { experiment, isExperimentRunning, featureFlags } = useValues(experimentLogic) + const { experiment, isExperimentRunning } = useValues(experimentLogic) const { setExperiment, setFunnelsMetric } = useActions(experimentLogic) const hasFilters = (currentTeam?.test_account_filters || []).length > 0 const currentMetric = experiment.metrics_secondary[metricIdx] as ExperimentFunnelsQuery @@ -35,104 +35,31 @@ export function SecondaryGoalFunnels({ metricIdx }: { metricIdx: number }): JSX.
Name (optional) { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.name - } - return experiment.secondary_metrics[metricIdx].name - })()} + value={currentMetric.name} onChange={(newName) => { - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - name: newName, - isSecondary: true, - }) - } else { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx ? { ...metric, name: newName } : metric - ), - }) - } + setFunnelsMetric({ + metricIdx, + name: newName, + isSecondary: true, + }) }} />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return queryNodeToFilter(currentMetric.funnels_query) - } - return experiment.secondary_metrics[metricIdx].filters - })()} + filters={queryNodeToFilter(currentMetric.funnels_query)} setFilters={({ actions, events, data_warehouse }: Partial): void => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const series = actionsAndEventsToSeries( - { actions, events, data_warehouse } as any, - true, - MathAvailability.None - ) + const series = actionsAndEventsToSeries( + { actions, events, data_warehouse } as any, + true, + MathAvailability.None + ) - setFunnelsMetric({ - metricIdx, - series, - isSecondary: true, - }) - } else { - if (actions?.length) { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - actions, - events: undefined, - data_warehouse: undefined, - }, - } - : metric - ), - }) - } else if (events?.length) { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - events, - actions: undefined, - data_warehouse: undefined, - }, - } - : metric - ), - }) - } else if (data_warehouse?.length) { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - data_warehouse, - actions: undefined, - events: undefined, - }, - } - : metric - ), - }) - } - } + setFunnelsMetric({ + metricIdx, + series, + isSecondary: true, + }) }} typeKey="experiment-metric" mathAvailability={MathAvailability.None} @@ -145,85 +72,27 @@ export function SecondaryGoalFunnels({ metricIdx }: { metricIdx: number }): JSX. />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return getHogQLValue( - currentMetric.funnels_query.aggregation_group_type_index ?? undefined, - currentMetric.funnels_query.funnelsFilter?.funnelAggregateByHogQL ?? undefined - ) - } - return getHogQLValue( - experiment.secondary_metrics[metricIdx].filters.aggregation_group_type_index, - (experiment.secondary_metrics[metricIdx].filters as FunnelsFilterType) - .funnel_aggregate_by_hogql - ) - })()} + value={getHogQLValue( + currentMetric.funnels_query.aggregation_group_type_index ?? undefined, + currentMetric.funnels_query.funnelsFilter?.funnelAggregateByHogQL ?? undefined + )} onChange={(value) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - funnelAggregateByHogQL: value, - isSecondary: true, - }) - } else { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - funnel_aggregate_by_hogql: value, - }, - } - : metric - ), - }) - } + setFunnelsMetric({ + metricIdx, + funnelAggregateByHogQL: value, + isSecondary: true, + }) }} /> { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.funnels_query?.funnelsFilter?.funnelWindowInterval - } - return (experiment.secondary_metrics[metricIdx].filters as FunnelsFilterType) - .funnel_window_interval - })()} - funnelWindowIntervalUnit={(() => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.funnels_query?.funnelsFilter?.funnelWindowIntervalUnit - } - return (experiment.secondary_metrics[metricIdx].filters as FunnelsFilterType) - .funnel_window_interval_unit - })()} + funnelWindowInterval={currentMetric.funnels_query?.funnelsFilter?.funnelWindowInterval} + funnelWindowIntervalUnit={currentMetric.funnels_query?.funnelsFilter?.funnelWindowIntervalUnit} onFunnelWindowIntervalChange={(funnelWindowInterval) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - funnelWindowInterval: funnelWindowInterval, - isSecondary: true, - }) - } else { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - funnel_window_interval: funnelWindowInterval, - }, - } - : metric - ), - }) - } + setFunnelsMetric({ + metricIdx, + funnelWindowInterval: funnelWindowInterval, + isSecondary: true, + }) }} onFunnelWindowIntervalUnitChange={(funnelWindowIntervalUnit) => { // :FLAG: CLEAN UP AFTER MIGRATION @@ -323,40 +192,13 @@ export function SecondaryGoalFunnels({ metricIdx }: { metricIdx: number }): JSX. })()} /> { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const val = (experiment.metrics_secondary[metricIdx] as ExperimentFunnelsQuery) - .funnels_query?.filterTestAccounts - return hasFilters ? !!val : false - } - return hasFilters - ? !!experiment.secondary_metrics[metricIdx].filters.filter_test_accounts - : false - })()} + checked={hasFilters ? !!currentMetric.funnels_query?.filterTestAccounts : false} onChange={(checked: boolean) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setFunnelsMetric({ - metricIdx, - filterTestAccounts: checked, - isSecondary: true, - }) - } else { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - filter_test_accounts: checked, - }, - } - : metric - ), - }) - } + setFunnelsMetric({ + metricIdx, + filterTestAccounts: checked, + isSecondary: true, + }) }} fullWidth /> @@ -368,17 +210,10 @@ export function SecondaryGoalFunnels({ metricIdx }: { metricIdx: number }): JSX. )}
- {/* :FLAG: CLEAN UP AFTER MIGRATION */} { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.funnels_query - } - return filtersToQueryNode(experiment.secondary_metrics[metricIdx].filters) - })(), + source: currentMetric.funnels_query, showTable: false, showLastComputation: true, showLastComputationRefresh: false, diff --git a/frontend/src/scenes/experiments/Metrics/SecondaryGoalTrends.tsx b/frontend/src/scenes/experiments/Metrics/SecondaryGoalTrends.tsx index 20aae645e6e1ec..1f844ce281b244 100644 --- a/frontend/src/scenes/experiments/Metrics/SecondaryGoalTrends.tsx +++ b/frontend/src/scenes/experiments/Metrics/SecondaryGoalTrends.tsx @@ -2,13 +2,13 @@ import { LemonLabel } from '@posthog/lemon-ui' import { LemonInput } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' import { TestAccountFilterSwitch } from 'lib/components/TestAccountFiltersSwitch' -import { EXPERIMENT_DEFAULT_DURATION, FEATURE_FLAGS } from 'lib/constants' +import { EXPERIMENT_DEFAULT_DURATION } from 'lib/constants' import { LemonBanner } from 'lib/lemon-ui/LemonBanner' import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter' import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow' import { teamLogic } from 'scenes/teamLogic' -import { actionsAndEventsToSeries, filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' +import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode' import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' import { Query } from '~/queries/Query/Query' import { ExperimentTrendsQuery, NodeKind } from '~/queries/schema' @@ -18,8 +18,8 @@ import { experimentLogic } from '../experimentLogic' import { commonActionFilterProps } from './Selectors' export function SecondaryGoalTrends({ metricIdx }: { metricIdx: number }): JSX.Element { - const { experiment, isExperimentRunning, featureFlags } = useValues(experimentLogic) - const { setExperiment, setTrendsMetric } = useActions(experimentLogic) + const { experiment, isExperimentRunning } = useValues(experimentLogic) + const { setTrendsMetric } = useActions(experimentLogic) const { currentTeam } = useValues(teamLogic) const hasFilters = (currentTeam?.test_account_filters || []).length > 0 const currentMetric = experiment.metrics_secondary[metricIdx] as ExperimentTrendsQuery @@ -29,104 +29,31 @@ export function SecondaryGoalTrends({ metricIdx }: { metricIdx: number }): JSX.E
Name (optional) { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.name - } - return experiment.secondary_metrics[metricIdx].name - })()} + value={currentMetric.name} onChange={(newName) => { - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setTrendsMetric({ - metricIdx, - name: newName, - isSecondary: true, - }) - } else { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx ? { ...metric, name: newName } : metric - ), - }) - } + setTrendsMetric({ + metricIdx, + name: newName, + isSecondary: true, + }) }} />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return queryNodeToFilter(currentMetric.count_query) - } - return experiment.secondary_metrics[metricIdx].filters - })()} + filters={queryNodeToFilter(currentMetric.count_query)} setFilters={({ actions, events, data_warehouse }: Partial): void => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const series = actionsAndEventsToSeries( - { actions, events, data_warehouse } as any, - true, - MathAvailability.All - ) + const series = actionsAndEventsToSeries( + { actions, events, data_warehouse } as any, + true, + MathAvailability.All + ) - setTrendsMetric({ - metricIdx, - series, - isSecondary: true, - }) - } else { - if (actions?.length) { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - actions, - events: undefined, - data_warehouse: undefined, - }, - } - : metric - ), - }) - } else if (events?.length) { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - events, - actions: undefined, - data_warehouse: undefined, - }, - } - : metric - ), - }) - } else if (data_warehouse?.length) { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - data_warehouse, - actions: undefined, - events: undefined, - }, - } - : metric - ), - }) - } - } + setTrendsMetric({ + metricIdx, + series, + isSecondary: true, + }) }} typeKey="experiment-metric" buttonCopy="Add graph series" @@ -137,39 +64,13 @@ export function SecondaryGoalTrends({ metricIdx }: { metricIdx: number }): JSX.E />
{ - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const val = currentMetric.count_query?.filterTestAccounts - return hasFilters ? !!val : false - } - return hasFilters - ? !!experiment.secondary_metrics[metricIdx].filters.filter_test_accounts - : false - })()} + checked={hasFilters ? !!currentMetric.count_query?.filterTestAccounts : false} onChange={(checked: boolean) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setTrendsMetric({ - metricIdx, - filterTestAccounts: checked, - isSecondary: true, - }) - } else { - setExperiment({ - secondary_metrics: experiment.secondary_metrics.map((metric, idx) => - idx === metricIdx - ? { - ...metric, - filters: { - ...metric.filters, - filter_test_accounts: checked, - }, - } - : metric - ), - }) - } + setTrendsMetric({ + metricIdx, + filterTestAccounts: checked, + isSecondary: true, + }) }} fullWidth /> @@ -181,17 +82,10 @@ export function SecondaryGoalTrends({ metricIdx }: { metricIdx: number }): JSX.E )}
- {/* :FLAG: CLEAN UP AFTER MIGRATION */} { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return currentMetric.count_query - } - return filtersToQueryNode(experiment.secondary_metrics[metricIdx].filters) - })(), + source: currentMetric.count_query, showTable: false, showLastComputation: true, showLastComputationRefresh: false, diff --git a/frontend/src/scenes/experiments/Metrics/SecondaryMetricModal.tsx b/frontend/src/scenes/experiments/Metrics/SecondaryMetricModal.tsx index 14a8304b973e2c..423fb1c48d5c1d 100644 --- a/frontend/src/scenes/experiments/Metrics/SecondaryMetricModal.tsx +++ b/frontend/src/scenes/experiments/Metrics/SecondaryMetricModal.tsx @@ -1,10 +1,9 @@ import { LemonButton, LemonModal, LemonSelect } from '@posthog/lemon-ui' import { useActions, useValues } from 'kea' -import { FEATURE_FLAGS } from 'lib/constants' import { Experiment, InsightType } from '~/types' -import { experimentLogic, getDefaultFilters, getDefaultFunnelsMetric, getDefaultTrendsMetric } from '../experimentLogic' +import { experimentLogic, getDefaultFunnelsMetric, getDefaultTrendsMetric } from '../experimentLogic' import { SecondaryGoalFunnels } from './SecondaryGoalFunnels' import { SecondaryGoalTrends } from './SecondaryGoalTrends' @@ -19,9 +18,7 @@ export function SecondaryMetricModal({ isOpen: boolean onClose: () => void }): JSX.Element { - const { experiment, experimentLoading, getSecondaryMetricType, featureFlags } = useValues( - experimentLogic({ experimentId }) - ) + const { experiment, experimentLoading, getSecondaryMetricType } = useValues(experimentLogic({ experimentId })) const { setExperiment, updateExperiment } = useActions(experimentLogic({ experimentId })) const metricType = getSecondaryMetricType(metricIdx) @@ -37,28 +34,15 @@ export function SecondaryMetricModal({ type="secondary" status="danger" onClick={() => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - const newMetricsSecondary = experiment.metrics_secondary.filter( - (_, idx) => idx !== metricIdx - ) - setExperiment({ - metrics_secondary: newMetricsSecondary, - }) - updateExperiment({ - metrics_secondary: newMetricsSecondary, - }) - } else { - const newSecondaryMetrics = experiment.secondary_metrics.filter( - (_, idx) => idx !== metricIdx - ) - setExperiment({ - secondary_metrics: newSecondaryMetrics, - }) - updateExperiment({ - secondary_metrics: newSecondaryMetrics, - }) - } + const newMetricsSecondary = experiment.metrics_secondary.filter( + (_, idx) => idx !== metricIdx + ) + setExperiment({ + metrics_secondary: newMetricsSecondary, + }) + updateExperiment({ + metrics_secondary: newMetricsSecondary, + }) }} > Delete @@ -69,16 +53,9 @@ export function SecondaryMetricModal({ { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - updateExperiment({ - metrics_secondary: experiment.metrics_secondary, - }) - } else { - updateExperiment({ - secondary_metrics: experiment.secondary_metrics, - }) - } + updateExperiment({ + metrics_secondary: experiment.metrics_secondary, + }) }} type="primary" loading={experimentLoading} @@ -96,30 +73,16 @@ export function SecondaryMetricModal({ data-attr="metrics-selector" value={metricType} onChange={(newMetricType) => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - setExperiment({ - ...experiment, - metrics_secondary: [ - ...experiment.metrics_secondary.slice(0, metricIdx), - newMetricType === InsightType.TRENDS - ? getDefaultTrendsMetric() - : getDefaultFunnelsMetric(), - ...experiment.metrics_secondary.slice(metricIdx + 1), - ], - }) - } else { - setExperiment({ - ...experiment, - secondary_metrics: [ - ...experiment.secondary_metrics.slice(0, metricIdx), - newMetricType === InsightType.TRENDS - ? { name: '', filters: getDefaultFilters(InsightType.TRENDS, undefined) } - : { name: '', filters: getDefaultFilters(InsightType.FUNNELS, undefined) }, - ...experiment.secondary_metrics.slice(metricIdx + 1), - ], - }) - } + setExperiment({ + ...experiment, + metrics_secondary: [ + ...experiment.metrics_secondary.slice(0, metricIdx), + newMetricType === InsightType.TRENDS + ? getDefaultTrendsMetric() + : getDefaultFunnelsMetric(), + ...experiment.metrics_secondary.slice(metricIdx + 1), + ], + }) }} options={[ { value: InsightType.TRENDS, label: Trends }, diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsx index 88d57b134e0d31..6f57ba78f013f2 100644 --- a/frontend/src/scenes/experiments/experimentLogic.tsx +++ b/frontend/src/scenes/experiments/experimentLogic.tsx @@ -5,7 +5,6 @@ import { loaders } from 'kea-loaders' import { router, urlToAction } from 'kea-router' import api from 'lib/api' import { EXPERIMENT_DEFAULT_DURATION, FunnelLayout } from 'lib/constants' -import { FEATURE_FLAGS } from 'lib/constants' import { dayjs } from 'lib/dayjs' import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast' import { Tooltip } from 'lib/lemon-ui/Tooltip' @@ -107,20 +106,6 @@ export interface ExperimentResultCalculationError { statusCode: number } -// :FLAG: CLEAN UP AFTER MIGRATION -export interface CachedSecondaryMetricExperimentFunnelsQueryResponse extends CachedExperimentFunnelsQueryResponse { - filters?: { - insight?: InsightType - } -} - -// :FLAG: CLEAN UP AFTER MIGRATION -export interface CachedSecondaryMetricExperimentTrendsQueryResponse extends CachedExperimentTrendsQueryResponse { - filters?: { - insight?: InsightType - } -} - export const experimentLogic = kea([ props({} as ExperimentLogicProps), key((props) => props.experimentId || 'new'), @@ -1338,11 +1323,7 @@ export const experimentLogic = kea([ () => [], () => ( - experimentResults: - | Partial - | CachedSecondaryMetricExperimentFunnelsQueryResponse - | CachedSecondaryMetricExperimentTrendsQueryResponse - | null, + experimentResults: Partial | null, variantKey: string, metricType: InsightType ): [number, number] | null => { @@ -1677,19 +1658,9 @@ export const experimentLogic = kea([ }, ], hasGoalSet: [ - (s) => [s.experiment, s.featureFlags], - (experiment, featureFlags): boolean => { - // :FLAG: CLEAN UP AFTER MIGRATION - if (featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL]) { - return !!experiment.metrics[0] - } - - const filters = experiment?.filters - return !!( - (filters?.actions && filters.actions.length > 0) || - (filters?.events && filters.events.length > 0) || - (filters?.data_warehouse && filters.data_warehouse.length > 0) - ) + (s) => [s.experiment], + (experiment): boolean => { + return !!experiment.metrics[0] }, ], }),