: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(web-analytics): precompute exit page, drop screen name from eager warmer (#62743)
Lucas Ricoy8ad23189856c
diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.pyindex b24ff2609c28..1384c36a5acf 100644--- a/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/test/test_web_stats_lazy_precompute.py@@ -39,6 +39,7 @@ PARITY_BREAKDOWNS = [("initial_referring_domain", WebStatsBreakdown.INITIAL_REFERRING_DOMAIN),("initial_referring_url", WebStatsBreakdown.INITIAL_REFERRING_URL),("language", WebStatsBreakdown.LANGUAGE),+ ("exit_page", WebStatsBreakdown.EXIT_PAGE),]diff --git a/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.py b/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.pyindex a8e82c24e129..ccc21023dfe3 100644--- a/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.py+++ b/products/web_analytics/backend/hogql_queries/web_stats_lazy_precompute.py@@ -107,6 +107,12 @@ SUPPORTED_BREAKDOWNS: set[WebStatsBreakdown] = {WebStatsBreakdown.CITY,WebStatsBreakdown.TIMEZONE,WebStatsBreakdown.LANGUAGE,+ # EXIT_PAGE is a session-scoped path (`session.$end_pathname`) served as a simple+ # breakdown — no bounce-rate join, unlike PAGE/INITIAL_PAGE which route to the+ # paths precompute family. It reads a materialized sessions column, so it carries+ # none of the unmaterialized-property OOM risk that keeps INITIAL_REFERRING_URL+ # out of the eager warmer.+ WebStatsBreakdown.EXIT_PAGE,}# Breakdowns whose value is a tuple — JSON-decoded as a list and converted backdiff --git a/products/web_analytics/dags/eager_web_analytics_precompute.py b/products/web_analytics/dags/eager_web_analytics_precompute.pyindex 120a5c2e157f..d0c9c73f002c 100644--- a/products/web_analytics/dags/eager_web_analytics_precompute.py+++ b/products/web_analytics/dags/eager_web_analytics_precompute.py@@ -75,7 +75,10 @@ BASELINE_BREAKDOWNS: tuple[WebStatsBreakdown, ...] = (WebStatsBreakdown.PAGE,WebStatsBreakdown.INITIAL_PAGE,WebStatsBreakdown.EXIT_PAGE,- WebStatsBreakdown.SCREEN_NAME,+ # SCREEN_NAME is deliberately excluded. It reads `$screen_name`, a+ # mobile-only ($screen) property that is empty for web teams, and there is+ # no precompute family for it — warming it only ever ran a raw query that+ # populated nothing. It stays available as an on-demand breakdown.WebStatsBreakdown.INITIAL_CHANNEL_TYPE,WebStatsBreakdown.INITIAL_REFERRING_DOMAIN,# INITIAL_REFERRING_URL is deliberately excluded. Unlike its domain@@ -179,6 +182,15 @@ def _warm_baseline_for_team(context: dagster.OpExecutionContext, team: Team) -># through to the raw stats query and the paths preagg table stays cold.if breakdown in (WebStatsBreakdown.PAGE, WebStatsBreakdown.INITIAL_PAGE):query["includeBounceRate"] = True+ # EXIT_PAGE is served by the simple precompute, which bakes the cleaned-or-raw+ # path into the stored breakdown value and the job hash (unlike PAGE/INITIAL_PAGE,+ # whose paths precompute stores raw paths and cleans at read time). The End-paths+ # tile sends `doPathCleaning=isPathCleaningEnabled` (true for teams with cleaning+ # rules), so without this the warmer fills the raw variant while the dashboard+ # reads the cleaned one and misses. True is a no-op for teams without cleaning+ # rules (`apply_path_cleaning` returns the bare expression → identical hash).+ if breakdown == WebStatsBreakdown.EXIT_PAGE:+ query["doPathCleaning"] = Truequeries.append(query)warmed = 0diff --git a/products/web_analytics/dags/tests/test_eager_web_analytics_precompute.py b/products/web_analytics/dags/tests/test_eager_web_analytics_precompute.pyindex 2d31f9014760..77f0ad893fe6 100644--- a/products/web_analytics/dags/tests/test_eager_web_analytics_precompute.py+++ b/products/web_analytics/dags/tests/test_eager_web_analytics_precompute.py@@ -167,6 +167,12 @@ class TestWarmBaselineForTeam(APIBaseTest):assert q["includeBounceRate"] is Trueelse:assert "includeBounceRate" not in q+ # EXIT_PAGE (simple precompute) bakes path cleaning into the stored value,+ # so the warmer must match the dashboard's cleaned End-paths request.+ if q["breakdownBy"] == WebStatsBreakdown.EXIT_PAGE.value:+ assert q["doPathCleaning"] is True+ else:+ assert "doPathCleaning" not in q# Every baseline breakdown must be covered.seen_breakdowns = {q["breakdownBy"] for q in captured if q["kind"] == "WebStatsTableQuery"}