:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(flags): test the flag_evaluations catalog for a mode 0 cloud org (#130445)
Phil Haack940ea1472b66
diff --git a/posthog/hogql/database/database.py b/posthog/hogql/database/database.pyindex f439a93d3081..28b0f9e89030 100644--- a/posthog/hogql/database/database.py+++ b/posthog/hogql/database/database.py@@ -2138,8 +2138,8 @@ class Database(BaseModel):# A direct-connection catalog has no "posthog" node to hold the table.include_flag_evaluations_table = not is_direct_query and is_flag_evaluations_table_enabled(team)- # This checks the read mode, not is_flag_evaluations_table_enabled. That one is true under DEBUG for an- # organization still on EVENTS.+ # This checks the read mode, not is_flag_evaluations_table_enabled. That one is true on Cloud and under+ # DEBUG for an organization still on EVENTS.read_mode: int = FlagEvaluationsMode.EVENTSif include_flag_evaluations_table:read_mode = get_flag_evaluations_read_mode(team.organization_id)diff --git a/posthog/hogql/database/test/test_database.py b/posthog/hogql/database/test/test_database.pyindex c94019180380..eebb2541eb74 100644--- a/posthog/hogql/database/test/test_database.py+++ b/posthog/hogql/database/test/test_database.py@@ -483,9 +483,10 @@ class TestDatabase(BaseTest, QueryMatchingTest):@parameterized.expand([- ("events_mode", FlagEvaluationsMode.EVENTS, False),+ param("events_mode", FlagEvaluationsMode.EVENTS, False, table_in_catalog=False),# DEBUG puts the table in the catalog on EVENTS, but events still holds every flag call.param("events_mode_under_debug", FlagEvaluationsMode.EVENTS, False, debug=True),+ param("events_mode_on_cloud", FlagEvaluationsMode.EVENTS, False, cloud=True),param("events_mode_with_the_table_forced_in",FlagEvaluationsMode.EVENTS,@@ -518,6 +519,7 @@ class TestDatabase(BaseTest, QueryMatchingTest):FlagEvaluationsMode.FLAG_EVALUATIONS_ONLY,False,include_flag_evaluations_table=False,+ table_in_catalog=False,),])@@ -528,8 +530,10 @@ class TestDatabase(BaseTest, QueryMatchingTest):expected: bool,reads_forced_to_events: bool = False,debug: bool = False,+ cloud: bool = False,include_flag_evaluations_table: bool | None = None,union_flag_enabled: bool = True,+ table_in_catalog: bool = True,) -> None:enabled_flags = {"hogql-flag-calls-union"} if union_flag_enabled else set()OrganizationFeatureFlagsConfig.objects.update_or_create(@@ -538,6 +542,7 @@ class TestDatabase(BaseTest, QueryMatchingTest):with (override_settings(DEBUG=debug),+ self.is_cloud(cloud),override_instance_config("FLAG_EVALUATIONS_READS_FORCE_EVENTS", reads_forced_to_events),patch("posthog.hogql.database.database.feature_enabled_or_false",@@ -549,6 +554,7 @@ class TestDatabase(BaseTest, QueryMatchingTest):)assert database.read_flag_calls_from_flag_evaluations is expected+ assert database.has_table(["posthog", "flag_evaluations"]) is table_in_catalogunion_expected = expected and union_flag_enabledassert database.read_flag_calls_with_union is union_expectedassert database.has_table(["posthog", "events_with_flag_calls"]) is union_expected