: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
chore(experiments): remove the timeseries recalculation publish pass (#111422)
Rodrigo Iloroc512038ceb0b
diff --git a/posthog/temporal/experiments/README.md b/posthog/temporal/experiments/README.mdindex 0c58bb4024c5..7ce1f53fe64e 100644--- a/posthog/temporal/experiments/README.md+++ b/posthog/temporal/experiments/README.md@@ -4,7 +4,7 @@ This module calculates experiment metrics in the background using Temporal, a wo## How it works-Each team can configure one or two times of day when their experiments are recalculated, at least six hours apart (default: once at 02:00 UTC), via `TeamExperimentsConfig.experiment_recalculation_times`. The system runs 24 schedules - one for each hour of the day. Each schedule starts between 2 and 32 minutes past its hour, so the runs do not pile up with other jobs at minute zero. When a schedule fires, it finds all experiments belonging to teams configured for that hour and calculates their metrics. A team with two configured times matches two schedules, so its experiments get two independent runs a day, each publishing its own recalculation.+Each team can configure one or two times of day when their experiments are recalculated, at least six hours apart (default: once at 02:00 UTC), via `TeamExperimentsConfig.experiment_recalculation_times`. The system runs 24 schedules - one for each hour of the day. Each schedule starts between 2 and 32 minutes past its hour, so the runs do not pile up with other jobs at minute zero. When a schedule fires, it finds all experiments belonging to teams configured for that hour and calculates their metrics. A team with two configured times matches two schedules, so its experiments get two independent runs a day.```text┌─────────────────────────────────────────────────────────────────────────┐@@ -34,21 +34,12 @@ When a schedule triggers, it starts a workflow that:1. Discovers which experiment-metric pairs need calculation. It skips the metrics that `is_scheduled_metric` rejects, the same as recalculation discovery: legacy metrics without a `metric_type`, and metrics without a uuid2. Calculates each experiment's metrics in parallel, under one hour-wide concurrency limit3. Stores results in the database-4. Assembles one completed metrics recalculation per experiment as soon as that experiment's own metrics finish (see below)-### Handing fresh points to the recalculation reader--The experiment page reads results through `GET /metrics_recalculation/latest`, which returns the newest completed `ExperimentMetricsRecalculation`. Timeseries rows alone never reach it, so each workflow runs `create_recalculation_from_timeseries` once per experiment it touched (`products/experiments/backend/timeseries_sync.py`). The publish runs right after the experiment's own metric activities complete, not behind a whole-hour barrier, so one slow experiment or a mid-batch worker restart delays only its own publish:--- A metric qualifies when its newest completed row under the config fingerprint has a `query_to` between the workflow start and now. Yesterday's row for a metric that failed today does not qualify, and neither does a future-dated day-end row from the backfill workflow.-- The activity creates a completed recalculation with trigger `timeseries_sync` and copies each qualifying row under the recalc fingerprint at one shared `query_to`, one second past the newest point. Copies at a point's own `query_to` would share the `(experiment, metric_uuid, query_to)` key with the timeseries row and rewrite its fingerprint.-- A supported metric without a qualifying point is counted in `total_metrics` but gets no copy, so the frontend sees the gap and heals it with a real run. Every buildable metric type (`DAILY_TIMESERIES_METRIC_TYPES` in `metric_resolution.py`) is computed on every scheduled run; legacy metrics without a `metric_type` are left out of `total_metrics` and `metric_uuids` entirely.-- The row belongs to one scheduled run of the experiment, not to one workflow. The inline and saved metric workflows both run the activity for the same experiment in the same hour, each with its own run start. The first pass creates the row; a later pass in the same hour finds that run's `timeseries_sync` row and adds the copies it still lacks, so the row covers every metric the run computed whichever workflow finishes last. The lookup is scoped to the run's start, so a team's second run of the day creates its own row instead of touching the earlier one.-- When no sync row exists for the run, the activity skips if any other recalculation, finished or executing, already has a `query_to` at or past the oldest qualifying point.--Each metric stamps its own `query_to` at the moment its activity runs, so the points of one run are seconds to minutes apart. The copies present them as one window; that approximation is deliberate.--Each run ends by emitting the `experiment_timeseries_publish_runs` Prometheus counter (labels: `workflow_type`, `status`), skipped when the run computed nothing. `status="missing"` means the run computed metrics but published zero recalculation rows - the silent-failure mode where results exist yet never reach users. One `missing` run can be legitimate (every row already covered by another run or a manual recalculation), so the Grafana alert thresholds over a window instead of firing per run.+These workflows used to publish a `timeseries_sync` recalculation row per experiment as well.+The scheduled recalculation workflow owns that job now, so the publish pass is gated out behind+`experiment-drop-timeseries-publish-2026-10`.+An execution that started before that patch keeps the old publish path, so its replay still finds+the activities its history recorded.```text┌────────────────────────────────────────────────────────────────────────────┐@@ -90,9 +81,8 @@ The `ExperimentSavedMetricsWorkflow` follows the same structure but:### Scheduled recalculations-The timeseries sync row is assembled from that day's points, so its window is approximate and a-metric the daily run could not compute has no row at all. A separate workflow therefore starts a-real recalculation for each eligible experiment, on one hourly schedule+The workflows above write timeseries points, which the recalculation reader never sees on their own.+A separate workflow starts a real recalculation for each eligible experiment, on one hourly schedule(`products/experiments/backend/temporal/schedule.py`).That schedule fires at `:30`, after the timeseries runs earlier in the hour, and carries no input.@@ -110,8 +100,8 @@ can outlive its hour. This one starts other workflows and returns, so a single s`SKIP` overlap policy covers it.It skips an experiment whose recalculation is already running, or whose last one finished within-the hour. That freshness check ignores `timeseries_sync` rows: one is published 30 minutes before-every scheduled run, so counting it would skip every experiment forever.+the hour. That freshness check ignores `timeseries_sync` rows, which carry a timeseries run's+window rather than a full recalculation.The coordinator never waits for the runs it starts. Each run's outcome lands on its own`ExperimentMetricsRecalculation` row, and the `experiment scheduled recalculation started` anddiff --git a/posthog/temporal/experiments/test_per_experiment_publish.py b/posthog/temporal/experiments/test_per_experiment_publish.pyindex 9929c6461ecd..a01791549719 100644--- a/posthog/temporal/experiments/test_per_experiment_publish.py+++ b/posthog/temporal/experiments/test_per_experiment_publish.py@@ -1,180 +1,18 @@-import uuid-import asyncio-import pytestfrom unittest.mock import patch-import temporalio.worker-from temporalio import activity-from temporalio.exceptions import ApplicationError-from temporalio.testing import WorkflowEnvironment-from temporalio.worker import Worker--from posthog.temporal.experiments.models import (- ExperimentSavedMetricInput,- ExperimentSavedMetricResult,- ExperimentSavedMetricsWorkflowInputs,-)-from posthog.temporal.experiments.workflows import ExperimentSavedMetricsWorkflow, _record_publish_outcome--FAST_EXPERIMENT = 101-SLOW_EXPERIMENT = 102---async def _run_workflow(activities: list) -> dict:- task_queue = str(uuid.uuid4())- async with await WorkflowEnvironment.start_time_skipping() as env:- async with Worker(- env.client,- task_queue=task_queue,- workflows=[ExperimentSavedMetricsWorkflow],- activities=activities,- workflow_runner=temporalio.worker.UnsandboxedWorkflowRunner(),- ):- return await env.client.execute_workflow(- ExperimentSavedMetricsWorkflow.run,- ExperimentSavedMetricsWorkflowInputs(hour=2),- id=str(uuid.uuid4()),- task_queue=task_queue,- )---async def test_an_experiment_publishes_before_the_whole_batch_finishes():- """A slow experiment must not delay another experiment's publish. The slow experiment's metric only- completes after the fast experiment's publish activity ran, so a workflow that publishes behind a- whole-batch barrier fails this test (the fast publish then cannot run until the slow metric ends)."""- fast_published = asyncio.Event()- publish_calls: list[int] = []-- @activity.defn(name="get_experiment_saved_metrics_for_hour")- async def mock_discover(hour: int) -> list[ExperimentSavedMetricInput]:- return [- ExperimentSavedMetricInput(- experiment_id=FAST_EXPERIMENT, metric_uuid="m-fast", fingerprint="f1", team_id=1- ),- ExperimentSavedMetricInput(- experiment_id=SLOW_EXPERIMENT, metric_uuid="m-slow", fingerprint="f2", team_id=1- ),- ]-- @activity.defn(name="calculate_experiment_saved_metric")- async def mock_calculate(experiment_id: int, metric_uuid: str, fingerprint: str) -> ExperimentSavedMetricResult:- if experiment_id == SLOW_EXPERIMENT:- try:- await asyncio.wait_for(fast_published.wait(), timeout=15)- except TimeoutError:- raise ApplicationError("the fast experiment never published", non_retryable=True)- return ExperimentSavedMetricResult(- experiment_id=experiment_id, metric_uuid=metric_uuid, fingerprint=fingerprint, success=True- )-- @activity.defn(name="create_recalculation_from_timeseries")- async def mock_publish(experiment_id: int, team_id: int, run_started_at: str) -> str | None:- publish_calls.append(experiment_id)- if experiment_id == FAST_EXPERIMENT:- fast_published.set()- return f"recalc-{experiment_id}"-- with patch("temporalio.workflow.metric_meter") as mock_meter:- result = await _run_workflow([mock_discover, mock_calculate, mock_publish])-- assert publish_calls == [FAST_EXPERIMENT, SLOW_EXPERIMENT]- assert result == {"hour": 2, "total": 2, "succeeded": 2, "failed": 0, "recalculations_synced": 2}- # Asserted through the harness so the test fails if the workflow body stops calling the helper,- # which would silently kill the missing-publish alert.- mock_meter.return_value.with_additional_attributes.assert_called_once_with(- {"workflow_type": "experiment-saved-metrics-workflow", "status": "published"}- )---async def test_publish_does_not_wait_in_the_metric_semaphore_queue():- """Every metric task in the hour enqueues on the shared metric semaphore up front, and waiters are- served in order. A publish that waited in that queue would sit behind the whole remaining batch. Here- the batch saturates the ten metric slots and every slow metric only completes after the fast- experiment's publish, so a queued-behind-metrics publish deadlocks and fails via the timeout guard."""- fast_published = asyncio.Event()-- @activity.defn(name="get_experiment_saved_metrics_for_hour")- async def mock_discover(hour: int) -> list[ExperimentSavedMetricInput]:- slow = [- ExperimentSavedMetricInput(- experiment_id=SLOW_EXPERIMENT, metric_uuid=f"m-slow-{i}", fingerprint=f"s{i}", team_id=1- )- for i in range(14)- ]- return [- ExperimentSavedMetricInput(- experiment_id=FAST_EXPERIMENT, metric_uuid="m-fast", fingerprint="f1", team_id=1- ),- *slow,- ]-- @activity.defn(name="calculate_experiment_saved_metric")- async def mock_calculate(experiment_id: int, metric_uuid: str, fingerprint: str) -> ExperimentSavedMetricResult:- if experiment_id == SLOW_EXPERIMENT:- try:- await asyncio.wait_for(fast_published.wait(), timeout=15)- except TimeoutError:- raise ApplicationError("the fast experiment never published", non_retryable=True)- return ExperimentSavedMetricResult(- experiment_id=experiment_id, metric_uuid=metric_uuid, fingerprint=fingerprint, success=True- )-- @activity.defn(name="create_recalculation_from_timeseries")- async def mock_publish(experiment_id: int, team_id: int, run_started_at: str) -> str | None:- if experiment_id == FAST_EXPERIMENT:- fast_published.set()- return f"recalc-{experiment_id}"-- result = await _run_workflow([mock_discover, mock_calculate, mock_publish])-- assert result == {"hour": 2, "total": 15, "succeeded": 15, "failed": 0, "recalculations_synced": 2}---async def test_a_failed_publish_skips_only_its_own_experiment():- """One experiment's publish failing after its retries must not fail the workflow or block the other- experiments' publishes, or a single bad row would lose the whole hour's freshness."""-- @activity.defn(name="get_experiment_saved_metrics_for_hour")- async def mock_discover(hour: int) -> list[ExperimentSavedMetricInput]:- return [- ExperimentSavedMetricInput(- experiment_id=FAST_EXPERIMENT, metric_uuid="m-fast", fingerprint="f1", team_id=1- ),- ExperimentSavedMetricInput(- experiment_id=SLOW_EXPERIMENT, metric_uuid="m-slow", fingerprint="f2", team_id=1- ),- ]-- @activity.defn(name="calculate_experiment_saved_metric")- async def mock_calculate(experiment_id: int, metric_uuid: str, fingerprint: str) -> ExperimentSavedMetricResult:- return ExperimentSavedMetricResult(- experiment_id=experiment_id, metric_uuid=metric_uuid, fingerprint=fingerprint, success=True- )-- @activity.defn(name="create_recalculation_from_timeseries")- async def mock_publish(experiment_id: int, team_id: int, run_started_at: str) -> str | None:- if experiment_id == FAST_EXPERIMENT:- raise ApplicationError("publish rejected", non_retryable=True)- return f"recalc-{experiment_id}"-- result = await _run_workflow([mock_discover, mock_calculate, mock_publish])-- assert result == {"hour": 2, "total": 2, "succeeded": 2, "failed": 0, "recalculations_synced": 1}+from posthog.temporal.experiments.workflows import _record_publish_outcome@pytest.mark.parametrize("succeeded,recalculations_synced,expected_status",[(2, 2, "published"), (2, 0, "missing"), (0, 0, None)],)-def test_publish_outcome_counter_feeds_the_missing_publish_alert(+def test_publish_outcome_counter_separates_published_from_missing(succeeded: int, recalculations_synced: int, expected_status: str | None) -> None:- """The "missing" emission is the alert signal for runs that compute results users never see. A flipped- condition kills the alert; emitting on runs that computed nothing floods it with false positives."""+ """The "missing" emission marks a run that computed results users never see. A flipped condition+ loses that signal; emitting on runs that computed nothing fills it with false positives."""with (patch("temporalio.workflow.metric_meter") as mock_meter,patch("temporalio.workflow.info") as mock_info,diff --git a/posthog/temporal/experiments/workflows.py b/posthog/temporal/experiments/workflows.pyindex a12b82081157..f2ed9713972f 100644--- a/posthog/temporal/experiments/workflows.py+++ b/posthog/temporal/experiments/workflows.py@@ -1,5 +1,7 @@import asyncio+from collections.abc import Callable, Sequencefrom datetime import datetime, timedelta+from typing import Anyimport temporalio.workflowfrom temporalio.common import RetryPolicy@@ -18,21 +20,32 @@ with temporalio.workflow.unsafe.imports_passed_through():)from posthog.temporal.experiments.models import (TIMESERIES_METRIC_MAX_ATTEMPTS,+ ExperimentRegularMetricInput,+ ExperimentRegularMetricResult,ExperimentRegularMetricsWorkflowInputs,+ ExperimentSavedMetricInput,+ ExperimentSavedMetricResult,ExperimentSavedMetricsWorkflowInputs,ExperimentTimeseriesRecalculationWorkflowInputs,)MAX_CONCURRENT_METRICS = 10+# One helper serves both workflows, so its metric type is whichever pair the caller passes.+type MetricInput = ExperimentRegularMetricInput | ExperimentSavedMetricInput+type MetricResult = ExperimentRegularMetricResult | ExperimentSavedMetricResult+def _record_publish_outcome(succeeded: int, recalculations_synced: int) -> None:- """Per-run counter behind the missing-publish alert: a run that computed metrics but published zero- recalculation rows is the silent-failure mode where results exist yet never reach users.+ """Per-run publish counter for the executions that still publish.++ A run that computed metrics but published zero recalculation rows is the silent-failure mode+ where results exist yet never reach users. Only the legacy branches call this, so the counter+ keeps that meaning: on the calculate-only path nothing publishes by design, and emitting there+ would report every healthy run as missing.- A single "missing" run can be legitimate (every row already covered by another run or a manual- recalculation), so the threshold lives in the Grafana alert rule, not here. `workflow.metric_meter()`- skips emission during replay, so no patch gate is needed."""+ `workflow.metric_meter()` skips emission during replay, so no patch gate is needed.+ """if succeeded == 0:returnstatus = "published" if recalculations_synced > 0 else "missing"@@ -133,6 +146,29 @@ async def _calculate_and_publish_per_experiment(return results, published+async def _calculate_metrics(+ calculate_activity: Callable[..., Any],+ experiment_metrics: Sequence[MetricInput],+ semaphore: asyncio.Semaphore,+) -> list[MetricResult | BaseException]:+ """Run one activity per metric, bounded by the shared concurrency limit."""++ async def _run_metric(em: MetricInput) -> MetricResult:+ async with semaphore:+ return await temporalio.workflow.execute_activity(+ calculate_activity,+ args=[em.experiment_id, em.metric_uuid, em.fingerprint],+ start_to_close_timeout=timedelta(minutes=15),+ retry_policy=RetryPolicy(+ maximum_attempts=TIMESERIES_METRIC_MAX_ATTEMPTS,+ initial_interval=timedelta(seconds=10),+ maximum_interval=timedelta(seconds=60),+ ),+ )++ return await asyncio.gather(*[_run_metric(em) for em in experiment_metrics], return_exceptions=True)++@temporalio.workflow.defn(name="experiment-regular-metrics-workflow")class ExperimentRegularMetricsWorkflow(PostHogWorkflow):"""@@ -140,8 +176,7 @@ class ExperimentRegularMetricsWorkflow(PostHogWorkflow):Runs daily per hour (24 schedules total). Each run:1. Discovers experiment-metrics for teams scheduled at this hour- 2. Per experiment: calculates its metrics in parallel (one activity per metric, shared concurrency- limit), then assembles its completed metrics recalculation from this run's points+ 2. Calculates those metrics in parallel (one activity per metric, shared concurrency limit)3. Returns summary of successes/failures"""@@ -151,8 +186,6 @@ class ExperimentRegularMetricsWorkflow(PostHogWorkflow):@temporalio.workflow.runasync def run(self, inputs: ExperimentRegularMetricsWorkflowInputs) -> dict:- run_started_at = temporalio.workflow.now()-# Step 1: Discover experiment-metrics for this hourexperiment_metrics = await temporalio.workflow.execute_activity(get_experiment_regular_metrics_for_hour,@@ -167,39 +200,27 @@ class ExperimentRegularMetricsWorkflow(PostHogWorkflow):"total": 0,"succeeded": 0,"failed": 0,- "recalculations_synced": 0,}- # Step 2: Per experiment, calculate its metrics and publish its recalculation as soon as they- # finish, so a team's results land minutes after its own experiments compute instead of hours- # after the whole batch. The patch gates keep replay of older histories deterministic.+ # Step 2: Calculate every metric, bounded by one shared concurrency limit.semaphore = asyncio.Semaphore(MAX_CONCURRENT_METRICS)+ run_started_at = temporalio.workflow.now()- if temporalio.workflow.patched("experiment-per-experiment-publish-2026-09"):- results, recalculations_synced = await _calculate_and_publish_per_experiment(+ # Only an execution carrying this marker skips the publish activities. A history without it+ # replays the commands it recorded, so the branches below must stay until no such execution+ # is left. These workflows set no execution timeout, so nothing bounds that wait.+ published: int | None = None+ if temporalio.workflow.patched("experiment-drop-timeseries-publish-2026-10"):+ results = await _calculate_metrics(calculate_experiment_regular_metric, experiment_metrics, semaphore)+ elif temporalio.workflow.patched("experiment-per-experiment-publish-2026-09"):+ results, published = await _calculate_and_publish_per_experiment(calculate_experiment_regular_metric, experiment_metrics, run_started_at, semaphore)else:-- async def _run_metric(em):- async with semaphore:- return await temporalio.workflow.execute_activity(- calculate_experiment_regular_metric,- args=[em.experiment_id, em.metric_uuid, em.fingerprint],- start_to_close_timeout=timedelta(minutes=15),- retry_policy=RetryPolicy(- maximum_attempts=TIMESERIES_METRIC_MAX_ATTEMPTS,- initial_interval=timedelta(seconds=10),- maximum_interval=timedelta(seconds=60),- ),- )-- tasks = [_run_metric(em) for em in experiment_metrics]- results = await asyncio.gather(*tasks, return_exceptions=True)-- recalculations_synced = 0+ results = await _calculate_metrics(calculate_experiment_regular_metric, experiment_metrics, semaphore)+ published = 0if temporalio.workflow.patched("experiment-timeseries-recalculation-sync-2026-09"):- recalculations_synced = await _create_recalculations_from_timeseries(+ published = await _create_recalculations_from_timeseries({(em.experiment_id, em.team_id) for em in experiment_metrics if em.team_id is not None},run_started_at,semaphore,@@ -217,14 +238,14 @@ class ExperimentRegularMetricsWorkflow(PostHogWorkflow):else:failed += 1- _record_publish_outcome(succeeded, recalculations_synced)+ if published is not None:+ _record_publish_outcome(succeeded, published)return {"hour": inputs.hour,"total": len(experiment_metrics),"succeeded": succeeded,"failed": failed,- "recalculations_synced": recalculations_synced,}@@ -235,8 +256,7 @@ class ExperimentSavedMetricsWorkflow(PostHogWorkflow):Runs daily per hour (24 schedules total). Each run:1. Discovers experiment-saved metrics for teams scheduled at this hour- 2. Per experiment: calculates its metrics in parallel (one activity per metric, shared concurrency- limit), then assembles its completed metrics recalculation from this run's points+ 2. Calculates those metrics in parallel (one activity per metric, shared concurrency limit)3. Returns summary of successes/failures"""@@ -246,8 +266,6 @@ class ExperimentSavedMetricsWorkflow(PostHogWorkflow):@temporalio.workflow.runasync def run(self, inputs: ExperimentSavedMetricsWorkflowInputs) -> dict:- run_started_at = temporalio.workflow.now()-# Step 1: Discover experiment-saved metrics for this hourexperiment_metrics = await temporalio.workflow.execute_activity(get_experiment_saved_metrics_for_hour,@@ -262,39 +280,27 @@ class ExperimentSavedMetricsWorkflow(PostHogWorkflow):"total": 0,"succeeded": 0,"failed": 0,- "recalculations_synced": 0,}- # Step 2: Per experiment, calculate its metrics and publish its recalculation as soon as they- # finish, so a team's results land minutes after its own experiments compute instead of hours- # after the whole batch. The patch gates keep replay of older histories deterministic.+ # Step 2: Calculate every metric, bounded by one shared concurrency limit.semaphore = asyncio.Semaphore(MAX_CONCURRENT_METRICS)+ run_started_at = temporalio.workflow.now()- if temporalio.workflow.patched("experiment-per-experiment-publish-2026-09"):- results, recalculations_synced = await _calculate_and_publish_per_experiment(+ # Only an execution carrying this marker skips the publish activities. A history without it+ # replays the commands it recorded, so the branches below must stay until no such execution+ # is left. These workflows set no execution timeout, so nothing bounds that wait.+ published: int | None = None+ if temporalio.workflow.patched("experiment-drop-timeseries-publish-2026-10"):+ results = await _calculate_metrics(calculate_experiment_saved_metric, experiment_metrics, semaphore)+ elif temporalio.workflow.patched("experiment-per-experiment-publish-2026-09"):+ results, published = await _calculate_and_publish_per_experiment(calculate_experiment_saved_metric, experiment_metrics, run_started_at, semaphore)else:-- async def _run_metric(em):- async with semaphore:- return await temporalio.workflow.execute_activity(- calculate_experiment_saved_metric,- args=[em.experiment_id, em.metric_uuid, em.fingerprint],- start_to_close_timeout=timedelta(minutes=15),- retry_policy=RetryPolicy(- maximum_attempts=TIMESERIES_METRIC_MAX_ATTEMPTS,- initial_interval=timedelta(seconds=10),- maximum_interval=timedelta(seconds=60),- ),- )-- tasks = [_run_metric(em) for em in experiment_metrics]- results = await asyncio.gather(*tasks, return_exceptions=True)-- recalculations_synced = 0+ results = await _calculate_metrics(calculate_experiment_saved_metric, experiment_metrics, semaphore)+ published = 0if temporalio.workflow.patched("experiment-timeseries-recalculation-sync-2026-09"):- recalculations_synced = await _create_recalculations_from_timeseries(+ published = await _create_recalculations_from_timeseries({(em.experiment_id, em.team_id) for em in experiment_metrics if em.team_id is not None},run_started_at,semaphore,@@ -312,14 +318,14 @@ class ExperimentSavedMetricsWorkflow(PostHogWorkflow):else:failed += 1- _record_publish_outcome(succeeded, recalculations_synced)+ if published is not None:+ _record_publish_outcome(succeeded, published)return {"hour": inputs.hour,"total": len(experiment_metrics),"succeeded": succeeded,"failed": failed,- "recalculations_synced": recalculations_synced,}