: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(growth): emit first team production event ingested (#61489)
Fernando Gomes46a874473f1b
diff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambrindex e945974b9353..5bf8f737e062 100644--- a/posthog/api/test/__snapshots__/test_element.ambr+++ b/posthog/api/test/__snapshots__/test_element.ambr@@ -105,6 +105,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/posthog/api/test/__snapshots__/test_preflight.ambr b/posthog/api/test/__snapshots__/test_preflight.ambrindex 77f46107c630..abdb4cd65f7f 100644--- a/posthog/api/test/__snapshots__/test_preflight.ambr+++ b/posthog/api/test/__snapshots__/test_preflight.ambr@@ -105,6 +105,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambrindex d58d0687f4d7..65bc09298990 100644--- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr+++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr@@ -118,6 +118,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -250,6 +251,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -386,6 +388,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -493,6 +496,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -662,6 +666,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -769,6 +774,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -869,6 +875,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1093,6 +1100,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1200,6 +1208,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1407,6 +1416,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1733,6 +1743,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2253,6 +2264,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2710,6 +2722,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2953,6 +2966,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3532,6 +3546,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3846,6 +3861,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3982,6 +3998,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4089,6 +4106,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4258,6 +4276,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4365,6 +4384,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4553,6 +4573,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4689,6 +4710,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4796,6 +4818,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4975,6 +4998,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -5145,6 +5169,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -5471,6 +5496,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6131,6 +6157,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6350,6 +6377,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6489,6 +6517,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6596,6 +6625,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6784,6 +6814,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6891,6 +6922,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7070,6 +7102,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7265,6 +7298,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7540,6 +7574,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7930,6 +7965,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8074,6 +8110,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8210,6 +8247,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8317,6 +8355,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8486,6 +8525,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8593,6 +8633,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8800,6 +8841,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8907,6 +8949,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9086,6 +9129,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9256,6 +9300,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9538,6 +9583,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9936,6 +9982,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10068,6 +10115,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10204,6 +10252,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10311,6 +10360,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10480,6 +10530,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10603,6 +10654,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10791,6 +10843,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10898,6 +10951,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11077,6 +11131,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11277,6 +11332,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11598,6 +11654,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11873,6 +11930,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -12355,6 +12413,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -12758,6 +12817,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -12993,6 +13053,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -13210,6 +13271,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -13782,6 +13844,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -13951,6 +14014,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -14347,6 +14411,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -14609,6 +14674,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -15055,6 +15121,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -15510,6 +15577,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -15642,6 +15710,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -15778,6 +15847,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -15885,6 +15955,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16103,6 +16174,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16210,6 +16282,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16398,6 +16471,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16505,6 +16579,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16642,6 +16717,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16749,6 +16825,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -16950,6 +17027,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -17057,6 +17135,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -17236,6 +17315,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -17406,6 +17486,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -17689,6 +17770,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -18084,6 +18166,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -18216,6 +18299,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -18352,6 +18436,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -18459,6 +18544,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -18785,6 +18871,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -19121,6 +19208,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -19338,6 +19426,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -19736,6 +19825,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -20144,6 +20234,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -20406,6 +20497,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -20719,6 +20811,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -20942,6 +21035,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -21338,6 +21432,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -21600,6 +21695,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -22046,6 +22142,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambrindex dca15ac1ef0a..0c73004b1ade 100644--- a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr+++ b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr@@ -147,6 +147,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -459,6 +460,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -696,6 +698,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -803,6 +806,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1203,6 +1207,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/posthog/clickhouse/query_tagging.py b/posthog/clickhouse/query_tagging.pyindex 97a49d4597e4..782116e9a626 100644--- a/posthog/clickhouse/query_tagging.py+++ b/posthog/clickhouse/query_tagging.py@@ -56,6 +56,7 @@ class Product(StrEnum):EXPERIMENTS = "experiments"FEATURE_FLAGS = "feature_flags"GROUP_ANALYTICS = "group_analytics"+ GROWTH = "growth" # growth-team activation/lifecycle jobs (e.g. production-event detection)INGESTION = "ingestion"LLM_ANALYTICS = "llm_analytics"LOGS = "logs"diff --git a/posthog/dags/locations/growth.py b/posthog/dags/locations/growth.pyindex b1f638946891..9605fe18d8bc 100644--- a/posthog/dags/locations/growth.py+++ b/posthog/dags/locations/growth.py@@ -1,6 +1,6 @@import dagster-from products.growth.dags import github_sdk_versions, oauth, user_product_list+from products.growth.dags import github_sdk_versions, oauth, team_production_event_activation, user_product_listfrom . import loggers, resources@@ -11,12 +11,14 @@ defs = dagster.Definitions(user_product_list.populate_user_product_list_job,user_product_list.sync_colleagues_products_monthly_job,user_product_list.sync_cross_sell_products_monthly_job,+ team_production_event_activation.detect_first_team_production_event_job,],schedules=[oauth.oauth_clear_expired_oauth_tokens_schedule,github_sdk_versions.cache_github_sdk_versions_schedule,user_product_list.sync_colleagues_products_monthly_schedule,user_product_list.sync_cross_sell_products_monthly_schedule,+ team_production_event_activation.detect_first_team_production_event_schedule,],loggers=loggers,resources=resources,diff --git a/posthog/migrations/1218_team_ingested_production_event_last_checked_at.py b/posthog/migrations/1218_team_ingested_production_event_last_checked_at.pynew file mode 100644index 000000000000..b711dd14e6d5--- /dev/null+++ b/posthog/migrations/1218_team_ingested_production_event_last_checked_at.py@@ -0,0 +1,15 @@+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("posthog", "1217_project_is_pending_deletion"),+ ]++ operations = [+ migrations.AddField(+ model_name="team",+ name="ingested_production_event_last_checked_at",+ field=models.DateTimeField(blank=True, null=True),+ ),+ ]diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txtindex 44335a24d758..37b9594a4d43 100644--- a/posthog/migrations/max_migration.txt+++ b/posthog/migrations/max_migration.txt@@ -1 +1 @@-1217_project_is_pending_deletion+1218_team_ingested_production_event_last_checked_atdiff --git a/posthog/models/team/production_event_activation.py b/posthog/models/team/production_event_activation.pynew file mode 100644index 000000000000..6661216430ab--- /dev/null+++ b/posthog/models/team/production_event_activation.py@@ -0,0 +1,447 @@+"""+Detection of whether a team has begun ingesting real production traffic.++This is the activation milestone behind `Team.ingested_production_event`. The+file is split into two layers so the heuristic can be retuned without+touching the rest of the system:++ 1. CRITERION — `_teams_meeting_criterion(team_ids)` is the single source+ of truth for what counts as "production traffic". The+ contract is intentionally narrow: `Iterable[team_id] ->+ dict[team_id, ProductionTrafficSignal]`. The implementation+ is free to change.++ 2. TRANSITION — `_mark_teams_ingested_production_event(signals, now)` is+ the only code that marks the column and emits the+ `first team production event ingested` analytics event.+ Idempotent under concurrent runs via `SELECT FOR UPDATE+ SKIP LOCKED`.++Scheduling lives in `products/growth/dags/team_production_event_activation.py`,+which wires these helpers into a Dagster job + daily schedule.++A team qualifies on the strongest available signal for its SDK class, checked+in this order within the window:++ - WEB: at least one event whose origin host (`$host`, falling back to the+ host of `$current_url`) is a real public host — see+ `is_production_host`. `$ip`/GeoIP can't be used instead: a+ developer's local backend still reaches us over the public+ internet from a public IP.+ - MOBILE: enough distinct physical devices (`$device_id`) on events that+ affirm `$is_emulator: false`. A single non-emulator event is *not*+ production evidence — a developer testing on their own phone looks+ identical — but several distinct physical devices means the app+ shipped to real hands. Events without a `$device_id` fail closed:+ distinct_ids churn under login/logout/reinstall, so they can't+ stand in for devices.+ - SERVER: enough distinct users on events from server-side SDKs. There is no+ environment signal at all in backend events, so this is a pure+ diversity proxy and intentionally has the highest bar.++Detection is fail-closed: each leg requires its positive signal, and anything+local/private/reserved/ambiguous does not qualify. A false positive silently+corrupts the activation metric and is hard to detect; a false negative is+recoverable while the team keeps sending production traffic — the sweep+re-checks unflagged teams. One segment is permanently invisible by design:+teams whose only traffic is posthog-js from non-public origins (Electron /+Capacitor wrapper apps report localhost-style hosts; intranet or VPN-only+deployments report private ones) can never satisfy any leg.+"""++from collections.abc import Iterable, Mapping+from dataclasses import dataclass+from datetime import datetime, timedelta+from ipaddress import IPv4Address, IPv6Address, ip_address+from typing import Final, Literal++from django.db import transaction++import structlog++from posthog.clickhouse.client import sync_execute+from posthog.clickhouse.client.connection import Workload+from posthog.clickhouse.query_tagging import Feature, Product, tags_context+from posthog.cloud_utils import is_cloud+from posthog.event_usage import groups+from posthog.exceptions_capture import capture_exception+from posthog.models.property.util import get_property_string_expr+from posthog.models.team.team import Team+from posthog.ph_client import ph_scoped_capture++logger = structlog.get_logger(__name__)++# --- Heuristic parameters ---------------------------------------------------+# Tune these to recalibrate the metric.++WINDOW_DAYS: Final[int] = 30+SWEEP_BATCH_SIZE: Final[int] = 5_000++# How long after an evaluation a still-unflagged team is left alone before the+# sweep re-checks it. Production events stay detectable for WINDOW_DAYS, so a+# backoff well below the window cannot miss a team that keeps sending traffic —+# it only defers detection by at most the backoff. This is what keeps both the+# ClickHouse scan volume and the `posthog_team` write churn bounded as the+# population of never-qualifying teams grows.+RECHECK_BACKOFF: Final[timedelta] = timedelta(days=7)++# Cap on distinct hosts fetched per team, bounding result size and aggregation+# state when a team emits pathological host cardinality. Retention under the+# cap is NOT a random resample: a production host crowded out by >1k distinct+# noise hosts can stay crowded out on later runs too. The SQL prefilter on the+# dominant dev noise (localhost/loopback, which also covers port-churn) is what+# keeps real production hosts inside the cap in practice.+HOSTS_PER_TEAM_CAP: Final[int] = 1_000++# Hostnames are capped at 253 characters by RFC 1035; anything longer is+# crafted input and fails closed. The SQL-side substring cap (256) bounds+# aggregation memory against unbounded user-controlled `$host` values.+MAX_HOSTNAME_LENGTH: Final[int] = 253+SQL_HOST_LENGTH_CAP: Final[int] = 256++# MOBILE: distinct physical devices (`$device_id`) on `$is_emulator: false`+# events. One developer owns one or two test phones; this many distinct real+# devices means the app shipped. Device IDs are required (no distinct_id+# fallback) because anonymous distinct_ids churn under one developer's+# login/logout/reinstall cycles.+MOBILE_PHYSICAL_DEVICES_THRESHOLD: Final[int] = 3++# SERVER: distinct users on events from server-side SDKs. Backend events carry+# no environment signal whatsoever, so this is a diversity proxy: a production+# backend serves many distinct users, a developer's test run uses a handful of+# fixture IDs. Deliberately the highest bar of the three legs — a seeded dev+# database can fabricate distinct IDs cheaply.+SERVER_LIB_USERS_THRESHOLD: Final[int] = 10++# `$lib` values treated as server-side evidence. Deliberately a positive+# allowlist (not "anything without a host") so that web traffic with stripped+# properties or e2e suites hammering localhost with fresh anonymous IDs can't+# drift into this leg.+SERVER_SIDE_LIBS: Final[tuple[str, ...]] = (+ "posthog-python",+ "posthog-node",+ "posthog-php",+ "posthog-ruby",+ "posthog-go",+ "posthog-java",+ "posthog-dotnet",+ "posthog-elixir",+ "posthog-rs",+)+++@dataclass(frozen=True, kw_only=True)+class ProductionTrafficSignal:+ """Which signal qualified a team, for the emitted analytics event.++ `production_host` is set for the web leg; `distinct_count` carries the+ device count (mobile leg) or user count (server leg).+ """++ kind: Literal["production_host", "mobile_physical_devices", "server_lib_users"]+ production_host: str | None = None+ distinct_count: int | None = None+++# Reserved / non-public TLD suffixes. A host ending in one of these is a dev or+# internal name, never a real public environment. Matched as an exact suffix+# (with the leading dot) so that production hosts which merely *contain* one of+# these words — mylocalbiz.com, localhosting.com — are not caught.+RESERVED_TLD_SUFFIXES: Final[tuple[str, ...]] = (+ ".local",+ ".test",+ ".internal",+ ".invalid",+ ".example",+ ".localdomain",+ ".home.arpa",+)++# Well-known dev-tunnel and wildcard-DNS suffixes. These are public hosts that+# overwhelmingly serve a developer's local machine (ngrok/cloudflared tunnels,+# nip.io-style wildcard DNS resolving to an embedded IP, tailnet-only hosts),+# so they don't count as production. Preview-deploy platforms (e.g.+# *.vercel.app) are deliberately NOT listed — real production apps live there.+DEV_TUNNEL_SUFFIXES: Final[tuple[str, ...]] = (+ ".ngrok.io",+ ".ngrok-free.app",+ ".ngrok.app",+ ".trycloudflare.com",+ ".loca.lt",+ ".serveo.net",+ ".nip.io",+ ".sslip.io",+ ".xip.io",+ ".localtest.me",+ ".lvh.me",+ ".ts.net",+)+++# --- Criterion --------------------------------------------------------------+++def is_production_host(raw_host: str) -> bool:+ """Decide whether an event origin host points at a real, public production+ environment — as opposed to a developer's localhost/dev setup.++ Fail-closed: returns True only on a positive public-host signal. IP+ literals classify by address range via `ipaddress` (`is_global`), which is+ stricter than plain RFC 1918: CGNAT (100.64/10, e.g. Tailscale),+ documentation and benchmarking ranges all stay non-production. IPv4-mapped+ IPv6 literals classify by the embedded IPv4 address. Trailing dots are+ stripped before matching — browsers report `location.host` as `localhost.`+ for `http://localhost./`, and an FQDN trailing dot must not defeat the+ localhost/suffix/IP checks.+ """+ host = _strip_port_and_brackets(raw_host.strip().lower()).rstrip(".")+ if not host or len(host) > MAX_HOSTNAME_LENGTH:+ return False+ if host == "localhost" or host.endswith(".localhost"):+ return False+ if host.endswith(RESERVED_TLD_SUFFIXES):+ return False+ if host.endswith(DEV_TUNNEL_SUFFIXES):+ return False++ try:+ ip: IPv4Address | IPv6Address = ip_address(host)+ except ValueError:+ if ":" in host:+ return False # colon-y but not a valid IPv6 literal — garbage+ if "." not in host:+ return False # bare machine name like "my-laptop"+ if all(label.isdigit() for label in host.split(".")):+ return False # malformed IP literal like 256.1.1.1 — never a navigable host+ return True # a dotted host that's neither reserved nor an IP — a real public domain++ if isinstance(ip, IPv6Address) and ip.ipv4_mapped is not None:+ ip = ip.ipv4_mapped+ return ip.is_global+++# `$host` carries a port (localhost:3000, [::1]:3000). Strip brackets and the+# port so we classify the bare host. A bare IPv6 literal (>=2 colons,+# unbracketed) has no port to strip — only bracketed IPv6 can carry one.+def _strip_port_and_brackets(host: str) -> str:+ if host.startswith("["):+ closing_bracket = host.find("]")+ return host[1:closing_bracket] if closing_bracket != -1 else host[1:]++ colon_count = host.count(":")+ if colon_count >= 2:+ return host+ if colon_count == 1:+ return host.partition(":")[0]+ return host+++def _teams_meeting_criterion(team_ids: Iterable[int]) -> dict[int, ProductionTrafficSignal]:+ """Return `{team_id: signal}` for the subset of `team_ids` whose recent+ traffic meets the criterion, with the strongest signal that matched (web+ origin host > mobile physical devices > server-side user diversity).++ Single source of truth for "what counts as production traffic." ClickHouse+ only collects per-team evidence — candidate origin hosts (`$host`, falling+ back to the host of `$current_url`), physical-device counts, and+ server-side user counts; host classification happens in+ `is_production_host` so it stays unit-testable. The localhost/loopback+ prefilter in SQL is an optimization only (it keeps the dominant dev noise+ out of the result set and away from the per-team cap); correctness lives+ in the Python classifier. `$is_emulator` is matched against its raw JSON+ value so both boolean and stringly-typed `false` count, and anything else+ (true, absent, garbage, SDK versions that don't send it) fails closed.+ """+ team_id_list = list(team_ids)+ if not team_id_list:+ return {}++ # Use materialized property columns where the deployment has them; the+ # fallback is the JSONExtractString these expressions would otherwise be.+ # `$is_emulator` stays on JSONExtractRaw deliberately: JSONExtractString+ # returns '' for JSON booleans, so the string-expression fallback would+ # silently kill the mobile leg on deployments without the materialized+ # column, while the raw value works everywhere.+ host_expr, _ = get_property_string_expr("events", "$host", "'$host'", "properties")+ current_url_expr, _ = get_property_string_expr("events", "$current_url", "'$current_url'", "properties")+ device_id_expr, _ = get_property_string_expr("events", "$device_id", "'$device_id'", "properties")+ lib_expr, _ = get_property_string_expr("events", "$lib", "'$lib'", "properties")++ # Internal background job, not a customer-facing query — tag it so it's+ # attributed to growth in ClickHouse query analytics (and so it doesn't trip+ # the untagged-query guard that raises in local dev). Routed to the offline+ # cluster on cloud: this is a fleet sweep over raw events and must not+ # compete with customer-facing queries.+ workload = Workload.OFFLINE if is_cloud() else Workload.DEFAULT+ # The interpolated fragments are server-side SQL expressions from+ # get_property_string_expr, never user input; all values go through+ # query parameters.+ query = f"""+ SELECT+ team_id,+ groupUniqArrayIf(%(hosts_per_team_cap)s)(+ host,+ host != ''+ AND host != 'localhost'+ AND NOT startsWith(host, 'localhost:')+ AND NOT startsWith(host, '127.0.0.1')+ ) AS candidate_hosts,+ uniqIf(+ device_id,+ device_id != '' AND is_emulator_raw IN ('false', '"false"')+ ) AS physical_devices,+ uniqIf(distinct_id, lib IN %(server_side_libs)s) AS server_lib_users+ FROM (+ SELECT+ team_id,+ distinct_id,+ substring(+ if({host_expr} != '', {host_expr}, domain({current_url_expr})),+ 1,+ %(host_length_cap)s+ ) AS host,+ JSONExtractRaw(properties, '$is_emulator') AS is_emulator_raw,+ {device_id_expr} AS device_id,+ {lib_expr} AS lib+ FROM events+ WHERE team_id IN %(team_ids)s+ AND timestamp >= now() - toIntervalDay(%(window_days)s)+ )+ GROUP BY team_id+ HAVING notEmpty(candidate_hosts)+ OR physical_devices >= %(mobile_threshold)s+ OR server_lib_users >= %(server_threshold)s+ """+ with tags_context(product=Product.GROWTH, feature=Feature.ENRICHMENT):+ rows = sync_execute(+ query,+ {+ "team_ids": team_id_list,+ "window_days": WINDOW_DAYS,+ "hosts_per_team_cap": HOSTS_PER_TEAM_CAP,+ "host_length_cap": SQL_HOST_LENGTH_CAP,+ "server_side_libs": list(SERVER_SIDE_LIBS),+ "mobile_threshold": MOBILE_PHYSICAL_DEVICES_THRESHOLD,+ "server_threshold": SERVER_LIB_USERS_THRESHOLD,+ },+ workload=workload,+ # One pathological batch must time out rather than occupy the pool+ # and shard CPU indefinitely; the op's retry policy contains the+ # failure to that batch.+ settings={"max_execution_time": 600},+ )++ qualifying: dict[int, ProductionTrafficSignal] = {}+ for team_id, candidate_hosts, physical_devices, server_lib_users in rows:+ production_host = next((host for host in candidate_hosts if is_production_host(host)), None)+ if production_host is not None:+ qualifying[team_id] = ProductionTrafficSignal(kind="production_host", production_host=production_host)+ elif physical_devices >= MOBILE_PHYSICAL_DEVICES_THRESHOLD:+ qualifying[team_id] = ProductionTrafficSignal(+ kind="mobile_physical_devices", distinct_count=physical_devices+ )+ elif server_lib_users >= SERVER_LIB_USERS_THRESHOLD:+ qualifying[team_id] = ProductionTrafficSignal(kind="server_lib_users", distinct_count=server_lib_users)+ return qualifying+++# --- Transition -------------------------------------------------------------+++def _mark_teams_ingested_production_event(team_signals: Mapping[int, ProductionTrafficSignal], now: datetime) -> int:+ """Mark `ingested_production_event` for the given teams and emit one+ activation event per team that is newly marked.++ Concurrent-safe via `SELECT FOR UPDATE SKIP LOCKED`: a second run+ running in parallel sees only the rows the first run hasn't locked, so+ each team's event fires at most once. Returns the number of teams that+ were marked this call.+ """+ if not team_signals:+ return 0++ with transaction.atomic():+ teams_to_mark = list(+ Team.objects.select_for_update(skip_locked=True)+ .filter(id__in=list(team_signals.keys()), ingested_production_event=False)+ # `groups()` below reads organization_id — fetch it here so the+ # emit loop stays free of per-team lazy-load queries.+ .only("id", "uuid", "organization_id")+ )+ if not teams_to_mark:+ return 0+ Team.objects.filter(id__in=[t.id for t in teams_to_mark]).update(+ ingested_production_event=True,+ ingested_production_event_last_checked_at=now,+ )++ # Audit trail: the signal kind only otherwise exists in the emitted+ # analytics events, which are at-most-once — log it so a bad run can be+ # scoped and repaired from worker logs.+ marked_kinds = {team.id: team_signals[team.id].kind for team in teams_to_mark}+ for start in range(0, len(teams_to_mark), 500):+ chunk = teams_to_mark[start : start + 500]+ logger.info(+ "marked_teams_ingested_production_event",+ team_signals={team.id: marked_kinds[team.id] for team in chunk},+ )++ # Emit outside the transaction so the PostHog client round-trip doesn't+ # hold row locks. Emission is at-most-once: rows are already marked, so a+ # crash between the commit above and the flush loses those events for good+ # (re-runs filter on ingested_production_event=False). The column is the+ # source of truth; the per-team guard below keeps one bad team from+ # forfeiting the rest of the batch.+ with ph_scoped_capture() as capture:+ for team in teams_to_mark:+ signal = team_signals[team.id]+ properties = {+ "detection_signal": signal.kind,+ "production_host": signal.production_host,+ "distinct_count": signal.distinct_count,+ "window_days": WINDOW_DAYS,+ # Parity with nodejs captureTeamEvent, which stamps the team+ # uuid on team-scoped events.+ "team": str(team.uuid),+ }+ try:+ capture(+ distinct_id=str(team.uuid),+ event="first team production event ingested",+ properties={key: value for key, value in properties.items() if value is not None},+ groups=groups(team=team),+ )+ except Exception as e:+ capture_exception(e, {"team": "team-growth", "team_id": team.id})+ logger.exception("production_event_activation_capture_failed", team_id=team.id)+ return len(teams_to_mark)+++# --- Per-batch helper used by the Dagster job ------------------------------+++def evaluate_and_mark_team_batch(team_ids: Iterable[int], now: datetime) -> tuple[int, int]:+ """Evaluate one batch of unflagged team IDs and apply the result.++ Returns `(qualifying_count, marked_count)`. `marked_count <=+ qualifying_count` because a concurrent run may have already marked+ rows under `SELECT FOR UPDATE SKIP LOCKED`.+ """+ batch = list(team_ids)+ if not batch:+ return 0, 0++ qualifying_signals = _teams_meeting_criterion(batch)+ marked = _mark_teams_ingested_production_event(qualifying_signals, now=now) if qualifying_signals else 0++ # Stamp `_last_checked_at` for the rest — the candidate query uses it to+ # skip recently-checked teams (RECHECK_BACKOFF), so this write is what+ # keeps the sweep's recurring cost bounded. Qualifying teams already had+ # it set inside the transition helper, so don't double-write them here.+ non_qualifying = [tid for tid in batch if tid not in qualifying_signals]+ if non_qualifying:+ Team.objects.filter(id__in=non_qualifying).update(+ ingested_production_event_last_checked_at=now,+ )++ return len(qualifying_signals), markeddiff --git a/posthog/models/team/team.py b/posthog/models/team/team.pyindex 6b1fdc8679f5..42cd61000e98 100644--- a/posthog/models/team/team.py+++ b/posthog/models/team/team.py@@ -322,6 +322,7 @@ class Team(UUIDTClassicModel):onboarding_tasks = models.JSONField(null=True, blank=True)ingested_event = models.BooleanField(default=False)ingested_production_event = models.BooleanField(default=False, db_default=False)+ ingested_production_event_last_checked_at = models.DateTimeField(null=True, blank=True)person_processing_opt_out = field_access_control(models.BooleanField(null=True, default=False), "project", "admin")secret_api_token = models.CharField(diff --git a/posthog/models/team/test_production_event_activation.py b/posthog/models/team/test_production_event_activation.pynew file mode 100644index 000000000000..f21fbc21e68a--- /dev/null+++ b/posthog/models/team/test_production_event_activation.py@@ -0,0 +1,409 @@+from contextlib import contextmanager+from datetime import UTC, datetime, timedelta+from typing import Any++from freezegun import freeze_time+from posthog.test.base import BaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events+from unittest import TestCase+from unittest.mock import MagicMock, patch++from parameterized import parameterized++from posthog.models.team.production_event_activation import (+ MOBILE_PHYSICAL_DEVICES_THRESHOLD,+ SERVER_LIB_USERS_THRESHOLD,+ WINDOW_DAYS,+ ProductionTrafficSignal,+ _mark_teams_ingested_production_event,+ _teams_meeting_criterion,+ evaluate_and_mark_team_batch,+ is_production_host,+)+from posthog.models.team.team import Team++# Fixed `now` for the transition assertions. The value is arbitrary — these+# tests only check that whatever `now` we pass through lands in+# `_last_checked_at` — but it must be a literal so the time-sensitivity+# semgrep rule doesn't flag a bare `datetime.now()` in a test.+_FIXED_NOW = datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC)++PRODUCTION_HOST = "app.example.com"+PRODUCTION_HOST_SIGNAL = ProductionTrafficSignal(kind="production_host", production_host=PRODUCTION_HOST)+++@contextmanager+def _mock_capture():+ # `ph_scoped_capture` is itself a context manager that yields the capture+ # function, so the patch has to provide a context manager whose `__enter__`+ # returns a callable. Tests can then assert against that callable directly.+ capture_fn: Any = MagicMock()+ with patch("posthog.models.team.production_event_activation.ph_scoped_capture") as mock_csm:+ mock_csm.return_value.__enter__.return_value = capture_fn+ mock_csm.return_value.__exit__.return_value = False+ yield capture_fn+++def _seed_event(+ team_id: int,+ properties: dict[str, Any] | None = None,+ days_ago: float = 1,+ distinct_id: str = "user-0",+) -> None:+ _create_event(+ team=Team.objects.get(id=team_id),+ event="$pageview",+ distinct_id=distinct_id,+ timestamp=datetime.now(tz=UTC) - timedelta(days=days_ago),+ properties=properties or {},+ )+ flush_persons_and_events()+++def _seed_mobile_events(team_id: int, device_count: int, is_emulator: Any = False) -> None:+ for i in range(device_count):+ _seed_event(+ team_id,+ properties={"$lib": "posthog-ios", "$is_emulator": is_emulator, "$device_id": f"device-{i}"},+ distinct_id=f"mobile-user-{i}",+ )+++def _seed_server_events(team_id: int, user_count: int, lib: str = "posthog-python") -> None:+ for i in range(user_count):+ _seed_event(team_id, properties={"$lib": lib}, distinct_id=f"server-user-{i}")+++class TestIsProductionHost(TestCase):+ @parameterized.expand(+ [+ ("example.com",),+ ("app.example.com",),+ ("sub.domain.co.uk",),+ ("example.com:8080",),+ ("EXAMPLE.com",),+ (" example.com ",),+ ("mylocalbiz.com",), # contains "local" but isn't a reserved suffix+ ("localhosting.com",), # starts with "localhost" but is a real domain+ ("myapp.dev",), # .dev is a real public TLD+ ("8.8.8.8",),+ ("8.8.8.8:443",),+ ("172.15.0.1",), # just below the 172.16/12 private range+ ("172.32.0.1",), # just above the 172.16/12 private range+ ("2606:4700::6810:84e5",),+ ("[2606:4700::6810:84e5]:443",),+ ("::ffff:8.8.8.8",), # IPv4-mapped public address+ ("example.com.",), # trailing-dot FQDN of a real domain is still production+ ]+ )+ def test_production_hosts(self, host: str) -> None:+ self.assertTrue(is_production_host(host), f"{host!r} should classify as production")++ @parameterized.expand(+ [+ ("",),+ (" ",),+ ("localhost",),+ ("localhost:3000",),+ ("LOCALHOST",),+ ("app.localhost",),+ ("myapp.local",),+ ("myapp.test",),+ ("service.internal",),+ ("site.invalid",),+ ("site.example",),+ ("box.localdomain",),+ ("router.home.arpa",),+ ("my-laptop",), # bare machine name+ ("foo:bar",), # garbage with a colon+ ("127.0.0.1",),+ ("127.0.0.1:8000",),+ ("10.0.0.5",),+ ("192.168.1.10",),+ ("172.16.0.1",),+ ("172.31.255.255",),+ ("169.254.1.1",),+ ("0.0.0.0",),+ ("100.64.0.1",), # CGNAT (e.g. Tailscale) — stricter than plain RFC 1918+ ("256.1.1.1",), # malformed IP literal+ ("::1",),+ ("::",),+ ("[::1]:3000",),+ ("fe80::1",),+ ("fd12:3456::1",),+ ("fc00::1",),+ ("::ffff:127.0.0.1",),+ ("::ffff:192.168.0.1",),+ ("localhost.",), # trailing dots must not defeat the deny rules+ ("localhost.:3000",),+ ("app.localhost.",),+ ("myapp.test.",),+ ("127.0.0.1.",),+ ("192.168.1.10.",),+ ("abc123.ngrok-free.app",), # dev tunnels+ ("tunnel.ngrok.io",),+ ("foo.trycloudflare.com",),+ ("bar.loca.lt",),+ ("127.0.0.1.nip.io",), # wildcard DNS to an embedded private IP+ ("myhost.ts.net",), # tailnet-only host+ ("app.lvh.me",),+ ("a" * 300 + ".com",), # longer than any valid hostname — crafted input+ ]+ )+ def test_non_production_hosts(self, host: str) -> None:+ self.assertFalse(is_production_host(host), f"{host!r} should classify as non-production")+++class TestTeamsMeetingCriterion(ClickhouseTestMixin, BaseTest):+ def test_empty_input_returns_empty_dict(self) -> None:+ self.assertEqual(_teams_meeting_criterion([]), {})++ def test_team_with_no_events_does_not_qualify(self) -> None:+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_single_production_event_qualifies(self) -> None:+ _seed_event(self.team.id, properties={"$host": PRODUCTION_HOST})+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {self.team.id: PRODUCTION_HOST_SIGNAL})++ def test_dev_only_traffic_does_not_qualify(self) -> None:+ for host in ["localhost:3000", "127.0.0.1:8000", "myapp.test", "192.168.1.10"]:+ _seed_event(self.team.id, properties={"$host": host})+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_current_url_fallback_qualifies(self) -> None:+ _seed_event(self.team.id, properties={"$current_url": f"https://{PRODUCTION_HOST}/dashboard?x=1"})+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {self.team.id: PRODUCTION_HOST_SIGNAL})++ def test_local_host_takes_precedence_over_production_current_url(self) -> None:+ _seed_event(+ self.team.id,+ properties={"$host": "localhost:3000", "$current_url": f"https://{PRODUCTION_HOST}/page"},+ )+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_event_without_host_signal_does_not_qualify(self) -> None:+ _seed_event(self.team.id, properties={"$lib": "posthog-python"})+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_events_outside_window_do_not_count(self) -> None:+ _seed_event(self.team.id, properties={"$host": PRODUCTION_HOST}, days_ago=WINDOW_DAYS + 1)+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_mixed_dev_and_production_traffic_qualifies_with_production_host(self) -> None:+ _seed_event(self.team.id, properties={"$host": "myapp.test"})+ _seed_event(self.team.id, properties={"$host": PRODUCTION_HOST})+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {self.team.id: PRODUCTION_HOST_SIGNAL})++ def test_mobile_physical_devices_at_threshold_qualify(self) -> None:+ _seed_mobile_events(self.team.id, device_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD)+ self.assertEqual(+ _teams_meeting_criterion([self.team.id]),+ {+ self.team.id: ProductionTrafficSignal(+ kind="mobile_physical_devices", distinct_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD+ )+ },+ )++ def test_mobile_physical_devices_below_threshold_do_not_qualify(self) -> None:+ _seed_mobile_events(self.team.id, device_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD - 1)+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_emulator_only_traffic_does_not_qualify(self) -> None:+ _seed_mobile_events(self.team.id, device_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD + 2, is_emulator=True)+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_mobile_counts_devices_not_distinct_ids(self) -> None:+ # One physical device with many logins/anon ids is still one device.+ for i in range(MOBILE_PHYSICAL_DEVICES_THRESHOLD + 2):+ _seed_event(+ self.team.id,+ properties={"$lib": "posthog-ios", "$is_emulator": False, "$device_id": "device-0"},+ distinct_id=f"mobile-user-{i}",+ )+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_mobile_without_device_id_does_not_qualify(self) -> None:+ # Without $device_id, distinct_ids can't stand in for devices — fail closed.+ for i in range(MOBILE_PHYSICAL_DEVICES_THRESHOLD + 2):+ _seed_event(+ self.team.id,+ properties={"$lib": "posthog-ios", "$is_emulator": False},+ distinct_id=f"mobile-user-{i}",+ )+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_mobile_stringly_false_emulator_counts_as_physical(self) -> None:+ _seed_mobile_events(self.team.id, device_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD, is_emulator="false")+ self.assertEqual(+ _teams_meeting_criterion([self.team.id]),+ {+ self.team.id: ProductionTrafficSignal(+ kind="mobile_physical_devices", distinct_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD+ )+ },+ )++ def test_server_lib_users_at_threshold_qualify(self) -> None:+ _seed_server_events(self.team.id, user_count=SERVER_LIB_USERS_THRESHOLD)+ self.assertEqual(+ _teams_meeting_criterion([self.team.id]),+ {self.team.id: ProductionTrafficSignal(kind="server_lib_users", distinct_count=SERVER_LIB_USERS_THRESHOLD)},+ )++ def test_server_lib_users_below_threshold_do_not_qualify(self) -> None:+ _seed_server_events(self.team.id, user_count=SERVER_LIB_USERS_THRESHOLD - 1)+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_web_lib_users_do_not_count_toward_server_leg(self) -> None:+ # Many distinct anonymous users on a dev host (e.g. an e2e suite) must not+ # drift into the server leg — it only counts allowlisted server SDKs.+ for i in range(SERVER_LIB_USERS_THRESHOLD + 5):+ _seed_event(+ self.team.id,+ properties={"$lib": "web", "$host": "localhost:3000"},+ distinct_id=f"e2e-user-{i}",+ )+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {})++ def test_production_host_takes_precedence_over_other_signals(self) -> None:+ _seed_mobile_events(self.team.id, device_count=MOBILE_PHYSICAL_DEVICES_THRESHOLD)+ _seed_server_events(self.team.id, user_count=SERVER_LIB_USERS_THRESHOLD)+ _seed_event(self.team.id, properties={"$host": PRODUCTION_HOST})+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {self.team.id: PRODUCTION_HOST_SIGNAL})++ def test_only_listed_teams_are_evaluated(self) -> None:+ other_team = Team.objects.create(organization=self.organization, name="other")+ _seed_event(self.team.id, properties={"$host": PRODUCTION_HOST})+ _seed_event(other_team.id, properties={"$host": PRODUCTION_HOST})++ # other_team has production events but isn't in the input set, so isn't returned.+ self.assertEqual(_teams_meeting_criterion([self.team.id]), {self.team.id: PRODUCTION_HOST_SIGNAL})+++class TestMarkTeamsIngestedProductionEvent(BaseTest):+ def test_empty_input_returns_zero(self) -> None:+ with _mock_capture() as capture:+ self.assertEqual(_mark_teams_ingested_production_event({}, now=_FIXED_NOW), 0)+ capture.assert_not_called()++ def test_unflagged_team_is_marked_and_emits(self) -> None:+ now = _FIXED_NOW+ self.assertFalse(self.team.ingested_production_event)++ with _mock_capture() as capture:+ marked = _mark_teams_ingested_production_event({self.team.id: PRODUCTION_HOST_SIGNAL}, now=now)++ self.team.refresh_from_db()+ self.assertEqual(marked, 1)+ self.assertTrue(self.team.ingested_production_event)+ self.assertEqual(self.team.ingested_production_event_last_checked_at, now)+ capture.assert_called_once()+ ((), kwargs) = capture.call_args+ self.assertEqual(kwargs["event"], "first team production event ingested")+ self.assertEqual(kwargs["distinct_id"], str(self.team.uuid))+ self.assertEqual(+ kwargs["properties"],+ {+ "detection_signal": "production_host",+ "production_host": PRODUCTION_HOST,+ "window_days": WINDOW_DAYS,+ "team": str(self.team.uuid),+ },+ )++ def test_mobile_signal_emits_distinct_count(self) -> None:+ signal = ProductionTrafficSignal(kind="mobile_physical_devices", distinct_count=4)++ with _mock_capture() as capture:+ marked = _mark_teams_ingested_production_event({self.team.id: signal}, now=_FIXED_NOW)++ self.assertEqual(marked, 1)+ ((), kwargs) = capture.call_args+ self.assertEqual(+ kwargs["properties"],+ {+ "detection_signal": "mobile_physical_devices",+ "distinct_count": 4,+ "window_days": WINDOW_DAYS,+ "team": str(self.team.uuid),+ },+ )++ def test_capture_failure_for_one_team_does_not_drop_the_rest(self) -> None:+ other = Team.objects.create(organization=self.organization, name="other")++ with _mock_capture() as capture:+ capture.side_effect = [Exception("boom"), None]+ marked = _mark_teams_ingested_production_event(+ {self.team.id: PRODUCTION_HOST_SIGNAL, other.id: PRODUCTION_HOST_SIGNAL}, now=_FIXED_NOW+ )++ self.assertEqual(marked, 2)+ self.assertEqual(capture.call_count, 2)+ self.team.refresh_from_db()+ other.refresh_from_db()+ self.assertTrue(self.team.ingested_production_event)+ self.assertTrue(other.ingested_production_event)++ def test_already_flagged_team_is_noop(self) -> None:+ self.team.ingested_production_event = True+ self.team.save(update_fields=["ingested_production_event"])++ with _mock_capture() as capture:+ marked = _mark_teams_ingested_production_event({self.team.id: PRODUCTION_HOST_SIGNAL}, now=_FIXED_NOW)++ self.assertEqual(marked, 0)+ capture.assert_not_called()++ def test_mix_of_flagged_and_unflagged_only_marks_unflagged(self) -> None:+ unflagged = self.team+ flagged = Team.objects.create(organization=self.organization, name="flagged", ingested_production_event=True)++ with _mock_capture() as capture:+ marked = _mark_teams_ingested_production_event(+ {unflagged.id: PRODUCTION_HOST_SIGNAL, flagged.id: PRODUCTION_HOST_SIGNAL}, now=_FIXED_NOW+ )++ self.assertEqual(marked, 1)+ unflagged.refresh_from_db()+ flagged.refresh_from_db()+ self.assertTrue(unflagged.ingested_production_event)+ self.assertTrue(flagged.ingested_production_event)+ capture.assert_called_once()+++class TestEvaluateAndMarkTeamBatch(ClickhouseTestMixin, BaseTest):+ def test_empty_batch_is_noop(self) -> None:+ self.assertEqual(evaluate_and_mark_team_batch([], now=_FIXED_NOW), (0, 0))++ def test_qualifying_team_is_flagged(self) -> None:+ _seed_event(self.team.id, properties={"$host": PRODUCTION_HOST})+ with freeze_time("2026-06-05T12:00:00Z"), _mock_capture():+ qualifying, marked = evaluate_and_mark_team_batch(+ [self.team.id], now=datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC)+ )++ self.assertEqual(qualifying, 1)+ self.assertEqual(marked, 1)+ self.team.refresh_from_db()+ self.assertTrue(self.team.ingested_production_event)+ self.assertEqual(+ self.team.ingested_production_event_last_checked_at,+ datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC),+ )++ def test_non_qualifying_team_only_gets_last_checked_at_bumped(self) -> None:+ _seed_event(self.team.id, properties={"$host": "localhost:3000"})+ with freeze_time("2026-06-05T12:00:00Z"):+ qualifying, marked = evaluate_and_mark_team_batch(+ [self.team.id], now=datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC)+ )++ self.assertEqual(qualifying, 0)+ self.assertEqual(marked, 0)+ self.team.refresh_from_db()+ self.assertFalse(self.team.ingested_production_event)+ self.assertEqual(+ self.team.ingested_production_event_last_checked_at,+ datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC),+ )diff --git a/posthog/ph_client.py b/posthog/ph_client.pyindex 68ff3ba46b43..ca0e768cdced 100644--- a/posthog/ph_client.py+++ b/posthog/ph_client.py@@ -45,9 +45,12 @@ def ph_scoped_capture():if is_cloud() and ph_client:ph_client.capture(*args, **kwargs)- yield capture_ph_event-- ph_client.shutdown()+ # Flush even when the caller's block raises — events already captured+ # before the exception shouldn't be dropped with the buffer.+ try:+ yield capture_ph_event+ finally:+ ph_client.shutdown()def get_client(region: str = "US", **kwargs: Any):diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambrindex 217477552f45..cf2d2218e6b4 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr@@ -97,6 +97,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -410,6 +411,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -759,6 +761,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1278,6 +1281,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1511,6 +1515,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1873,6 +1878,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2114,6 +2120,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2481,6 +2488,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambrindex da2c43733282..254a90dfef49 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr@@ -164,6 +164,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -371,6 +372,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -946,6 +948,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1149,6 +1152,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1724,6 +1728,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1923,6 +1928,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2498,6 +2504,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2697,6 +2704,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3272,6 +3280,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3475,6 +3484,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4050,6 +4060,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4253,6 +4264,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -4828,6 +4840,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -5031,6 +5044,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -5660,6 +5674,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -5966,6 +5981,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6103,6 +6119,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6578,6 +6595,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -6933,6 +6951,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7450,6 +7469,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7677,6 +7697,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -7900,6 +7921,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8426,6 +8448,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -8744,6 +8767,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9265,6 +9289,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9657,6 +9682,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -9878,6 +9904,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10215,6 +10242,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -10690,6 +10718,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11026,6 +11055,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11550,6 +11580,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -11902,6 +11933,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -12427,6 +12459,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -12725,6 +12758,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -13234,6 +13268,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -13567,6 +13602,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambrindex 4e042315502a..d336ead88217 100644--- a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr+++ b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr@@ -384,6 +384,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -575,6 +576,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1103,6 +1105,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1424,6 +1427,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/products/actions/backend/api/test/__snapshots__/test_action.ambr b/products/actions/backend/api/test/__snapshots__/test_action.ambrindex ad41f86c0a71..45df508c4d7d 100644--- a/products/actions/backend/api/test/__snapshots__/test_action.ambr+++ b/products/actions/backend/api/test/__snapshots__/test_action.ambr@@ -105,6 +105,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -596,6 +597,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -732,6 +734,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr b/products/annotations/backend/api/test/__snapshots__/test_annotation.ambrindex 1d82d2a75d97..9e92789d09ee 100644--- a/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr+++ b/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr@@ -105,6 +105,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -605,6 +606,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -741,6 +743,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr b/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambrindex c07e4c65b872..1ec57b739726 100644--- a/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr+++ b/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr@@ -62,6 +62,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -522,6 +523,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -662,6 +664,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambrindex b06cb7b6c311..1be96dc6b9ef 100644--- a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr+++ b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr@@ -545,6 +545,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -884,6 +885,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1096,6 +1098,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1299,6 +1302,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1616,6 +1620,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1884,6 +1889,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2153,6 +2159,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2260,6 +2267,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2474,6 +2482,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambrindex c1ab6f99e159..c94809214292 100644--- a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr+++ b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr@@ -105,6 +105,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -296,6 +297,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -600,6 +602,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -768,6 +771,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -939,6 +943,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1038,6 +1043,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1451,6 +1457,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1587,6 +1594,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1694,6 +1702,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1814,6 +1823,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1936,6 +1946,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2057,6 +2068,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2194,6 +2206,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2433,6 +2446,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2540,6 +2554,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2702,6 +2717,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2838,6 +2854,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2945,6 +2962,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3082,6 +3100,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3316,6 +3335,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -3423,6 +3443,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",diff --git a/products/growth/dags/team_production_event_activation.py b/products/growth/dags/team_production_event_activation.pynew file mode 100644index 000000000000..b09c31ea9ae7--- /dev/null+++ b/products/growth/dags/team_production_event_activation.py@@ -0,0 +1,175 @@+"""+Daily Dagster job that marks `Team.ingested_production_event` for teams+whose recent traffic crosses the production-traffic criterion.++The criterion and the row-marking transition live in+`posthog/models/team/production_event_activation.py` (they're plain Python+helpers, tested in isolation). This file just orchestrates them: a single+op fans out candidate team IDs into batches, each batch evaluates ++marks under a multiprocess executor, and an aggregate op emits run-level+counts as Dagster metadata.++The schedule starts STOPPED. The first run evaluates every team ever created+(nothing has set the flag before), so launch it manually and supervised —+off-peak, watching the run metadata — before enabling the schedule.+"""++from dataclasses import dataclass+from datetime import UTC, datetime++from django.conf import settings+from django.db import connections+from django.db.models import Q++import dagster++from posthog.clickhouse.query_tagging import get_query_tags+from posthog.dags.common import JobOwners, dagster_tags, skip_if_already_running+from posthog.exceptions_capture import capture_exception+from posthog.models.team.production_event_activation import (+ RECHECK_BACKOFF,+ SWEEP_BATCH_SIZE,+ WINDOW_DAYS,+ evaluate_and_mark_team_batch,+)+from posthog.models.team.team import Team+++@dataclass(kw_only=True)+class TeamBatchResult:+ team_count: int+ qualifying: int+ marked: int++[email protected](out=dagster.DynamicOut(list[int]))+def get_teams_without_production_event_op(context: dagster.OpExecutionContext):+ """Pull candidate teams still missing `ingested_production_event` and fan+ out as batches.++ Excluded: demo projects and internal-metrics orgs (their seeded traffic+ carries production-looking hosts and would permanently corrupt the+ activation metric — same exclusions as the usage report), and teams+ checked within RECHECK_BACKOFF (the criterion window is much longer than+ the backoff, so deferred re-checks can't miss a team that keeps sending+ production traffic).++ Using `DynamicOut` so downstream `.map()` runs each batch as its own+ op invocation — gives us per-batch retry and parallel execution under+ the multiprocess executor.+ """+ recheck_cutoff = datetime.now(tz=UTC) - RECHECK_BACKOFF+ candidate_ids = list(+ Team.objects.filter(ingested_production_event=False)+ .filter(+ Q(ingested_production_event_last_checked_at__isnull=True)+ | Q(ingested_production_event_last_checked_at__lt=recheck_cutoff)+ )+ .exclude(Q(is_demo=True) | Q(organization__for_internal_metrics=True) | Q(id=0))+ .values_list("id", flat=True)+ )+ total = len(candidate_ids)+ batch_count = (total + SWEEP_BATCH_SIZE - 1) // SWEEP_BATCH_SIZE++ context.log.info(f"Found {total} candidate teams, fanning out into {batch_count} batches of {SWEEP_BATCH_SIZE}")++ # `add_output_metadata` is not permitted on a `DynamicOut` op without a per-output+ # `mapping_key`. Run-level totals get surfaced by `summarize_run_op`.+ for index in range(0, total, SWEEP_BATCH_SIZE):+ batch = candidate_ids[index : index + SWEEP_BATCH_SIZE]+ yield dagster.DynamicOutput(batch, mapping_key=f"batch_{index // SWEEP_BATCH_SIZE}")+++ retry_policy=dagster.RetryPolicy(+ max_retries=3,+ delay=30,+ backoff=dagster.Backoff.EXPONENTIAL,+ jitter=dagster.Jitter.FULL,+ )+)+def evaluate_and_mark_team_batch_op(+ context: dagster.OpExecutionContext,+ team_ids: list[int],+) -> TeamBatchResult:+ """Evaluate the criterion against this batch and mark qualifying teams.++ Failures here surface as Dagster retries on this single batch — the+ rest of the run keeps going. Retrying is safe: marking is idempotent+ (`ingested_production_event=False` filter + `SKIP LOCKED`).+ """+ get_query_tags().with_dagster(dagster_tags(context))+ try:+ qualifying, marked = evaluate_and_mark_team_batch(team_ids, now=datetime.now(tz=UTC))+ result = TeamBatchResult(team_count=len(team_ids), qualifying=qualifying, marked=marked)+ context.log.info(f"Batch of {result.team_count}: {result.qualifying} qualifying, {result.marked} marked")+ context.add_output_metadata(+ {+ "team_count": dagster.MetadataValue.int(result.team_count),+ "qualifying": dagster.MetadataValue.int(result.qualifying),+ "marked": dagster.MetadataValue.int(result.marked),+ }+ )+ return result+ except Exception as e:+ context.log.exception(f"Failed to evaluate batch of {len(team_ids)} teams")+ capture_exception(e, {"team": "team-growth", "team_count": len(team_ids)})+ raise+ finally:+ # Release this step's Django DB connections before the executor+ # process moves on (processes may be reused depending on executor+ # configuration). Skipped under TEST because `execute_in_process`+ # shares the test's outer transactional connection.+ if not settings.TEST:+ connections.close_all()+++def summarize_run_op(+ context: dagster.OpExecutionContext,+ results: list[TeamBatchResult],+) -> None:+ """Roll up per-batch counts into a single run-level summary."""+ teams_evaluated = sum(r.team_count for r in results)+ teams_qualifying = sum(r.qualifying for r in results)+ teams_marked = sum(r.marked for r in results)++ context.log.info(f"Run complete: {teams_evaluated} evaluated, {teams_qualifying} qualifying, {teams_marked} marked")+ context.add_output_metadata(+ {+ "teams_evaluated": dagster.MetadataValue.int(teams_evaluated),+ "teams_qualifying": dagster.MetadataValue.int(teams_qualifying),+ "teams_marked": dagster.MetadataValue.int(teams_marked),+ "batches": dagster.MetadataValue.int(len(results)),+ "window_days": dagster.MetadataValue.int(WINDOW_DAYS),+ }+ )+++ description=(+ "Daily job that marks Team.ingested_production_event for teams whose recent "+ "traffic crosses the production-traffic criterion."+ ),+ executor_def=dagster.multiprocess_executor.configured({"max_concurrent": 5}),+ tags={"owner": JobOwners.TEAM_GROWTH.value},+)+def detect_first_team_production_event_job():+ batches = get_teams_without_production_event_op()+ results = batches.map(evaluate_and_mark_team_batch_op)+ summarize_run_op(results.collect())+++ job=detect_first_team_production_event_job,+ cron_schedule="0 4 * * *",+ execution_timezone="UTC",+ default_status=dagster.DefaultScheduleStatus.STOPPED,+)+@skip_if_already_running+def detect_first_team_production_event_schedule(context: dagster.ScheduleEvaluationContext):+ # A run that outlives a day (e.g. the initial backfill) must not stack+ # with the next day's: the marking path is SKIP LOCKED-safe, but the+ # ClickHouse scans would fully duplicate and the bookkeeping bulk UPDATEs+ # can deadlock across overlapping ID sets.+ return dagster.RunRequest()diff --git a/products/growth/dags/tests/test_team_production_event_activation.py b/products/growth/dags/tests/test_team_production_event_activation.pynew file mode 100644index 000000000000..326bf80ff479--- /dev/null+++ b/products/growth/dags/tests/test_team_production_event_activation.py@@ -0,0 +1,138 @@+from contextlib import contextmanager+from datetime import UTC, datetime, timedelta+from typing import Any++from freezegun import freeze_time+from posthog.test.base import BaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events+from unittest.mock import MagicMock, patch++from posthog.models.organization import Organization+from posthog.models.team.production_event_activation import RECHECK_BACKOFF+from posthog.models.team.team import Team++from products.growth.dags.team_production_event_activation import detect_first_team_production_event_job+++@contextmanager+def _mock_capture():+ capture_fn: Any = MagicMock()+ with patch("posthog.models.team.production_event_activation.ph_scoped_capture") as mock_csm:+ mock_csm.return_value.__enter__.return_value = capture_fn+ mock_csm.return_value.__exit__.return_value = False+ yield capture_fn+++def _seed_event(team_id: int, host: str, days_ago: float = 1) -> None:+ _create_event(+ team=Team.objects.get(id=team_id),+ event="$pageview",+ distinct_id="user-0",+ timestamp=datetime.now(tz=UTC) - timedelta(days=days_ago),+ properties={"$host": host},+ )+ flush_persons_and_events()+++# The backoff tests need timestamps relative to real wall-clock time — the+# candidate filter and ClickHouse's `now()` both use it, so freezing time here+# would desynchronize the two. Kept out of test bodies for the+# test-no-datetime-now semgrep rule; relative offsets are midnight-safe.+def _real_now() -> datetime:+ return datetime.now(tz=UTC)+++class TestDetectFirstTeamProductionEventJob(ClickhouseTestMixin, BaseTest):+ def test_no_unflagged_teams_skips_evaluation(self) -> None:+ # All teams already flagged → the dynamic op yields zero batches → criterion is never queried.+ Team.objects.filter(id=self.team.id).update(ingested_production_event=True)++ with patch("posthog.models.team.production_event_activation._teams_meeting_criterion") as mock_criterion:+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ mock_criterion.assert_not_called()++ def test_qualifying_team_is_flagged(self) -> None:+ _seed_event(self.team.id, host="app.example.com")++ with freeze_time("2026-06-05T12:00:00Z"), _mock_capture():+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ self.team.refresh_from_db()+ self.assertTrue(self.team.ingested_production_event)+ self.assertEqual(+ self.team.ingested_production_event_last_checked_at,+ datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC),+ )++ def test_non_qualifying_team_only_gets_last_checked_at_bumped(self) -> None:+ _seed_event(self.team.id, host="localhost:3000")++ with freeze_time("2026-06-05T12:00:00Z"):+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ self.team.refresh_from_db()+ self.assertFalse(self.team.ingested_production_event)+ self.assertEqual(+ self.team.ingested_production_event_last_checked_at,+ datetime(2026, 6, 5, 12, 0, 0, tzinfo=UTC),+ )++ def test_demo_team_is_excluded_from_the_sweep(self) -> None:+ demo_team = Team.objects.create(organization=self.organization, name="demo", is_demo=True)+ _seed_event(demo_team.id, host="hedgebox.net")++ with _mock_capture() as capture:+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ demo_team.refresh_from_db()+ self.assertFalse(demo_team.ingested_production_event)+ # Never evaluated at all — not even the bookkeeping stamp.+ self.assertIsNone(demo_team.ingested_production_event_last_checked_at)+ capture.assert_not_called()++ def test_internal_metrics_org_team_is_excluded_from_the_sweep(self) -> None:+ internal_org = Organization.objects.create(name="internal", for_internal_metrics=True)+ internal_team = Team.objects.create(organization=internal_org, name="internal")+ _seed_event(internal_team.id, host="app.example.com")++ with _mock_capture():+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ internal_team.refresh_from_db()+ self.assertFalse(internal_team.ingested_production_event)+ self.assertIsNone(internal_team.ingested_production_event_last_checked_at)++ def test_recently_checked_team_is_skipped(self) -> None:+ recently_checked_at = _real_now() - timedelta(hours=1)+ Team.objects.filter(id=self.team.id).update(+ ingested_production_event_last_checked_at=recently_checked_at,+ )+ _seed_event(self.team.id, host="app.example.com")++ with _mock_capture() as capture:+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ self.team.refresh_from_db()+ self.assertFalse(self.team.ingested_production_event)+ # Untouched: skipped teams keep their previous check timestamp.+ self.assertEqual(self.team.ingested_production_event_last_checked_at, recently_checked_at)+ capture.assert_not_called()++ def test_stale_checked_team_is_rechecked(self) -> None:+ Team.objects.filter(id=self.team.id).update(+ ingested_production_event_last_checked_at=_real_now() - RECHECK_BACKOFF - timedelta(days=1),+ )+ _seed_event(self.team.id, host="app.example.com")++ with _mock_capture():+ result = detect_first_team_production_event_job.execute_in_process()++ self.assertTrue(result.success)+ self.team.refresh_from_db()+ self.assertTrue(self.team.ingested_production_event)diff --git a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambrindex f83ce10db833..9efe8adf2575 100644--- a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr+++ b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr@@ -521,6 +521,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -657,6 +658,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -764,6 +766,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -933,6 +936,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1040,6 +1044,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1228,6 +1233,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1364,6 +1370,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1471,6 +1478,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -1678,6 +1686,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2011,6 +2020,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2337,6 +2347,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",@@ -2764,6 +2775,7 @@"posthog_team"."onboarding_tasks","posthog_team"."ingested_event","posthog_team"."ingested_production_event",+ "posthog_team"."ingested_production_event_last_checked_at","posthog_team"."person_processing_opt_out","posthog_team"."secret_api_token","posthog_team"."secret_api_token_backup",