Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(experiments): hogql migration cleanup - secondary metrics #26962

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading