From e2645519307dd2bc5ad5f9296ff64bdd1b3b2346 Mon Sep 17 00:00:00 2001 From: Anders <754494+andehen@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:35:33 +0100 Subject: [PATCH] chore(experiments): hogql migration cleanup - SecondaryMetricModal (#27040) --- .../Metrics/SecondaryMetricModal.tsx | 85 ++++++------------- 1 file changed, 24 insertions(+), 61 deletions(-) diff --git a/frontend/src/scenes/experiments/Metrics/SecondaryMetricModal.tsx b/frontend/src/scenes/experiments/Metrics/SecondaryMetricModal.tsx index 14a8304b973e2..423fb1c48d5c1 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 },