: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(workflows): remove workflows-audience-query-v2 flag (#114339)
Meikel Ratzd5d2927949c6
diff --git a/.agents/skills/optimizing-clickhouse-and-hogql-queries/references/learnings.md b/.agents/skills/optimizing-clickhouse-and-hogql-queries/references/learnings.mdindex 1bc7a465a79c..13057f7e751a 100644--- a/.agents/skills/optimizing-clickhouse-and-hogql-queries/references/learnings.md+++ b/.agents/skills/optimizing-clickhouse-and-hogql-queries/references/learnings.md@@ -249,4 +249,4 @@ Traps we hit:- `count(DISTINCT id)` on the persons table is a waste when nothing joins: the dedup already returns one row per person, plain `count()` is the same result without holding every id. But a filter that adds a join needs the DISTINCT back, e.g. a `distinct_id` filter joins one row per alias and plain `count()` counts that person once per alias.- The `id IN (prefilter)` set the persons table builds stays in memory no matter what (it is a set, not a GROUP BY, so the spill setting can't touch it). ~1 GiB per ~6M matched ids. Sampling shrinks it; exact queries on huge broad audiences keep paying it, which is where precalculated audiences eventually win.-Applied in `products/workflows/backend/services/audience_v2.py` behind the `workflows-audience-query-v2` flag.+Applied in `products/workflows/backend/services/audience_v2.py`.diff --git a/products/feature_flags/backend/user_blast_radius.py b/products/feature_flags/backend/user_blast_radius.pyindex fc1a85735aa1..f48046332e49 100644--- a/products/feature_flags/backend/user_blast_radius.py+++ b/products/feature_flags/backend/user_blast_radius.py@@ -194,8 +194,7 @@ def get_person_blast_radius_v2(team: Team, feature_flag_condition: dict) -> BlasFlags-owned entry point for the sampled person count, behind flags-blast-radius-query-v2.The gate is applied by the caller, not inside get_user_blast_radius: workflows shares that- function and gates its own audience counts on workflows-audience-query-v2, so a gate in- there would move workflows counts outside the workflows rollout.+ function for group audience counts, so a gate in there would also change workflows counts."""with unevaluable_filters_as_validation_errors():cleaned_filter = replace_proxy_properties(team, feature_flag_condition)diff --git a/products/workflows/backend/services/audience_v2.py b/products/workflows/backend/services/audience_v2.pyindex 3b6e2592133f..dee8db07d648 100644--- a/products/workflows/backend/services/audience_v2.py+++ b/products/workflows/backend/services/audience_v2.py@@ -1,7 +1,5 @@from typing import Optional-import posthoganalytics-from posthog.hogql import astfrom posthog.hogql.context import HogQLContextfrom posthog.hogql.database.database import Database@@ -30,21 +28,9 @@ from products.workflows.backend.services.batch_audience import (email_dedupe_group_expr,)-AUDIENCE_QUERY_V2_FLAG = "workflows-audience-query-v2"-QUERY_TYPE = "workflows_audience_count_v2"-def use_audience_query_v2(team: Team) -> bool:- return bool(- posthoganalytics.feature_enabled(- AUDIENCE_QUERY_V2_FLAG,- str(team.uuid),- send_feature_flag_events=False,- )- )--def get_person_audience_count_v2(team: Team, filters: dict) -> BlastRadiusResult:"""Person-audience blast radius sized from a sample of the person keyspace.@@ -68,8 +54,8 @@ def get_dedupe_audience_count_v2(team: Team, filters: dict, dedupe_key: str) ->times more likely to land in the sample, and the estimate would drift back toward aperson count. Hashing the group gives every group the same chance."""- # Defence-in-depth mirror of get_batch_audience_count: a new supported key must be- # taught to this function too, instead of silently getting the email grouping.+ # Defence-in-depth against a new dedupe key slipping past the endpoint's allowlist: a new+ # supported key must be taught to this function too, instead of silently getting the email grouping.if dedupe_key != EMAIL_DEDUPE_KEY:raise ValueError(f"Unsupported dedupe_key: {dedupe_key!r} (supported: {SUPPORTED_DEDUPE_KEYS})")diff --git a/products/workflows/backend/services/batch_audience.py b/products/workflows/backend/services/batch_audience.pyindex fc7e9e670496..c2eead39cc71 100644--- a/products/workflows/backend/services/batch_audience.py+++ b/products/workflows/backend/services/batch_audience.py@@ -70,61 +70,6 @@ def get_batch_audience_person_ids(return [str(row[0]) for row in response.results] if response.results else []-def get_batch_audience_count(- team: Team,- filters: dict,- dedupe_key: str,-) -> int:- """- Count how many sends a batch workflow would produce with dedup applied — i.e. the- number of dedupe groups (unique emails, plus one group per email-less person).- Mirrors get_batch_audience_person_ids so the preview matches the actual audience.-- The count is exact up to uniqCombined's hash-table threshold and approximate above it,- so a very large audience can read a fraction of a percent off the delivered send count.- Nothing gates on this number: the confirm token signs the filters rather than the count,- and the batch trigger cap is applied by the resolver at dispatch.- """- # Defence-in-depth against a new dedupe key slipping past the endpoint's allowlist:- # if we ever add another supported key, this raise forces the caller to teach this- # function about it too, rather than silently returning the email-deduped count.- if dedupe_key == EMAIL_DEDUPE_KEY:- group_expr = email_dedupe_group_expr()- else:- raise ValueError(f"Unsupported dedupe_key: {dedupe_key!r} (supported: {SUPPORTED_DEDUPE_KEYS})")-- with unevaluable_filters_as_validation_errors():- cleaned_filter = replace_proxy_properties(team, filters)-- where_exprs: list[ast.Expr] = [- ast.CompareOperation(- op=ast.CompareOperationOp.Eq,- left=ast.Field(chain=["persons", "team_id"]),- right=ast.Constant(value=team.pk),- ),- property_to_expr(cleaned_filter, team, scope="person"),- ]-- # uniqCombined, not count(DISTINCT ...): the latter compiles to uniqExact, which holds- # every distinct email of the matching audience in memory and runs the query out of memory- # on large person tables. uniqCombined keeps an exact set below its threshold and switches- # to a fixed-size sketch above it, so the aggregate state stops growing with the audience.- # The persons expansion still holds one entry per matching person, in the id set it pushes- # the filter into and in the group-by that picks the latest version, so this drops one term- # from peak memory instead of making it flat.- select_query = ast.SelectQuery(- select=[ast.Call(name="uniqCombined", args=[group_expr])],- select_from=ast.JoinExpr(table=ast.Field(chain=["persons"])),- where=ast.And(exprs=where_exprs),- )-- tag_queries(product=Product.WORKFLOWS, feature=Feature.QUERY)- response = execute_hogql_query(query=select_query, team=team)-- # uniqCombined over a nullable expression returns NULL rather than 0 when no person matches.- return (response.results[0][0] if response.results else None) or 0--def email_dedupe_group_expr() -> ast.Expr:# Fields stay fully qualified so nothing resolves to an enclosing query's alias.return parse_expr(diff --git a/products/workflows/backend/services/blast_radius.py b/products/workflows/backend/services/blast_radius.pyindex bb9e19bf28a9..3565d7fb2985 100644--- a/products/workflows/backend/services/blast_radius.py+++ b/products/workflows/backend/services/blast_radius.py@@ -5,7 +5,7 @@ from posthog.models.property import GroupTypeIndexfrom posthog.models.team.team import Teamfrom products.feature_flags.backend.person_sampling import bounded_memory_settings-from products.feature_flags.backend.user_blast_radius import BlastRadiusResult, get_user_blast_radius+from products.feature_flags.backend.user_blast_radius import get_user_blast_radiusfrom products.workflows.backend.facade.contracts import AudiencePage, AudienceSizefrom products.workflows.backend.services.account_audience import (ACCOUNT_BATCH_SIZE,@@ -13,16 +13,8 @@ from products.workflows.backend.services.account_audience import (get_account_audience_page,get_account_group_type_name as _get_account_group_type_name,)-from products.workflows.backend.services.audience_v2 import (- get_dedupe_audience_count_v2,- get_person_audience_count_v2,- use_audience_query_v2,-)-from products.workflows.backend.services.batch_audience import (- audience_page_size,- get_batch_audience_count,- get_batch_audience_person_ids,-)+from products.workflows.backend.services.audience_v2 import get_dedupe_audience_count_v2, get_person_audience_count_v2+from products.workflows.backend.services.batch_audience import audience_page_size, get_batch_audience_person_idsfrom products.workflows.backend.utils.batch_trigger_limit import get_hogflow_batch_trigger_limit@@ -36,25 +28,17 @@ def get_audience_size() -> AudienceSize:team = Team.objects.get(id=team_id)# Preview matches the actual send: with dedup active, "affected" is the number of- # sends (unique emails + email-less persons), not the number of matching persons -- # the legacy person-count query is skipped entirely, "total" comes straight from- # the cached team-wide count it would have returned anyway. The applied key is- # echoed back so the frontend labels the count from the response instead of- # guessing whether the dedup actually ran.+ # sends (unique emails + email-less persons), not the number of matching persons.+ # The applied key is echoed back so the frontend labels the count from the response+ # instead of guessing whether the dedup actually ran.applied_dedupe_key = None- audience_v2 = group_type_index is None and use_audience_query_v2(team)- if dedupe_key is not None and group_type_index is None:- if audience_v2:- blast_radius = get_dedupe_audience_count_v2(team, filters, dedupe_key)- else:- total = team.persons_seen_so_far- affected = min(get_batch_audience_count(team, filters, dedupe_key), total)- blast_radius = BlastRadiusResult(affected=affected, total=total)+ if group_type_index is not None:+ blast_radius = get_user_blast_radius(team, filters, group_type_index)+ elif dedupe_key is not None:+ blast_radius = get_dedupe_audience_count_v2(team, filters, dedupe_key)applied_dedupe_key = dedupe_key- elif audience_v2:- blast_radius = get_person_audience_count_v2(team, filters)else:- blast_radius = get_user_blast_radius(team, filters, group_type_index)+ blast_radius = get_person_audience_count_v2(team, filters)return AudienceSize(affected=blast_radius.affected,@@ -83,9 +67,7 @@ def get_audience_person_page(dedupe_key: str | None,) -> AudiencePage:team = Team.objects.get(id=team_id)- enumeration_settings = (- bounded_memory_settings() if group_type_index is None and use_audience_query_v2(team) else None- )+ enumeration_settings = bounded_memory_settings() if group_type_index is None else Noneids = get_batch_audience_person_ids(team, filters, group_type_index, cursor, dedupe_key=dedupe_key, settings=enumeration_settings)diff --git a/products/workflows/backend/test/test_audience_v2.py b/products/workflows/backend/test/test_audience_v2.pyindex 1a95a8b99339..f56ae5594ec1 100644--- a/products/workflows/backend/test/test_audience_v2.py+++ b/products/workflows/backend/test/test_audience_v2.py@@ -1,3 +1,4 @@+import pytestfrom posthog.test.base import BaseTest, ClickhouseTestMixin, _create_person, flush_persons_and_eventsfrom unittest.mock import patch@@ -11,7 +12,7 @@ from products.workflows.backend.services.audience_v2 import (get_dedupe_audience_count_v2,get_person_audience_count_v2,)-from products.workflows.backend.services.batch_audience import get_batch_audience_count+from products.workflows.backend.services.batch_audience import get_batch_audience_person_idsFILTERS = {"properties": [{"key": "subscribed", "type": "person", "value": ["true"], "operator": "exact"}]}@@ -142,7 +143,7 @@ class TestAudienceV2(ClickhouseTestMixin, BaseTest):assert (result.affected, result.total) == (3, 6)- def test_dedupe_count_matches_v1(self):+ def test_dedupe_count_matches_deduped_audience_size(self):# Duplicate emails (case/whitespace variants) collapse to one send group; persons# without an email keep their own group. Small data exercises the exact fallback.@@ -155,16 +156,20 @@ class TestAudienceV2(ClickhouseTestMixin, BaseTest):result = get_dedupe_audience_count_v2(self.team, FILTERS, "email")- assert result.affected == get_batch_audience_count(self.team, FILTERS, dedupe_key="email") == 4+ assert result.affected == len(get_batch_audience_person_ids(self.team, FILTERS, dedupe_key="email")) == 4assert result.total == 5+ def test_dedupe_count_rejects_unsupported_dedupe_key(self):+ with pytest.raises(ValueError, match="Unsupported dedupe_key"):+ get_dedupe_audience_count_v2(self.team, FILTERS, "sms")+def test_dedupe_count_is_zero_when_no_person_matches(self):_create_person(team=self.team, distinct_ids=["user-1"], properties={"subscribed": "false", "email": "[email protected]"})flush_persons_and_events()result = get_dedupe_audience_count_v2(self.team, FILTERS, "email")- assert result.affected == get_batch_audience_count(self.team, FILTERS, dedupe_key="email") == 0+ assert result.affected == 0def test_sampled_dedupe_count_extrapolates_by_modulus(self):for i in range(3):diff --git a/products/workflows/backend/test/test_batch_audience.py b/products/workflows/backend/test/test_batch_audience.pyindex aaf61f9c0f0f..81f388d35b2d 100644--- a/products/workflows/backend/test/test_batch_audience.py+++ b/products/workflows/backend/test/test_batch_audience.py@@ -1,4 +1,3 @@-import pytestfrom posthog.test.base import BaseTest, ClickhouseTestMixin, _create_person, flush_persons_and_eventsfrom django.test import override_settings@@ -6,11 +5,7 @@ from django.test import override_settingsfrom parameterized import parameterizedfrom products.feature_flags.backend.user_blast_radius import PERSON_BATCH_SIZE, get_user_blast_radius_persons-from products.workflows.backend.services.batch_audience import (- audience_page_size,- get_batch_audience_count,- get_batch_audience_person_ids,-)+from products.workflows.backend.services.batch_audience import audience_page_size, get_batch_audience_person_idsFILTERS = {"properties": [{"key": "subscribed", "type": "person", "value": ["true"], "operator": "exact"}]}@@ -47,20 +42,6 @@ class TestBatchAudience(ClickhouseTestMixin, BaseTest):assert sorted(result) == [_uuid(i) for i in expected_indices]- def test_count_matches_deduped_audience_size(self):- self._create_audience(["[email protected]", " [email protected] ", "[email protected]", None, ""])-- count = get_batch_audience_count(self.team, FILTERS, dedupe_key="email")-- assert count == len(get_batch_audience_person_ids(self.team, FILTERS, dedupe_key="email")) == 4-- def test_count_rejects_unsupported_dedupe_key(self):- # Defence-in-depth: the endpoint's serializer allowlist is the primary gate, but this- # raise forces a future maintainer adding a new supported key to teach the count- # function about it too, rather than silently returning email-deduped counts.- with pytest.raises(ValueError, match="Unsupported dedupe_key"):- get_batch_audience_count(self.team, FILTERS, dedupe_key="sms")-def test_audience_without_dedupe_matches_legacy_query(self):diff --git a/products/workflows/backend/tests/api/test_hog_flow.py b/products/workflows/backend/tests/api/test_hog_flow.pyindex 1824dcba8dbe..721208b455eb 100644--- a/products/workflows/backend/tests/api/test_hog_flow.py+++ b/products/workflows/backend/tests/api/test_hog_flow.py@@ -7,7 +7,7 @@ from typing import Any, Optionalfrom uuid import uuid4from posthog.test.base import APIBaseTest, ClickhouseTestMixin-from unittest.mock import ANY, MagicMock, PropertyMock, patch+from unittest.mock import ANY, MagicMock, patchfrom django.core.management import call_commandfrom django.db import connection@@ -3739,21 +3739,21 @@ class TestHogFlowAPI(APIBaseTest):def test_hog_flow_user_blast_radius_requires_filters(self):with patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius:+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count:response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius", {})assert response.status_code == 400, response.json()assert response.json().get("attr") == "filters"- mock_get_user_blast_radius.assert_not_called()+ mock_get_person_audience_count.assert_not_called()def test_hog_flow_user_blast_radius_returns_counts(self):with patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius:+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count:from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415- mock_get_user_blast_radius.return_value = BlastRadiusResult(affected=4, total=10)+ mock_get_person_audience_count.return_value = BlastRadiusResult(affected=4, total=10)response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",@@ -3767,9 +3767,8 @@ class TestHogFlowAPI(APIBaseTest):assert "limit" in bodyassert body["limit"] > 0- def test_hog_flow_user_blast_radius_routes_to_v2_when_flag_enabled(self):+ def test_hog_flow_user_blast_radius_routes_by_audience_kind(self):with (- patch("products.workflows.backend.services.blast_radius.use_audience_query_v2", return_value=True),patch("products.workflows.backend.services.blast_radius.get_person_audience_count_v2") as mock_v2,patch("products.workflows.backend.services.blast_radius.get_dedupe_audience_count_v2") as mock_dedupe_v2,patch("products.workflows.backend.services.blast_radius.get_user_blast_radius") as mock_v1,@@ -3803,8 +3802,7 @@ class TestHogFlowAPI(APIBaseTest):mock_dedupe_v2.assert_called_once_with(self.team, {"properties": []}, "email")mock_v1.assert_not_called()- # Group audiences stay on the v1 query even with the flag on: the v2- # sampled count only covers person audiences.+ # Group audiences stay on the exact query: the sampled count only covers person audiences.mock_v1.return_value = BlastRadiusResult(affected=1, total=2)response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",@@ -3815,25 +3813,6 @@ class TestHogFlowAPI(APIBaseTest):mock_v1.assert_called_once()mock_v2.assert_called_once()- def test_hog_flow_user_blast_radius_ignores_the_feature_flags_gate(self):- # Workflows counts follow workflows-audience-query-v2 only. The flags product gates its- # own sampled count on a separate flag, and that gate must not reach this endpoint: a- # sampled count here would move workflows numbers outside the workflows rollout.- # The routing test above mocks get_user_blast_radius away, so it cannot see this.- with (- patch("products.workflows.backend.services.blast_radius.use_audience_query_v2", return_value=False),- patch("products.feature_flags.backend.user_blast_radius.use_blast_radius_query_v2", return_value=True),- patch("products.feature_flags.backend.user_blast_radius.sampled_person_blast_radius") as mock_sampled,- ):- response = self.client.post(- f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",- {"filters": {"properties": []}},- )-- assert response.status_code == 200, response.json()- assert response.json()["total"] == self.team.persons_seen_so_far- mock_sampled.assert_not_called()-@override_settings(HOGFLOW_BATCH_TRIGGER_LIMIT=5000,HOGFLOW_BATCH_TRIGGER_LIMIT_ELEVATED=50000,@@ -3841,11 +3820,11 @@ class TestHogFlowAPI(APIBaseTest):)def test_hog_flow_user_blast_radius_returns_default_limit_for_unlisted_team(self):with patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius:+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count:from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415- mock_get_user_blast_radius.return_value = BlastRadiusResult(affected=0, total=0)+ mock_get_person_audience_count.return_value = BlastRadiusResult(affected=0, total=0)response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",{"filters": {"properties": []}},@@ -3862,12 +3841,12 @@ class TestHogFlowAPI(APIBaseTest):HOGFLOW_BATCH_TRIGGER_ELEVATED_TEAM_IDS={self.team.id},),patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius,+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count,):from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415- mock_get_user_blast_radius.return_value = BlastRadiusResult(affected=0, total=0)+ mock_get_person_audience_count.return_value = BlastRadiusResult(affected=0, total=0)response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",{"filters": {"properties": []}},@@ -3900,11 +3879,11 @@ class TestHogFlowAPI(APIBaseTest):scopes=["hog_flow:read", "person:read"],)with patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius:+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count:from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415- mock_get_user_blast_radius.return_value = BlastRadiusResult(affected=1, total=10)+ mock_get_person_audience_count.return_value = BlastRadiusResult(affected=1, total=10)response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",{"filters": {"properties": []}},@@ -3932,8 +3911,8 @@ class TestHogFlowAPI(APIBaseTest):# Feature flags can't be sized as a static batch audience — reject with a clean 400 before# the condition reaches the blast-radius query (where it would otherwise 500).with patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius:+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count:response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",{"filters": {"properties": properties}},@@ -3941,13 +3920,13 @@ class TestHogFlowAPI(APIBaseTest):assert response.status_code == 400, response.json()assert "Feature flags can't be used as a batch audience condition" in response.json().get("detail", "")- mock_get_user_blast_radius.assert_not_called()+ mock_get_person_audience_count.assert_not_called()@override_settings(INTERNAL_API_SECRET="test-secret-123")def test_internal_user_blast_radius_rejects_flag_condition(self):with patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius"- ) as mock_get_user_blast_radius:+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2"+ ) as mock_get_person_audience_count:response = self.client.post(f"/api/projects/{self.team.id}/internal/hog_flows/user_blast_radius",{"filters": {"properties": [{"key": "my-other-flag", "type": "flag", "value": "true"}]}},@@ -3957,7 +3936,7 @@ class TestHogFlowAPI(APIBaseTest):assert response.status_code == 400, response.json()assert "Feature flags can't be used as a batch audience condition" in response.json().get("error", "")- mock_get_user_blast_radius.assert_not_called()+ mock_get_person_audience_count.assert_not_called()@override_settings(INTERNAL_API_SECRET="test-secret-123")def test_internal_user_blast_radius_persons_rejects_flag_condition(self):@@ -3975,21 +3954,12 @@ class TestHogFlowAPI(APIBaseTest):assert "Feature flags can't be used as a batch audience condition" in response.json().get("error", "")mock_get_batch_audience_person_ids.assert_not_called()- @parameterized.expand(- [- ("gate off", False, None),- ("gate on", True, "throw"),- ]- )@override_settings(INTERNAL_API_SECRET="test-secret-123")- def test_internal_user_blast_radius_persons_uses_workflows_query(self, _name, gate_on, expected_timeout_mode):- with (- patch("products.workflows.backend.services.blast_radius.use_audience_query_v2", return_value=gate_on),- patch(- "products.workflows.backend.services.blast_radius.get_batch_audience_person_ids",- return_value=["id-1"],- ) as mock_workflows_query,- ):+ def test_internal_user_blast_radius_persons_uses_workflows_query(self):+ with patch(+ "products.workflows.backend.services.blast_radius.get_batch_audience_person_ids",+ return_value=["id-1"],+ ) as mock_workflows_query:response = self.client.post(f"/api/projects/{self.team.id}/internal/hog_flows/user_blast_radius_persons",{"filters": {"properties": []}, "dedupe_key": "email"},@@ -4002,10 +3972,10 @@ class TestHogFlowAPI(APIBaseTest):mock_workflows_query.assert_called_once_with(self.team, {"properties": []}, None, None, dedupe_key="email", settings=ANY)- # Gated on, a timed-out page has to raise instead of coming back short. A short page- # reads as the end of the audience, so the batch send skips every recipient after it.+ # A timed-out page has to raise instead of coming back short. A short page reads as+ # the end of the audience, so the batch send skips every recipient after it.passed_settings = mock_workflows_query.call_args.kwargs["settings"]- assert getattr(passed_settings, "timeout_overflow_mode", None) == expected_timeout_mode+ assert getattr(passed_settings, "timeout_overflow_mode", None) == "throw"@parameterized.expand([@@ -4022,17 +3992,13 @@ class TestHogFlowAPI(APIBaseTest):with (patch(- "products.workflows.backend.services.blast_radius.get_user_blast_radius",+ "products.workflows.backend.services.blast_radius.get_person_audience_count_v2",return_value=BlastRadiusResult(affected=5, total=10),- ) as mock_legacy_count,+ ) as mock_person_count,patch(- "products.workflows.backend.services.blast_radius.get_batch_audience_count", return_value=3+ "products.workflows.backend.services.blast_radius.get_dedupe_audience_count_v2",+ return_value=BlastRadiusResult(affected=3, total=10),) as mock_deduped_count,- patch(- "posthog.models.team.team.Team.persons_seen_so_far",- new_callable=PropertyMock,- return_value=10,- ),):response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",@@ -4047,10 +4013,10 @@ class TestHogFlowAPI(APIBaseTest):if dedupe_key is not None:# The person-count query is skipped — only the deduped count runsmock_deduped_count.assert_called_once_with(self.team, {"properties": []}, "email")- mock_legacy_count.assert_not_called()+ mock_person_count.assert_not_called()else:mock_deduped_count.assert_not_called()- mock_legacy_count.assert_called_once()+ mock_person_count.assert_called_once()def test_user_blast_radius_rejects_unsupported_dedupe_key(self):response = self.client.post(