: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): name the wrong ID when GA4 property ID is rejected (#70193)
Tom Owerse18057bea318
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.pyindex 458fa9f36d94..3a886690e5f8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py@@ -118,6 +118,23 @@ class GoogleAnalyticsSource(ResumableSource[GoogleAnalyticsSourceConfig, GoogleA) -> tuple[bool, str | None]:property_id = normalize_property_id(config.property_id)if not property_id.isdigit():+ # Name the two IDs users most often paste by mistake — both are non-numeric and+ # look plausible, so the generic "use a numeric ID" hint leaves them hunting.+ upper_id = property_id.upper()+ if upper_id.startswith("G-"):+ return (+ False,+ f"'{config.property_id}' looks like a Measurement ID (from your GA4 data stream / "+ "website tag), not a property ID. Use the numeric property ID from Google Analytics "+ "Admin → Property settings → Property details (e.g. '123456789').",+ )+ if upper_id.startswith("UA-"):+ return (+ False,+ f"'{config.property_id}' is a Universal Analytics property ID. This connector supports "+ "Google Analytics 4 only — use the numeric GA4 property ID from Admin → Property "+ "settings → Property details (e.g. '123456789').",+ )return (False,f"'{config.property_id}' is not a valid GA4 property ID. Use the numeric ID from "diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.pyindex aec9531345db..42a8becfa6e9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py@@ -148,6 +148,21 @@ def test_validate_credentials_rejects_non_numeric_property_id(bad_property_id):assert "not a valid GA4 property ID" in (message or "")+ "wrong_id,expected_substring",+ [+ ("G-ABC123XYZ", "Measurement ID"),+ ("g-abc123xyz", "Measurement ID"),+ ("UA-12345678-1", "Universal Analytics"),+ ],+)+def test_validate_credentials_names_common_wrong_ids(wrong_id, expected_substring):+ ok, message = GoogleAnalyticsSource().validate_credentials(_config(wrong_id), team_id=1)++ assert ok is False+ assert expected_substring in (message or "")++def _http_error(status_code: int) -> requests.HTTPError:response = mock.MagicMock()response.status_code = status_code