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.

refactor(experiments): register experiments in the unfiled file registry (#125418)

Andersd3dfc10e7141
diff --git a/posthog/models/file_system/unfiled_file_saver.py b/posthog/models/file_system/unfiled_file_saver.py
index 46df02bfde2a..82fb925c7465 100644
--- a/posthog/models/file_system/unfiled_file_saver.py
+++ b/posthog/models/file_system/unfiled_file_saver.py
@@ -16,7 +16,6 @@ from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.cohorts.backend.models.cohort import Cohort
from products.dashboards.backend.models.dashboard import Dashboard
from products.early_access_features.backend.models import EarlyAccessFeature
-from products.experiments.backend.models.experiment import Experiment
from products.feature_flags.backend.models.feature_flag import FeatureFlag
from products.notebooks.backend.models import Notebook
from products.product_analytics.backend.facade.models import Insight
@@ -25,7 +24,6 @@ from products.surveys.backend.models import Survey
MIXIN_MODELS: dict[str, type[FileSystemSyncMixin]] = {
"action": Action,
"feature_flag": FeatureFlag,
- "experiment": Experiment,
"insight": Insight,
"dashboard": Dashboard,
"notebook": Notebook,
diff --git a/products/experiments/backend/apps.py b/products/experiments/backend/apps.py
index 1f2f9b86d049..8ac6bc163d1e 100644
--- a/products/experiments/backend/apps.py
+++ b/products/experiments/backend/apps.py
@@ -8,4 +8,9 @@ class ExperimentsConfig(AppConfig):
def ready(self) -> None:
# Registers activity signal receivers after the app registry is ready.
+ from posthog.models.file_system.unfiled_file_saver import register_mixin_model # noqa: PLC0415
+
import products.experiments.backend.activity_logging # noqa: F401, PLC0415
+ from products.experiments.backend.models.experiment import Experiment # noqa: PLC0415
+
+ register_mixin_model("experiment", Experiment)