: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(experiments): changing experiment setting should dispatch a full reload of all metrics. (#60162)
Rodrigo Iloro5588113c3104
diff --git a/frontend/src/scenes/experiments/ExperimentView/CupedModal.tsx b/frontend/src/scenes/experiments/ExperimentView/CupedModal.tsxindex 87ae42a81c60..e3826a5c0892 100644--- a/frontend/src/scenes/experiments/ExperimentView/CupedModal.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/CupedModal.tsx@@ -11,7 +11,7 @@ import { CupedSelection, getCupedSelection, resolveCupedLookbackDays } from './cexport function CupedModal(): JSX.Element {const { experiment } = useValues(experimentLogic)- const { updateExperiment, setExperiment, restoreUnmodifiedExperiment } = useActions(experimentLogic)+ const { updateExperimentSettings, setExperiment, restoreUnmodifiedExperiment } = useActions(experimentLogic)const { experimentsConfig } = useValues(experimentsConfigLogic)const { closeCupedModal } = useActions(modalsLogic)const { isCupedModalOpen } = useValues(modalsLogic)@@ -61,7 +61,7 @@ export function CupedModal(): JSX.Element {}const onSave = (): void => {- updateExperiment({ stats_config: experiment.stats_config })+ updateExperimentSettings({ stats_config: experiment.stats_config })closeCupedModal()}diff --git a/frontend/src/scenes/experiments/ExperimentView/SettingsTab.tsx b/frontend/src/scenes/experiments/ExperimentView/SettingsTab.tsxindex c8bdf81dc034..239f23c30cc3 100644--- a/frontend/src/scenes/experiments/ExperimentView/SettingsTab.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/SettingsTab.tsx@@ -19,7 +19,7 @@ import { StatsMethodModal } from './StatsMethodModal'export function SettingsTab(): JSX.Element {const { experiment, statsMethod } = useValues(experimentLogic)- const { updateExperiment } = useActions(experimentLogic)+ const { updateExperimentSettings } = useActions(experimentLogic)const { openStatsEngineModal, openCupedModal } = useActions(modalsLogic)const { experimentsConfig } = useValues(experimentsConfigLogic)const showCupedOption = useFeatureFlag('EXPERIMENT_CUPED')@@ -95,7 +95,7 @@ export function SettingsTab(): JSX.Element {label="Require completed conversion or retention window"checked={experiment.only_count_matured_users ?? false}onChange={(checked) => {- updateExperiment({ only_count_matured_users: checked })+ updateExperimentSettings({ only_count_matured_users: checked })}}/></div>diff --git a/frontend/src/scenes/experiments/ExperimentView/StatsMethodModal.tsx b/frontend/src/scenes/experiments/ExperimentView/StatsMethodModal.tsxindex a502d6f72561..5d3ac324b7a8 100644--- a/frontend/src/scenes/experiments/ExperimentView/StatsMethodModal.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/StatsMethodModal.tsx@@ -12,7 +12,7 @@ import { modalsLogic } from '../modalsLogic'export function StatsMethodModal(): JSX.Element {const { experiment, statsMethod } = useValues(experimentLogic)- const { updateExperiment, setExperiment, restoreUnmodifiedExperiment } = useActions(experimentLogic)+ const { updateExperimentSettings, setExperiment, restoreUnmodifiedExperiment } = useActions(experimentLogic)const { closeStatsEngineModal } = useActions(modalsLogic)const { isStatsEngineModalOpen } = useValues(modalsLogic)@@ -67,7 +67,7 @@ export function StatsMethodModal(): JSX.Element {<LemonButtontype="primary"onClick={() => {- updateExperiment({ stats_config: experiment.stats_config })+ updateExperimentSettings({ stats_config: experiment.stats_config })closeStatsEngineModal()}}>diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsxindex 8a0951dc202f..548ba5439a6a 100644--- a/frontend/src/scenes/experiments/experimentLogic.tsx+++ b/frontend/src/scenes/experiments/experimentLogic.tsx@@ -654,6 +654,7 @@ export const experimentLogic = kea<experimentLogicType>([updateExperimentMetrics: true,updateExperimentCollectionGoal: true,updateExposureCriteria: true,+ updateExperimentSettings: (update: Partial<Experiment>) => ({ update }),changeExperimentStartDate: (startDate: string) => ({ startDate }),changeExperimentEndDate: (endDate: string) => ({ endDate }),launchExperiment: true,@@ -1654,6 +1655,12 @@ export const experimentLogic = kea<experimentLogicType>([})actions.refreshExperimentResults(true, 'config_change')},+ updateExperimentSettings: async ({ update }) => {+ // Settings like stats config, CUPED, and conversion-window handling change+ // how metrics and exposures are computed, so persist then re-query.+ await asyncActions.updateExperiment({ ...update, update_feature_flag_params: false })+ actions.refreshExperimentResults(true, 'config_change')+ },resetRunningExperiment: async () => {try {const response: Experiment = await api.create(