: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(google_ads): drop the backfilled 30-day incremental lookback (#84474)
posthog[bot]f43d13a33a9d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.pyindex 240911f9007b..aeddc14ddeeb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/source.py@@ -58,17 +58,21 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.google_ads)from products.warehouse_sources.backend.types import ExternalDataSourceType-# Default incremental overlap re-read window for Google Ads stats tables (the 12 schemas-# carrying a `segments.date` filter). Google reports recent-day cost/conversion data as-# provisional and keeps revising it for days after the fact (see "About data freshness":-# https://support.google.com/google-ads/answer/2544985), so an incremental sync that only-# re-fetches the newest day freezes each day at its first-imported, not-yet-final value.-# Re-reading a 30-day trailing window each run lets those days catch up as Google finalizes-# them; merge-by-primary-key makes the overlap idempotent. 30 days also covers the App--# campaign conversion attribution window for the conversion metrics in these tables. These-# tables are small, so the extra re-read is negligible. Tunable; stays under the 60-day cap-# enforced at the creation/update endpoints.-GOOGLE_ADS_STATS_INCREMENTAL_LOOKBACK_SECONDS = 30 * 24 * 60 * 60+# Default incremental overlap re-read window for Google Ads stats tables (those carrying a+# `segments.date` filter). Google reports recent-day cost/conversion data as provisional and keeps+# revising it for days after the fact (see "About data freshness":+# https://support.google.com/google-ads/answer/2544985), so an incremental sync that only re-fetches+# the newest day freezes each day at its first-imported, not-yet-final value. Re-reading a trailing+# window each run lets those days catch up; merge-by-primary-key makes the overlap idempotent.+#+# The window is a direct multiplier on the rows an incremental run reports: on the largest stats+# tables (`search_term_stats`, `keyword_stats`, which grow with query volume rather than account+# size) an N-day window costs roughly N times the rows of a newest-day-only sync. Two weeks buys+# most of Google's restatement window at half that cost. Only schemas created from here on pick this+# up — existing schemas keep whatever lookback they already carry. It sits above the length at which+# SyncMethodForm warns a window is expensive, so accounts that would rather sync less lower it per+# schema, up to the 60-day cap the creation/update endpoints enforce.+GOOGLE_ADS_STATS_INCREMENTAL_LOOKBACK_SECONDS = 15 * 24 * 60 * 60_OAUTH_ACCOUNTS_CACHE_TTL_SECONDS = 60diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.pyindex 8da892e71c08..bd27c744c368 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py@@ -365,8 +365,9 @@ class TestGoogleAdsLookbackDefault:assert schemas["campaign"].supports_incremental is Falseassert schemas["campaign"].default_incremental_lookback_seconds is None# The default must satisfy the 60-day cap the creation/update endpoints enforce, or creation- # would reject it.- assert 0 < GOOGLE_ADS_STATS_INCREMENTAL_LOOKBACK_SECONDS <= 5_184_000+ # would reject it. It must also stay under 30 days: that window re-read a trailing month of+ # the stats tables on every incremental run, multiplying both synced rows and warehouse spend.+ assert 0 < GOOGLE_ADS_STATS_INCREMENTAL_LOOKBACK_SECONDS < 2_592_000class TestGrpcReceiveLimit: