: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(data-warehouse): let a quota-failed ga4 incremental run keep its progress (#118720)
posthog[bot]2cd1201f519b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.pyindex cdd5302e017f..37c9621eafee 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py@@ -64,6 +64,8 @@ class GoogleAnalyticsQuotaExceededError(Exception):Deliberately NOT matched by `get_non_retryable_errors` so Temporal retriesthe activity later (the resumable source picks up from the last savedchunk), which is the right recovery for hourly/daily property token quotas.+ An incremental run that already read past the watermark does not raise it:+ the run ends early instead, so the next run continues from the promoted watermark.Tagged `(retryable)` so `GoogleAnalyticsSource.get_retryable_errors` cankeep this self-recovering failure out of error tracking."""diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics.pyindex 7340c6099a9c..2c33940a06b4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics.py@@ -444,6 +444,49 @@ def test_source_paginates_within_chunk_and_saves_offsets(monkeypatch):assert [(s.chunk_start, s.offset) for s in saved_states] == [("2026-04-23", 2), ("2026-04-30", 0)]+ "should_use_incremental_field,quota_on_call,ends_early",+ [+ (True, 1, True),+ (False, 1, False),+ (True, 0, False),+ ],+)+def test_source_quota_exhaustion_ends_incremental_run_after_progress(+ monkeypatch, should_use_incremental_field, quota_on_call, ends_early+):+ monkeypatch.setattr(ga, "_today", lambda: dt.date(2026, 4, 30))+ _patch_session(monkeypatch)++ calls: list[str] = []++ def fake_run_report(session, property_id, start_date, end_date, dimensions, metrics, offset, limit=50000):+ calls.append(start_date)+ if len(calls) > quota_on_call:+ raise GoogleAnalyticsQuotaExceededError("quota (retryable)")+ return _report_payload(["20260301"], [1])++ monkeypatch.setattr(ga, "_run_report", fake_run_report)++ manager = mock.MagicMock()+ manager.can_resume.return_value = False++ response = google_analytics_source(+ config=_config(history_days=90),+ resource_name="website_overview",+ team_id=1,+ resumable_source_manager=manager,+ should_use_incremental_field=should_use_incremental_field,+ db_incremental_field_last_value=None,+ )++ if ends_early:+ assert len(list(cast(Iterable[Any], response.items()))) == quota_on_call+ else:+ with pytest.raises(GoogleAnalyticsQuotaExceededError):+ list(cast(Iterable[Any], response.items()))++@pytest.mark.parametrize("history_days,expected_first_start",[