: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
fix(signals): scope web analytics channel queries to the scored windows (#76348)
posthog[bot]726b71430eaf
diff --git a/products/signals/skills/signals-scout-web-analytics/SKILL.md b/products/signals/skills/signals-scout-web-analytics/SKILL.mdindex abb25a20ebae..b2508daf475b 100644--- a/products/signals/skills/signals-scout-web-analytics/SKILL.md+++ b/products/signals/skills/signals-scout-web-analytics/SKILL.md@@ -90,7 +90,10 @@ SELECT $channel_type AS channel,AND $start_timestamp < now() - INTERVAL 14 DAY) AS aligned_2w_ago,round(avgIf($is_bounce, $start_timestamp >= now() - INTERVAL 1 DAY), 3) AS bounce_24hFROM sessions-WHERE $start_timestamp >= now() - INTERVAL 15 DAY+WHERE ($start_timestamp >= now() - INTERVAL 1 DAY+ OR ($start_timestamp >= now() - INTERVAL 8 DAY AND $start_timestamp < now() - INTERVAL 7 DAY)+ OR ($start_timestamp >= now() - INTERVAL 15 DAY AND $start_timestamp < now() - INTERVAL 14 DAY))+ AND $start_timestamp >= now() - INTERVAL 15 DAYAND $start_timestamp <= now() + INTERVAL 1 DAYGROUP BY channel ORDER BY sessions_24h DESCLIMIT 25@@ -132,7 +135,12 @@ SELECT $channel_type AS channel,(deviations[2] + deviations[3]) / 2 AS mad,round((sessions_24h - baseline) / greatest(1.4826 * mad, sqrt(baseline)), 1) AS zFROM sessions-WHERE $start_timestamp >= now() - INTERVAL 29 DAY+WHERE ($start_timestamp >= now() - INTERVAL 1 DAY+ OR ($start_timestamp >= now() - INTERVAL 8 DAY AND $start_timestamp < now() - INTERVAL 7 DAY)+ OR ($start_timestamp >= now() - INTERVAL 15 DAY AND $start_timestamp < now() - INTERVAL 14 DAY)+ OR ($start_timestamp >= now() - INTERVAL 22 DAY AND $start_timestamp < now() - INTERVAL 21 DAY)+ OR ($start_timestamp >= now() - INTERVAL 29 DAY AND $start_timestamp < now() - INTERVAL 28 DAY))+ AND $start_timestamp >= now() - INTERVAL 29 DAYAND $start_timestamp <= now() + INTERVAL 1 DAYGROUP BY channelHAVING baseline >= 10@@ -140,6 +148,10 @@ ORDER BY abs(z) DESCLIMIT 25```+**Filter to the windows you score, not to their span.** Five aligned 24h windows is all these aggregates ever read, so the `WHERE` enumerates those five days and keeps the outer 29-day bounds only for partition pruning and the future-clock guard. A plain contiguous `>= now() - INTERVAL 29 DAY` range costs the same bytes off disk but pushes roughly six times the rows through the session-level aggregation — on a high-traffic project that is the difference between a query that returns in a couple of seconds and one that dies on the memory limit. Apply the same shape to any query here whose aggregates only read specific windows; the entry-path query below is the exception, because its `bounce_prior` genuinely reads the whole range.++If the scored query still exceeds memory on a very high-volume project, narrow in this order and record which step you took in the close-out: first scope to the site's own hosts (`$entry_hostname IN (...)`, minus whatever is already in `noise:`), then fall back to three windows (7/14/21 days back), where the median is `aligned[2]` and the MAD is `deviations[2]`. Three windows still scores, but the baseline is thinner — treat a borderline `|z|` as a `remember`, not a report.+Same-weekday alignment absorbs weekly rhythm for free (a Tuesday send-day spike is scored against four prior Tuesdays), and a channel that spikes _every_ week carries that spike in its MAD — so recurring campaign cadence self-suppresses. For each candidate, find the moving part _inside_ the channel:```sql