From baa6a18761fbbe9fccea8a75dcf82e1833d1ce17 Mon Sep 17 00:00:00 2001
From: Anders <754494+andehen@users.noreply.github.com>
Date: Mon, 6 Jan 2025 18:16:56 +0100
Subject: [PATCH] chore(experiments): hogql migration cleanup - Goal (#27264)
---
.../experiments/ExperimentView/Goal.tsx | 136 ++++++------------
1 file changed, 47 insertions(+), 89 deletions(-)
diff --git a/frontend/src/scenes/experiments/ExperimentView/Goal.tsx b/frontend/src/scenes/experiments/ExperimentView/Goal.tsx
index 86a9b27c23eea..bab3d4d8190f1 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 { experimentLogic, getDefaultFilters, getDefaultFunnelsMetric } from '../experimentLogic'
+import { experimentLogic, getDefaultFunnelsMetric } from '../experimentLogic'
import { PrimaryTrendsExposureModal } from '../Metrics/PrimaryTrendsExposureModal'
export function MetricDisplayTrends({ query }: { query: TrendsQuery | undefined }): JSX.Element {
@@ -113,21 +113,14 @@ export function MetricDisplayOld({ filters }: { filters?: FilterType }): JSX.Ele
}
export function ExposureMetric({ experimentId }: { experimentId: Experiment['id'] }): JSX.Element {
- const { experiment, featureFlags } = useValues(experimentLogic({ experimentId }))
+ const { experiment } = useValues(experimentLogic({ experimentId }))
const { updateExperimentGoal, loadExperiment, setExperiment, setEditingPrimaryMetricIndex } = 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,15 +132,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
)}
@@ -157,51 +143,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
+ ),
+ })
}
setEditingPrimaryMetricIndex(metricIdx)
setIsModalOpen(true)
@@ -244,14 +218,12 @@ 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, openPrimaryMetricModal } = useActions(experimentLogic)
const metricType = _getMetricType(experiment.metrics[0])
- // :FLAG: CLEAN UP AFTER MIGRATION
const isDataWarehouseMetric =
- featureFlags[FEATURE_FLAGS.EXPERIMENTS_HOGQL] &&
metricType === InsightType.TRENDS &&
(experiment.metrics[0] as ExperimentTrendsQuery).count_query?.series[0].kind === NodeKind.DataWarehouseNode
@@ -286,17 +258,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()],
+ })
openPrimaryMetricModal(0)
}}
>
@@ -309,19 +274,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 ? (
+
) : (
-
+
)}
openPrimaryMetricModal(0)}>
Change goal