: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(data-warehouse): add channels, variants, refunds and transactions to bigcommerce (#118517)
Tom Owers626b254a4657
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex e5a9e9532aa8..f7c8100ee990 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -293,7 +293,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/better_stack/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/bettermode/bettermode.py1 products/warehouse_sources/backend/temporal/data_imports/sources/bettermode/settings.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/bigcommerce.py1 products/warehouse_sources/backend/temporal/data_imports/sources/bigmailer/bigmailer.py1 products/warehouse_sources/backend/temporal/data_imports/sources/bigmailer/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/bill_com/bill_com.pydiff --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 0bff6e2b72fb..de5ddfc4091e 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@@ -1566,11 +1566,11 @@ Diffed against: <https://raw.githubusercontent.com/bigcommerce/api-specs/master/- [ ] `Order statuses (GET /v2/order_statuses)` — resolve status_id on imported orders to status names and descriptions (high)- [ ] `Customer groups (GET /v2/customer_groups)` — resolve customer_group_id on imported customers and compare purchasing behavior across customer segments (high)-- [ ] `Channels (GET /v3/channels)` — resolve channel_id on orders and channel references on customers to sales channel names and types (high)+- [x] `Channels (GET /v3/channels)` — resolve channel_id on orders and channel references on customers to sales channel names and types (high)- [ ] `Order products (GET /v2/orders/{order_id}/products)` — measure item sales, quantities, discounts, and product revenue from order line details (high)-- [ ] `Product variants (GET /v3/catalog/variants)` — analyze SKU prices and stock, and resolve variant IDs in order line records (high)-- [ ] `Refunds (GET /v3/orders/payment_actions/refunds)` — calculate net sales and analyze refund amounts, reasons, and refunded items (high)-- [ ] `Order transactions (GET /v3/orders/{order_id}/transactions)` — reconcile payments, captures, refunds, and payment provider outcomes against orders (high)+- [x] `Product variants (GET /v3/catalog/variants)` — analyze SKU prices and stock, and resolve variant IDs in order line records (high)+- [x] `Refunds (GET /v3/orders/payment_actions/refunds)` — calculate net sales and analyze refund amounts, reasons, and refunded items (high)+- [x] `Order transactions (GET /v3/orders/{order_id}/transactions)` — reconcile payments, captures, refunds, and payment provider outcomes against orders (high)- [ ] `Order shipments (GET /v2/orders/{order_id}/shipments)` — measure fulfillment and connect shipped quantities, tracking references, and shipping providers to orders (medium)- [ ] `Order coupons (GET /v2/orders/{order_id}/coupons)` — attribute discounts and order revenue to specific coupon codes (medium)- [ ] `Product reviews (GET /v3/catalog/products/{product_id}/reviews)` — compare product ratings and review activity with sales and repeat purchases (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/bigcommerce.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/bigcommerce.pyindex 6d41417c53f0..a5c0373ca55a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/bigcommerce.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/bigcommerce.py@@ -1,10 +1,11 @@import dataclasses+from collections.abc import Iteratorfrom datetime import UTC, datetimefrom typing import Any, Optionalfrom products.warehouse_sources.backend.temporal.data_imports.sources.bigcommerce.settings import (ENDPOINT_PATHS,- INCREMENTAL_FIELDS,+ INCREMENTAL_FILTERS,V2_ENDPOINTS,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session@@ -12,9 +13,15 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resRESTAPIConfig,rest_api_resource,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import APIKeyAuth+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.config_setup import (+ create_response_hooks,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (PageNumberPaginator,+ SinglePagePaginator,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import RESTClientfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (Endpoint,EndpointResource,@@ -27,9 +34,12 @@ BASE_URL = "https://api.bigcommerce.com"PAGE_SIZE = 250[email protected](frozen=True)class BigCommerceResumeConfig:- page: int+ # Next page of a flat listing, or the orders page an order transactions sync is on.+ page: Optional[int] = None+ # Order transactions only: how many orders on `page` are already read.+ order_index: int = 0def _to_v3_timestamp(value: Any) -> str:@@ -54,24 +64,17 @@ def _to_v2_timestamp(value: Any) -> str:def get_resource(name: str, should_use_incremental_field: bool) -> EndpointResource:path = ENDPOINT_PATHS[name]is_v2 = name in V2_ENDPOINTS- use_incremental = should_use_incremental_field and name in INCREMENTAL_FIELDS+ use_incremental = should_use_incremental_field and name in INCREMENTAL_FILTERSparams: dict[str, Any] = {"limit": PAGE_SIZE}if use_incremental:- if is_v2:- params["min_date_modified"] = {- "type": "incremental",- "cursor_path": "date_modified",- "initial_value": None,- "convert": _to_v2_timestamp,- }- else:- params["date_modified:min"] = {- "type": "incremental",- "cursor_path": "date_modified",- "initial_value": None,- "convert": _to_v3_timestamp,- }+ filter_param, cursor_path = INCREMENTAL_FILTERS[name]+ params[filter_param] = {+ "type": "incremental",+ "cursor_path": cursor_path,+ "initial_value": None,+ "convert": _to_v2_timestamp if is_v2 else _to_v3_timestamp,+ }# V3 reports the page count directly, so pagination stops without an extra empty-page# request. V2 has no such envelope, so it falls back to stopping on a short/empty page.@@ -127,7 +130,7 @@ def bigcommerce_source(initial_paginator_state: Optional[dict[str, Any]] = Noneif resumable_source_manager.can_resume():resume_config = resumable_source_manager.load_state()- if resume_config is not None:+ if resume_config is not None and resume_config.page is not None:initial_paginator_state = {"page": resume_config.page}def save_checkpoint(state: Optional[dict[str, Any]]) -> None:@@ -146,6 +149,63 @@ def bigcommerce_source()+def order_transactions_source(+ store_hash: str,+ access_token: str,+ resumable_source_manager: ResumableSourceManager[BigCommerceResumeConfig],+) -> Iterator[list[dict[str, Any]]]:+ """Read the transactions of every order, one request per order.++ BigCommerce has no collection endpoint for transactions, so this walks the V2 orders listing+ page by page. The resume state is the orders page and the position in it, which keeps each+ checkpoint the same size however many orders the store has.+ """+ client = RESTClient(+ base_url=f"{BASE_URL}/stores/{store_hash}",+ headers={"Accept": "application/json"},+ auth=APIKeyAuth(api_key=access_token, name="X-Auth-Token", location="header"),+ )+ # An order deleted between the orders listing and its transactions request has nothing to read.+ skip_deleted_order = create_response_hooks([{"status_code": 404, "action": "ignore"}])++ page, order_index = 1, 0+ if resumable_source_manager.can_resume():+ resume_config = resumable_source_manager.load_state()+ if resume_config is not None and resume_config.page is not None:+ page, order_index = resume_config.page, resume_config.order_index++ while True:+ orders = next(+ client.paginate(+ path=ENDPOINT_PATHS["orders"],+ params={"limit": PAGE_SIZE, "page": page},+ paginator=SinglePagePaginator(),+ ),+ [],+ )+ if not orders:+ return++ for index in range(order_index, len(orders)):+ transactions = [+ row+ for transactions_page in client.paginate(+ path=ENDPOINT_PATHS["order_transactions"].format(order_id=orders[index]["id"]),+ paginator=SinglePagePaginator(),+ data_selector="data",+ hooks=skip_deleted_order,+ )+ for row in transactions_page+ ]+ resumable_source_manager.save_state(BigCommerceResumeConfig(page=page, order_index=index + 1))+ if transactions:+ yield transactions+ else:+ resumable_source_manager.safe_point()++ page, order_index = page + 1, 0++def validate_credentials(store_hash: str, access_token: str) -> Optional[int]:"""Probe a cheap V3 endpoint. Returns the HTTP status code, or None on a connection error."""try:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/canonical_descriptions.pyindex 6b909d789c40..c31241d57f5e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/canonical_descriptions.py@@ -105,4 +105,75 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"is_deleted": "Whether the order has been deleted.",},},+ "variants": {+ "description": "A purchasable variant of a catalog product, such as one size and color combination, with its own SKU, price and stock.",+ "docs_url": "https://developer.bigcommerce.com/docs/rest-catalog/product-variants",+ "columns": {+ "id": "Unique identifier for the variant.",+ "product_id": "Identifier of the product this variant belongs to.",+ "sku": "Stock keeping unit (SKU) of the variant.",+ "sku_id": "Reference to the V2 API SKU ID. Null for a product's base variant.",+ "option_values": "Option and option value IDs that make up this variant. Empty for a product's base variant.",+ "price": "Base price of the variant on the storefront.",+ "sale_price": "Sale price of the variant on the storefront.",+ "retail_price": "Retail price of the variant on the storefront.",+ "cost_price": "Cost price of the variant, for internal reporting.",+ "calculated_price": "Price of the variant as seen on the storefront, after sale price and price adjustment rules.",+ "inventory_level": "Inventory level of the variant, used when the product tracks inventory by variant.",+ "inventory_warning_level": "Inventory level at which the variant is considered low stock.",+ "purchasing_disabled": "Whether the variant cannot be purchased on the storefront.",+ "upc": "UPC code used in feeds for shopping comparison sites and external channels.",+ },+ },+ "channels": {+ "description": "A sales channel the store sells through, such as a storefront, marketplace, or point of sale.",+ "docs_url": "https://developer.bigcommerce.com/docs/rest-management/channels",+ "columns": {+ "id": "Unique identifier for the channel. The default storefront has ID 1.",+ "name": "Name of the channel as it appears in the store control panel.",+ "type": "Type of channel, such as `storefront`, `marketplace`, `marketing` or `pos`.",+ "platform": "Platform the channel runs on, such as `bigcommerce`, `amazon` or `facebook`.",+ "status": "Status of the channel, such as `active`, `prelaunch` or `inactive`.",+ "external_id": "Identifier of the channel in a system outside BigCommerce.",+ "is_visible": "Whether the channel is visible in the store control panel.",+ "is_listable_from_ui": "Whether listings for the channel can be created from the BigCommerce UI.",+ "date_created": "Date and time the channel was created.",+ "date_modified": "Date and time the channel was last modified.",+ },+ },+ "order_transactions": {+ "description": "A payment event recorded against an order, such as an authorization, capture, refund or void.",+ "docs_url": "https://developer.bigcommerce.com/docs/rest-management/orders/order-transactions",+ "columns": {+ "id": "Unique identifier for the transaction.",+ "order_id": "Identifier of the order the transaction belongs to.",+ "event": "Store event that created the transaction, such as `purchase`, `authorization`, `capture`, `refund` or `void`.",+ "method": "Payment method, such as `credit_card`, `electronic_wallet`, `store_credit` or `gift_certificate`.",+ "amount": "Amount of money in the transaction.",+ "currency": "Currency of the transaction.",+ "gateway": "Payment gateway that processed the transaction, where applicable.",+ "gateway_transaction_id": "Transaction ID returned by the payment gateway.",+ "status": "Status of the transaction, such as `ok`, `error` or `pending`.",+ "test": "Whether the transaction was a test, or the gateway was in test mode.",+ "fraud_review": "Result of the gateway fraud review, if any.",+ "reference_transaction_id": "Identifier of an existing transaction this transaction acts on.",+ "date_created": "Date and time of the transaction.",+ },+ },+ "refunds": {+ "description": "A refund issued against an order, with the refunded items and the payments returned to the shopper.",+ "docs_url": "https://developer.bigcommerce.com/docs/rest-management/orders/payment-actions",+ "columns": {+ "id": "Unique identifier for the refund.",+ "order_id": "Identifier of the refunded order.",+ "user_id": "Identifier of the user who created the refund.",+ "created": "Date and time the refund was created.",+ "reason": "Reason for the refund.",+ "total_amount": "Total amount refunded.",+ "total_tax": "Total tax refunded to the shopper.",+ "uses_merchant_override_values": "Whether the merchant set the refund amount and tax explicitly.",+ "items": "Items refunded.",+ "payments": "Refund payments made to payment providers.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/settings.pyindex 6d0110c021fd..90513c217ff9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/settings.py@@ -6,45 +6,71 @@ from products.warehouse_sources.backend.types import IncrementalField, Increment# replacement for `/v2/orders`), so orders stays on the legacy API.ENDPOINTS = ("products",+ "variants","categories","brands","customers",+ "channels","orders",+ "order_transactions",+ "refunds",)# Schema/endpoint name -> BigCommerce REST API path (relative to# `https://api.bigcommerce.com/stores/{store_hash}`).ENDPOINT_PATHS: dict[str, str] = {"products": "/v3/catalog/products",+ "variants": "/v3/catalog/variants","categories": "/v3/catalog/categories","brands": "/v3/catalog/brands","customers": "/v3/customers",+ "channels": "/v3/channels","orders": "/v2/orders",+ "order_transactions": "/v3/orders/{order_id}/transactions",+ "refunds": "/v3/orders/payment_actions/refunds",}# Endpoints still served by the legacy V2 API: no `data` envelope, no `meta.pagination`,# and a different incremental filter param + date format than V3.V2_ENDPOINTS = frozenset({"orders"})-# Categories and brands carry no modification timestamp in either API version, so they're-# full refresh only. Products, customers and orders all expose a genuine server-side-# "modified since" filter.+# Endpoint -> (server-side "since" filter param, cursor field it filters on). Categories, brands+# and variants carry no modification timestamp, and order transactions have no filter, so those+# are full refresh only.+INCREMENTAL_FILTERS: dict[str, tuple[str, str]] = {+ "products": ("date_modified:min", "date_modified"),+ "customers": ("date_modified:min", "date_modified"),+ "channels": ("date_modified:min", "date_modified"),+ "orders": ("min_date_modified", "date_modified"),+ # Refunds are never modified after creation, so their creation time is the cursor.+ "refunds": ("created:min", "created"),+}+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {endpoint: [{- "label": "date_modified",+ "label": field,"type": IncrementalFieldType.DateTime,- "field": "date_modified",+ "field": field,"field_type": IncrementalFieldType.DateTime,}]- for endpoint in ("products", "customers", "orders")+ for endpoint, (_, field) in INCREMENTAL_FILTERS.items()+}++# Transactions are read per order. The order id joins the key so it stays unique table-wide even+# if a store reuses transaction ids across orders.+PRIMARY_KEYS: dict[str, list[str]] = {+ "order_transactions": ["order_id", "id"],}-# Stable creation-time field to partition on, per endpoint. Categories and brands have no-# creation timestamp field and are left unpartitioned.+# Stable creation-time field to partition on, per endpoint. Categories, brands and variants+# have no creation timestamp field and are left unpartitioned.PARTITION_FIELDS: dict[str, str] = {"products": "date_created","customers": "date_created",+ "channels": "date_created","orders": "date_created",+ "order_transactions": "date_created",+ "refunds": "created",}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/source.pyindex 8f95486a792d..4d076cd12b83 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/source.py@@ -11,12 +11,14 @@ from products.warehouse_sources.backend.facade.source_config import (from products.warehouse_sources.backend.temporal.data_imports.sources.bigcommerce.bigcommerce import (BigCommerceResumeConfig,bigcommerce_source,+ order_transactions_source,validate_credentials as validate_bigcommerce_credentials,)from products.warehouse_sources.backend.temporal.data_imports.sources.bigcommerce.settings import (ENDPOINTS,INCREMENTAL_FIELDS,PARTITION_FIELDS,+ PRIMARY_KEYS,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (@@ -127,6 +129,18 @@ class BigCommerceSource(ResumableSource[BigCommerceSourceConfig, BigCommerceResu# incrementally — guard against a stale schema requesting it elsewhere.use_incremental = inputs.should_use_incremental_field and inputs.schema_name in INCREMENTAL_FIELDS+ if inputs.schema_name == "order_transactions":+ response = SourceResponse(+ name=inputs.schema_name,+ items=lambda: order_transactions_source(+ config.store_hash, config.access_token, resumable_source_manager+ ),+ primary_keys=PRIMARY_KEYS[inputs.schema_name],+ sort_mode="asc",+ )+ self._set_partitioning(response, inputs.schema_name)+ return response+resource = bigcommerce_source(store_hash=config.store_hash,access_token=config.access_token,@@ -141,7 +155,7 @@ class BigCommerceSource(ResumableSource[BigCommerceSourceConfig, BigCommerceResuresponse = SourceResponse(name=resource.name,items=lambda: resource,- primary_keys=["id"],+ primary_keys=PRIMARY_KEYS.get(inputs.schema_name, ["id"]),column_hints=resource.column_hints,# Whether BigCommerce's `sort`/`direction` params hold a stable ascending order# page-to-page isn't verified against a live store. Deferring the watermark commit@@ -150,7 +164,12 @@ class BigCommerceSource(ResumableSource[BigCommerceSourceConfig, BigCommerceResusort_mode="desc" if use_incremental else "asc",)- partition_key = PARTITION_FIELDS.get(inputs.schema_name)+ self._set_partitioning(response, inputs.schema_name)+ return response++ @staticmethod+ def _set_partitioning(response: SourceResponse, schema_name: str) -> None:+ partition_key = PARTITION_FIELDS.get(schema_name)if partition_key:response.partition_count = 1response.partition_size = 1@@ -158,8 +177,6 @@ class BigCommerceSource(ResumableSource[BigCommerceSourceConfig, BigCommerceResuresponse.partition_format = "month"response.partition_keys = [partition_key]- return response-@propertydef get_source_config(self) -> SourceConfig:return SourceConfig(@@ -170,7 +187,8 @@ class BigCommerceSource(ResumableSource[BigCommerceSourceConfig, BigCommerceResu"Enter your BigCommerce store hash and API access token to pull your store data into ""the PostHog Data warehouse. Create an API account under **Settings → API → ""Store-level API accounts** with `read-only` scope for **Products**, **Orders** and "- "**Customers**."+ "**Customers**. To sync channels and order transactions, also grant `read-only` scope for "+ "**Channel Settings** and **Order Transactions**."),iconPath="/static/services/bigcommerce.png",docsUrl="https://posthog.com/docs/cdp/sources/bigcommerce",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce.pyindex 0bc4ea2b7676..34dad0a08b46 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce.py@@ -56,37 +56,37 @@ class TestGetResource:@parameterized.expand([- ("products", False),- ("categories", False),- ("brands", False),- ("customers", False),- ("orders", False),- ("products", True),- ("categories", True), # categories has no date_modified field: stays full refresh- ("brands", True), # same for brands- ("customers", True),- ("orders", True),+ (name, should_use_incremental_field, filter_param, cursor_path)+ for should_use_incremental_field in (False, True)+ for name, filter_param, cursor_path in [+ ("products", "date_modified:min", "date_modified"),+ ("customers", "date_modified:min", "date_modified"),+ ("channels", "date_modified:min", "date_modified"),+ ("orders", "min_date_modified", "date_modified"),+ ("refunds", "created:min", "created"),+ # No modification timestamp on these: they stay full refresh.+ ("categories", None, None),+ ("brands", None, None),+ ("variants", None, None),+ ]])- def test_write_disposition_and_incremental_param(self, name: str, should_use_incremental_field: bool) -> None:+ def test_write_disposition_and_incremental_param(+ self, name: str, should_use_incremental_field: bool, filter_param: str | None, cursor_path: str | None+ ) -> None:resource = get_resource(name, should_use_incremental_field)endpoint = cast(Endpoint, resource["endpoint"])params = cast(dict[str, Any], endpoint["params"])+ incremental_params = {key: value for key, value in params.items() if isinstance(value, dict)}- incremental_capable = name in ("products", "customers", "orders")- use_incremental = should_use_incremental_field and incremental_capable-- if use_incremental:+ if should_use_incremental_field and filter_param is not None:assert resource["write_disposition"] == {"disposition": "merge", "strategy": "upsert"}+ assert list(incremental_params) == [filter_param]+ assert incremental_params[filter_param]["type"] == "incremental"+ assert incremental_params[filter_param]["cursor_path"] == cursor_pathelse:assert resource["write_disposition"] == "replace"-- incremental_key = "min_date_modified" if name == "orders" else "date_modified:min"- if use_incremental:- assert incremental_key in params- assert params[incremental_key]["type"] == "incremental"- else:- assert incremental_key not in params+ assert incremental_params == {}class TestTimestampConverters:@@ -193,6 +193,72 @@ class TestBigCommerceSourceResumeBehavior:assert result.raised is Noneassert result.requests[0].param("date_modified:min") == "2024-05-06T07:08:09Z"+ def test_order_transactions_fan_out_over_every_order(self) -> None:+ result = self._driver().run(+ "order_transactions",+ [+ ScriptedResponse(json=[{"id": 101}, {"id": 102}, {"id": 103}]),+ ScriptedResponse(json={"data": [{"id": 1, "order_id": 101}, {"id": 2, "order_id": 101}], "meta": {}}),+ # Order deleted after the order listing was read.+ ScriptedResponse(status=404, json={"status": 404, "title": "Order not found"}),+ ScriptedResponse(status=204),+ ScriptedResponse(json=[]),+ ],+ )++ assert result.raised is None+ assert [request.path for request in result.requests] == [+ "/stores/store123/v2/orders",+ "/stores/store123/v3/orders/101/transactions",+ "/stores/store123/v3/orders/102/transactions",+ "/stores/store123/v3/orders/103/transactions",+ "/stores/store123/v2/orders",+ ]+ assert result.params("page") == ["1", None, None, None, "2"]+ assert [(row["order_id"], row["id"]) for row in result.rows] == [(101, 1), (101, 2)]+ assert result.saved_states == [+ BigCommerceResumeConfig(page=1, order_index=1),+ BigCommerceResumeConfig(page=1, order_index=2),+ BigCommerceResumeConfig(page=1, order_index=3),+ ]++ def test_order_transactions_resume_skips_completed_orders(self) -> None:+ result = self._driver().run(+ "order_transactions",+ [+ ScriptedResponse(json=[{"id": 101}, {"id": 102}]),+ ScriptedResponse(json={"data": [{"id": 3, "order_id": 102}], "meta": {}}),+ ScriptedResponse(json=[]),+ ],+ resume_state=BigCommerceResumeConfig(page=4, order_index=1),+ )++ assert result.raised is None+ assert [request.path for request in result.requests] == [+ "/stores/store123/v2/orders",+ "/stores/store123/v3/orders/102/transactions",+ "/stores/store123/v2/orders",+ ]+ assert result.params("page") == ["4", None, "5"]+ assert result.rows == [{"id": 3, "order_id": 102}]++ def test_refunds_stop_on_empty_page_without_pagination_meta(self) -> None:+ last_value = datetime(2024, 5, 6, 7, 8, 9, tzinfo=UTC)+ result = self._driver().run(+ "refunds",+ [+ ScriptedResponse(json={"data": [{"id": 1}], "meta": {}}),+ ScriptedResponse(json={"data": [], "meta": {}}),+ ],+ should_use_incremental_field=True,+ db_incremental_field_last_value=last_value,+ )++ assert result.raised is None+ assert result.params("page") == ["1", "2"]+ assert result.requests[0].param("created:min") == "2024-05-06T07:08:09Z"+ assert result.rows == [{"id": 1}]+def test_v2_incremental_param_carries_rfc2822_timestamp(self) -> None:last_value = datetime(2024, 5, 6, 7, 8, 9, tzinfo=UTC)result = self._driver().run(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce_source.pyindex c91cc54a2117..19a8dd8c9e8b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bigcommerce/tests/test_bigcommerce_source.py@@ -26,7 +26,8 @@ class TestBigCommerceSource:@staticmethoddef _empty_page(endpoint: str) -> ScriptedResponse:- if endpoint == "orders":+ # Order transactions fan out over the V2 orders listing.+ if endpoint in ("orders", "order_transactions"):return ScriptedResponse(json=[])return ScriptedResponse(json={"data": [], "meta": {"pagination": {"current_page": 1, "total_pages": 1}}})