: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
refactor(insights): drop the action and filter fields from results (#126129)
Thomas Obermüller406b2b8fa0f9
diff --git a/ee/hogai/context/insight/format/test/test_format_query_results_for_llm.py b/ee/hogai/context/insight/format/test/test_format_query_results_for_llm.pyindex 564fdc523c7b..2cad3e9263e5 100644--- a/ee/hogai/context/insight/format/test/test_format_query_results_for_llm.py+++ b/ee/hogai/context/insight/format/test/test_format_query_results_for_llm.py@@ -81,7 +81,7 @@ class TestFormatQueryResultsForLlm(TestCase):"labels": ["20-Jan"],"label": "new","status": "new",- "action": {},+ "order": 0,},{"data": [-5.0],@@ -89,7 +89,7 @@ class TestFormatQueryResultsForLlm(TestCase):"labels": ["20-Jan"],"label": "dormant","status": "dormant",- "action": {},+ "order": 0,},],},@@ -106,7 +106,7 @@ class TestFormatQueryResultsForLlm(TestCase):"days": [1, 2],"labels": ["1 day", "2 days"],"label": "$pageview",- "action": {"custom_name": None},+ "order": 0,},],},diff --git a/ee/hogai/context/insight/test/test_query_executor.py b/ee/hogai/context/insight/test/test_query_executor.pyindex b7a06276bc5c..fdc57d0bdf32 100644--- a/ee/hogai/context/insight/test/test_query_executor.py+++ b/ee/hogai/context/insight/test/test_query_executor.py@@ -816,13 +816,7 @@ class TestAssistantQueryExecutor(NonAtomicBaseTest):"days": [1, 2, 3],"labels": ["1 day", "2 days", "3 days"],"label": "$pageview",- "action": {- "order": 0,- "type": "events",- "name": "$pageview",- "id": "$pageview",- "custom_name": None,- },+ "order": 0,}]}@@ -840,7 +834,7 @@ class TestAssistantQueryExecutor(NonAtomicBaseTest):"labels": ["20-Jan", "21-Jan"],"label": "$pageview - new","status": "new",- "action": {},+ "order": 0,},{"data": [120.0, 105.0],@@ -848,7 +842,7 @@ class TestAssistantQueryExecutor(NonAtomicBaseTest):"labels": ["20-Jan", "21-Jan"],"label": "$pageview - returning","status": "returning",- "action": {},+ "order": 0,},{"data": [15.0, 22.0],@@ -856,7 +850,7 @@ class TestAssistantQueryExecutor(NonAtomicBaseTest):"labels": ["20-Jan", "21-Jan"],"label": "$pageview - resurrecting","status": "resurrecting",- "action": {},+ "order": 0,},{"data": [-30.0, -45.0],@@ -864,7 +858,7 @@ class TestAssistantQueryExecutor(NonAtomicBaseTest):"labels": ["20-Jan", "21-Jan"],"label": "$pageview - dormant","status": "dormant",- "action": {},+ "order": 0,},]}diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 51c3028dac66..7c3eb5d53944 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -60102,7 +60102,8 @@"additionalProperties": false,"properties": {"action": {- "$ref": "#/definitions/WebVitalsItemAction"+ "$ref": "#/definitions/WebVitalsItemAction",+ "deprecated": "The runner no longer writes this field. Only responses cached before 2026-10-30 carry it, and it goes\nonce those entries expire. Read the series from the query at `order` instead."},"data": {"items": {@@ -60121,7 +60122,7 @@"description": "The index of the row's series in the query."}},- "required": ["data", "days", "order", "action"],+ "required": ["data", "days", "order"],"type": "object"},"WebVitalsItemAction": {diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 58e609e05182..60a09416ea51 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -4443,7 +4443,11 @@ export interface WebVitalsItem {days: string[]/** The index of the row's series in the query. */order: integer- action: WebVitalsItemAction+ /**+ * @deprecated The runner no longer writes this field. Only responses cached before 2026-10-30 carry it, and it goes+ * once those entries expire. Read the series from the query at `order` instead.+ */+ action?: WebVitalsItemAction}export interface WebVitalsQueryResponse extends AnalyticsQueryResponseBase {diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsxindex 67304a957a7a..73f7edb31451 100644--- a/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsx+++ b/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsx@@ -39,13 +39,11 @@ const webVitalsQuery: WebVitalsQuery = {const webVitalsRows: WebVitalsItem[] = [{- action: { custom_name: 'LCP', math: PropertyMathType.P90 },order: 0,days: ['2026-09-01', '2026-09-02'],data: [2400, 2600],},{- action: { custom_name: 'CLS', math: PropertyMathType.P90 },order: 1,days: ['2026-09-01', '2026-09-02'],data: [0.04, 0.05],diff --git a/posthog/api/test/test_web_vitals.py b/posthog/api/test/test_web_vitals.pyindex 49bba04dc434..c98884fd5a67 100644--- a/posthog/api/test/test_web_vitals.py+++ b/posthog/api/test/test_web_vitals.py@@ -8,22 +8,12 @@ from posthog.models.utils import uuid7class TestWebVitalsAPI(ClickhouseTestMixin, APIBaseTest):def assert_values(self, results, expected_values):- # Verify that all web vitals metrics are present in the response- metrics = [result["action"]["custom_name"] for result in results]- self.assertCountEqual(metrics, ["INP", "LCP", "CLS", "FCP"])+ # The toolbar maps a row's `order` to a metric by this list, its WEB_VITALS_SERIES_ORDER+ metrics = ["INP", "LCP", "CLS", "FCP"]+ self.assertCountEqual([result["order"] for result in results], range(len(metrics)))- # Verify the p90 values of the metricsfor result in results:- custom_name = result["action"]["custom_name"]-- if custom_name == "INP":- self.assertEqual(result["data"][-1], expected_values["INP"])- elif custom_name == "LCP":- self.assertEqual(result["data"][-1], expected_values["LCP"])- elif custom_name == "CLS":- self.assertEqual(result["data"][-1], expected_values["CLS"])- elif custom_name == "FCP":- self.assertEqual(result["data"][-1], expected_values["FCP"])+ self.assertEqual(result["data"][-1], expected_values[metrics[result["order"]]])def test_web_vitals_missing_pathname(self):response = self.client.get(f"/api/environments/{self.team.pk}/web_vitals/")diff --git a/posthog/caching/test/test_calculate_results.py b/posthog/caching/test/test_calculate_results.pyindex be0d8719abcc..5b3f9cfa03b8 100644--- a/posthog/caching/test/test_calculate_results.py+++ b/posthog/caching/test/test_calculate_results.py@@ -93,7 +93,7 @@ class TestCalculateForQueryBasedInsight(BaseTest):assert insight_result.result == "ERROR: nope"def test_plain_dict_results_pass_through_without_copying(self):- series = {"data": [1.0, 2.0], "label": "series", "action": {"order": 0}}+ series = {"data": [1.0, 2.0], "label": "series", "order": 0}response = CachedTrendsQueryResponse(results=[series],is_cached=True,diff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.pyindex cc9cdb59c186..0252ec88f89d 100644--- a/posthog/hogql_queries/query_runner.py+++ b/posthog/hogql_queries/query_runner.py@@ -1894,19 +1894,6 @@ SourceT = TypeVar("SourceT", bound=BaseModel)_RunMethod = TypeVar("_RunMethod", bound=Callable[..., Any])-def resolve_series_custom_name(series: Any, raw_label: str | None) -> str | None:- # A series' display override for legends and tooltips. `custom_name` is set by the in-app- # "Rename graph series" modal; a `name` that differs from the raw event/action label is a rename- # applied via the query editor or API. Either should win over the raw event name.- custom_name = getattr(series, "custom_name", None)- if custom_name:- return custom_name- name = getattr(series, "name", None)- if name and name != raw_label:- return name- return None--def query_node_modifiers(query: BaseModel) -> Optional[HogQLQueryModifiers]:# A wrapper query (actors, correlation, actor options) runs its source insight, so it reads the same# events table and person data as that insight. Modifiers set on the wrapper itself take precedence.@@ -2143,10 +2130,10 @@ class QueryRunner(ABC, Generic[Q, R, CR]):)def _query_has_series_custom_names(self) -> bool:- series = getattr(self.query, "series", None)- if not series:+ # apply_series_custom_names patches only funnel steps, so another query kind has nothing to patch+ if not isinstance(self.query, FunnelsQuery):return False- return any(getattr(s, "custom_name", None) is not None for s in series)+ return any(s.custom_name is not None for s in self.query.series)@propertydef _limit_context_aliased_for_cache(self) -> LimitContext:@@ -2311,7 +2298,6 @@ class QueryRunner(ABC, Generic[Q, R, CR]):)if isinstance(cached_response, CachedResponse):- self._fill_cached_result_order(cached_response)self._fill_action_names(cached_response)# Apply current query's custom_name values to cached response# (custom_name is excluded from cache key, so cached values may be stale)@@ -3331,30 +3317,10 @@ class QueryRunner(ABC, Generic[Q, R, CR]):Tuple of (patched_response, was_modified) - was_modified is True if anycustom_name values were actually changed."""- if isinstance(self.query, TrendsQuery | StickinessQuery | LifecycleQuery):- return self._apply_trends_custom_names(cached_response)- elif isinstance(self.query, FunnelsQuery):+ if isinstance(self.query, FunnelsQuery):return self._apply_funnels_custom_names(cached_response)return cached_response, False- def _fill_cached_result_order(self, cached_response: CR) -> None:- """Copy `action.order` to the top level of cached trends, stickiness and lifecycle rows that lack it.-- Stickiness, lifecycle and calendar heatmap rows cached before those runners emitted a top-level `order`- carry it only on `action`, and readers take a row's series from the top-level `order`.- """- if not isinstance(self.query, TrendsQuery | StickinessQuery | LifecycleQuery):- return- results = getattr(cached_response, "results", None)- if not isinstance(results, list):- return- for result in results:- if not isinstance(result, dict) or "order" in result:- continue- action = result.get("action")- if isinstance(action, dict) and isinstance(action.get("order"), int):- result["order"] = action["order"]-def _fill_action_names(self, response: object) -> None:"""Set `action_names` on a trends, stickiness or lifecycle response that lacks it.@@ -3374,44 +3340,6 @@ class QueryRunner(ABC, Generic[Q, R, CR]):if response.action_names is None:response.action_names = get_response_action_names(self.team, self.query.model_dump(mode="json"))- def _apply_trends_custom_names(self, cached_response: CR) -> tuple[CR, bool]:- """Apply custom_name values to TrendsQuery results (nested under action)."""- series = getattr(self.query, "series", None)- if not series:- return cached_response, False-- results = getattr(cached_response, "results", None)- if not results or not isinstance(results, list):- return cached_response, False-- series_by_order = dict(enumerate(series))- # Only TrendsQuery surfaces a `name`-based rename into custom_name on the fresh path (see- # TrendsQueryRunner's use of resolve_series_custom_name). Stickiness/lifecycle use custom_name- # only, so honoring `name` here would desync their cached responses from a fresh computation.- honor_name = isinstance(self.query, TrendsQuery)-- was_modified = False- for result in results:- if not isinstance(result, dict):- continue- action = result.get("action")- if not isinstance(action, dict):- continue- order = action.get("order")- if order is None or order not in series_by_order:- continue- s = series_by_order[order]- if honor_name:- # The cached action's `name` holds the raw event/action label (`series_label or "All events"`).- new_name = resolve_series_custom_name(s, action.get("name"))- else:- new_name = getattr(s, "custom_name", None)- if action.get("custom_name") != new_name:- action["custom_name"] = new_name- was_modified = True-- return cached_response, was_modified-def _apply_funnels_custom_names(self, cached_response: CR) -> tuple[CR, bool]:"""Apply custom_name values to FunnelsQuery results (top-level of step dict).diff --git a/posthog/hogql_queries/test/test_query_runner.py b/posthog/hogql_queries/test/test_query_runner.pyindex 4aa6d28df76e..9b3a2f2a7077 100644--- a/posthog/hogql_queries/test/test_query_runner.py+++ b/posthog/hogql_queries/test/test_query_runner.py@@ -1752,167 +1752,6 @@ class TestSeriesCustomNameCaching(BaseTest):self.assertNotEqual(cache_key_a, cache_key_b)-class TestApplySeriesCustomNames(BaseTest):- @parameterized.expand(- [- (- "applies_custom_name_to_single_series",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="My Custom Name")]),- [{"action": {"order": 0, "custom_name": None}, "data": [1, 2, 3]}],- [{"action": {"order": 0, "custom_name": "My Custom Name"}, "data": [1, 2, 3]}],- ),- (- "applies_custom_names_to_multiple_series",- TrendsQuery(- series=[- EventsNode(event="$pageview", custom_name="Series A"),- EventsNode(event="$autocapture", custom_name="Series B"),- ]- ),- [- {"action": {"order": 0, "custom_name": "Old A"}, "data": [1]},- {"action": {"order": 1, "custom_name": "Old B"}, "data": [2]},- ],- [- {"action": {"order": 0, "custom_name": "Series A"}, "data": [1]},- {"action": {"order": 1, "custom_name": "Series B"}, "data": [2]},- ],- ),- (- "handles_breakdown_results_sharing_same_order",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="Renamed")]),- [- {"action": {"order": 0, "custom_name": None}, "breakdown_value": "Chrome"},- {"action": {"order": 0, "custom_name": None}, "breakdown_value": "Firefox"},- ],- [- {"action": {"order": 0, "custom_name": "Renamed"}, "breakdown_value": "Chrome"},- {"action": {"order": 0, "custom_name": "Renamed"}, "breakdown_value": "Firefox"},- ],- ),- (- "sets_none_when_custom_name_removed",- TrendsQuery(series=[EventsNode(event="$pageview")]),- [{"action": {"order": 0, "custom_name": "Had Name"}, "data": [1]}],- [{"action": {"order": 0, "custom_name": None}, "data": [1]}],- ),- (- # Guards the Greptile P1: a `name`-based rename (set via query editor / API, not the- # modal) must survive cache normalization, not revert to the raw event name.- "applies_name_based_rename_from_cache",- TrendsQuery(series=[EventsNode(event="$pageview", name="Renamed")]),- [{"action": {"order": 0, "name": "$pageview", "custom_name": None}, "data": [1]}],- [{"action": {"order": 0, "name": "$pageview", "custom_name": "Renamed"}, "data": [1]}],- ),- (- "name_echoing_the_event_is_not_a_rename",- TrendsQuery(series=[EventsNode(event="$pageview", name="$pageview")]),- [{"action": {"order": 0, "name": "$pageview", "custom_name": None}, "data": [1]}],- [{"action": {"order": 0, "name": "$pageview", "custom_name": None}, "data": [1]}],- ),- (- "skips_results_without_action",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="Name")]),- [{"action": None, "data": [1]}, {"data": [2]}],- [{"action": None, "data": [1]}, {"data": [2]}],- ),- (- "skips_results_with_unknown_order",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="Name")]),- [{"action": {"order": 99, "custom_name": "Unknown"}, "data": [1]}],- [{"action": {"order": 99, "custom_name": "Unknown"}, "data": [1]}],- ),- ]- )- def test_apply_series_custom_names(- self,- _name: str,- query: TrendsQuery,- cached_results: list[dict],- expected_results: list[dict],- ):- from posthog.schema import CachedTrendsQueryResponse-- runner = TrendsQueryRunner(query=query, team=self.team)-- cached_response = CachedTrendsQueryResponse(- results=cached_results,- is_cached=True,- last_refresh=datetime.now(UTC),- next_allowed_client_refresh=datetime.now(UTC),- cache_key="test_key",- timezone="UTC",- )-- patched_response, was_modified = runner.apply_series_custom_names(cached_response)-- self.assertEqual(patched_response.results, expected_results)-- @parameterized.expand(- [- (- "modified_when_name_changes",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="New Name")]),- [{"action": {"order": 0, "custom_name": "Old Name"}, "data": [1]}],- True,- ),- (- "modified_when_name_added",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="New Name")]),- [{"action": {"order": 0, "custom_name": None}, "data": [1]}],- True,- ),- (- "modified_when_name_removed",- TrendsQuery(series=[EventsNode(event="$pageview")]),- [{"action": {"order": 0, "custom_name": "Had Name"}, "data": [1]}],- True,- ),- (- "not_modified_when_names_match",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="Same Name")]),- [{"action": {"order": 0, "custom_name": "Same Name"}, "data": [1]}],- False,- ),- (- "not_modified_when_both_none",- TrendsQuery(series=[EventsNode(event="$pageview")]),- [{"action": {"order": 0, "custom_name": None}, "data": [1]}],- False,- ),- (- "not_modified_when_no_matching_orders",- TrendsQuery(series=[EventsNode(event="$pageview", custom_name="Name")]),- [{"action": {"order": 99, "custom_name": "Other"}, "data": [1]}],- False,- ),- ]- )- def test_was_modified_flag(- self,- _name: str,- query: TrendsQuery,- cached_results: list[dict],- expect_modified: bool,- ):- from posthog.schema import CachedTrendsQueryResponse-- runner = TrendsQueryRunner(query=query, team=self.team)-- cached_response = CachedTrendsQueryResponse(- results=cached_results,- is_cached=True,- last_refresh=datetime.now(UTC),- next_allowed_client_refresh=datetime.now(UTC),- cache_key="test_key",- timezone="UTC",- )-- _, was_modified = runner.apply_series_custom_names(cached_response)-- self.assertEqual(was_modified, expect_modified)--class TestSharedInsightsExecutionMode(BaseTest):@parameterized.expand([diff --git a/posthog/query_cache/serialization.py b/posthog/query_cache/serialization.pyindex cef92e4f4a24..86afcbf729ea 100644--- a/posthog/query_cache/serialization.py+++ b/posthog/query_cache/serialization.py@@ -42,12 +42,7 @@ class CachedEntry:def _item_has_custom_name(item: Any) -> bool:- if not isinstance(item, dict):- return False- if item.get("custom_name") is not None:- return True- action = item.get("action")- return isinstance(action, dict) and action.get("custom_name") is not None+ return isinstance(item, dict) and item.get("custom_name") is not Nonedef results_have_custom_names(results: list) -> bool:diff --git a/posthog/schema.py b/posthog/schema.pyindex 0eeb559c34ff..93f34619f0c0 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -27491,7 +27491,7 @@ class WebVitalsItem(BaseModel):model_config = ConfigDict(extra="forbid",)- action: WebVitalsItemAction+ action: WebVitalsItemAction | None = Nonedata: list[float]days: list[str]order: int = Field(..., description="The index of the row's series in the query.")diff --git a/posthog/tasks/alerts/test/test_detector_breakdowns.py b/posthog/tasks/alerts/test/test_detector_breakdowns.pyindex 4292476367aa..b482f28dd519 100644--- a/posthog/tasks/alerts/test/test_detector_breakdowns.py+++ b/posthog/tasks/alerts/test/test_detector_breakdowns.py@@ -35,7 +35,6 @@ from products.product_analytics.backend.facade.models import Insightdef _make_trend_result(label: str, data: list[float], breakdown_value: str = "") -> dict[str, Any]:days = [f"2024-06-{i + 1:02d}" for i in range(len(data))]return {- "action": {},"actions": [],"count": sum(data),"data": data,@@ -49,7 +48,6 @@ def _make_trend_result(label: str, data: list[float], breakdown_value: str = "")"compare": False,"persons_urls": [],"persons": {},- "filter": {},}diff --git a/products/alerts/backend/tests/api/test_alert.py b/products/alerts/backend/tests/api/test_alert.pyindex 4a5c237113ca..fdc74e6ecfe5 100644--- a/products/alerts/backend/tests/api/test_alert.py+++ b/products/alerts/backend/tests/api/test_alert.py@@ -1772,7 +1772,6 @@ class TestAlertSimulate(TrendsInsightAPITest):"days": [f"2024-01-{i:02d}" for i in range(1, 36)],"labels": [f"2024-01-{i:02d}" for i in range(1, 36)],"label": "pageview",- "action": {"name": "pageview"},"actions": [],"count": 35,"breakdown_value": "",@@ -1781,7 +1780,6 @@ class TestAlertSimulate(TrendsInsightAPITest):"compare": False,"persons_urls": [],"persons": {},- "filter": {},}])@@ -1941,7 +1939,6 @@ class TestAlertSimulate(TrendsInsightAPITest):"days": [f"2024-01-{i:02d}" for i in range(1, 36)],"labels": [f"2024-01-{i:02d}" for i in range(1, 36)],"label": "pageview",- "action": {"name": "pageview"},"actions": [],"count": 35,"breakdown_value": "",@@ -1950,7 +1947,6 @@ class TestAlertSimulate(TrendsInsightAPITest):"compare": False,"persons_urls": [],"persons": {},- "filter": {},}])@@ -3329,7 +3325,6 @@ class TestLLMDetectorValidation(TrendsInsightAPITest):"days": dates,"labels": dates,"label": "pageview",- "action": {"name": "pageview"},"actions": [],"count": 7,}diff --git a/products/endpoints/backend/tests/test_insight_response_parity.py b/products/endpoints/backend/tests/test_insight_response_parity.pyindex 9e53b84d0d71..97699e8d9cbe 100644--- a/products/endpoints/backend/tests/test_insight_response_parity.py+++ b/products/endpoints/backend/tests/test_insight_response_parity.py@@ -44,7 +44,7 @@ from products.warehouse_sources.backend.facade.models import DataWarehouseTablepytestmark = [pytest.mark.django_db]# Fields that every TrendsQuery result dict must have-TRENDS_REQUIRED_FIELDS = {"data", "labels", "days", "count", "label", "action"}+TRENDS_REQUIRED_FIELDS = {"data", "labels", "days", "count", "label", "order"}class TestInsightResponseParity(ClickhouseTestMixin, APIBaseTest):diff --git a/products/model_crossing_uses_baseline.txt b/products/model_crossing_uses_baseline.txtindex 7d961e0d9cbd..6bb55fa7882e 100644--- a/products/model_crossing_uses_baseline.txt+++ b/products/model_crossing_uses_baseline.txt@@ -607,7 +607,7 @@ product_analytics:backend/hogql_queries/ posthog.hogql_queries.test.test_dashboaproduct_analytics:backend/hogql_queries/ posthog.hogql_queries.test.test_dashboard_filters_overrides drives(TrendsQueryRunner) 1product_analytics:backend/hogql_queries/ posthog.hogql_queries.test.test_insight_actors_query_runner drives(TrendsQuery) 7product_analytics:backend/hogql_queries/ posthog.hogql_queries.test.test_query_runner drives(TrendsQuery) 4-product_analytics:backend/hogql_queries/ posthog.hogql_queries.test.test_query_runner drives(TrendsQueryRunner) 4+product_analytics:backend/hogql_queries/ posthog.hogql_queries.test.test_query_runner drives(TrendsQueryRunner) 2product_analytics:backend/hogql_queries/ posthog.tasks.alerts.test.test_alert_check_helpers drives(TrendsQuery) 1product_analytics:backend/hogql_queries/ posthog.tasks.alerts.test.test_alert_evaluation drives(TrendsQuery) 5product_analytics:backend/hogql_queries/ posthog.tasks.alerts.test.test_alert_subscriptions drives(TrendsQuery) 3diff --git a/products/product_analytics/backend/hogql_queries/funnels/test/test_funnels_query_runner.py b/products/product_analytics/backend/hogql_queries/funnels/test/test_funnels_query_runner.pyindex c0220a39f2a5..8a37f04304e7 100644--- a/products/product_analytics/backend/hogql_queries/funnels/test/test_funnels_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/funnels/test/test_funnels_query_runner.py@@ -1,6 +1,7 @@from datetime import UTC, datetimefrom posthog.test.base import BaseTest+from unittest.mock import patchfrom parameterized import parameterized@@ -11,9 +12,12 @@ from posthog.schema import (DateRange,EventsNode,FunnelsQuery,+ FunnelsQueryResponse,IntervalType,)+from posthog.hogql_queries.query_runner import ExecutionMode+from products.product_analytics.backend.hogql_queries.funnels.funnels_query_runner import FunnelsQueryRunner@@ -189,3 +193,21 @@ class TestFunnelsSeriesCustomNames(BaseTest):self.assertEqual(patched_response.results, expected_results)self.assertEqual(was_modified, expect_modified)++ def test_raw_cache_read_patches_a_step_renamed_after_caching(self) -> None:+ cached_steps = [{"order": 0, "custom_name": None, "count": 100}, {"order": 1, "custom_name": None, "count": 50}]+ with patch.object(FunnelsQueryRunner, "calculate", return_value=FunnelsQueryResponse(results=cached_steps)):+ FunnelsQueryRunner(+ query=FunnelsQuery(series=[EventsNode(event="step1"), EventsNode(event="step2")]), team=self.team+ ).run(execution_mode=ExecutionMode.CALCULATE_BLOCKING_ALWAYS)++ runner = FunnelsQueryRunner(+ query=FunnelsQuery(series=[EventsNode(event="step1", custom_name="Renamed"), EventsNode(event="step2")]),+ team=self.team,+ )+ runner.serve_raw_cached_results = True+ response = runner.run(execution_mode=ExecutionMode.CACHE_ONLY_NEVER_CALCULATE)++ assert isinstance(response, CachedFunnelsQueryResponse)+ assert runner.raw_cached_results_bytes is None+ assert [step["custom_name"] for step in response.results] == ["Renamed", None]diff --git a/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.py b/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.pyindex a4b24561b9d2..79dd16ac9b28 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/lifecycle_query_runner.py@@ -236,54 +236,19 @@ class LifecycleQueryRunner(AnalyticsQueryRunner[LifecycleQueryResponse]):status = val[cols["status"]]data = [float(counts_by_date.get(date, 0)) for date in all_dates]- # legacy response compatibility object- action_object = {}label = "{} - {}".format("", status)if isinstance(series, ActionsNode):action = Action.objects.get(pk=int(series.id), team__project_id=self.team.project_id)label = "{} - {}".format(action.name, status)- action_object = {- "id": str(action.pk),- "name": action.name,- "type": "actions",- "order": 0,- "math": "total",- }- custom_name = getattr(series, "custom_name", None)- if custom_name is not None:- action_object["custom_name"] = custom_nameelif isinstance(series, EventsNode):event = series.eventlabel = "{} - {}".format("All events" if event is None else event, status)- action_object = {- "id": event,- "name": "All events" if event is None else event,- "type": "events",- "order": 0,- "math": "total",- }- custom_name = getattr(series, "custom_name", None)- if custom_name is not None:- action_object["custom_name"] = custom_nameelif isinstance(series, LifecycleDataWarehouseNode):- data_warehouse_node = series- label = "{} - {}".format(data_warehouse_node.table_name, status)- action_object = {- "id": data_warehouse_node.id,- "name": data_warehouse_node.table_name,- "type": "data_warehouse",- "order": 0,- "math": "total",- "table_name": data_warehouse_node.table_name,- "timestamp_field": data_warehouse_node.timestamp_field,- "aggregation_target_field": data_warehouse_node.aggregation_target_field,- "created_at_field": data_warehouse_node.created_at_field,- }+ label = "{} - {}".format(series.table_name, status)additional_values = {"label": label, "status": status}results.append({- "action": action_object,"data": data,"count": float(sum(data)),"labels": labels,diff --git a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_data_warehouse.py b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_data_warehouse.pyindex 7f3e8ff809c9..f97b73593d70 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_data_warehouse.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_data_warehouse.py@@ -246,20 +246,7 @@ class TestLifecycleDataWarehouse(ClickhouseTestMixin, APIBaseTest):self.assertEqual([0.0, 1.0], results_by_status["returning"]["data"])self.assertEqual([0.0, 1.0], results_by_status["resurrecting"]["data"])self.assertEqual([0.0, -1.0], results_by_status["dormant"]["data"])- self.assertEqual(- {- "name": table_name,- "type": "data_warehouse",- "order": 0,- "math": "total",- "table_name": table_name,- "timestamp_field": "sent_at",- "aggregation_target_field": "users.person_id",- "created_at_field": "users.signed_up",- "id": "posthog_test_sent_messages",- },- results_by_status["new"]["action"],- )+ self.assertEqual(f"{table_name} - new", results_by_status["new"]["label"])with time_machine.travel("2025-11-07T12:00:00Z", tick=False):for status, expected_name in {diff --git a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_endpoint_contract.py b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_endpoint_contract.pyindex 2c660aec3b86..f6fc91068027 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_endpoint_contract.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_endpoint_contract.py@@ -7,7 +7,7 @@ from posthog.schema import EventsNode, LifecycleQueryfrom products.endpoints.backend.facade.api import build_endpoint_hogql, transform_materialized_insight_response-LIFECYCLE_REQUIRED_FIELDS = {"data", "labels", "days", "count", "label", "action", "status"}+LIFECYCLE_REQUIRED_FIELDS = {"data", "labels", "days", "count", "label", "order", "status"}# What the endpoints product needs from this runner, tested where the runner lives. Both pathsdiff --git a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.py b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.pyindex abcdb2b1482e..967f099f1850 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.py@@ -189,13 +189,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "new",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": 4.0,@@ -241,13 +234,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "returning",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": 3.0,@@ -293,13 +279,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "resurrecting",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": -3.0,@@ -345,13 +324,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "dormant",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},],response.results,@@ -467,13 +439,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "new",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": 6.0,@@ -519,13 +484,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "returning",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": 3.0,@@ -571,13 +529,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "resurrecting",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": -4.0,@@ -623,13 +574,6 @@ class TestLifecycleQueryRetentionGroupAggregation(ClickhouseTestMixin, APIBaseTe],"order": 0,"status": "dormant",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},],response.results,@@ -971,13 +915,6 @@ class TestLifecycleQueryRunner(ClickhouseTestMixin, APIBaseTest):],"order": 0,"status": "new",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": 2.0,@@ -1023,13 +960,6 @@ class TestLifecycleQueryRunner(ClickhouseTestMixin, APIBaseTest):],"order": 0,"status": "returning",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": 4.0,@@ -1075,13 +1005,6 @@ class TestLifecycleQueryRunner(ClickhouseTestMixin, APIBaseTest):],"order": 0,"status": "resurrecting",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},{"count": -7.0,@@ -1127,13 +1050,6 @@ class TestLifecycleQueryRunner(ClickhouseTestMixin, APIBaseTest):],"order": 0,"status": "dormant",- "action": {- "id": "$pageview",- "math": "total",- "name": "$pageview",- "order": 0,- "type": "events",- },},],response.results,diff --git a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner_filters.py b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner_filters.pyindex 2680423f9fb1..aca6a29688e3 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner_filters.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner_filters.py@@ -1,10 +1,8 @@-from datetime import UTC, datetime-from posthog.test.base import BaseTestfrom parameterized import parameterized-from posthog.schema import CachedLifecycleQueryResponse, DashboardFilter, EventsNode, IntervalType, LifecycleQuery+from posthog.schema import DashboardFilter, EventsNode, IntervalType, LifecycleQueryfrom products.product_analytics.backend.hogql_queries.lifecycle.lifecycle_query_runner import LifecycleQueryRunner@@ -48,64 +46,3 @@ class TestLifecycleDashboardFilters(BaseTest):runner.apply_dashboard_filters(DashboardFilter(filterTestAccounts=dashboard_filter))assert runner.query.filterTestAccounts is expected---class TestLifecycleSeriesCustomNames(BaseTest):- @parameterized.expand(- [- (- "patches_all_lifecycle_statuses",- [- {"action": {"order": 0, "custom_name": None}, "status": "new", "data": [1]},- {"action": {"order": 0, "custom_name": None}, "status": "returning", "data": [2]},- {"action": {"order": 0, "custom_name": None}, "status": "resurrecting", "data": [3]},- {"action": {"order": 0, "custom_name": None}, "status": "dormant", "data": [4]},- ],- [- {"action": {"order": 0, "custom_name": "My Lifecycle"}, "status": "new", "data": [1]},- {"action": {"order": 0, "custom_name": "My Lifecycle"}, "status": "returning", "data": [2]},- {"action": {"order": 0, "custom_name": "My Lifecycle"}, "status": "resurrecting", "data": [3]},- {"action": {"order": 0, "custom_name": "My Lifecycle"}, "status": "dormant", "data": [4]},- ],- True,- ),- (- "not_modified_when_lifecycle_names_match",- [- {"action": {"order": 0, "custom_name": "My Lifecycle"}, "status": "new", "data": [1]},- ],- [- {"action": {"order": 0, "custom_name": "My Lifecycle"}, "status": "new", "data": [1]},- ],- False,- ),- ]- )- def test_apply_lifecycle_custom_names(- self,- _name: str,- cached_results: list,- expected_results: list,- expect_modified: bool,- ):- query = LifecycleQuery(- series=[- EventsNode(event="$pageview", custom_name="My Lifecycle"),- ]- )-- runner = LifecycleQueryRunner(query=query, team=self.team)-- cached_response = CachedLifecycleQueryResponse(- results=cached_results,- is_cached=True,- last_refresh=datetime.now(UTC),- next_allowed_client_refresh=datetime.now(UTC),- cache_key="test_key",- timezone="UTC",- )-- patched_response, was_modified = runner.apply_series_custom_names(cached_response)-- self.assertEqual(patched_response.results, expected_results)- self.assertEqual(was_modified, expect_modified)diff --git a/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py b/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.pyindex 592930e6427f..146353c1d65e 100644--- a/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/stickiness/stickiness_query_runner.py@@ -371,15 +371,6 @@ class StickinessQueryRunner(AnalyticsQueryRunner[StickinessQueryResponse]):],}- # Add minimal action data for color consistency with trends- series_object["action"] = {- "order": series_with_extra.series_order,- "type": "events",- "name": series_label or "All events",- "id": series_label,- "custom_name": series_with_extra.series.custom_name,- }-# Modifications for when comparing to previous periodif self.query.compareFilter is not None and self.query.compareFilter.compare:series_object["compare"] = Truediff --git a/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.py b/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.pyindex e3437f6bb548..a9d1d6b7206a 100644--- a/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.py@@ -1,5 +1,4 @@from dataclasses import dataclass-from datetime import UTC, datetimefrom pathlib import Pathfrom typing import Optional, Union@@ -1599,57 +1598,15 @@ class TestStickinessDashboardFilters(BaseTest):assert len(runner.series) == 1-class TestStickinessSeriesCustomNames(BaseTest):- @parameterized.expand(- [- (- "applies_custom_name_to_stickiness_series",- [{"action": {"order": 0, "custom_name": None}, "data": [1, 2, 3]}],- [{"action": {"order": 0, "custom_name": "My Stickiness Name"}, "data": [1, 2, 3]}],- True,- ),- (- "not_modified_when_stickiness_names_match",- [{"action": {"order": 0, "custom_name": "My Stickiness Name"}, "data": [1, 2, 3]}],- [{"action": {"order": 0, "custom_name": "My Stickiness Name"}, "data": [1, 2, 3]}],- False,- ),- ]- )- def test_apply_stickiness_custom_names(- self,- _name: str,- cached_results: list,- expected_results: list,- expect_modified: bool,- ) -> None:- runner = StickinessQueryRunner(- query=StickinessQuery(series=[EventsNode(event="$pageview", custom_name="My Stickiness Name")]),- team=self.team,- )-- cached_response = CachedStickinessQueryResponse(- results=cached_results,- is_cached=True,- last_refresh=datetime.now(UTC),- next_allowed_client_refresh=datetime.now(UTC),- cache_key="test_key",- timezone="UTC",- )-- patched_response, was_modified = runner.apply_series_custom_names(cached_response)-- assert patched_response.results == expected_results- assert was_modified is expect_modified-+class TestStickinessCacheHit(BaseTest):def test_a_response_cached_by_an_older_runner_reads_like_a_fresh_one(self) -> None:action = Action.objects.create(team=self.team, name="Signed up")query = StickinessQuery(series=[EventsNode(event="$pageview"), ActionsNode(id=action.id)])cached_rows = [- {"label": "$pageview", "data": [3], "action": {"order": 0, "name": "$pageview"}},- {"label": "Signed up", "data": [1], "action": {"order": 1, "name": "Signed up"}},+ {"label": "$pageview", "data": [3], "order": 0},+ {"label": "Signed up", "data": [1], "order": 1},]- # An older runner cached rows without a top-level `order` and a response without `action_names`.+ # An older runner cached a response without `action_names`.with patch.object(StickinessQueryRunner, "calculate", return_value=StickinessQueryResponse(results=cached_rows)):@@ -1662,7 +1619,6 @@ class TestStickinessSeriesCustomNames(BaseTest):)assert isinstance(response, CachedStickinessQueryResponse)- assert [row["order"] for row in response.results] == [0, 1]assert response.action_names == {str(action.id): "Signed up"}diff --git a/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_trends_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_trends_query_runner.pyindex 15ee64bbac3a..382197bb80d2 100644--- a/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_trends_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/calendar_heatmap_trends_query_runner.py@@ -66,13 +66,6 @@ class CalendarHeatmapTrendsQueryRunner(TrendsQueryRunner):return TrendsQueryResponse(results=[{- "action": {- "id": self.series_event(self.query.series[0]) if self.query.series else "heatmap",- "type": "events",- "order": 0,- "name": self.series_event(self.query.series[0]) if self.query.series else "Heatmap",- "math": self.query.series[0].math if self.query.series else "total",- },"label": self.series_event(self.query.series[0]) if self.query.series else "Heatmap","order": 0,"data": [], # Empty array for non-time-series datadiff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_formula.py b/products/product_analytics/backend/hogql_queries/trends/test/test_formula.pyindex 407b6aba66a3..67430a364544 100644--- a/products/product_analytics/backend/hogql_queries/trends/test/test_formula.py+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_formula.py@@ -9,7 +9,6 @@ from posthog.test.base import (flush_persons_and_events,snapshot_clickhouse_queries,)-from unittest import mockfrom django.test import override_settings@@ -563,8 +562,6 @@ class TestFormula(ClickhouseTestMixin, APIBaseTest):],"label": "Formula (B / A)","breakdown_value": "Paris",- "action": None,- "filter": mock.ANY,"order": 0,},{@@ -592,8 +589,6 @@ class TestFormula(ClickhouseTestMixin, APIBaseTest):],"label": "Formula (B / A)","breakdown_value": "London",- "action": None,- "filter": mock.ANY,"order": 0,},],diff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_trends.py b/products/product_analytics/backend/hogql_queries/trends/test/test_trends.pyindex d2567380af9f..20c03789a9e6 100644--- a/products/product_analytics/backend/hogql_queries/trends/test/test_trends.py+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_trends.py@@ -2527,18 +2527,6 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):date_to="2020-11-24",result=[{- "action": {- "id": "event_name",- "type": "events",- "order": None,- "name": "event_name",- "custom_name": None,- "math": None,- "math_hogql": None,- "math_property": None,- "math_group_type_index": None,- "properties": [],- },"label": "event_name","count": 4.0,"data": [0.0, 1.0, 2.0, 1.0, 0.0],@@ -2568,18 +2556,6 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):date_to="2020-11-24",result=[{- "action": {- "id": "event_name",- "type": "events",- "order": None,- "name": "event_name",- "custom_name": None,- "math": None,- "math_hogql": None,- "math_property": None,- "math_group_type_index": None,- "properties": [],- },"label": "event_name","count": 3.0,"data": [0.0, 2.0, 0.0, 0.0, 1.0, 0.0],@@ -2611,18 +2587,6 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):date_to="2020-11-24",result=[{- "action": {- "id": "event_name",- "type": "events",- "order": None,- "name": "event_name",- "custom_name": None,- "math": None,- "math_hogql": None,- "math_property": None,- "math_group_type_index": None,- "properties": [],- },"label": "event_name","count": 3.0, # includes only events after date_from"data": [0.0, 2.0, 1.0, 0.0],@@ -2645,18 +2609,6 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):date_to="2020-7-30",result=[{- "action": {- "id": "event_name",- "type": "events",- "order": None,- "name": "event_name",- "custom_name": None,- "math": None,- "math_hogql": None,- "math_property": None,- "math_group_type_index": None,- "properties": [],- },"label": "event_name","count": 1.0,"data": [0.0, 1.0],@@ -2682,18 +2634,6 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):query_time="2020-12-30 10:20:00",result=[{- "action": {- "id": "event_name",- "type": "events",- "order": None,- "name": "event_name",- "custom_name": None,- "math": None,- "math_hogql": None,- "math_property": None,- "math_group_type_index": None,- "properties": [],- },"label": "event_name","count": 6,"data": [6],@@ -2718,18 +2658,6 @@ class TestTrends(ClickhouseTestMixin, APIBaseTest):query_time="2020-04-30 10:20:00",result=[{- "action": {- "id": "event_name",- "type": "events",- "order": None,- "name": "event_name",- "custom_name": None,- "math": None,- "math_hogql": None,- "math_property": None,- "math_group_type_index": None,- "properties": [],- },"label": "event_name","count": 5.0,"data": [2.0, 2.0, 1.0, 0.0],diff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.pyindex 2949cb013b81..17df6f95d867 100644--- a/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.py@@ -499,29 +499,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):assert len(response.results) == 2assert mock_create_for.call_count == 1- @parameterized.expand(- [- ("custom_name set via rename modal", EventsNode(event="$pageview", custom_name="Renamed"), "Renamed"),- ("name set via query editor / API", EventsNode(event="$pageview", name="Renamed"), "Renamed"),- ("custom_name wins over name", EventsNode(event="$pageview", name="A", custom_name="B"), "B"),- ("name echoing the event is not a rename", EventsNode(event="$pageview", name="$pageview"), None),- ("no override", EventsNode(event="$pageview"), None),- ]- )- def test_trends_series_custom_name(self, _name, series, expected_custom_name):- self._create_test_events()-- response = self._run_trends_query(- self.default_date_from,- self.default_date_to,- IntervalType.DAY,- [series],- None,- None,- )-- self.assertEqual(expected_custom_name, response.results[0]["action"]["custom_name"])-def test_trends_count(self):self._create_test_events()@@ -746,7 +723,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):# Formula queries return only the formula resultassert len(response.results) == 1formula_result = response.results[0]- assert formula_result["action"] is None# 11 days Thu-Sun, weekend buckets removed leaves 7 weekdaysassert formula_result["days"] == ["2020-01-09", # Thu@@ -1224,7 +1200,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):# response shapeassert response.results[0]["label"] == "Formula (A+2*B)"- assert response.results[0]["action"] is None # action needs to be unset to display custom labeldef test_formula_with_breakdown_and_compare(self):self._create_test_events()@@ -1440,9 +1415,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):assert response.results[1]["breakdown_value"] == cohort2.pkassert response.results[1]["count"] == 3- # action needs to be unset to display custom label- assert response.results[0]["action"] is None-def test_cohort_breakdown_does_not_leak_series_filter_cohort(self):# Regression: when a trends series has a `person is in cohort` property filter AND the# breakdown is by a list of other cohorts, the LEFTJOIN_CONJOINED resolver unions every@@ -1707,9 +1679,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):assert response.results[1]["count"] == 16assert response.results[1]["data"] == [1, 0, 2, 4, 4, 0, 2, 1, 1, 0, 1, 0]- # action needs to be unset to display custom label- assert response.results[0]["action"] is None-def test_multiple_formula_with_multi_cohort_all_breakdown(self):self._create_test_events()cohort1 = Cohort.objects.create(@@ -1769,9 +1738,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):assert response.results[3]["count"] == 16assert response.results[3]["data"] == [1, 0, 2, 4, 4, 0, 2, 1, 1, 0, 1, 0]- # action needs to be unset to display custom label- assert response.results[0]["action"] is None-def test_formula_with_multi_cohort_all_breakdown_with_compare(self):self._create_test_events()cohort1 = Cohort.objects.create(@@ -1835,9 +1801,6 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):assert response.results[3]["count"] == 11assert response.results[3]["data"] == [1.0, 0.0, 2.0, 4.0, 4.0, 0.0]- # action needs to be unset to display custom label- assert response.results[0]["action"] is None-def test_formula_with_breakdown_and_no_data(self):self._create_test_events()@@ -8185,17 +8148,17 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):self.assertEqual(16, response.results[0]["count"])self.assertIn("$pageleave", response.results[0]["label"])self.assertIn("Page Action", response.results[0]["label"])- self.assertEqual(0, response.results[0]["action"]["order"])+ self.assertEqual(0, response.results[0]["order"])# Second result: EventsNode (pageview only)self.assertEqual(10, response.results[1]["count"])self.assertEqual("$pageview", response.results[1]["label"])- self.assertEqual(1, response.results[1]["action"]["order"])+ self.assertEqual(1, response.results[1]["order"])# Third result: ActionsNode (Pageview Action - matches only $pageview)self.assertEqual(10, response.results[2]["count"])self.assertEqual("Pageview Action", response.results[2]["label"])- self.assertEqual(2, response.results[2]["action"]["order"])+ self.assertEqual(2, response.results[2]["order"])# Verify all series have proper data arraysfor result in response.results:diff --git a/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.pyindex 225763a6a824..a7528969732f 100644--- a/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/trends_query_runner.py@@ -53,7 +53,7 @@ from posthog.caching.insights_api import (REDUCED_MINIMUM_INSIGHT_REFRESH_INTERVAL,)from posthog.clickhouse.client.connection import ClickHouseUser, Workload-from posthog.hogql_queries.query_runner import AnalyticsQueryRunner, resolve_series_custom_name+from posthog.hogql_queries.query_runner import AnalyticsQueryRunnerfrom posthog.hogql_queries.utils.breakdowns import (BREAKDOWN_NULL_DISPLAY,BREAKDOWN_NULL_STRING_LABEL,@@ -647,20 +647,6 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):"count": 0,"aggregated_value": get_value("total", val),"label": "All events" if series_label is None else series_label,- "filter": self._query_to_filter(),- "action": { # TODO: Populate missing props in `action`- "days": self.query_date_range.all_values(),- "id": series_label,- "type": "events",- "order": series.series_order,- "name": series_label or "All events",- "custom_name": resolve_series_custom_name(series.series, series_label),- "math": series.series.math,- "math_property": series.series.math_property,- "math_hogql": series.series.math_hogql,- "math_group_type_index": series.series.math_group_type_index,- "properties": {},- },}else:if self._trends_display.display_type == ChartDisplayType.ACTIONS_LINE_GRAPH_CUMULATIVE:@@ -684,20 +670,6 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):],"count": count,"label": "All events" if series_label is None else series_label,- "filter": self._query_to_filter(),- "action": { # TODO: Populate missing props in `action`- "days": self.query_date_range.all_values(),- "id": series_label,- "type": "events",- "order": series.series_order,- "name": series_label or "All events",- "custom_name": resolve_series_custom_name(series.series, series_label),- "math": series.series.math,- "math_property": series.series.math_property,- "math_hogql": series.series.math_hogql,- "math_group_type_index": series.series.math_group_type_index,- "properties": {},- },}# Modifications for when comparing to previous period@@ -834,12 +806,6 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):else:new_result["count"] = float(sum(new_result["data"]))- # Filter action.days too (formula series have action=None)- if new_result.get("action") is not None and "days" in new_result["action"]:- action_days = new_result["action"]["days"]- new_result["action"] = {**new_result["action"]}- new_result["action"]["days"] = [d for d in action_days if d.isoweekday() in allowed_iso_days]-filtered.append(new_result)return filtered@@ -1131,7 +1097,6 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):"data": [0] * data_length,"count": 0,"aggregated_value": 0,- "action": None,"breakdown_value": any_result.get("breakdown_value"),"compare_label": any_result.get("compare_label"),"days": any_result.get("days"),@@ -1184,7 +1149,6 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):formula = formula_node.formulabase_result = results_group[0]base_result["label"] = formula_node.custom_name or f"Formula ({formula})"- base_result["action"] = Noneif aggregate_values:series_data = [[s["aggregated_value"]] for s in results_group]@@ -1329,28 +1293,6 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):except PropertyDefinition.DoesNotExist:return "String"- # TODO: Move this to posthog/hogql_queries/legacy_compatibility/query_to_filter.py- def _query_to_filter(self) -> dict[str, Any]:- filter_dict = {- "insight": "TRENDS",- "properties": self.query.properties,- "filter_test_accounts": self.query.filterTestAccounts,- "date_to": self.query_date_range.date_to(),- "date_from": self.query_date_range.date_from(),- "entity_type": "events",- "sampling_factor": self.query.samplingFactor,- "aggregation_group_type_index": self.query.aggregation_group_type_index,- "interval": self.query.interval,- }-- if self.query.trendsFilter is not None:- filter_dict.update(self.query.trendsFilter.__dict__)-- if self.query.breakdownFilter is not None:- filter_dict.update(**self.query.breakdownFilter.__dict__)-- return {k: v for k, v in filter_dict.items() if v is not None}-@cached_propertydef _trends_display(self) -> TrendsDisplay:if self.query.trendsFilter is None or self.query.trendsFilter.display is None:diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_trends_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/test/test_web_trends_lazy_precompute.pyindex 9b8059993972..b8fa7139cbe0 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_trends_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_trends_lazy_precompute.py@@ -218,7 +218,7 @@ class TestWebTrendsLazyPrecompute(ClickhouseTestMixin, APIBaseTest):assert pre_series["labels"] == live_series["labels"]assert pre_series["count"] == live_series["count"]assert pre_series["label"] == live_series["label"]- assert pre_series["action"]["custom_name"] == "My metric"+ assert pre_series["order"] == live_series["order"]@time_machine.travel("2024-01-15T12:00:00Z", tick=False)def test_compare_period_matches_live_trends(self) -> None:@@ -235,11 +235,8 @@ class TestWebTrendsLazyPrecompute(ClickhouseTestMixin, APIBaseTest):assert pre_series["compare_label"] == live_series["compare_label"]assert pre_series["data"] == live_series["data"]assert pre_series["days"] == live_series["days"]- # The previous series' labels and action.days must use the CURRENT- # range's context like the live runner does — the compare tooltip- # pairs points across series by these.+ # The compare tooltip pairs points across series by these labelsassert pre_series["labels"] == live_series["labels"]- assert pre_series["action"]["days"] == live_series["action"]["days"]assert precomputed.resolved_compare_date_range is not None@time_machine.travel("2024-01-15T12:00:00Z", tick=False)diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_vitals_timeseries_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/test/test_web_vitals_timeseries_lazy_precompute.pyindex d94ec68a62b5..32fbdb7ee470 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_vitals_timeseries_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_vitals_timeseries_lazy_precompute.py@@ -247,8 +247,8 @@ class TestWebVitalsTimeseriesLazyPrecompute(ClickhouseTestMixin, APIBaseTest):assert len(precomputed.results) == len(live.results) == 4for live_series, pre_series in zip(live.results, precomputed.results):assert pre_series["days"] == live_series["days"]- assert pre_series["data"] == live_series["data"], live_series["action"]["custom_name"]- assert pre_series["action"]["custom_name"] == live_series["action"]["custom_name"]+ assert pre_series["data"] == live_series["data"], live_series["order"]+ assert pre_series["order"] == live_series["order"]@time_machine.travel("2024-01-15T12:00:00Z", tick=False)def test_dispatch_routes_only_when_flag_enabled(self) -> None:diff --git a/products/web_analytics/backend/hogql_queries/web_trends_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_trends_lazy_precompute.pyindex e061c6082052..e5c8ceda9c23 100644--- a/products/web_analytics/backend/hogql_queries/web_trends_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_trends_lazy_precompute.py@@ -26,7 +26,6 @@ from posthog.clickhouse.preaggregation.web_overview_preaggregated_sql import (DISTRIBUTED_WEB_OVERVIEW_PREAGGREGATED_TABLE,)from posthog.clickhouse.query_tagging import Feature, Product, tag_queries-from posthog.hogql_queries.query_runner import resolve_series_custom_namefrom posthog.hogql_queries.utils.timestamp_utils import format_label_datefrom posthog.models.team import Teamfrom posthog.week_start_day import WeekStartDay@@ -301,28 +300,11 @@ def _series_dict(series_object: dict[str, Any] = {"data": data,- # Labels are formatted in the CURRENT range's context and action.days is- # always the current range, even for the previous compare series — the- # live runner does both (build_series_response passes- # self.query_date_range regardless of series period).+ # The live runner also formats the previous compare series' labels in the current range"labels": [format_label_date(item, runner.query_date_range, runner.team.week_start_day) for item in buckets],"days": [item.strftime(day_fmt) for item in buckets],"count": float(sum(data)),"label": "All events" if series_label is None else series_label,- "filter": runner._query_to_filter(),- "action": {- "days": runner.query_date_range.all_values(),- "id": series_label,- "type": "events",- "order": 0,- "name": series_label or "All events",- "custom_name": resolve_series_custom_name(series, series_label),- "math": series.math,- "math_property": series.math_property,- "math_hogql": series.math_hogql,- "math_group_type_index": series.math_group_type_index,- "properties": {},- },"order": 0,}if query.compareFilter is not None and query.compareFilter.compare:diff --git a/products/web_analytics/backend/hogql_queries/web_vitals_timeseries_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_vitals_timeseries_lazy_precompute.pyindex 5ad240842ade..88cc37c27035 100644--- a/products/web_analytics/backend/hogql_queries/web_vitals_timeseries_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_vitals_timeseries_lazy_precompute.py@@ -285,20 +285,6 @@ def _series_dict("days": [item.strftime(day_fmt) for item in buckets],"count": float(sum(data)),"label": "All events" if series_label is None else series_label,- "filter": runner._query_to_filter(),- "action": {- "days": date_range.all_values(),- "id": series_label,- "type": "events",- "order": order,- "name": series_label or "All events",- "custom_name": series.custom_name,- "math": series.math,- "math_property": series.math_property,- "math_hogql": series.math_hogql,- "math_group_type_index": series.math_group_type_index,- "properties": {},- },"order": order,}