: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(alerts): clear platform alert history before each lifecycle test (#110376)
Jimmy Zhu0c67a594b6a1
diff --git a/products/alerts/backend/test/test_platform_lifecycle.py b/products/alerts/backend/test/test_platform_lifecycle.pyindex dd2595b7fe5e..bc5a41c21819 100644--- a/products/alerts/backend/test/test_platform_lifecycle.py+++ b/products/alerts/backend/test/test_platform_lifecycle.py@@ -16,11 +16,17 @@ from products.alerts.backend.facade.contracts import ()from products.alerts.backend.facade.platform_alerts import due_checks, record_outcomes, upsert_configurationfrom products.alerts.backend.models import PlatformAlert, PlatformAlertConfiguration+from products.alerts.backend.models.platform_alert_events_sql import SHARDED_PLATFORM_ALERT_EVENTS_TABLEclass TestPlatformAlertLifecycle(ClickhouseTestMixin, APIBaseTest):def setUp(self) -> None:super().setUp()+ # History rows outlive the run that wrote them, while Postgres reissues the same team ids,+ # so a test reads another run's checks unless the table starts empty. The sharded table,+ # because a truncate of the distributed one in front of it reports success and clears+ # nothing.+ sync_execute(f"TRUNCATE TABLE IF EXISTS {SHARDED_PLATFORM_ALERT_EVENTS_TABLE}")self.cutoff = datetime(2026, 9, 16, 10, tzinfo=UTC)with team_scope(self.team.id):self.configuration = PlatformAlertConfiguration.objects.create(