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): remove unused actions from the experiment logic. (#57750)

Rodrigo Iloro051f6999357a
diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsx
index 2748914ee32a..452352129567 100644
--- a/frontend/src/scenes/experiments/experimentLogic.tsx
+++ b/frontend/src/scenes/experiments/experimentLogic.tsx
@@ -112,7 +112,6 @@ import {
getOrderedMetricsWithResults,
initializeMetricOrdering,
isLegacyExperiment,
- percentageDistribution,
} from './utils'
export const NEW_EXPERIMENT: Experiment = {
@@ -717,12 +716,7 @@ export const experimentLogic = kea<experimentLogicType>([
createExperiment: (draft?: boolean, folder?: string | null) => ({ draft, folder }),
setCreateExperimentLoading: (loading: boolean) => ({ loading }),
setLaunchExperimentLoading: (loading: boolean) => ({ loading }),
- setExperimentType: (type?: string) => ({ type }),
-
- addVariant: true,
- removeVariant: (idx: number) => ({ idx }),
setEditExperiment: (editing: boolean) => ({ editing }),
- setExposureAndSampleSize: (exposure: number, sampleSize: number) => ({ exposure, sampleSize }),
refreshExperimentResults: (forceRefresh?: boolean, triggeredBy?: ExperimentTriggeredBy) => ({
forceRefresh,
triggeredBy: triggeredBy ?? 'manual',
@@ -926,55 +920,6 @@ export const experimentLogic = kea<experimentLogicType>([
setExperiment: (state, { experiment }) => {
return { ...state, ...experiment }
},
- addVariant: (state) => {
- if (state?.parameters?.feature_flag_variants) {
- const newRolloutPercentages = percentageDistribution(
- state.parameters.feature_flag_variants.length + 1
- )
- const updatedRolloutPercentageVariants = state.parameters.feature_flag_variants.map(
- (variant: MultivariateFlagVariant, i: number) => ({
- ...variant,
- rollout_percentage: newRolloutPercentages[i],
- })
- )
- return {
- ...state,
- parameters: {
- ...state.parameters,
- feature_flag_variants: [
- ...updatedRolloutPercentageVariants,
- {
- key: `test-${state.parameters.feature_flag_variants.length}`,
- rollout_percentage: newRolloutPercentages[newRolloutPercentages.length - 1],
- },
- ],
- },
- }
- }
- return state
- },
- removeVariant: (state, { idx }) => {
- if (!state) {
- return { ...NEW_EXPERIMENT }
- }
- const variants = [...(state.parameters?.feature_flag_variants || [])]
- variants.splice(idx, 1)
- const newRolloutPercentages = percentageDistribution(
- (state?.parameters?.feature_flag_variants || []).length - 1
- )
- const updatedVariants = variants.map((variant: MultivariateFlagVariant, i: number) => ({
- ...variant,
- rollout_percentage: newRolloutPercentages[i],
- }))
-
- return {
- ...state,
- parameters: {
- ...state.parameters,
- feature_flag_variants: updatedVariants,
- },
- }
- },
setExposureCriteria: (
state,
{ exposureCriteria }: { exposureCriteria: ExperimentExposureCriteria }
@@ -1565,9 +1510,6 @@ export const experimentLogic = kea<experimentLogicType>([
}
actions.setCreateExperimentLoading(false)
},
- setExperimentType: async ({ type }) => {
- actions.setExperiment({ type: type })
- },
loadExperimentSuccess: async ({ experiment, payload }) => {
const duration = experiment?.start_date ? dayjs().diff(experiment.start_date, 'second') : null
experiment && actions.reportExperimentViewed(experiment, duration)