Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(experiments): delete the unrouted create path and dead selectors (#100149)

Andersdb2ec81742c9
diff --git a/frontend/src/scenes/experiments/Experiment.tsx b/frontend/src/scenes/experiments/Experiment.tsx
index 4cbe6b274db2..c786d0e501a7 100644
--- a/frontend/src/scenes/experiments/Experiment.tsx
+++ b/frontend/src/scenes/experiments/Experiment.tsx
@@ -42,7 +42,7 @@ export function Experiment(): JSX.Element {
return <NotFound object="experiment" />
}
- const isCreateMode = formMode && ([FORM_MODES.create, FORM_MODES.duplicate] as string[]).includes(formMode)
+ const isCreateMode = formMode === FORM_MODES.create
return (
<BindLogic logic={experimentLogic} props={logicProps}>
diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsx
index 04b5b7799181..e03b6619a4ad 100644
--- a/frontend/src/scenes/experiments/experimentLogic.tsx
+++ b/frontend/src/scenes/experiments/experimentLogic.tsx
@@ -11,8 +11,6 @@ import {
reducers,
selectors,
} from 'kea'
-import { forms } from 'kea-forms'
-import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from 'kea-forms'
import { loaders } from 'kea-loaders'
import { router } from 'kea-router'
@@ -26,8 +24,6 @@ import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { featureFlagLogic, type FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { addProjectIdIfMissing } from 'lib/utils/kea-router'
-import { hasFormErrors } from 'lib/utils/objects'
-import { toParams } from 'lib/utils/url'
import { showApprovalRequiredToast } from 'scenes/approvals/ApprovalRequiredBanner'
import { dispatchChangeRequestCreated } from 'scenes/approvals/utils'
import { billingLogic } from 'scenes/billing/billingLogic'
@@ -36,8 +32,6 @@ import {
hasMultipleVariantsActive,
hasZeroRollout,
featureFlagLogic as sceneFeatureFlagLogic,
- validateFeatureFlagKey,
- validateFeatureFlagVariantKey,
} from 'scenes/feature-flags/featureFlagLogic'
import { featureFlagsLogic } from 'scenes/feature-flags/featureFlagsLogic'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'
@@ -65,8 +59,6 @@ import {
InsightVizNode,
isExperimentFunnelMetric,
NodeKind,
- ProductIntentContext,
- ProductKey,
TrendsQuery,
} from '~/queries/schema/schema-general'
import { setLatestVersionsOnQuery } from '~/queries/utils'
@@ -74,7 +66,6 @@ import {
BreakdownAttributionType,
BreakdownType,
CohortType,
- CountPerActorMathType,
DashboardType,
Experiment,
ExperimentConclusion,
@@ -82,7 +73,6 @@ import {
FeatureFlagType,
InsightType,
MultivariateFlagVariant,
- PropertyMathType,
} from '~/types'
import {
@@ -121,7 +111,6 @@ import type {
import type { TrendResult } from '../../types'
import type { ExperimentsConfig } from '../settings/environment/experimentsConfigLogic'
import { experimentMetricsLogic } from './experimentMetricsLogic'
-import { experimentSceneLogic } from './experimentSceneLogic'
import { featureFlagVariantProperty, resolvedExposureEvent } from './exposureContract'
import { holdoutsLogic } from './holdoutsLogic'
import {
@@ -138,7 +127,6 @@ import { SharedMetric } from './SharedMetrics/sharedMetricLogic'
import { sharedMetricsLogic } from './SharedMetrics/sharedMetricsLogic'
import {
type ExperimentUpdatePayload,
- featureFlagEligibleForExperiment,
getExperimentVariants,
getOrderedMetricsWithResults,
initializeMetricOrdering,
@@ -146,7 +134,6 @@ import {
isExperimentConflictError,
isLegacyExperiment,
toConcurrencyPayload,
- toExperimentWritePayload,
toFlagVariantsInput,
} from './utils'
@@ -543,7 +530,6 @@ export interface experimentLogicValues {
interval: number
}
compatibleSharedMetrics: SharedMetric[]
- createExperimentLoading: boolean
currentRefresh: CurrentRefreshSnapshot | null
editingPrimaryMetricUuid: string | null
editingSecondaryMetricUuid: string | null
@@ -551,31 +537,20 @@ export interface experimentLogicValues {
endExperimentLoading: boolean
excludedVariants: string[]
experiment: Experiment
- experimentAllErrors: Record<string, any>
- experimentChanged: boolean
- experimentErrors: DeepPartialMap<Experiment, ValidationErrorType>
- experimentHasErrors: boolean
experimentId: Experiment['id']
experimentLoading: boolean
- experimentManualErrors: Record<string, any>
- experimentMathAggregationForTrends: () => CountPerActorMathType | PropertyMathType | undefined
experimentMissing: boolean
- experimentTouched: boolean
- experimentTouches: Record<string, boolean>
experimentUpdate: Experiment | null
experimentUpdateLoading: boolean
- experimentValidationErrors: DeepPartialMap<Experiment, ValidationErrorType>
experimentWarning: ExperimentWarning | null
exposureCohort: CohortType | null
exposureCohortLoading: boolean
exposureCriteria: ExperimentExposureCriteria | undefined
exposures: any
exposuresLoading: boolean
- featureFlagValidationError: string | null
firstPrimaryMetric: ExperimentFunnelsQuery | ExperimentMetric | ExperimentTrendsQuery | undefined
formMode: FormModes
freezeExposureLoading: boolean
- getExperimentMetricType: (metric: ExperimentMetricUnion | undefined) => ExperimentMetricType
getInsightType: (
metric: ExperimentFunnelsQuery | ExperimentMetricUnion | ExperimentTrendsQuery | undefined
) => InsightType
@@ -587,15 +562,12 @@ export interface experimentLogicValues {
result: any
}[]
hasMinimumExposureForResults: boolean
- hasPrimaryMetricSet: boolean
hogfettiTrigger: (() => void) | null
isCreatingExperimentDashboard: boolean
isExperimentDraft: boolean
isExperimentLaunched: boolean
isExperimentRunning: boolean
isExperimentStopped: boolean
- isExperimentSubmitting: boolean
- isExperimentValid: boolean
isFlagActive: boolean
isPageVisible: boolean
isSingleVariantShipped: boolean
@@ -624,19 +596,16 @@ export interface experimentLogicValues {
recommendedRunningTime: number
recommendedSampleSize: number
resolvedExposureEvent: string
- secondaryMetricsLengthWithSharedMetrics: number
secondaryMetricsResults: CachedNewExperimentQueryResponse[]
secondaryMetricsResultsErrors: any[]
secondaryMetricsResultsLoading: boolean
shippedVariantKey: string | null
showDebugPanel: boolean
- showExperimentErrors: boolean
showNotificationOffer: boolean
statsMethod: ExperimentStatsMethod
unfreezeExposureLoading: boolean
unmodifiedExperiment: Experiment | null
usesNewQueryRunner: boolean
- validExistingFeatureFlag: FeatureFlagType | null
variants: MultivariateFlagVariant[]
}
@@ -782,7 +751,6 @@ export interface experimentLogicActions {
duration: number | null
experiment: Experiment
} // eventUsageLogic
- addToExperiments: (experiment: Experiment) => Experiment // experimentsLogic
updateExperiments: (experiment: Experiment) => Experiment // experimentsLogic
setFeatureFlags: (
flags: string[],
@@ -854,13 +822,6 @@ export interface experimentLogicActions {
clearMetricsResults: () => {
value: true
}
- createExperiment: (
- draft?: boolean,
- folder?: string | null
- ) => {
- draft: boolean | undefined
- folder: string | null | undefined
- }
createExperimentDashboard: () => {
value: true
}
@@ -1062,9 +1023,6 @@ export interface experimentLogicActions {
resetAutoRefreshInterval: () => {
value: true
}
- resetExperiment: (values?: Experiment) => {
- values?: Experiment
- }
resetRunningExperiment: () => {
value: true
}
@@ -1087,9 +1045,6 @@ export interface experimentLogicActions {
enabled: boolean
interval: number
}
- setCreateExperimentLoading: (loading: boolean) => {
- loading: boolean
- }
setEditExperiment: (editing: boolean) => {
editing: boolean
}
@@ -1099,28 +1054,12 @@ export interface experimentLogicActions {
setExperiment: (experiment: Partial<Experiment>) => {
experiment: Partial<Experiment>
}
- setExperimentManualErrors: (errors: Record<string, any>) => {
- errors: Record<string, any>
- }
setExperimentMissing: () => {
value: true
}
- setExperimentValue: (
- key: FieldName,
- value: any
- ) => {
- name: FieldName
- value: any
- }
- setExperimentValues: (values: DeepPartial<Experiment>) => {
- values: DeepPartial<Experiment>
- }
setExposureCriteria: (exposureCriteria: ExperimentExposureCriteria) => {
exposureCriteria: ExperimentExposureCriteria
}
- setFeatureFlagValidationError: (error: string) => {
- error: string
- }
setFreezeExposureLoading: (loading: boolean) => {
loading: boolean
}
@@ -1257,9 +1196,6 @@ export interface experimentLogicActions {
setUnmodifiedExperiment: (experiment: Experiment) => {
experiment: Experiment
}
- setValidExistingFeatureFlag: (featureFlag: FeatureFlagType | null) => {
- featureFlag: FeatureFlagType | null
- }
setVariantExcluded: (
variantKey: string,
excluded: boolean
@@ -1270,31 +1206,12 @@ export interface experimentLogicActions {
stopAutoRefreshInterval: () => {
value: true
}
- submitExperiment: () => {
- value: boolean
- }
- submitExperimentFailure: (
- error: Error,
- errors: Record<string, any>
- ) => {
- error: Error
- errors: Record<string, any>
- }
- submitExperimentRequest: (experiment: Experiment) => {
- experiment: Experiment
- }
- submitExperimentSuccess: (experiment: Experiment) => {
- experiment: Experiment
- }
subscribeToResultsNotification: () => {
value: true
}
toggleDebugPanel: () => {
value: true
}
- touchExperimentField: (key: string) => {
- key: string
- }
unarchiveExperiment: () => {
value: true
}
@@ -1309,9 +1226,6 @@ export interface experimentLogicActions {
variants: MultivariateFlagVariant[]
}
updateExperiment: (update: ExperimentUpdatePayload) => ExperimentUpdatePayload
- updateExperimentCollectionGoal: () => {
- value: true
- }
updateExperimentFailure: (
error: string,
errorObject?: any
@@ -1364,9 +1278,6 @@ export interface experimentLogicActions {
breakdownLimit: number
uuid: string
}
- validateFeatureFlag: (featureFlagKey: string) => {
- featureFlagKey: string
- }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -1384,9 +1295,6 @@ export interface experimentLogicMeta {
isExperimentStopped: (experiment: Experiment) => boolean
variants: (experiment: Experiment) => MultivariateFlagVariant[]
excludedVariants: (experiment: Experiment) => string[]
- experimentMathAggregationForTrends: (
- experiment: Experiment
- ) => () => CountPerActorMathType | PropertyMathType | undefined
minimumDetectableEffect: (experiment: Experiment, defaultMinimumDetectableEffect: number) => number
recommendedSampleSize: (
conversionMetrics: FunnelTimeConversionMetrics,
@@ -1416,12 +1324,10 @@ export interface experimentLogicMeta {
isSingleVariantShipped: boolean,
shippedVariantKey: string | null
) => ExperimentWarning | null
- hasPrimaryMetricSet: (primaryMetricsLengthWithSharedMetrics: number) => boolean
firstPrimaryMetric: (
experiment: Experiment
) => ExperimentFunnelsQuery | ExperimentMetric | ExperimentTrendsQuery | undefined
primaryMetricsLengthWithSharedMetrics: (experiment: Experiment) => number
- secondaryMetricsLengthWithSharedMetrics: (experiment: Experiment) => number
compatibleSharedMetrics: (sharedMetrics: SharedMetric[], usesNewQueryRunner: boolean) => SharedMetric[]
usesNewQueryRunner: (experiment: Experiment) => boolean
hasMinimumExposureForResults: (exposures: any, usesNewQueryRunner: boolean) => boolean
@@ -1515,7 +1421,7 @@ export const experimentLogic = kea<experimentLogicType>([
],
actions: [
experimentsLogic,
- ['updateExperiments', 'addToExperiments'],
+ ['updateExperiments'],
eventUsageLogic,
[
'reportExperimentCreated',
@@ -1560,8 +1466,6 @@ export const experimentLogic = kea<experimentLogicType>([
actions({
setExperimentMissing: true,
setExperiment: (experiment: Partial<Experiment>) => ({ experiment }),
- createExperiment: (draft?: boolean, folder?: string | null) => ({ draft, folder }),
- setCreateExperimentLoading: (loading: boolean) => ({ loading }),
setLaunchExperimentLoading: (loading: boolean) => ({ loading }),
setEndExperimentLoading: (loading: boolean) => ({ loading }),
setEditExperiment: (editing: boolean) => ({ editing }),
@@ -1584,7 +1488,6 @@ export const experimentLogic = kea<experimentLogicType>([
finalState,
}),
updateExperimentMetrics: true,
- updateExperimentCollectionGoal: true,
updateExposureCriteria: true,
updateExperimentSettings: (update: Partial<Experiment>) => ({ update }),
changeExperimentStartDate: (startDate: string) => ({ startDate }),
@@ -1645,9 +1548,6 @@ export const experimentLogic = kea<experimentLogicType>([
setIsCreatingExperimentDashboard: (isCreating: boolean) => ({ isCreating }),
setUnmodifiedExperiment: (experiment: Experiment) => ({ experiment }),
restoreUnmodifiedExperiment: true,
- setValidExistingFeatureFlag: (featureFlag: FeatureFlagType | null) => ({ featureFlag }),
- setFeatureFlagValidationError: (error: string) => ({ error }),
- validateFeatureFlag: (featureFlagKey: string) => ({ featureFlagKey }),
setHogfettiTrigger: (trigger: (() => void) | null) => ({ trigger }),
// METRICS
setMetric: ({
@@ -2377,24 +2277,6 @@ export const experimentLogic = kea<experimentLogicType>([
setIsCreatingExperimentDashboard: (_, { isCreating }) => isCreating,
},
],
- validExistingFeatureFlag: [
- null as FeatureFlagType | null,
- {
- setValidExistingFeatureFlag: (_, { featureFlag }) => featureFlag,
- },
- ],
- featureFlagValidationError: [
- null as string | null,
- {
- setFeatureFlagValidationError: (_, { error }) => error,
- },
- ],
- createExperimentLoading: [
- false,
- {
- setCreateExperimentLoading: (_, { loading }) => loading,
- },
- ],
launchExperimentLoading: [
false,
{
@@ -2480,136 +2362,6 @@ export const experimentLogic = kea<experimentLogicType>([
)
}
},
- createExperiment: async ({ draft, folder }) => {
- actions.setCreateExperimentLoading(true)
- const { recommendedRunningTime, recommendedSampleSize, minimumDetectableEffect } = values
-
- actions.touchExperimentField('name')
- actions.touchExperimentField('feature_flag_key')
- getExperimentVariants(values.experiment).forEach((_, i) =>
- actions.touchExperimentField(`feature_flag_config.filters.multivariate.variants.${i}.key`)
- )
-
- if (hasFormErrors(values.experimentErrors)) {
- actions.setCreateExperimentLoading(false)
- return
- }
-
- // Minimum Detectable Effect is calculated based on a loaded insight
- // Terminate if the insight did not manage to load in time
- if (!minimumDetectableEffect) {
- eventUsageLogic.actions.reportExperimentInsightLoadFailed()
- actions.setCreateExperimentLoading(false)
- lemonToast.error(
- 'Failed to load insight. Experiment cannot be saved without this value. Try changing the experiment goal.'
- )
- return
- }
-
- let response: Experiment | null = null
- const isUpdate = values.formMode === FORM_MODES.update
- try {
- if (isUpdate) {
- response = await api.update(
- `api/projects/${values.currentProjectId}/experiments/${values.experimentId}`,
- {
- // Sends variant split and rollout through the feature_flag object,
- // dropping the deprecated flag-config parameters keys.
- ...toExperimentWritePayload(values.experiment),
- running_time_calculation: {
- ...values.experiment?.running_time_calculation,
- recommended_running_time: recommendedRunningTime,
- recommended_sample_size: recommendedSampleSize,
- minimum_detectable_effect: minimumDetectableEffect,
- },
- ...(!draft && { start_date: dayjs() }),
- // backwards compatibility: Remove any global properties set on the experiment.
- // These were used to change feature flag targeting, but this is controlled directly
- // on the feature flag now.
- filters: {
- events: [],
- actions: [],
- ...values.experiment.filters,
- properties: [],
- },
- // Signal the backend to sync variant split and rollout
- // percentage to the linked feature flag.
- update_feature_flag_params: true,
- }
- )
-
- if (response?.id) {
- actions.updateExperiments(response)
- actions.setEditExperiment(false)
- actions.loadExperimentSuccess(response)
- return
- }
- } else {
- response = await api.create(`api/projects/${values.currentProjectId}/experiments`, {
- // A pre-existing flag is linked as-is: the API rejects explicit flag
- // config for it, so only send config when the flag will be created.
- // Key-aware so a stale match for a previously typed key can't suppress
- // config for a fresh key.
- ...toExperimentWritePayload(values.experiment, {
- omitFlagConfig: values.validExistingFeatureFlag?.key === values.experiment.feature_flag_key,
- }),
- running_time_calculation:
- /**
- * only if we are creating a new experiment we need to reset
- * the recommended running time. If we are duplicating we want to
- * preserve this values.
- */
- values.formMode === FORM_MODES.create
- ? {
- ...values.experiment?.running_time_calculation,
- recommended_running_time: recommendedRunningTime,
- recommended_sample_size: recommendedSampleSize,
- minimum_detectable_effect: minimumDetectableEffect,
- }
- : values.experiment?.running_time_calculation,
- ...(!draft && { start_date: dayjs() }),
- ...(typeof folder === 'string' ? { _create_in_folder: folder } : {}),
- })
-
- if (response) {
- actions.addProductIntent({
- product_type: ProductKey.EXPERIMENTS,
- intent_context: ProductIntentContext.EXPERIMENT_CREATED,
- })
- if (response.feature_flag?.id) {
- refreshTreeItem('feature_flag', String(response.feature_flag.id))
- }
- }
- }
- } catch (error: any) {
- lemonToast.error(error.detail || 'Failed to create experiment')
- actions.setCreateExperimentLoading(false)
- return
- }
-
- if (response?.id) {
- const experimentId = response.id
- refreshTreeItem('experiment', String(experimentId))
- const navigateToExperiment = (): void => {
- const scene = experimentSceneLogic.findMounted()
- if (scene) {
- scene.actions.setSceneState(experimentId, FORM_MODES.update)
- } else {
- router.actions.push(urls.experiment(experimentId))
- }
- }
-
- navigateToExperiment()
- actions.addToExperiments(response)
- lemonToast.success(`Experiment ${isUpdate ? 'updated' : 'created'}`, {
- button: {
- label: 'View it',
- action: navigateToExperiment,
- },
- })
- }
- actions.setCreateExperimentLoading(false)
- },
loadExperimentSuccess: async ({ experiment, payload }) => {
const duration = experiment?.start_date ? dayjs().diff(experiment.start_date, 'second') : null
// eslint-disable-next-line no-unused-expressions
@@ -3000,19 +2752,6 @@ export const experimentLogic = kea<experimentLogicType>([
// Reload results for added/edited metrics
actions.refreshExperimentResults(true, 'metric_config_change')
},
- updateExperimentCollectionGoal: async () => {
- const { recommendedRunningTime, recommendedSampleSize, minimumDetectableEffect } = values
-
- actions.updateExperiment({
- running_time_calculation: {
- ...values.experiment?.running_time_calculation,
- recommended_running_time: recommendedRunningTime,
- recommended_sample_size: recommendedSampleSize,
- minimum_detectable_effect: minimumDetectableEffect || 0,
- },
- update_feature_flag_params: false,
- })
- },
updateExposureCriteria: async () => {
actions.updateExperiment({
exposure_criteria: {
@@ -3389,52 +3128,6 @@ export const experimentLogic = kea<experimentLogicType>([
actions.setExperiment(structuredClone(values.unmodifiedExperiment))
}
},
- validateFeatureFlag: async ({ featureFlagKey }: { featureFlagKey: string }, breakpoint) => {
- await breakpoint(200)
- const response = await api.get(
- `api/projects/${values.currentProjectId}/feature_flags/?${toParams({ search: featureFlagKey })}`
- )
- const existingErrors = {
- // :KLUDGE: If there is no name error, we don't want to trigger the 'required' error early
- name: undefined,
- ...values.experimentErrors,
- }
- if (response.results.length > 0) {
- const matchingFlag = response.results.find((flag: FeatureFlagType) => flag.key === featureFlagKey)
- if (matchingFlag) {
- let isValid
- try {
- isValid = featureFlagEligibleForExperiment(matchingFlag)
- } catch {
- isValid = false
- }
- actions.setValidExistingFeatureFlag(isValid ? matchingFlag : null)
- actions.setFeatureFlagValidationError(
- isValid ? '' : 'Existing feature flag is not eligible for experiments.'
- )
- actions.setExperimentManualErrors({
- ...existingErrors,
- feature_flag_key: values.featureFlagValidationError || undefined,
- })
- return
- }
- }
-
- actions.setValidExistingFeatureFlag(null)
- actions.setFeatureFlagValidationError(validateFeatureFlagKey(featureFlagKey) || '')
- actions.setExperimentManualErrors({
- ...existingErrors,
- feature_flag_key: values.featureFlagValidationError || undefined,
- })
- },
- touchExperimentField: ({ key }) => {
- // :KLUDGE: Persist the existing feature_flag_key validation when the field is blurred.
- if (key === 'feature_flag_key') {
- actions.setExperimentManualErrors({
- feature_flag_key: values.featureFlagValidationError || undefined,
- })
- }
- },
loadPrimaryMetricsResults: async ({ refresh, refreshId }: { refresh?: boolean; refreshId?: string }) => {
actions.setPrimaryMetricsResultsLoading(true)
actions.setPrimaryMetricsResults([])
@@ -4022,34 +3715,10 @@ export const experimentLogic = kea<experimentLogicType>([
void payload?.triggeredBy
if (values.experimentId && values.experimentId !== 'new') {
try {
- let response: Experiment = await api.get(
+ const response: Experiment = await api.get(
`api/projects/${values.currentProjectId}/experiments/${values.experimentId}`
)
- /**
- * if we are duplicating, we need to clear a lot of props to ensure that
- * the experiment will be in draft mode and available for launch
- */
- if (values.formMode === FORM_MODES.duplicate) {
- response = {
- ...response,
- name: `${response.name} (duplicate)`,
- // A duplicate starts as a fresh draft with a new flag: seed default
- // draft flag config and drop the source's linked flag.
- feature_flag_config: structuredClone(NEW_EXPERIMENT.feature_flag_config),
- feature_flag: undefined,
- feature_flag_key: '',
- archived: false,
- start_date: undefined,
- end_date: undefined,
- conclusion: undefined,
- conclusion_comment: undefined,
- created_by: null,
- created_at: null,
- updated_at: null,
- }
- }
-
const responseWithMetricsOrdering = initializeMetricOrdering(response)
actions.setUnmodifiedExperiment(structuredClone(responseWithMetricsOrdering))
@@ -4206,13 +3875,6 @@ export const experimentLogic = kea<experimentLogicType>([
: InsightType.FUNNELS
},
],
- getExperimentMetricType: [
- () => [],
- () =>
- (metric: ExperimentMetric | undefined): ExperimentMetricType => {
- return metric?.metric_type || ExperimentMetricType.MEAN
- },
- ],
isExperimentDraft: [
(s) => [s.experiment],
(experiment: Experiment): boolean => {
@@ -4260,32 +3922,6 @@ export const experimentLogic = kea<experimentLogicType>([
(s) => [s.experiment],
(experiment: Experiment): string[] => experiment?.excluded_variants ?? [],
],
- experimentMathAggregationForTrends: [
- (s) => [s.experiment],
- (experiment: Experiment) => (): PropertyMathType | CountPerActorMathType | undefined => {
- const query = experiment?.metrics?.[0] as ExperimentTrendsQuery
- if (!query) {
- return undefined
- }
- const entities = query.count_query?.series || []
-
- // Find out if we're using count per actor math aggregates averages per user
- const userMathValue = entities.filter((entity) =>
- Object.values(CountPerActorMathType).includes(entity?.math as CountPerActorMathType)
- )[0]?.math
-
- // alternatively, if we're using property math
- // remove 'sum' property math from the list of math types
- // since we can handle that as a regular case
- const targetValues = Object.values(PropertyMathType).filter((value) => value !== PropertyMathType.Sum)
-
- const propertyMathValue = entities.filter((entity) =>
- (targetValues as readonly PropertyMathType[]).includes(entity?.math as PropertyMathType)
- )[0]?.math
-
- return (userMathValue ?? propertyMathValue) as PropertyMathType | CountPerActorMathType | undefined
- },
- ],
minimumDetectableEffect: [
(s) => [s.experiment, s.defaultMinimumDetectableEffect],
(newExperiment: Experiment, defaultMinimumDetectableEffect: number): number => {
@@ -4435,12 +4071,6 @@ export const experimentLogic = kea<experimentLogicType>([
return null
},
],
- hasPrimaryMetricSet: [
- (s) => [s.primaryMetricsLengthWithSharedMetrics],
- (primaryMetricsLengthWithSharedMetrics: number): boolean => {
- return primaryMetricsLengthWithSharedMetrics > 0
- },
- ],
firstPrimaryMetric: [
(s) => [s.experiment],
(experiment: Experiment): ExperimentMetric | ExperimentTrendsQuery | ExperimentFunnelsQuery | undefined => {
@@ -4462,15 +4092,6 @@ export const experimentLogic = kea<experimentLogicType>([
)
},
],
- secondaryMetricsLengthWithSharedMetrics: [
- (s) => [s.experiment],
- (experiment: Experiment): number => {
- return (
- experiment.metrics_secondary.length +
- experiment.saved_metrics.filter((savedMetric) => savedMetric.metadata.type === 'secondary').length
- )
- },
- ],
compatibleSharedMetrics: [
(s) => [s.sharedMetrics, s.usesNewQueryRunner],
(sharedMetrics: SharedMetric[], usesNewQueryRunner: boolean): SharedMetric[] => {
@@ -4589,33 +4210,4 @@ export const experimentLogic = kea<experimentLogicType>([
},
],
}),
- forms(({ actions, values }) => ({
- experiment: {
- options: { showErrorsOnTouch: true },
- defaults: { ...NEW_EXPERIMENT } as Experiment,
- errors: ({ name, feature_flag_config }) => ({
- name: !name && 'Please enter a name',
- // feature_flag_key is handled asynchronously
- feature_flag_config: {
- filters: {
- multivariate: {
- variants: feature_flag_config?.filters?.multivariate?.variants?.map(({ key }) => ({
- key: validateFeatureFlagVariantKey(key),
- })),
- },
- },
- },
- }),
- submit: () => {
- if (
- values.experimentId &&
- ([FORM_MODES.create, FORM_MODES.duplicate] as FormModes[]).includes(values.formMode)
- ) {
- actions.createExperiment(true)
- } else {
- actions.createExperiment(true, 'Unfiled/Experiments')
- }
- },
- },
- })),
])
diff --git a/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts b/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts
index dc11d7092dbe..a019b8044e6d 100644
--- a/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts
+++ b/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts
@@ -67,27 +67,6 @@ export interface experimentTimeseriesLogicActions {
experimentId: ExperimentIdType
metric: ExperimentMetricUnion
} // eventUsageLogic
- clearTimeseries: () => {
- value: true
- }
- clearTimeseriesFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- clearTimeseriesSuccess: (
- timeseries: null,
- payload?: {
- value: true
- }
- ) => {
- timeseries: null
- payload?: {
- value: true
- }
- }
loadTimeseries: ({ metric }: { metric: ExperimentMetric }) => {
metric: ExperimentMetric
}
@@ -165,7 +144,6 @@ export const experimentTimeseriesLogic = kea<experimentTimeseriesLogicType>([
})),
actions(() => ({
- clearTimeseries: true,
recalculateTimeseries: ({ metric }: { metric: ExperimentMetric }) => ({ metric }),
})),
@@ -186,7 +164,6 @@ export const experimentTimeseriesLogic = kea<experimentTimeseriesLogicType>([
)
return response
},
- clearTimeseries: () => null,
recalculateTimeseries: async ({ metric }: { metric: ExperimentMetric }) => {
if (!metric.fingerprint) {
throw new Error('Metric fingerprint is required')
diff --git a/frontend/src/scenes/experiments/holdoutsLogic.tsx b/frontend/src/scenes/experiments/holdoutsLogic.tsx
index f897ab0e5d6b..4bcc7bb40b10 100644
--- a/frontend/src/scenes/experiments/holdoutsLogic.tsx
+++ b/frontend/src/scenes/experiments/holdoutsLogic.tsx
@@ -79,9 +79,6 @@ export interface holdoutsLogicActions {
id: number | null
}
}
- loadHoldout: (id: number | null) => {
- id: number | null
- }
loadHoldouts: () => any
loadHoldoutsFailure: (
error: string,
@@ -138,7 +135,6 @@ export const holdoutsLogic = kea<holdoutsLogicType>([
createHoldout: true,
updateHoldout: (id: number | null, holdout: Partial<ExperimentHoldoutType>) => ({ id, holdout }),
deleteHoldout: (id: number | null) => ({ id }),
- loadHoldout: (id: number | null) => ({ id }),
}),
connect(() => ({
actions: [eventUsageLogic, ['reportExperimentHoldoutCreated']],
diff --git a/frontend/src/scenes/experiments/modalsLogic.ts b/frontend/src/scenes/experiments/modalsLogic.ts
index d18a3047d610..efc649a4f88e 100644
--- a/frontend/src/scenes/experiments/modalsLogic.ts
+++ b/frontend/src/scenes/experiments/modalsLogic.ts
@@ -17,7 +17,6 @@ export interface modalsLogicValues {
isDistributionModalOpen: boolean
isDuplicateExperimentModalOpen: boolean
isEditConclusionModalOpen: boolean
- isExperimentCollectionGoalModalOpen: boolean
isExposureCriteriaModalOpen: boolean
isFinishExperimentModalOpen: boolean
isPauseExperimentModalOpen: boolean
@@ -32,7 +31,6 @@ export interface modalsLogicValues {
isSecondaryMetricSourceModalOpen: boolean
isSecondarySharedMetricModalOpen: boolean
isStatsEngineModalOpen: boolean
- isVariantDeltaTimeseriesModalOpen: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -61,9 +59,6 @@ export interface modalsLogicActions {
closeEditConclusionModal: () => {
value: true
}
- closeExperimentCollectionGoalModal: () => {
- value: true
- }
closeExposureCriteriaModal: () => {
value: true
}
@@ -106,9 +101,6 @@ export interface modalsLogicActions {
closeStatsEngineModal: () => {
value: true
}
- closeVariantDeltaTimeseriesModal: () => {
- value: true
- }
openCopyToProjectModal: () => {
value: true
}
@@ -127,9 +119,6 @@ export interface modalsLogicActions {
openEditConclusionModal: () => {
value: true
}
- openExperimentCollectionGoalModal: () => {
- value: true
- }
openExposureCriteriaModal: () => {
value: true
}
@@ -172,9 +161,6 @@ export interface modalsLogicActions {
openStatsEngineModal: () => {
value: true
}
- openVariantDeltaTimeseriesModal: () => {
- value: true
- }
}
export type modalsLogicType = MakeLogicType<modalsLogicValues, modalsLogicActions>
@@ -187,8 +173,6 @@ export const modalsLogic = kea<modalsLogicType>([
})),
actions({
closeAllModals: true,
- openExperimentCollectionGoalModal: true,
- closeExperimentCollectionGoalModal: true,
openExposureCriteriaModal: true,
closeExposureCriteriaModal: true,
openFinishExperimentModal: true,
@@ -221,8 +205,6 @@ export const modalsLogic = kea<modalsLogicType>([
closePrimarySharedMetricModal: true,
openSecondarySharedMetricModal: (sharedMetricId: SharedMetric['id'] | null) => ({ sharedMetricId }),
closeSecondarySharedMetricModal: true,
- openVariantDeltaTimeseriesModal: true,
- closeVariantDeltaTimeseriesModal: true,
openRunningTimeConfigModal: true,
closeRunningTimeConfigModal: true,
openDuplicateExperimentModal: true,
@@ -233,14 +215,6 @@ export const modalsLogic = kea<modalsLogicType>([
closeQuickSurveyModal: true,
}),
reducers({
- isExperimentCollectionGoalModalOpen: [
- false,
- {
- openExperimentCollectionGoalModal: () => true,
- closeExperimentCollectionGoalModal: () => false,
- closeAllModals: () => false,
- },
- ],
isExposureCriteriaModalOpen: [
false,
{
@@ -345,14 +319,6 @@ export const modalsLogic = kea<modalsLogicType>([
closeAllModals: () => false,
},
],
- isVariantDeltaTimeseriesModalOpen: [
- false,
- {
- openVariantDeltaTimeseriesModal: () => true,
- closeVariantDeltaTimeseriesModal: () => false,
- closeAllModals: () => false,
- },
- ],
isDescriptionModalOpen: [
false,
{
diff --git a/products/experiments/frontend/legacy/legacyUtils.ts b/products/experiments/frontend/legacy/legacyUtils.ts
index a168fdaecdcd..b6f92d5454b0 100644
--- a/products/experiments/frontend/legacy/legacyUtils.ts
+++ b/products/experiments/frontend/legacy/legacyUtils.ts
@@ -98,10 +98,6 @@ export const getTabularExperimentResults =
return tabularResults
}
-/**
- * @deprecated
- * Use the experimentMathAggregationForTrends function from the experimentLogic instead.
- */
export const getExperimentMathAggregationForTrends = (
experiment: Experiment
): PropertyMathType | CountPerActorMathType | undefined => {
diff --git a/products/experiments/frontend/scenes/experimentsLogic.ts b/products/experiments/frontend/scenes/experimentsLogic.ts
index e8b5a826900e..18d7c49f023f 100644
--- a/products/experiments/frontend/scenes/experimentsLogic.ts
+++ b/products/experiments/frontend/scenes/experimentsLogic.ts
@@ -398,9 +398,6 @@ export interface experimentsLogicActions {
}
payload?: void
}
- openFeatureFlagModal: () => {
- value: true
- }
resetFeatureFlagModalFilters: () => {
value: true
}
@@ -541,7 +538,6 @@ export const experimentsLogic = kea<experimentsLogicType>([
replace,
}),
resetFeatureFlagModalFilters: true,
- openFeatureFlagModal: true,
}),
reducers({
filters: [
@@ -597,9 +593,6 @@ export const experimentsLogic = kea<experimentsLogicType>([
resetFeatureFlagModalFilters: () => {
actions.loadFeatureFlagModalFeatureFlags()
},
- openFeatureFlagModal: () => {
- actions.loadFeatureFlagModalFeatureFlags()
- },
loadCurrentTeamSuccess: () => {
if (values.featureFlagModalFeatureFlags.results.length > 0) {
actions.loadFeatureFlagModalFeatureFlags()
@@ -873,7 +866,7 @@ export const experimentsLogic = kea<experimentsLogicType>([
afterMount(({ actions, values }) => {
actions.loadExperimentsStats()
// Sync modal page with URL on mount. Eligible flags themselves are loaded lazily when the
- // "link existing flag" modal opens (openFeatureFlagModal listener), not on every list mount.
+ // "link existing flag" modal sets or resets its filters, not on every list mount.
const urlPage = values.featureFlagModalPageFromURL
if (urlPage !== 1) {
actions.setFeatureFlagModalFilters({ page: urlPage })