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.

feat(experiments): add running_time_calculation field to experiment model (#62942)

Anders78f5c0e6458a
diff --git a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr
index c2358440fc74..e415cd85204e 100644
--- a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr
+++ b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr
@@ -213,6 +213,7 @@
'only_count_matured_users',
'parameters',
'primary_metrics_ordered_uuids',
+ 'running_time_calculation',
'scheduling_config',
'secondary_metrics',
'secondary_metrics_ordered_uuids',
diff --git a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
index 9431d4718309..714a41ba598a 100644
--- a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
+++ b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
@@ -337,6 +337,7 @@
"posthog_experiment"."secondary_metrics_ordered_uuids",
"posthog_experiment"."stats_config",
"posthog_experiment"."scheduling_config",
+ "posthog_experiment"."running_time_calculation",
"posthog_experiment"."only_count_matured_users",
"posthog_experiment"."status",
"posthog_experiment"."conclusion",
@@ -1080,6 +1081,7 @@
"posthog_experiment"."secondary_metrics_ordered_uuids",
"posthog_experiment"."stats_config",
"posthog_experiment"."scheduling_config",
+ "posthog_experiment"."running_time_calculation",
"posthog_experiment"."only_count_matured_users",
"posthog_experiment"."status",
"posthog_experiment"."conclusion",
diff --git a/products/experiments/backend/migrations/0019_experiment_running_time_calculation.py b/products/experiments/backend/migrations/0019_experiment_running_time_calculation.py
new file mode 100644
index 000000000000..647efd1b7071
--- /dev/null
+++ b/products/experiments/backend/migrations/0019_experiment_running_time_calculation.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.14 on 2026-06-11 12:11
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("experiments", "0018_migrate_cohorts_models"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="experiment",
+ name="running_time_calculation",
+ field=models.JSONField(blank=True, default=dict, null=True),
+ ),
+ ]
diff --git a/products/experiments/backend/migrations/max_migration.txt b/products/experiments/backend/migrations/max_migration.txt
index 15c88b098ed1..648ec32b48d0 100644
--- a/products/experiments/backend/migrations/max_migration.txt
+++ b/products/experiments/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0018_migrate_cohorts_models
+0019_experiment_running_time_calculation
diff --git a/products/experiments/backend/models/experiment.py b/products/experiments/backend/models/experiment.py
index e4bbd7dedf14..ca1d204834e8 100644
--- a/products/experiments/backend/models/experiment.py
+++ b/products/experiments/backend/models/experiment.py
@@ -32,14 +32,12 @@ class Experiment(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.
# Filters define the target metric of an Experiment
filters = models.JSONField(default=dict, blank=True)
- # Parameters include configuration fields for the experiment: What the control & test variant are called,
- # and any test significance calculation parameters
- # We have 4 parameters today:
- # minimum_detectable_effect: number
- # recommended_running_time: number
- # recommended_sample_size: number
- # feature_flag_variants: { key: string, name: string, rollout_percentage: number }[]
- # custom_exposure_filter: Filter json
+ # DEPRECATED: catch-all config blob being split into dedicated homes.
+ # Feature flag config (feature_flag_variants, rollout_percentage, aggregation_group_type_index,
+ # feature_flag_payloads, ensure_experience_continuity) belongs on the linked FeatureFlag.
+ # Running-time calculator state (minimum_detectable_effect, recommended_running_time,
+ # recommended_sample_size, exposure_estimate_config) belongs in `running_time_calculation`.
+ # Do not add new keys here.
parameters = models.JSONField(default=dict, null=True)
# A list of filters for secondary metrics
@@ -72,6 +70,11 @@ class Experiment(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.
stats_config = models.JSONField(default=dict, null=True, blank=True)
scheduling_config = models.JSONField(default=dict, null=True, blank=True)
+ # Running-time calculator state: minimum_detectable_effect, recommended_running_time,
+ # recommended_sample_size, exposure_estimate_config. Canonical home for these keys,
+ # which historically lived in `parameters`.
+ running_time_calculation = models.JSONField(default=dict, null=True, blank=True)
+
only_count_matured_users = models.BooleanField(default=False)
status = models.CharField(
diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr
index 376973588531..0b92f2bd4697 100644
--- a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr
+++ b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr
@@ -2666,6 +2666,7 @@
"posthog_experiment"."secondary_metrics_ordered_uuids",
"posthog_experiment"."stats_config",
"posthog_experiment"."scheduling_config",
+ "posthog_experiment"."running_time_calculation",
"posthog_experiment"."only_count_matured_users",
"posthog_experiment"."status",
"posthog_experiment"."conclusion",
@@ -2999,6 +3000,7 @@
"posthog_experiment"."secondary_metrics_ordered_uuids",
"posthog_experiment"."stats_config",
"posthog_experiment"."scheduling_config",
+ "posthog_experiment"."running_time_calculation",
"posthog_experiment"."only_count_matured_users",
"posthog_experiment"."status",
"posthog_experiment"."conclusion",
diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr
index 90c02e34b16e..cc670fca62f8 100644
--- a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr
+++ b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr
@@ -3902,6 +3902,7 @@
"posthog_experiment"."secondary_metrics_ordered_uuids",
"posthog_experiment"."stats_config",
"posthog_experiment"."scheduling_config",
+ "posthog_experiment"."running_time_calculation",
"posthog_experiment"."only_count_matured_users",
"posthog_experiment"."status",
"posthog_experiment"."conclusion",
@@ -3939,6 +3940,7 @@
"posthog_experiment"."secondary_metrics_ordered_uuids",
"posthog_experiment"."stats_config",
"posthog_experiment"."scheduling_config",
+ "posthog_experiment"."running_time_calculation",
"posthog_experiment"."only_count_matured_users",
"posthog_experiment"."status",
"posthog_experiment"."conclusion",