: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
feat(alerts): record which stack owns an insight alert (#119956)
Jimmy Zhuea4757c43707
diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambrindex d77990059f30..e31555d3c202 100644--- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr+++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr@@ -1550,6 +1550,8 @@"posthog_alertconfiguration"."investigation_agent_enabled","posthog_alertconfiguration"."investigation_gates_notifications","posthog_alertconfiguration"."investigation_inconclusive_action",+ "posthog_alertconfiguration"."owner",+ "posthog_alertconfiguration"."owner_changed_at","posthog_user"."id","posthog_user"."password","posthog_user"."last_login",@@ -3760,6 +3762,8 @@"posthog_alertconfiguration"."investigation_agent_enabled","posthog_alertconfiguration"."investigation_gates_notifications","posthog_alertconfiguration"."investigation_inconclusive_action",+ "posthog_alertconfiguration"."owner",+ "posthog_alertconfiguration"."owner_changed_at","posthog_user"."id","posthog_user"."password","posthog_user"."last_login",@@ -7673,6 +7677,8 @@"posthog_alertconfiguration"."investigation_agent_enabled","posthog_alertconfiguration"."investigation_gates_notifications","posthog_alertconfiguration"."investigation_inconclusive_action",+ "posthog_alertconfiguration"."owner",+ "posthog_alertconfiguration"."owner_changed_at","posthog_user"."id","posthog_user"."password","posthog_user"."last_login",diff --git a/products/alerts/backend/migrations/0013_alertconfiguration_owner.py b/products/alerts/backend/migrations/0013_alertconfiguration_owner.pynew file mode 100644index 000000000000..55a1e2c4dc72--- /dev/null+++ b/products/alerts/backend/migrations/0013_alertconfiguration_owner.py@@ -0,0 +1,27 @@+# Generated by Django 5.2.18 on 2026-10-19 23:52++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("alerts", "0012_move_platform_models_to_alerts_platform"),+ ]++ operations = [+ migrations.AddField(+ model_name="alertconfiguration",+ name="owner",+ field=models.CharField(+ choices=[("source", "Source"), ("platform", "Platform")],+ db_default="source",+ default="source",+ max_length=16,+ ),+ ),+ migrations.AddField(+ model_name="alertconfiguration",+ name="owner_changed_at",+ field=models.DateTimeField(blank=True, null=True),+ ),+ ]diff --git a/products/alerts/backend/migrations/max_migration.txt b/products/alerts/backend/migrations/max_migration.txtindex 3c74d15f3f74..923cc25a9a25 100644--- a/products/alerts/backend/migrations/max_migration.txt+++ b/products/alerts/backend/migrations/max_migration.txt@@ -1 +1 @@-0012_move_platform_models_to_alerts_platform+0013_alertconfiguration_ownerdiff --git a/products/alerts/backend/models/alert.py b/products/alerts/backend/models/alert.pyindex c55492b4c845..a9ec7fa6b1f0 100644--- a/products/alerts/backend/models/alert.py+++ b/products/alerts/backend/models/alert.py@@ -18,6 +18,8 @@ from posthog.models.activity_logging.model_activity import ModelActivityMixinfrom posthog.models.utils import CreatedMetaFields, UUIDTModelfrom posthog.schema_enums import AlertCalculationInterval, AlertState+from products.alerts_platform.backend.facade.enums import PlatformAlertOwner+ALERT_STATE_CHOICES = [(AlertState.FIRING, AlertState.FIRING),(AlertState.NOT_FIRING, AlertState.NOT_FIRING),@@ -199,6 +201,17 @@ class AlertConfiguration(ModelActivityMixin, CreatedMetaFields, UUIDTModel):default="notify",)+ # Which stack evaluates and delivers this alert. The platform's copy records the same owner,+ # and only the cutover and rollback commands write the two. After a cutover the insight stack+ # keeps evaluating the alert for a shadow window from `owner_changed_at`, and sends nothing.+ owner = models.CharField(+ max_length=16,+ choices=PlatformAlertOwner.choices,+ default=PlatformAlertOwner.SOURCE.value,+ db_default=PlatformAlertOwner.SOURCE.value,+ )+ owner_changed_at = models.DateTimeField(null=True, blank=True)+class Meta:db_table = "posthog_alertconfiguration"