: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): add mailerlite e-commerce tables (#115405)
Tom Owers010c91363f3c
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.mdindex fa40ea9b039b..8c3a068aee66 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@@ -5334,12 +5334,12 @@ Diffed against: <https://developers.mailerlite.com/llms.txt>- [x] `GET /api/groups/{group_id}/subscribers` — group membership join table for the groups and subscribers we already sync (high)- [x] `GET /api/automations/{automation_id}/activity` — subscribers flowing through each automation, the automation-side event stream (high)- [x] `GET /api/segments/{segment_id}/subscribers` — segment membership join table (high)-- [ ] `GET /api/ecommerce/shops/{shop_id}/orders` — purchase transactions — the highest-value analytical object in the e-commerce API (high)-- [ ] `GET /api/ecommerce/shops` — lookup resolving shop ids for every e-commerce record (high)+- [x] `GET /api/ecommerce/shops/{shop_id}/orders` — purchase transactions — the highest-value analytical object in the e-commerce API (high)+- [x] `GET /api/ecommerce/shops` — lookup resolving shop ids for every e-commerce record (high)- [ ] `GET /api/ecommerce/shops/{shop_id}/customers` — shop customers linked to subscribers, joins revenue to email (medium)-- [ ] `GET /api/ecommerce/shops/{shop_id}/products` — product catalog resolving order line items (medium)+- [x] `GET /api/ecommerce/shops/{shop_id}/products` — product catalog resolving order line items (medium)- [ ] `GET /api/forms/{form_id}/subscribers` — signups attributable to each popup/embedded/promotion form (medium)-- [ ] `GET /api/ecommerce/shops/{shop_id}/categories` — category dimension for product and order breakdowns (medium)+- [x] `GET /api/ecommerce/shops/{shop_id}/categories` — category dimension for product and order breakdowns (medium)- [ ] `GET /api/timezones` — lookup resolving the timezone id on subscribers and account settings (low)- [ ] `GET /api/campaign-languages` — lookup resolving campaign language codes (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/api_inventory.mdindex f4c85acec67c..c90c156bb6d0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/api_inventory.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/api_inventory.md@@ -29,6 +29,7 @@ conservative (follow `links.next`, yield rows verbatim, merge on `id`).| forms_embedded | /forms/embedded | page number | id | created_at || forms_promotion | /forms/promotion | page number | id | created_at || webhooks | /webhooks | page number | id | created_at |+| ecommerce_shops | /ecommerce/shops | page number | id | created_at |### Fan-out endpoints@@ -41,9 +42,15 @@ primary key. A 404 on a child (parent deleted mid-sync) is skipped.| group_subscribers | /groups/{group_id}/subscribers | groups | cursor | group_id, id | created_at || segment_subscribers | /segments/{segment_id}/subscribers | segments | cursor | segment_id, id | created_at || automation_activity | /automations/{automation_id}/activity | automations × status | page number | automation_id, id | (none) |+| ecommerce_orders | /ecommerce/shops/{shop_id}/orders | ecommerce_shops | page number | shop_id, id | created_at |+| ecommerce_products | /ecommerce/shops/{shop_id}/products | ecommerce_shops | page number | shop_id, id | (none) |+| ecommerce_categories | /ecommerce/shops/{shop_id}/categories | ecommerce_shops | page number | shop_id, id | created_at |- `campaign_subscriber_activity` sends `include=subscriber`; without it a row carries only itscounts. Reports exist only for sent campaigns, so the parent list is filtered to `sent`.+- The e-commerce children fan out over every connected shop. Shop-scoped ids aren't documented as+ globally unique, so the shop id is part of each key. Products carry no creation timestamp, so+ that table is not partitioned. An account with no connected shop syncs empty tables.- The membership endpoints default `filter[status]` to `active`, so they hold active members only.- `automation_activity` requires `filter[status]` and takes one value per request, so eachautomation is fetched four times (`active`, `completed`, `canceled`, `failed`). Its `date`@@ -56,7 +63,8 @@ primary key. A 404 on a child (parent deleted mid-sync) is skipped.All list endpoints wrap rows in `{"data": [...], "links": {...}, "meta": {...}}`. Both thecursor-based `subscribers` endpoint and the page-number endpoints expose an absolute next-page URLat `links.next` (or `null` on the last page), so a single "follow `links.next`" loop covers both.-Page size capped at 100 (default 25); we request `limit=100`.+Page size capped at 100 (default 25); we request `limit=100`. The e-commerce shops list defaults+to 50 and documents no higher cap, so it requests `limit=50`.## Incremental syncdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/canonical_descriptions.pyindex b109fb39a287..03c70cf4dd43 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/canonical_descriptions.py@@ -200,4 +200,65 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"nextStep": "The automation step the run moves to next.",},},+ "ecommerce_shops": {+ "description": "An external shop connected to the MailerLite account through the E-commerce API.",+ "docs_url": "https://developers.mailerlite.com/ecommerce/shops",+ "columns": {+ "id": "Unique identifier for the shop.",+ "name": "The shop name.",+ "url": "The shop URL.",+ "currency": "ISO 4217 currency code the shop uses.",+ "currency_sign": "The symbol of the shop's currency.",+ "enabled": "Whether e-commerce functionality is enabled for the shop.",+ "enable_popups": "Whether MailerLite popups are enabled on the shop.",+ "group": "The group the shop's subscribers are automatically added to.",+ "created_at": "Time the shop was connected.",+ "updated_at": "Time the shop was last updated.",+ },+ },+ "ecommerce_orders": {+ "description": "An order placed in a connected shop, one row per shop and order.",+ "docs_url": "https://developers.mailerlite.com/ecommerce/orders",+ "columns": {+ "id": "Unique identifier for the order.",+ "shop_id": "The ID of the shop the order belongs to.",+ "shop": "The shop the order was placed in.",+ "customer": "The shop customer who placed the order, with the linked subscriber.",+ "cart": "The cart the order was placed from, including its line items and products.",+ "total": "The order total, in the shop's currency.",+ "status": "Status of the order.",+ "attribution": "The campaign or automation email the order is attributed to, if any.",+ "created_at": "Time the order was created.",+ "updated_at": "Time the order was last updated.",+ },+ },+ "ecommerce_products": {+ "description": "A product synced from a connected shop, one row per shop and product.",+ "docs_url": "https://developers.mailerlite.com/ecommerce/products",+ "columns": {+ "id": "Unique identifier for the product.",+ "shop_id": "The ID of the shop the product belongs to.",+ "name": "The product name.",+ "price": "The product price, in the shop's currency.",+ "url": "The URL of the product page.",+ "image": "The URL of the product image.",+ "exclude_from_automations": "Whether the product is excluded from e-commerce automations.",+ "short_description": "The product's short description.",+ "description": "The product's long description.",+ "categories": "The categories the product belongs to.",+ "variants": "The variants of the product.",+ },+ },+ "ecommerce_categories": {+ "description": "A product category synced from a connected shop, one row per shop and category.",+ "docs_url": "https://developers.mailerlite.com/ecommerce/categories",+ "columns": {+ "id": "Unique identifier for the category.",+ "shop_id": "The ID of the shop the category belongs to.",+ "name": "The category name.",+ "exclude_from_automations": "Whether products in the category are excluded from e-commerce automations.",+ "created_at": "Time the category was created.",+ "updated_at": "Time the category was last updated.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/mailerlite.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/mailerlite.pyindex 15e26984bca0..ef9a97d99f3c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/mailerlite.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/mailerlite.py@@ -183,7 +183,7 @@ def mailerlite_source("name": endpoint,"endpoint": {"path": endpoint_config.path,- "params": {"limit": PAGE_SIZE},+ "params": {"limit": endpoint_config.page_size},# Every list response wraps its rows in {"data": [...], "links": {...}, "meta": {...}};# a missing/empty "data" is a legit zero-row page, not an error."data_selector": "data",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/settings.pyindex 19b5ec4a39f8..d3cd6506eeae 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/settings.py@@ -37,6 +37,16 @@ _CHILD_404_IGNORE: list[ResponseAction] = [{"status_code": 404, "action": "ignorAUTOMATION_ACTIVITY_STATUSES: tuple[str, ...] = ("active", "completed", "canceled", "failed")+_SHOP_FANOUT = DependentEndpointConfig(+ parent_name="ecommerce_shops",+ resolve_param="shop_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "shop_id"},+ child_response_actions=_CHILD_404_IGNORE,+)++def _explode_automation_statuses(automation: dict[str, Any]) -> list[dict[str, Any]]:return [{**automation, "activity_status": status} for status in AUTOMATION_ACTIVITY_STATUSES]@@ -166,6 +176,37 @@ MAILERLITE_ENDPOINTS: dict[str, MailerLiteEndpointConfig] = {child_response_actions=_CHILD_404_IGNORE,),),+ "ecommerce_shops": MailerLiteEndpointConfig(+ name="ecommerce_shops",+ path="/ecommerce/shops",+ partition_key="created_at",+ # The shops list defaults to 50 rows per page and documents no higher cap.+ page_size=50,+ ),+ # Shop-scoped e-commerce ids aren't documented as globally unique, so the shop id is part of+ # each child key.+ "ecommerce_orders": MailerLiteEndpointConfig(+ name="ecommerce_orders",+ path="/ecommerce/shops/{shop_id}/orders",+ partition_key="created_at",+ primary_keys=["shop_id", "id"],+ fanout=_SHOP_FANOUT,+ ),+ "ecommerce_products": MailerLiteEndpointConfig(+ name="ecommerce_products",+ path="/ecommerce/shops/{shop_id}/products",+ # Product objects carry no creation timestamp.+ partition_key=None,+ primary_keys=["shop_id", "id"],+ fanout=_SHOP_FANOUT,+ ),+ "ecommerce_categories": MailerLiteEndpointConfig(+ name="ecommerce_categories",+ path="/ecommerce/shops/{shop_id}/categories",+ partition_key="created_at",+ primary_keys=["shop_id", "id"],+ fanout=_SHOP_FANOUT,+ ),}ENDPOINTS = tuple(MAILERLITE_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/tests/test_mailerlite.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/tests/test_mailerlite.pyindex b4669d61a01f..2cd438476e27 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/tests/test_mailerlite.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/tests/test_mailerlite.py@@ -172,6 +172,14 @@ class TestFanout:{"limit": ["100"]},{"limit": ["100"]},),+ (+ "ecommerce_orders",+ "/ecommerce/shops",+ "/ecommerce/shops/c1/orders",+ "shop_id",+ {"limit": ["50"]},+ {"limit": ["100"]},+ ),],)def test_walks_every_child_page_and_tags_rows_with_the_parent(