Skip to content

Commit

Permalink
clean up SecondaryMetricsTable
Browse files Browse the repository at this point in the history
  • Loading branch information
andehen committed Dec 17, 2024
1 parent 27b3d2e commit cbc2106
Showing 1 changed file with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -39,7 +33,6 @@ export function SecondaryMetricsTable({ experimentId }: { experimentId: Experime
credibleIntervalForVariant,
experimentMathAggregationForTrends,
getHighestProbabilityVariant,
featureFlags,
} = useValues(experimentLogic({ experimentId }))
const { loadExperiment } = useActions(experimentLogic({ experimentId }))

Expand All @@ -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<any> = [
{
Expand Down Expand Up @@ -339,34 +326,19 @@ 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 (
<LemonButton
icon={<IconPlus />}
type="secondary"
size="small"
onClick={() => {
// :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
Expand Down

0 comments on commit cbc2106

Please sign in to comment.