: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): bump recalculation max age to 60 days (#59871)
Juraj Majerik73393474df48
diff --git a/frontend/src/scenes/experiments/MetricsView/new/TimeseriesModal.tsx b/frontend/src/scenes/experiments/MetricsView/new/TimeseriesModal.tsxindex 8133d4feca6b..3a1e81594218 100644--- a/frontend/src/scenes/experiments/MetricsView/new/TimeseriesModal.tsx+++ b/frontend/src/scenes/experiments/MetricsView/new/TimeseriesModal.tsx@@ -12,6 +12,7 @@ import { urls } from 'scenes/urls'import { ExperimentMetric, isExperimentRatioMetric } from '~/queries/schema/schema-general'import type { Experiment } from '~/types'+import { EXPERIMENT_RECALCULATION_MAX_AGE_DAYS } from '../../constants'import { hasEnded, isLaunched } from '../../experimentsLogic'import { experimentTimeseriesLogic } from '../../experimentTimeseriesLogic'import { VariantTag } from '../../ExperimentView/VariantTag'@@ -46,7 +47,7 @@ export function TimeseriesModal({const isStaleExperiment =isLaunched(experiment) && !hasEnded(experiment)- ? dayjs(experiment.start_date).isBefore(dayjs().subtract(30, 'days'))+ ? dayjs(experiment.start_date).isBefore(dayjs().subtract(EXPERIMENT_RECALCULATION_MAX_AGE_DAYS, 'days')): falseconst handleRecalculate = (): void => {@@ -114,9 +115,9 @@ export function TimeseriesModal({<div className="flex items-center justify-between"><div className="flex-1"><div className="text-sm">- This experiment has been running for more than 30 days. Automatic- timeseries updates are disabled. You can still manually recalculate the- data.+ This experiment has been running for more than{' '}+ {EXPERIMENT_RECALCULATION_MAX_AGE_DAYS} days. Automatic timeseries+ updates are disabled. You can still manually recalculate the data.</div></div><LemonButtondiff --git a/frontend/src/scenes/experiments/constants.ts b/frontend/src/scenes/experiments/constants.tsindex ec66d2c1a0ce..6a6efe3f092b 100644--- a/frontend/src/scenes/experiments/constants.ts+++ b/frontend/src/scenes/experiments/constants.ts@@ -50,6 +50,9 @@ export const DEFAULT_MDE = 30export const EXPERIMENT_MIN_REFRESH_INTERVAL_MINUTES = 5export const EXPERIMENT_AUTO_REFRESH_INITIAL_INTERVAL_SECONDS = 1800 // 30 min+// Mirrors EXPERIMENT_RECALCULATION_MAX_AGE_DAYS in posthog/temporal/experiments/activities.py+export const EXPERIMENT_RECALCULATION_MAX_AGE_DAYS = 60+export const CONCLUSION_DISPLAY_CONFIG: Record<ExperimentConclusion,{ title: string; description: string; color: string }diff --git a/posthog/temporal/experiments/activities.py b/posthog/temporal/experiments/activities.pyindex ed8768abfbb6..4f1defc5f9e4 100644--- a/posthog/temporal/experiments/activities.py+++ b/posthog/temporal/experiments/activities.py@@ -37,6 +37,8 @@ from products.experiments.stats.shared.statistics import StatisticErrorlogger = structlog.get_logger(__name__)+EXPERIMENT_RECALCULATION_MAX_AGE_DAYS = 60+@database_sync_to_asyncdef _get_experiment_regular_metrics_for_hour_sync(hour: int) -> list[ExperimentRegularMetricInput]:@@ -59,7 +61,7 @@ def _get_experiment_regular_metrics_for_hour_sync(hour: int) -> list[ExperimentRtime_filter,deleted=False,status=Experiment.Status.RUNNING,- start_date__gte=datetime.now(ZoneInfo("UTC")) - timedelta(days=30),+ start_date__gte=datetime.now(ZoneInfo("UTC")) - timedelta(days=EXPERIMENT_RECALCULATION_MAX_AGE_DAYS),).exclude(Q(metrics__isnull=True) | Q(metrics=[]),Q(metrics_secondary__isnull=True) | Q(metrics_secondary=[]),@@ -310,7 +312,7 @@ def _get_experiment_saved_metrics_for_hour_sync(hour: int) -> list[ExperimentSavtime_filter,deleted=False,status=Experiment.Status.RUNNING,- start_date__gte=datetime.now(ZoneInfo("UTC")) - timedelta(days=30),+ start_date__gte=datetime.now(ZoneInfo("UTC")) - timedelta(days=EXPERIMENT_RECALCULATION_MAX_AGE_DAYS),).prefetch_related("experimenttosavedmetric_set__saved_metric")for experiment in experiments: