: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
feat(warehouse_sources): support Squarespace API version v2 (#86333)
Tom Owers6905de5ad526
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/source.pyindex 724eb8b2adc3..1002f1dd90e7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/source.py@@ -9,7 +9,11 @@ from posthog.schema import (SourceFieldInputConfigType,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (+ UNVERSIONED_API_VERSION,+ FieldType,+ ResumableSource,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (CanonicalDescriptions,)@@ -31,10 +35,21 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.squarespac)from products.warehouse_sources.backend.types import ExternalDataSourceType+# Source-level vendor API version labels — opaque framework pins stored in+# `ExternalDataSource.api_version`, distinct from the per-endpoint URL segments in+# `SquarespaceEndpointConfig.api_version`. The source already requests each resource's newest+# documented route — notably products via `/v2/commerce/products` (Products API v2, GA+# 2025-12-18) — so both pins resolve to the same wire; `v2` only formalizes that generation as+# the default for newly created sources.+SQUARESPACE_API_VERSION_V1 = UNVERSIONED_API_VERSION+SQUARESPACE_API_VERSION_V2 = "v2"+@SourceRegistry.registerclass SquarespaceSource(ResumableSource[SquarespaceSourceConfig, SquarespaceResumeConfig]):- api_docs_url = "https://developers.squarespace.com"+ supported_versions = (SQUARESPACE_API_VERSION_V1, SQUARESPACE_API_VERSION_V2)+ default_version = SQUARESPACE_API_VERSION_V2+ api_docs_url = "https://developers.squarespace.com/commerce-apis/changelog"@propertydef source_type(self) -> ExternalDataSourceType:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/test_squarespace_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/test_squarespace_source.pyindex 894ca9a3dce0..7fc1319f5387 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/test_squarespace_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/squarespace/test_squarespace_source.py@@ -13,7 +13,11 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.squarespacENDPOINTS,SQUARESPACE_ENDPOINTS,)-from products.warehouse_sources.backend.temporal.data_imports.sources.squarespace.source import SquarespaceSource+from products.warehouse_sources.backend.temporal.data_imports.sources.squarespace.source import (+ SQUARESPACE_API_VERSION_V1,+ SQUARESPACE_API_VERSION_V2,+ SquarespaceSource,+)from products.warehouse_sources.backend.temporal.data_imports.sources.squarespace.squarespace import (SquarespaceResumeConfig,)@@ -56,6 +60,21 @@ class TestSquarespaceSource:assert api_key_field.required is Trueassert api_key_field.secret is True+ def test_supported_versions_and_default(self) -> None:+ # v2 is the newest generation and the default new sources start on; v1 stays supported so+ # existing pins keep resolving. The generic registry test only checks invariants — this+ # pins the specific labels so a reorder or a default flip-back is caught.+ assert self.source.supported_versions == (SQUARESPACE_API_VERSION_V1, SQUARESPACE_API_VERSION_V2)+ assert self.source.default_version == SQUARESPACE_API_VERSION_V2++ @pytest.mark.parametrize("api_version", [SQUARESPACE_API_VERSION_V1, SQUARESPACE_API_VERSION_V2])+ def test_get_schemas_table_set_is_version_independent(self, api_version: str) -> None:+ # Discovery must expose the same tables under every pin — the source already rides each+ # resource's newest route, so v1 and v2 build identical requests. Guards against a future+ # version-conditional discovery silently dropping a table for an existing (v1) source.+ schemas = self.source.get_schemas(self.config, self.team_id, api_version=api_version)+ assert {s.name for s in schemas} == set(ENDPOINTS)+def test_get_schemas_matches_endpoints(self) -> None:schemas = self.source.get_schemas(self.config, self.team_id)assert {s.name for s in schemas} == set(ENDPOINTS)