Skip to content

: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.

fix(google-search-console): suggest the domain property for a www hostname (#120919)

Tom Owers27936731493f
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.py
index 140d5ed57392..af6ca9c09f91 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
@@ -193,6 +193,9 @@ def suggest_registered_site(site_url: str, registered: collections.abc.Iterable[
check whether either canonical form *is* registered and point the user at it, so a
dead-end "not visible" error becomes "enter this exact value instead".
+ A ``www.`` hostname, with or without a scheme, also matches the domain property of the bare
+ domain, because that property covers every subdomain.
+
A site's root URL entered where only its domain property is registered gets the domain
property suggested. A URL with a path doesn't: the domain property covers the whole
site, so syncing it would import more than the entry asked for.
@@ -224,7 +227,12 @@ def suggest_registered_site(site_url: str, registered: collections.abc.Iterable[
if not host:
return None
registered_set = set(registered)
- for candidate in (f"https://{host}/", f"http://{host}/", f"sc-domain:{host}"):
+ for candidate in (
+ f"https://{host}/",
+ f"http://{host}/",
+ f"sc-domain:{host}",
+ f"sc-domain:{host.removeprefix('www.')}",
+ ):
if candidate in registered_set:
return candidate
return None
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.py
index 0ddc642fb441..9bd527ea8456 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
@@ -694,6 +694,9 @@ def test_normalize_site_url(raw, expected):
# An uppercase bare hostname is lowercased to match Google's canonical property names.
("PlotLens.AI", ["https://plotlens.ai/"], "https://plotlens.ai/"),
("EXAMPLE.COM", ["sc-domain:example.com"], "sc-domain:example.com"),
+ # A bare www hostname matches the domain property of the bare domain.
+ ("www.example.com", ["sc-domain:example.com"], "sc-domain:example.com"),
+ ("www.example.com/blog", ["sc-domain:example.com"], None),
# No registered property matches — nothing to suggest.
("plotlens.ai", ["https://other.com/"], None),
# A root URL whose site is registered only as a domain property.