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): explain why no primary metric has users yet (#126722)

Marcel Poelker6111859a4978
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 8cd6f411ee05..5e21cd185a8a 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3344,6 +3344,10 @@ snapshots:
hash: v1.k794b7964.c513495899160638ead3ad13632d4ca59a62c8ea0fb2c86fa1ea17719d46a2fa.8ApNUhlTxYF7nrUqO1zsTZte04NzMXf7hmjJz3P4rPE
experiments-healthchecksoverview--running-with-an-issue--light:
hash: v1.k794b7964.3cbd4355330c14f1afadb886cd182879c5b436b5143fe8f136771027bd56cc7f.YApFmE4xWr1dZ_tNUv89PeWQW5QEDxuJwxaSW7siajc
+ experiments-healthchecksoverview--running-with-metric-windows-not-complete--dark:
+ hash: v1.k794b7964.6eeec0309943fa9a7c2aced8868a68f47121b1a8373cc17f7b6b97cfcecc9859.IrL3JyoUu6PSyiksHlET0I8NbG1kk28CYOeQu162PDs
+ experiments-healthchecksoverview--running-with-metric-windows-not-complete--light:
+ hash: v1.k794b7964.aff07efeabeb82703966b262feb3e0e672f5aa6bb3c6adb742b0280d84921e2e.3bb625satJvU42HKwWn_CENwuFl18P8IqD-7aN6Qk54
experiments-healthchecksoverview--running-with-significance-on-a-small-sample--dark:
hash: v1.k794b7964.409d7eccff93e0d58ad5f9272a09937b807b66863ffa41bce1946aeb716f5ab3.UgfqDxyCdNSrMh_WE_Cf9KXyjPelEnkBYw3FzAWgkeY
experiments-healthchecksoverview--running-with-significance-on-a-small-sample--light:
@@ -11387,9 +11391,9 @@ snapshots:
scenes-app-experiments--experiment-frequentist-two-variants--light:
hash: v1.k794b7964.4ddea1c7537af9d50c57b4b9a76d4bcba39f743a23b4715683c0ce59d4c24f57.0ueR8XMLqRby_u6I0EyNIiUwXkbjmWMH3vBdoFNYmII
scenes-app-experiments--experiment-health-debug-tab--dark:
- hash: v1.k794b7964.863d816b2c24b6fa01a30dacd4a4063821b92841f0e956c0edc2993fef3e4052.7HVs6LuSPxNPN0TgT4WOTkxbV0mmlp6QFcNXeUVvAd0
+ hash: v1.k794b7964.32832ef3ce0f1022d129240ea341f976f33cf255235c6087276d52f7c7b9f6cf.vED1QUQ3zvRyI8X34z6AuD0HovPU9T-JBoCSZkIbiY0
scenes-app-experiments--experiment-health-debug-tab--light:
- hash: v1.k794b7964.36fb2426b5f162520cddd87fc35a8072394bca74a0531a01141c798eb88c9cf6.k8xnoPQlSGjY5h6bXrZbZJcxlqukl8OPoKZaAHCrUBQ
+ hash: v1.k794b7964.87903c4dee6ea41ecd16e0aae00f3a9d4784b394fa221e3b3516992ddacd6b3d.ww5bg6uopL7e_XLA9pdodLWT5aiZFCBsQRbuQ_0d2NI
scenes-app-experiments--experiment-recordings-dropped-metric--dark:
hash: v1.k794b7964.9ce950830524de179a4d761af104781fdc05347d59f18de814e72bc40a486158.T1SiGxL_fGBQT61rjwuJe9MPz1NPcjeZBRv6rKiSzrE
scenes-app-experiments--experiment-recordings-dropped-metric--light:
diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.ts
index 9d4ea2757b05..7d78e5e00b8e 100644
--- a/products/desktop/packages/api-client/src/generated.ts
+++ b/products/desktop/packages/api-client/src/generated.ts
@@ -9974,6 +9974,7 @@ export namespace Schemas {
* * `release_conditions_changed_mid_run` - Release Conditions Changed Mid Run
* * `new_flag_no_traffic` - New Flag No Traffic
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
*/
export type ExperimentHealthFindingCodeEnum =
| "flag_off_while_running"
@@ -9998,7 +9999,8 @@ export namespace Schemas {
| "bucketing_changed_mid_run"
| "release_conditions_changed_mid_run"
| "new_flag_no_traffic"
- | "early_significance";
+ | "early_significance"
+ | "metrics_not_matured";
/**
* * `critical` - Critical severity
* * `warning` - Warning severity
@@ -10054,6 +10056,7 @@ export namespace Schemas {
* * `release_conditions_changed_mid_run` - Release Conditions Changed Mid Run
* * `new_flag_no_traffic` - New Flag No Traffic
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
*/
code: ExperimentHealthFindingCodeEnum;
/**
@@ -10109,6 +10112,7 @@ export namespace Schemas {
* * `exposure_criteria_cannot_match` - Exposure Criteria Cannot Match
* * `exposure_filters` - Exposure Filters
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
* * `zero_exposures` - Zero Exposures
* * `test_account_filter_removes_exposures` - Test Account Filter Removes Exposures
* * `srm` - Srm
@@ -10131,6 +10135,7 @@ export namespace Schemas {
| "exposure_criteria_cannot_match"
| "exposure_filters"
| "early_significance"
+ | "metrics_not_matured"
| "zero_exposures"
| "test_account_filter_removes_exposures"
| "srm"
@@ -10166,6 +10171,7 @@ export namespace Schemas {
* * `exposure_criteria_cannot_match` - Exposure Criteria Cannot Match
* * `exposure_filters` - Exposure Filters
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
* * `zero_exposures` - Zero Exposures
* * `test_account_filter_removes_exposures` - Test Account Filter Removes Exposures
* * `srm` - Srm
diff --git a/products/experiments/backend/facade/contracts.py b/products/experiments/backend/facade/contracts.py
index a853b9dc6575..0462e3eaf827 100644
--- a/products/experiments/backend/facade/contracts.py
+++ b/products/experiments/backend/facade/contracts.py
@@ -215,6 +215,7 @@ class ExperimentHealthFindingCode(LabeledStrEnum):
RELEASE_CONDITIONS_CHANGED_MID_RUN = "release_conditions_changed_mid_run"
NEW_FLAG_NO_TRAFFIC = "new_flag_no_traffic"
EARLY_SIGNIFICANCE = "early_significance"
+ METRICS_NOT_MATURED = "metrics_not_matured"
class ExperimentHealthMetricCompileErrorKind(LabeledStrEnum):
@@ -314,6 +315,7 @@ class ExperimentHealthCheckKey(LabeledStrEnum):
EXPOSURE_CRITERIA_CANNOT_MATCH = "exposure_criteria_cannot_match"
EXPOSURE_FILTERS = "exposure_filters"
EARLY_SIGNIFICANCE = "early_significance"
+ METRICS_NOT_MATURED = "metrics_not_matured"
ZERO_EXPOSURES = "zero_exposures"
TEST_ACCOUNT_FILTER_REMOVES_EXPOSURES = "test_account_filter_removes_exposures"
SRM = "srm"
diff --git a/products/experiments/backend/health/checks/early_significance.py b/products/experiments/backend/health/checks/early_significance.py
index 0e34886b3b00..910d1f9eb79a 100644
--- a/products/experiments/backend/health/checks/early_significance.py
+++ b/products/experiments/backend/health/checks/early_significance.py
@@ -16,6 +16,7 @@ from products.experiments.backend.facade.contracts import (
)
from products.experiments.backend.health.context import HealthContext
from products.experiments.backend.health.skips import (
+ NEEDS_PRIMARY_METRIC,
NOT_AFTER_END,
NOT_ON_ARCHIVED,
RUNS_AFTER_LAUNCH,
@@ -52,7 +53,7 @@ def early_significance(ctx: HealthContext) -> CheckOutcome:
if ctx.has_ended:
return not_applicable(NOT_AFTER_END)
if ctx.primary_metric_count == 0:
- return not_applicable("Runs once the experiment has a primary metric")
+ return not_applicable(NEEDS_PRIMARY_METRIC)
metric = ctx.primary_metric
if metric is None:
return not_checked("Couldn't read the results of the primary metric")
diff --git a/products/experiments/backend/health/checks/metrics_not_matured.py b/products/experiments/backend/health/checks/metrics_not_matured.py
new file mode 100644
index 000000000000..6c8b52ebb5a2
--- /dev/null
+++ b/products/experiments/backend/health/checks/metrics_not_matured.py
@@ -0,0 +1,84 @@
+"""
+Primary metrics that can't have users yet, because the experiment is younger than their windows. Pure functions, no I/O.
+
+With "Require completed conversion or retention window" on, the query of a metric leaves a user out until the metric's
+window has passed. The exposure query applies no such filter, so the exposure count and `zero_exposures` look healthy
+while the results show no users.
+"""
+
+from datetime import UTC
+
+from products.experiments.backend.facade.contracts import (
+ ExperimentHealthFinding,
+ ExperimentHealthFindingCode,
+ ExperimentHealthFindingSeverity,
+)
+from products.experiments.backend.health.context import HealthContext, MetricWindow
+from products.experiments.backend.health.skips import (
+ NEEDS_PRIMARY_METRIC,
+ NOT_AFTER_END,
+ NOT_ON_ARCHIVED,
+ RUNS_AFTER_LAUNCH,
+ CheckOutcome,
+ not_applicable,
+ not_checked,
+)
+from products.experiments.backend.health.split_changes import format_change_time
+
+_SETTING_LABEL = '"Require completed conversion or retention window"'
+_SECONDS_PER_HOUR = 3600
+
+
+def metrics_not_matured(ctx: HealthContext) -> CheckOutcome:
+ if ctx.archived:
+ return not_applicable(NOT_ON_ARCHIVED)
+ if not ctx.is_launched:
+ return not_applicable(RUNS_AFTER_LAUNCH)
+ if ctx.has_ended:
+ return not_applicable(NOT_AFTER_END)
+ if not ctx.only_count_matured_users:
+ return not_applicable(f"Runs when {_SETTING_LABEL} is on")
+ if ctx.primary_metric_count == 0:
+ return not_applicable(NEEDS_PRIMARY_METRIC)
+ windows = ctx.primary_metric_windows
+ # The calculation leaves out a metric in the legacy format, which `primary_metric_count` counts.
+ if windows == ():
+ return not_applicable("Runs once the experiment has a primary metric in the current format")
+ hours_since_launch = ctx.hours_since_launch
+ if windows is None or hours_since_launch is None:
+ return not_checked("Couldn't check because the primary metric windows couldn't be read")
+ if not all(_holds_back_every_user(window, hours_since_launch) for window in windows):
+ return None
+ first_users = " and ".join(
+ f'for "{window.name}" on {format_change_time(window.first_users_count_at, ctx.team_timezone)}'
+ for window in windows
+ )
+ earliest = min(window.first_users_count_at for window in windows)
+ return ExperimentHealthFinding(
+ code=ExperimentHealthFindingCode.METRICS_NOT_MATURED,
+ subcode=None,
+ severity=ExperimentHealthFindingSeverity.INFO,
+ title="No results yet because the metric windows aren't complete",
+ detail=" ".join(
+ [
+ "The Exposures panel counts users without waiting for these windows.",
+ "A metric counts a user only after its conversion or retention window has passed, so no primary metric "
+ "has results yet.",
+ f"The first users can count {first_users}.",
+ f"To see results sooner, turn off {_SETTING_LABEL} in the experiment's Settings tab.",
+ "Users whose window is still open then count too.",
+ ]
+ ),
+ evidence={
+ "hours_since_launch": int(hours_since_launch),
+ "first_users_count_at": earliest.astimezone(UTC).isoformat(),
+ },
+ actions=(),
+ diagnostic_ref=None,
+ )
+
+
+def _holds_back_every_user(window: MetricWindow, hours_since_launch: float) -> bool:
+ # `MaturityGate` counts a user at `anchor + window <= now`, so a user exposed at launch counts at the exact age of
+ # the window.
+ return window.window_seconds > 0 and hours_since_launch * _SECONDS_PER_HOUR < window.window_seconds
diff --git a/products/experiments/backend/health/context.py b/products/experiments/backend/health/context.py
index 12226da79d60..f0ffc30500f9 100644
--- a/products/experiments/backend/health/context.py
+++ b/products/experiments/backend/health/context.py
@@ -232,6 +232,18 @@ class PrimaryMetric:
result: MetricResultStats | None
+@frozen
+class MetricWindow:
+ """How long a primary metric holds a user back while "Require completed conversion or retention window" is on."""
+
+ name: str
+ # 0 when the metric has no window, so the setting holds nobody back.
+ window_seconds: int
+ # The launch plus the window. The window starts at a user's first exposure, or at the start event for retention,
+ # so a user who arrives later counts later.
+ first_users_count_at: datetime
+
+
@frozen
class ExposureSegment:
"""The persons or groups whose first exposure carries one value of a dimension, such as the SDK library."""
@@ -541,6 +553,11 @@ class HealthContext:
# None when not loaded, unknown, or the experiment calculates no primary metric. Only the health endpoints load it,
# and only for a launched experiment.
primary_metric: PrimaryMetric | None
+ only_count_matured_users: bool
+ # In the order of the results page. None when not loaded or when a metric doesn't parse. Only the health endpoints
+ # load it, and only for a launched experiment that hasn't ended, isn't archived and has `only_count_matured_users`
+ # on.
+ primary_metric_windows: tuple[MetricWindow, ...] | None
# The variants that the analysis leaves out of the results.
excluded_variant_keys: frozenset[str]
# None when not loaded or unknown. Only the health endpoints load it, as the reader.
@@ -1007,6 +1024,8 @@ def load_health_context(
condition_set_traffic=None,
pause_history=None,
primary_metric=None,
+ only_count_matured_users=experiment.only_count_matured_users,
+ primary_metric_windows=None,
excluded_variant_keys=frozenset(experiment.excluded_variants or []),
metric_compiles=None,
latest_calculation=None,
diff --git a/products/experiments/backend/health/loader.py b/products/experiments/backend/health/loader.py
index f0b79e63b39b..674aea76be02 100644
--- a/products/experiments/backend/health/loader.py
+++ b/products/experiments/backend/health/loader.py
@@ -13,6 +13,7 @@ from products.experiments.backend.health.exposure_gate import load_flag_history
from products.experiments.backend.health.exposure_inputs import ExposureInputs, load_exposure_inputs
from products.experiments.backend.health.latest_calculation import load_latest_calculation
from products.experiments.backend.health.metric_compiles import load_metric_compiles
+from products.experiments.backend.health.metric_windows import load_primary_metric_windows
from products.experiments.backend.health.pause_history import load_pause_history
from products.experiments.backend.health.primary_metric import load_primary_metric
from products.experiments.backend.models.experiment import Experiment
@@ -81,6 +82,7 @@ def _health_context(
condition_set_traffic=traffic,
pause_history=load_pause_history(experiment, reader_access=reader_access),
primary_metric=load_primary_metric(experiment),
+ primary_metric_windows=load_primary_metric_windows(experiment),
metric_compiles=load_metric_compiles(experiment, user=user),
latest_calculation=latest_calculation,
exposure_filters_without_column=load_filters_without_column(experiment)
diff --git a/products/experiments/backend/health/metric_windows.py b/products/experiments/backend/health/metric_windows.py
new file mode 100644
index 000000000000..ec20899e6c7b
--- /dev/null
+++ b/products/experiments/backend/health/metric_windows.py
@@ -0,0 +1,63 @@
+from datetime import datetime, timedelta
+from typing import Any
+
+from pydantic import ValidationError
+
+from posthog.exceptions_capture import capture_exception
+
+from products.experiments.backend.health.context import MetricWindow
+from products.experiments.backend.hogql_queries.experiment_metric_values import get_maturity_window_seconds
+from products.experiments.backend.metric_calculation.config import (
+ MetricCalculationConfig,
+ build_primary_calculation_configs,
+ calculation_metric_name,
+)
+from products.experiments.backend.metric_resolution import build_metric
+from products.experiments.backend.models.experiment import Experiment
+
+
+def load_primary_metric_windows(experiment: Experiment) -> tuple[MetricWindow, ...] | None:
+ """
+ The windows of the primary metrics of a launched experiment that hasn't ended, isn't archived and has
+ `only_count_matured_users` on, or None. Never raises: the check that reads them then reports that it couldn't check.
+ """
+ start_date = experiment.start_date
+ if start_date is None or experiment.is_stopped or experiment.archived or not experiment.only_count_matured_users:
+ return None
+ try:
+ return _load_primary_metric_windows(experiment, start_date)
+ except Exception as error:
+ capture_exception(error)
+ return None
+
+
+def metric_window(*, name: str, definition: dict[str, Any], start_date: datetime) -> MetricWindow | None:
+ """The window of one metric definition. None when the definition doesn't parse, which `metric_cannot_compile`
+ reports, so this captures nothing."""
+ try:
+ window_seconds = get_maturity_window_seconds(build_metric(definition))
+ except ValidationError:
+ return None
+ return MetricWindow(
+ name=name,
+ window_seconds=window_seconds,
+ first_users_count_at=start_date + timedelta(seconds=window_seconds),
+ )
+
+
+def _load_primary_metric_windows(experiment: Experiment, start_date: datetime) -> tuple[MetricWindow, ...] | None:
+ # Metrics that share a uuid share its first definition, so one window covers them.
+ configs: dict[str, MetricCalculationConfig] = {}
+ for calculation_config in build_primary_calculation_configs(experiment):
+ configs.setdefault(calculation_config.metric_id, calculation_config)
+ windows: list[MetricWindow] = []
+ for calculation_config in configs.values():
+ window = metric_window(
+ name=calculation_metric_name(experiment, calculation_config),
+ definition=calculation_config.definition,
+ start_date=start_date,
+ )
+ if window is None:
+ return None
+ windows.append(window)
+ return tuple(windows)
diff --git a/products/experiments/backend/health/registry.py b/products/experiments/backend/health/registry.py
index fd8840ee97b8..6861344571f6 100644
--- a/products/experiments/backend/health/registry.py
+++ b/products/experiments/backend/health/registry.py
@@ -25,6 +25,7 @@ from products.experiments.backend.health.checks.forced_variant import forced_var
from products.experiments.backend.health.checks.metric_calculation_failed import metric_calculation_failed
from products.experiments.backend.health.checks.metric_cannot_compile import metric_cannot_compile
from products.experiments.backend.health.checks.metric_event_not_ingested import metric_event_not_ingested
+from products.experiments.backend.health.checks.metrics_not_matured import metrics_not_matured
from products.experiments.backend.health.checks.multiple_variants import multiple_variants_share
from products.experiments.backend.health.checks.new_flag_no_traffic import new_flag_no_traffic
from products.experiments.backend.health.checks.no_metric import no_metric
@@ -118,6 +119,11 @@ EXPERIMENT_HEALTH_CHECKS: tuple[HealthCheck, ...] = (
name="Significance on a small sample",
run=early_significance,
),
+ HealthCheck(
+ key=ExperimentHealthCheckKey.METRICS_NOT_MATURED,
+ name="Metric windows not complete yet",
+ run=metrics_not_matured,
+ ),
)
# The exposure query runs these on its answer. They must not include the checks above: the exposure answer
diff --git a/products/experiments/backend/health/skips.py b/products/experiments/backend/health/skips.py
index f853f8a7ab3e..89b742ca65eb 100644
--- a/products/experiments/backend/health/skips.py
+++ b/products/experiments/backend/health/skips.py
@@ -22,6 +22,7 @@ NOT_ON_ARCHIVED = "Doesn't run on archived experiments"
NO_FLAG = "The experiment has no feature flag"
FLAG_DELETED = "The feature flag is deleted"
NEEDS_VARIANTS = "Runs once the feature flag has variants"
+NEEDS_PRIMARY_METRIC = "Runs once the experiment has a primary metric"
def not_applicable(reason: str) -> CheckSkip:
diff --git a/products/experiments/backend/health/test/factories.py b/products/experiments/backend/health/test/factories.py
index 0a3ad42f0622..0cdff87ff0fc 100644
--- a/products/experiments/backend/health/test/factories.py
+++ b/products/experiments/backend/health/test/factories.py
@@ -44,6 +44,8 @@ RUNNING_CONTEXT = HealthContext(
condition_set_traffic=None,
pause_history=None,
primary_metric=None,
+ only_count_matured_users=False,
+ primary_metric_windows=None,
excluded_variant_keys=frozenset(),
metric_compiles=None,
latest_calculation=None,
diff --git a/products/experiments/backend/health/test/test_metrics_not_matured.py b/products/experiments/backend/health/test/test_metrics_not_matured.py
new file mode 100644
index 000000000000..84a9514910f4
--- /dev/null
+++ b/products/experiments/backend/health/test/test_metrics_not_matured.py
@@ -0,0 +1,249 @@
+from dataclasses import replace
+from datetime import UTC, datetime, timedelta
+from typing import Any
+
+from posthog.test.base import BaseTest
+from unittest import TestCase
+
+from django.utils import timezone
+
+from parameterized import parameterized
+
+from products.experiments.backend.facade.api import get_experiment_health
+from products.experiments.backend.facade.contracts import (
+ ExperimentHealthCheckKey,
+ ExperimentHealthCheckStatus,
+ ExperimentHealthFinding,
+ ExperimentHealthFindingCode,
+ ExperimentHealthFindingSeverity,
+ ExperimentHealthReaderAccess,
+)
+from products.experiments.backend.health.checks.metrics_not_matured import metrics_not_matured
+from products.experiments.backend.health.context import HealthContext, MetricWindow
+from products.experiments.backend.health.metric_windows import metric_window
+from products.experiments.backend.health.skips import (
+ NEEDS_PRIMARY_METRIC,
+ NOT_AFTER_END,
+ NOT_ON_ARCHIVED,
+ RUNS_AFTER_LAUNCH,
+ CheckSkip,
+)
+from products.experiments.backend.health.test.factories import DRAFT, ENDED, RUNNING_CONTEXT
+from products.experiments.backend.models.experiment import Experiment, ExperimentSavedMetric, ExperimentToSavedMetric
+from products.feature_flags.backend.models.feature_flag import FeatureFlag
+
+Status = ExperimentHealthCheckStatus
+NO_QUERIES = ExperimentHealthReaderAccess(
+ can_read_flag_history=False, can_query_events=False, denied_event_properties=frozenset()
+)
+LAUNCHED_AT = datetime(2026, 10, 1, 12, tzinfo=UTC)
+PURCHASE = {"kind": "EventsNode", "event": "purchase"}
+NO_WINDOW = {"kind": "ExperimentMetric", "metric_type": "funnel", "series": [PURCHASE]}
+THREE_DAYS = {**NO_WINDOW, "conversion_window": 3, "conversion_window_unit": "day"}
+FOUR_DAYS = {**NO_WINDOW, "conversion_window": 4, "conversion_window_unit": "day"}
+WINDOW_WITHOUT_UNIT = {**NO_WINDOW, "conversion_window": 4}
+MEAN_FOUR_DAYS = {
+ "kind": "ExperimentMetric",
+ "metric_type": "mean",
+ "source": PURCHASE,
+ "conversion_window": 4,
+ "conversion_window_unit": "day",
+}
+RETENTION = {
+ "kind": "ExperimentMetric",
+ "metric_type": "retention",
+ "start_event": PURCHASE,
+ "completion_event": PURCHASE,
+ "start_handling": "first_seen",
+ "retention_window_start": 1,
+ "retention_window_end": 14,
+ "retention_window_unit": "day",
+ "conversion_window": 1,
+ "conversion_window_unit": "hour",
+}
+
+
+def _window(name: str, metric: dict[str, Any]) -> MetricWindow:
+ window = metric_window(name=name, definition=metric, start_date=LAUNCHED_AT)
+ assert window is not None
+ return window
+
+
+def _context(metrics: list[tuple[str, dict[str, Any]]], *, hours_since_launch: float = 72) -> HealthContext:
+ return replace(
+ RUNNING_CONTEXT,
+ only_count_matured_users=True,
+ hours_since_launch=hours_since_launch,
+ primary_metric_count=len(metrics),
+ primary_metric_windows=tuple(_window(name, metric) for name, metric in metrics),
+ )
+
+
+class TestMetricsNotMatured(TestCase):
+ @parameterized.expand(
+ [
+ ("one_primary_held_back", [("Checkout", FOUR_DAYS)], 72, True),
+ ("mean_metric_held_back", [("Revenue", MEAN_FOUR_DAYS)], 72, True),
+ ("every_primary_held_back", [("Checkout", FOUR_DAYS), ("Return", RETENTION)], 72, True),
+ ("age_below_the_window", [("Checkout", THREE_DAYS)], 71.9, True),
+ ("age_equal_to_the_window", [("Checkout", THREE_DAYS)], 72, False),
+ ("retention_uses_its_own_window_not_the_conversion_window", [("Return", RETENTION)], 13 * 24, True),
+ (
+ "retention_uses_its_own_unit",
+ [("Return", {**RETENTION, "retention_window_unit": "hour"})],
+ 14,
+ False,
+ ),
+ ("window_without_a_unit", [("Checkout", WINDOW_WITHOUT_UNIT)], 72, False),
+ ("no_window_before_a_future_start_date", [("Signup", NO_WINDOW)], -1, False),
+ ("one_of_two_without_a_window", [("Checkout", FOUR_DAYS), ("Signup", NO_WINDOW)], 72, False),
+ ("one_of_two_past_its_window", [("Checkout", FOUR_DAYS), ("Signup", THREE_DAYS)], 72, False),
+ ]
+ )
+ def test_finds_only_when_every_primary_metric_is_held_back(
+ self, _name: str, metrics: list[tuple[str, dict[str, Any]]], hours_since_launch: float, expected: bool
+ ) -> None:
+ outcome = metrics_not_matured(_context(metrics, hours_since_launch=hours_since_launch))
+
+ self.assertEqual(isinstance(outcome, ExperimentHealthFinding), expected)
+ if not expected:
+ self.assertIsNone(outcome)
+
+ def test_names_each_metric_and_the_time_its_first_users_count(self) -> None:
+ outcome = metrics_not_matured(_context([("Return", RETENTION), ("Checkout", FOUR_DAYS)]))
+
+ assert isinstance(outcome, ExperimentHealthFinding)
+ self.assertEqual(
+ (outcome.code, outcome.subcode, outcome.reason, outcome.severity, outcome.actions),
+ (ExperimentHealthFindingCode.METRICS_NOT_MATURED, None, None, ExperimentHealthFindingSeverity.INFO, ()),
+ )
+ self.assertIn(
+ 'The first users can count for "Return" on October 15, 2026 at 2:00 PM CEST and for "Checkout" on '
+ "October 5, 2026 at 2:00 PM CEST.",
+ outcome.detail,
+ )
+ self.assertEqual(
+ outcome.evidence, {"hours_since_launch": 72, "first_users_count_at": "2026-10-05T12:00:00+00:00"}
+ )
+
+ @parameterized.expand(
+ [
+ (
+ "setting_off",
+ {"only_count_matured_users": False},
+ Status.NOT_APPLICABLE,
+ 'Runs when "Require completed conversion or retention window" is on',
+ ),
+ ("draft", DRAFT, Status.NOT_APPLICABLE, RUNS_AFTER_LAUNCH),
+ ("ended", ENDED, Status.NOT_APPLICABLE, NOT_AFTER_END),
+ ("archived", {"archived": True, **ENDED}, Status.NOT_APPLICABLE, NOT_ON_ARCHIVED),
+ (
+ "no_primary_metric",
+ {"primary_metric_count": 0, "primary_metric_windows": None},
+ Status.NOT_APPLICABLE,
+ NEEDS_PRIMARY_METRIC,
+ ),
+ (
+ "only_secondary_metrics",
+ {"primary_metric_count": 0, "secondary_metric_count": 1, "primary_metric_windows": ()},
+ Status.NOT_APPLICABLE,
+ NEEDS_PRIMARY_METRIC,
+ ),
+ (
+ "only_legacy_primary_metrics",
+ {"primary_metric_windows": (), "secondary_metric_count": 1},
+ Status.NOT_APPLICABLE,
+ "Runs once the experiment has a primary metric in the current format",
+ ),
+ (
+ "windows_not_loaded",
+ {"primary_metric_windows": None},
+ Status.NOT_CHECKED,
+ "Couldn't check because the primary metric windows couldn't be read",
+ ),
+ ]
+ )
+ def test_says_why_it_did_not_look(self, _name: str, changes: dict[str, Any], status: Status, reason: str) -> None:
+ outcome = metrics_not_matured(replace(_context([("Checkout", FOUR_DAYS)]), **changes))
+
+ assert isinstance(outcome, CheckSkip)
+ self.assertEqual((outcome.status, outcome.reason), (status, reason))
+
+
+class TestMetricsNotMaturedFromStoredMetrics(BaseTest):
+ @parameterized.expand(
+ [
+ ("saved_primary_held_back", [], [], FOUR_DAYS, Status.FINDING, "Checkout funnel"),
+ (
+ "a_secondary_past_its_window_does_not_clear_the_primaries",
+ [FOUR_DAYS],
+ [NO_WINDOW],
+ None,
+ Status.FINDING,
+ "purchase conversion",
+ ),
+ (
+ "a_saved_metric_that_shares_the_uuid_of_an_inline_primary",
+ [FOUR_DAYS],
+ [],
+ {**FOUR_DAYS, "uuid": "primary-0"},
+ Status.FINDING,
+ "purchase conversion",
+ ),
+ ("only_a_secondary_held_back", [NO_WINDOW], [FOUR_DAYS], None, Status.PASSED, None),
+ ("a_primary_that_does_not_parse", [{"metric_type": "funnel"}], [], None, Status.NOT_CHECKED, None),
+ ]
+ )
+ def test_reads_the_windows_of_the_stored_primary_metrics(
+ self,
+ _name: str,
+ primary: list[dict[str, Any]],
+ secondary: list[dict[str, Any]],
+ saved_primary: dict[str, Any] | None,
+ expected: Status,
+ expected_metric: str | None,
+ ) -> None:
+ flag = FeatureFlag.objects.create(
+ team=self.team,
+ key="checkout-flag",
+ created_by=self.user,
+ filters={
+ "groups": [{"properties": [], "rollout_percentage": 100}],
+ "multivariate": {
+ "variants": [
+ {"key": "control", "rollout_percentage": 50},
+ {"key": "test", "rollout_percentage": 50},
+ ]
+ },
+ },
+ )
+ experiment = Experiment.objects.create(
+ team=self.team,
+ name="checkout",
+ feature_flag=flag,
+ start_date=timezone.now() - timedelta(days=3),
+ only_count_matured_users=True,
+ metrics=[{**metric, "uuid": f"primary-{index}"} for index, metric in enumerate(primary)],
+ metrics_secondary=[{**metric, "uuid": f"secondary-{index}"} for index, metric in enumerate(secondary)],
+ )
+ if saved_primary is not None:
+ saved_metric = ExperimentSavedMetric.objects.create(
+ team=self.team, name="Checkout funnel", query={"uuid": "saved-primary", **saved_primary}
+ )
+ ExperimentToSavedMetric.objects.create(
+ experiment=experiment, saved_metric=saved_metric, metadata={"type": "primary"}
+ )
+
+ health = get_experiment_health(
+ team_id=self.team.id, experiment_id=experiment.id, reader_access=NO_QUERIES, user=self.user
+ )
+
+ check = next(check for check in health.checks if check.key == ExperimentHealthCheckKey.METRICS_NOT_MATURED)
+ self.assertEqual(check.status, expected)
+ finding = next(
+ (finding for finding in health.findings if finding.code == ExperimentHealthFindingCode.METRICS_NOT_MATURED),
+ None,
+ )
+ self.assertEqual(finding is not None, expected == Status.FINDING)
+ if finding:
+ self.assertEqual(finding.detail.count(f'"{expected_metric}"'), 1)
diff --git a/products/experiments/backend/health/test/test_registry.py b/products/experiments/backend/health/test/test_registry.py
index 7ab5aaaa1c36..573c915faf49 100644
--- a/products/experiments/backend/health/test/test_registry.py
+++ b/products/experiments/backend/health/test/test_registry.py
@@ -249,6 +249,11 @@ class TestEvaluate(TestCase):
{"primary_metric": None},
{Key.EARLY_SIGNIFICANCE: Status.NOT_CHECKED},
),
+ (
+ "metrics_not_matured_needs_the_primary_metric_windows",
+ {"only_count_matured_users": True},
+ {Key.METRICS_NOT_MATURED: Status.NOT_CHECKED},
+ ),
(
"zero_exposures_finds_a_day_after_launch",
{"exposures": replace(NO_EXPOSURES, hours_since_launch=24)},
diff --git a/products/experiments/backend/hogql_queries/experiment_metric_values.py b/products/experiments/backend/hogql_queries/experiment_metric_values.py
index 88c38c706b9c..3426c7f41759 100644
--- a/products/experiments/backend/hogql_queries/experiment_metric_values.py
+++ b/products/experiments/backend/hogql_queries/experiment_metric_values.py
@@ -43,6 +43,14 @@ def get_conversion_window_seconds(metric: ExperimentMetric) -> int:
return 0
+def get_maturity_window_seconds(metric: ExperimentMetric) -> int:
+ """How long `only_count_matured_users` holds an entity back after the metric's anchor. Returns 0 when the metric
+ has no window. A retention metric can also carry a conversion window, which its maturity ignores."""
+ if isinstance(metric, ExperimentRetentionMetric):
+ return conversion_window_to_seconds(metric.retention_window_end, metric.retention_window_unit)
+ return get_conversion_window_seconds(metric)
+
+
def build_conversion_window_predicate(conversion_window_seconds: int) -> ast.Expr:
return build_conversion_window_predicate_for_events("metric_events", conversion_window_seconds)
diff --git a/products/experiments/backend/hogql_queries/experiment_query_builder.py b/products/experiments/backend/hogql_queries/experiment_query_builder.py
index c0b27a68eb5a..1ec7840a53dd 100644
--- a/products/experiments/backend/hogql_queries/experiment_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_query_builder.py
@@ -41,6 +41,7 @@ from products.experiments.backend.hogql_queries.experiment_metric_values import
build_value_aggregation_expr,
build_value_expr,
get_conversion_window_seconds,
+ get_maturity_window_seconds,
)
from products.experiments.backend.hogql_queries.experiment_query_context import (
ExperimentPrecomputationContext,
@@ -338,7 +339,7 @@ class ExperimentQueryBuilder:
"""
if self.metric is None or isinstance(self.metric, ExperimentRetentionMetric):
return 0
- return self._get_conversion_window_seconds()
+ return get_maturity_window_seconds(self.metric)
def _build_conversion_window_predicate(self) -> ast.Expr:
"""Uses "metric_events" as the events alias."""
diff --git a/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py b/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py
index f4ba11db4d81..00efd12c6c40 100644
--- a/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py
+++ b/products/experiments/backend/hogql_queries/experiment_retention_query_builder.py
@@ -21,6 +21,7 @@ from products.experiments.backend.hogql_queries.base_query_utils import (
event_or_action_to_filter,
)
from products.experiments.backend.hogql_queries.experiment_exposure_query_builder import ExposureQueryBuilder
+from products.experiments.backend.hogql_queries.experiment_metric_values import get_maturity_window_seconds
from products.experiments.backend.hogql_queries.experiment_query_context import MaturityGate
if TYPE_CHECKING:
@@ -57,10 +58,7 @@ class RetentionQueryBuilder:
not contribute. Only retention_window_end counts.
"""
assert isinstance(self._b.metric, ExperimentRetentionMetric)
- return conversion_window_to_seconds(
- self._b.metric.retention_window_end,
- self._b.metric.retention_window_unit,
- )
+ return get_maturity_window_seconds(self._b.metric)
def get_metric_events_window_extension_seconds(self) -> int:
"""
diff --git a/products/experiments/backend/presentation/views.py b/products/experiments/backend/presentation/views.py
index b21cf20209f5..26acf3d3b6bf 100644
--- a/products/experiments/backend/presentation/views.py
+++ b/products/experiments/backend/presentation/views.py
@@ -1073,6 +1073,10 @@ class EnterpriseExperimentsViewSet(
sample is below the one the running time estimate plans for the minimum detectable
effect. It reads the metric's current stored result, the one the results page shows
after its last calculation, and the running time calculator's formula.
+
+ A running experiment with `only_count_matured_users` on gets the info
+ `metrics_not_matured` while it is younger than the conversion or retention window of
+ every primary metric, because no user can count for those metrics until a window passes.
"""
experiment: Experiment = self.get_object()
health = get_experiment_health(
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index 803faca7df21..ee3ab5a194fe 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -2319,6 +2319,7 @@ export type _ExperimentApiMetricsListApi = ExperimentApiMetricApi[]
* * `release_conditions_changed_mid_run` - Release Conditions Changed Mid Run
* * `new_flag_no_traffic` - New Flag No Traffic
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
*/
export type ExperimentHealthFindingCodeEnumApi =
(typeof ExperimentHealthFindingCodeEnumApi)[keyof typeof ExperimentHealthFindingCodeEnumApi]
@@ -2347,6 +2348,7 @@ export const ExperimentHealthFindingCodeEnumApi = {
ReleaseConditionsChangedMidRun: 'release_conditions_changed_mid_run',
NewFlagNoTraffic: 'new_flag_no_traffic',
EarlySignificance: 'early_significance',
+ MetricsNotMatured: 'metrics_not_matured',
} as const
/**
@@ -2417,7 +2419,8 @@ export interface ExperimentHealthFindingApi {
* * `bucketing_changed_mid_run` - Bucketing Changed Mid Run
* * `release_conditions_changed_mid_run` - Release Conditions Changed Mid Run
* * `new_flag_no_traffic` - New Flag No Traffic
- * * `early_significance` - Early Significance */
+ * * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured */
code: ExperimentHealthFindingCodeEnumApi
/**
* The case within the code, when a code covers several, for example 'running_but_no_rollout' within 'flag_off_while_running'. Null when the code has one case.
@@ -2466,6 +2469,7 @@ export interface ExperimentHealthFindingApi {
* * `exposure_criteria_cannot_match` - Exposure Criteria Cannot Match
* * `exposure_filters` - Exposure Filters
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
* * `zero_exposures` - Zero Exposures
* * `test_account_filter_removes_exposures` - Test Account Filter Removes Exposures
* * `srm` - Srm
@@ -2491,6 +2495,7 @@ export const ExperimentHealthCheckKeyEnumApi = {
ExposureCriteriaCannotMatch: 'exposure_criteria_cannot_match',
ExposureFilters: 'exposure_filters',
EarlySignificance: 'early_significance',
+ MetricsNotMatured: 'metrics_not_matured',
ZeroExposures: 'zero_exposures',
TestAccountFilterRemovesExposures: 'test_account_filter_removes_exposures',
Srm: 'srm',
@@ -2532,6 +2537,7 @@ export interface ExperimentHealthCheckResultApi {
* * `exposure_criteria_cannot_match` - Exposure Criteria Cannot Match
* * `exposure_filters` - Exposure Filters
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
* * `zero_exposures` - Zero Exposures
* * `test_account_filter_removes_exposures` - Test Account Filter Removes Exposures
* * `srm` - Srm
diff --git a/products/experiments/frontend/generated/api.ts b/products/experiments/frontend/generated/api.ts
index b2eac705f422..17137fc3f978 100644
--- a/products/experiments/frontend/generated/api.ts
+++ b/products/experiments/frontend/generated/api.ts
@@ -818,6 +818,10 @@ export const getExperimentsHealthRetrieveUrl = (projectId: string, id: number) =
* sample is below the one the running time estimate plans for the minimum detectable
* effect. It reads the metric's current stored result, the one the results page shows
* after its last calculation, and the running time calculator's formula.
+ *
+ * A running experiment with `only_count_matured_users` on gets the info
+ * `metrics_not_matured` while it is younger than the conversion or retention window of
+ * every primary metric, because no user can count for those metrics until a window passes.
*/
export const experimentsHealthRetrieve = async (
projectId: string,
diff --git a/products/experiments/frontend/health/HealthChecksOverview.stories.tsx b/products/experiments/frontend/health/HealthChecksOverview.stories.tsx
index 7feb4a9f65e2..d13450162c4b 100644
--- a/products/experiments/frontend/health/HealthChecksOverview.stories.tsx
+++ b/products/experiments/frontend/health/HealthChecksOverview.stories.tsx
@@ -142,6 +142,30 @@ export const RunningWithSignificanceOnASmallSample: Story = {
},
}
+export const RunningWithMetricWindowsNotComplete: Story = {
+ args: {
+ checks: [
+ ...FLAG_SETUP_CHECKS,
+ passed('no_metric', 'Metrics not set up'),
+ found('metrics_not_matured', 'Metric windows not complete yet'),
+ ],
+ findings: [
+ {
+ code: 'metrics_not_matured',
+ subcode: null,
+ reason: null,
+ severity: 'info',
+ title: "No results yet because the metric windows aren't complete",
+ detail: 'The Exposures panel counts users without waiting for these windows. A metric counts a user only after its conversion or retention window has passed, so no primary metric has results yet. The first users can count for "Checkout" on October 5, 2026 at 2:00 PM CEST and for "Return visits" on October 15, 2026 at 2:00 PM CEST. To see results sooner, turn off "Require completed conversion or retention window" in the experiment\'s Settings tab. Users whose window is still open then count too.',
+ evidence: { hours_since_launch: 72, first_users_count_at: '2026-10-05T12:00:00+00:00' },
+ actions: [],
+ },
+ ],
+ isDraft: false,
+ exposureChecksMissing: false,
+ },
+}
+
export const ChecksThatCouldNotRun: Story = {
args: {
checks: [
diff --git a/products/experiments/frontend/health/debug/healthDebugReport.ts b/products/experiments/frontend/health/debug/healthDebugReport.ts
index 6ed1e6de4763..2751dc4ad03c 100644
--- a/products/experiments/frontend/health/debug/healthDebugReport.ts
+++ b/products/experiments/frontend/health/debug/healthDebugReport.ts
@@ -388,6 +388,7 @@ export function buildHealthDebugChecks(input: HealthDebugInput): HealthDebugChec
serverOnlyCheck(input, 'exposure_criteria_cannot_match', exposureCriteriaNote, ['experiment', 'project']),
exposureFiltersCheck(input),
serverOnlyCheck(input, 'early_significance', null, ['experiment', 'metrics']),
+ serverOnlyCheck(input, 'metrics_not_matured', null, ['experiment', 'metrics']),
...exposureChecks(input),
]
}
diff --git a/products/experiments/frontend/health/experimentHealthFindingEvents.ts b/products/experiments/frontend/health/experimentHealthFindingEvents.ts
index fa06ebe8d7ec..73450b56e36f 100644
--- a/products/experiments/frontend/health/experimentHealthFindingEvents.ts
+++ b/products/experiments/frontend/health/experimentHealthFindingEvents.ts
@@ -41,6 +41,7 @@ export type ExperimentHealthFindingCode =
| 'release_conditions_changed_mid_run'
| 'new_flag_no_traffic'
| 'early_significance'
+ | 'metrics_not_matured'
export interface ExperimentHealthFinding {
code: ExperimentHealthFindingCode
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5e4c472a9bff..2764df183e02 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -47757,6 +47757,7 @@ export namespace Schemas {
* * `release_conditions_changed_mid_run` - Release Conditions Changed Mid Run
* * `new_flag_no_traffic` - New Flag No Traffic
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
*/
export type ExperimentHealthFindingCodeEnum = typeof ExperimentHealthFindingCodeEnum[keyof typeof ExperimentHealthFindingCodeEnum];
@@ -47785,6 +47786,7 @@ export namespace Schemas {
ReleaseConditionsChangedMidRun: 'release_conditions_changed_mid_run',
NewFlagNoTraffic: 'new_flag_no_traffic',
EarlySignificance: 'early_significance',
+ MetricsNotMatured: 'metrics_not_matured',
} as const;
/**
@@ -47855,7 +47857,8 @@ export namespace Schemas {
* * `bucketing_changed_mid_run` - Bucketing Changed Mid Run
* * `release_conditions_changed_mid_run` - Release Conditions Changed Mid Run
* * `new_flag_no_traffic` - New Flag No Traffic
- * * `early_significance` - Early Significance */
+ * * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured */
code: ExperimentHealthFindingCodeEnum;
/**
* The case within the code, when a code covers several, for example 'running_but_no_rollout' within 'flag_off_while_running'. Null when the code has one case.
@@ -47904,6 +47907,7 @@ export namespace Schemas {
* * `exposure_criteria_cannot_match` - Exposure Criteria Cannot Match
* * `exposure_filters` - Exposure Filters
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
* * `zero_exposures` - Zero Exposures
* * `test_account_filter_removes_exposures` - Test Account Filter Removes Exposures
* * `srm` - Srm
@@ -47929,6 +47933,7 @@ export namespace Schemas {
ExposureCriteriaCannotMatch: 'exposure_criteria_cannot_match',
ExposureFilters: 'exposure_filters',
EarlySignificance: 'early_significance',
+ MetricsNotMatured: 'metrics_not_matured',
ZeroExposures: 'zero_exposures',
TestAccountFilterRemovesExposures: 'test_account_filter_removes_exposures',
Srm: 'srm',
@@ -47970,6 +47975,7 @@ export namespace Schemas {
* * `exposure_criteria_cannot_match` - Exposure Criteria Cannot Match
* * `exposure_filters` - Exposure Filters
* * `early_significance` - Early Significance
+ * * `metrics_not_matured` - Metrics Not Matured
* * `zero_exposures` - Zero Exposures
* * `test_account_filter_removes_exposures` - Test Account Filter Removes Exposures
* * `srm` - Srm