: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-search-console): suggest the url-prefix property for a domain entry (#116799)
Tom Owersff602e66fc27
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/google_search_console.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/google_search_console.pyindex fe6b7adf9628..9709b7a01aed 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/google_search_console.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/google_search_console.py@@ -196,8 +196,19 @@ def suggest_registered_site(site_url: str, registered: collections.abc.Iterable[A site's root URL entered where only its domain property is registered gets the domainproperty suggested. A URL with a path doesn't: the domain property covers the wholesite, so syncing it would import more than the entry asked for.++ A domain property entered where only the site's root URL-prefix property is registered+ gets that URL-prefix property suggested."""if site_url.startswith("sc-domain:"):+ domain = site_url.removeprefix("sc-domain:").strip().strip("/").lower()+ if not domain:+ return None+ registered_set = set(registered)+ for scheme in ("https", "http"):+ for host in (domain, f"www.{domain}"):+ if f"{scheme}://{host}/" in registered_set:+ return f"{scheme}://{host}/"return Noneparsed = urlparse(site_url)if parsed.scheme:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.pyindex 1da4f9113ebf..c4d10183181a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_search_console/tests/test_google_search_console.py@@ -717,6 +717,10 @@ def test_normalize_site_url(raw, expected):("https://example.com/blog/", ["sc-domain:example.com"], None),("https://plotlens.ai/", ["https://other.com/"], None),("sc-domain:plotlens.ai", ["sc-domain:plotlens.ai"], None),+ # A domain property whose site is registered only as a root URL-prefix property.+ ("sc-domain:example.com", ["https://example.com/"], "https://example.com/"),+ ("sc-domain:example.com", ["http://www.example.com/"], "http://www.example.com/"),+ ("sc-domain:example.com", ["https://example.com/blog/"], None),],)def test_suggest_registered_site(site_url, registered, expected):