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.

feat(warehouse-sources): add commercetools messages, product types, prices and lists (#103704)

Tom Owers090993454ddb
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 5e7de485b3d2..1c724c757794 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -1904,12 +1904,12 @@ Note: coinmarketcap.com/api/documentation is a client-rendered zudoku app, but e
## Commercetools — gaps
-Today (12): `carts`, `categories`, `channels`, `customer_groups`, `customers`, `discount_codes`, `inventory`, `orders`, `payments`, `product_projections`, `states`, `stores`
+Today (16): `carts`, `categories`, `channels`, `customer_groups`, `customers`, `discount_codes`, `inventory`, `messages`, `orders`, `payments`, `product_projections`, `product_types`, `shopping_lists`, `standalone_prices`, `states`, `stores`
Diffed against: <https://raw.githubusercontent.com/commercetools/commercetools-api-reference/main/oas/api/openapi.yaml>
-- [ ] `/{projectKey}/messages` — the change-event stream (OrderStateChanged, PaymentStatusChanged, CustomerCreated...) - state and transition history for everything we already sync (high)
-- [ ] `/{projectKey}/product-types` — lookup resolving the productType id carried on every synced product projection (high)
+- [x] `/{projectKey}/messages` — the change-event stream (OrderStateChanged, PaymentStatusChanged, CustomerCreated...) - state and transition history for everything we already sync (high)
+- [x] `/{projectKey}/product-types` — lookup resolving the productType id carried on every synced product projection (high)
- [x] `/{projectKey}/states` — lookup resolving the state ids on orders, payments, products and reviews; without it order state is an opaque uuid (high)
- [x] `/{projectKey}/customer-groups` — lookup resolving customerGroup on customers, carts and orders - the standard segmentation dimension (high)
- [x] `/{projectKey}/channels` — lookup resolving supplyChannel and distributionChannel ids on the inventory and orders we sync (high)
@@ -1918,8 +1918,8 @@ Diffed against: <https://raw.githubusercontent.com/commercetools/commercetools-a
- [ ] `/{projectKey}/products` — full product master data including staged versus current, which product-projections flattens away (medium)
- [ ] `/{projectKey}/cart-discounts` — resolves the discount ids applied to synced carts and orders; discount_codes alone does not explain the discount (medium)
- [ ] `/{projectKey}/product-discounts` — explains discounted prices appearing on product projections (medium)
-- [ ] `/{projectKey}/standalone-prices` — prices held outside the product, so price analysis on product-projections alone is incomplete (medium)
-- [ ] `/{projectKey}/shopping-lists` — wishlist and saved-cart behavior, a common pre-purchase funnel table (medium)
+- [x] `/{projectKey}/standalone-prices` — prices held outside the product, so price analysis on product-projections alone is incomplete (medium)
+- [x] `/{projectKey}/shopping-lists` — wishlist and saved-cart behavior, a common pre-purchase funnel table (medium)
Note: The full OpenAPI (292 paths) is published at commercetools/commercetools-api-reference under oas/api/openapi.yaml; the docs site itself is navigational only. Static endpoint config in sources/commercetools/settings.py, no dynamic discovery. Also uncovered but lower value: reviews, payment-methods, business-units and associate-roles (B2B), quotes/quote-requests/staged-quotes, recurring-orders and recurrence-policies, tax-categories, zones, orders/edits. Excluded as config or plumbing: subscriptions, extensions, api-clients, types, custom-objects, product-selections.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/canonical_descriptions.py
index adc447eb9c74..16097d1c257e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/canonical_descriptions.py
@@ -84,6 +84,22 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
anonymousId="Identifier for an anonymous session owning the cart.",
),
},
+ "shopping_lists": {
+ "description": "A shopping list, used to model wishlists and saved carts a customer keeps before checkout.",
+ "docs_url": "https://docs.commercetools.com/api/projects/shoppingLists",
+ "columns": _columns(
+ name="Localized name of the shopping list.",
+ slug="Localized, URL-friendly identifier of the shopping list.",
+ description="Localized description of the shopping list.",
+ customer="Reference to the customer the shopping list belongs to.",
+ anonymousId="Identifier for an anonymous session owning the shopping list.",
+ lineItems="Product variants on the list, each with a quantity and the date it was added.",
+ textLineItems="Free-text entries on the list that do not reference a product.",
+ store="Reference to the store the shopping list belongs to.",
+ businessUnit="Reference to the business unit the shopping list belongs to.",
+ deleteDaysAfterLastModification="Days of inactivity after which the shopping list is deleted.",
+ ),
+ },
"product_projections": {
"description": "A projected (current or staged) view of a product, ready for storefront display.",
"docs_url": "https://docs.commercetools.com/api/projects/productProjections",
@@ -98,6 +114,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
published="Whether the product is currently published.",
),
},
+ "product_types": {
+ "description": "A product type defining the common custom attributes shared by many products. Products and product projections reference the product type they were created from.",
+ "docs_url": "https://docs.commercetools.com/api/projects/productTypes",
+ "columns": _columns(
+ name="Name of the product type, unique within the project.",
+ description="Description of the product type.",
+ attributes="Attribute definitions of the product type, including each attribute's name, type and constraints.",
+ ),
+ },
"categories": {
"description": "A category used to organize products into a navigable hierarchy.",
"docs_url": "https://docs.commercetools.com/api/projects/categories",
@@ -135,6 +160,23 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
expectedDelivery="Date and time when restocked items are expected to arrive.",
),
},
+ "standalone_prices": {
+ "description": "A price held outside the product it applies to, matched to a product variant by SKU.",
+ "docs_url": "https://docs.commercetools.com/api/projects/standalone-prices",
+ "columns": _columns(
+ sku="SKU of the product variant the price applies to.",
+ value="Money value of the price.",
+ country="Two-letter country code the price applies in.",
+ customerGroup="Reference to the customer group the price applies to.",
+ channel="Reference to the distribution channel the price applies to.",
+ validFrom="Date and time from which the price is valid.",
+ validUntil="Date and time until which the price is valid.",
+ tiers="Quantity-based price tiers that override the value above a threshold.",
+ discounted="Discounted price set by a product discount.",
+ staged="Staged changes to the price that are not yet published.",
+ active="Whether the price is currently active.",
+ ),
+ },
"stores": {
"description": "A store, modelling the physical or digital context a customer shops in. Orders and carts reference the store they belong to.",
"docs_url": "https://docs.commercetools.com/api/projects/stores",
@@ -180,4 +222,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
transitions="References to the states this state can transition to. An empty list means no transitions are allowed; absent means all are.",
),
},
+ "messages": {
+ "description": "A change event recorded for a resource, such as OrderStateChanged or CustomerCreated. Only recorded while the Messages Query feature is enabled for the project, and only kept until the project's message retention period expires, so this table covers that window rather than all history.",
+ "docs_url": "https://docs.commercetools.com/api/projects/messages",
+ "columns": _columns(
+ type="Type of the message, naming the change it records (for example OrderStateChanged).",
+ resource="Reference to the resource the message was recorded for.",
+ resourceVersion="Version of the resource at the time the message was recorded.",
+ sequenceNumber="Position of the message in the ordered sequence of messages for its resource.",
+ resourceUserProvidedIdentifiers="User-provided identifiers of the resource, such as its key, SKU or order number.",
+ ),
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/settings.py
index 085ede6975e2..d1dc40fa4b53 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/settings.py
@@ -47,11 +47,21 @@ COMMERCETOOLS_ENDPOINTS: dict[str, CommercetoolsEndpointConfig] = {
path="/carts",
scope="view_orders",
),
+ "shopping_lists": CommercetoolsEndpointConfig(
+ name="shopping_lists",
+ path="/shopping-lists",
+ scope="view_shopping_lists",
+ ),
"product_projections": CommercetoolsEndpointConfig(
name="product_projections",
path="/product-projections",
scope="view_products",
),
+ "product_types": CommercetoolsEndpointConfig(
+ name="product_types",
+ path="/product-types",
+ scope="view_product_types",
+ ),
"categories": CommercetoolsEndpointConfig(
name="categories",
path="/categories",
@@ -67,6 +77,11 @@ COMMERCETOOLS_ENDPOINTS: dict[str, CommercetoolsEndpointConfig] = {
path="/inventory",
scope="view_products",
),
+ "standalone_prices": CommercetoolsEndpointConfig(
+ name="standalone_prices",
+ path="/standalone-prices",
+ scope="view_standalone_prices",
+ ),
"stores": CommercetoolsEndpointConfig(
name="stores",
path="/stores",
@@ -87,6 +102,15 @@ COMMERCETOOLS_ENDPOINTS: dict[str, CommercetoolsEndpointConfig] = {
path="/states",
scope="view_states",
),
+ # Rows only exist once the Messages Query feature is switched on for the
+ # project; before that commercetools persists no messages and the table syncs empty.
+ # commercetools also deletes messages past the project's retention period, so this
+ # table can only ever cover that window.
+ "messages": CommercetoolsEndpointConfig(
+ name="messages",
+ path="/messages",
+ scope="view_messages",
+ ),
}
ENDPOINTS = tuple(COMMERCETOOLS_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/source.py
index 91e833620681..175682400b13 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/source.py
@@ -75,7 +75,9 @@ class CommercetoolsSource(ResumableSource[CommercetoolsSourceConfig, Commercetoo
label="commercetools",
caption="""Enter your commercetools API client credentials to pull your commerce data into the PostHog Data warehouse.
-Create an API client in the Merchant Center under Settings > Developer settings with the view scopes for the datasets you want to sync (`view_orders`, `view_customers`, `view_payments`, `view_products`, `view_categories`, `view_discount_codes`, `view_stores`, `view_channels`, `view_customer_groups`, `view_states`). Your project key and region are shown alongside the generated credentials.""",
+Create an API client in the Merchant Center under Settings > Developer settings with the view scopes for the datasets you want to sync (`view_orders`, `view_customers`, `view_payments`, `view_shopping_lists`, `view_products`, `view_product_types`, `view_categories`, `view_discount_codes`, `view_standalone_prices`, `view_stores`, `view_channels`, `view_customer_groups`, `view_states`, `view_messages`). Your project key and region are shown alongside the generated credentials.
+
+The messages table also needs the Messages Query feature turned on in your project settings. Without it commercetools keeps no messages and the table syncs empty. commercetools also deletes messages once they pass your project's retention period, so the table covers that window rather than all history.""",
iconPath="/static/services/commercetools.png",
docsUrl="https://posthog.com/docs/cdp/sources/commercetools",
releaseStatus=ReleaseStatus.ALPHA,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/tests/test_commercetools_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/tests/test_commercetools_source.py
index 37b02ea1e64a..2d4ecd9caaa0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/tests/test_commercetools_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/commercetools/tests/test_commercetools_source.py
@@ -1,7 +1,13 @@
import pytest
from unittest import mock
-from products.warehouse_sources.backend.temporal.data_imports.sources.commercetools.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.commercetools.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.commercetools.settings import (
+ COMMERCETOOLS_ENDPOINTS,
+ ENDPOINTS,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.commercetools.source import CommercetoolsSource
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.commercetools import (
CommercetoolsSourceConfig,
@@ -47,6 +53,14 @@ class TestCommercetoolsSource:
non_retryable_errors = self.source.get_non_retryable_errors()
assert not any(key in other_error for key in non_retryable_errors)
+ @pytest.mark.parametrize("endpoint", list(ENDPOINTS))
+ def test_canonical_descriptions_cover_every_endpoint(self, endpoint):
+ # A missing entry silently falls back to LLM enrichment for the whole table.
+ entry = CANONICAL_DESCRIPTIONS[endpoint]
+
+ assert entry["description"]
+ assert COMMERCETOOLS_ENDPOINTS[endpoint].primary_key in entry["columns"]
+
def test_get_schemas(self):
schemas = self.source.get_schemas(self.config, self.team_id)