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(data-warehouse): add maxio price point and subscription component tables (#115049)

Tom Owers907dea6d2cd7
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 c6bc31471434..0c209cfb25b2 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
@@ -5485,12 +5485,12 @@ Today (10): `components`, `coupons`, `credit_notes`, `customers`, `events`, `inv
Diffed against: <https://github.com/maxio-com/ab-python-sdk/tree/main/doc/controllers>
-- [ ] `insights: Read Mrr / List Mrr Movements / List Mrr per Subscription` — MRR and MRR movement is Maxio's headline metric and has no equivalent in the synced tables (high)
-- [ ] `subscription-components: List Subscription Components for Site` — Per-subscription component allocations - the line items joining subscriptions to components (high)
+- [ ] `insights: Read Mrr / List Mrr Movements / List Mrr per Subscription` — MRR and MRR movement is Maxio's headline metric and has no equivalent in the synced tables (high) — all three endpoints are marked deprecated in the vendor SDK docs, so not worth building a table on
+- [x] `subscription-components: List Subscription Components for Site` — Per-subscription component allocations - the line items joining subscriptions to components (high)
- [ ] `subscription-components: List Usages` — Metered usage records, the basis of consumption billing analysis (high)
- [ ] `subscription-components: List Allocations` — Quantity change history per component, i.e. seat expansion/contraction over time (high)
-- [ ] `component-price-points: List All Component Price Points` — Lookup table resolving the price_point_id carried on components and subscriptions (high)
-- [ ] `product-price-points: List All Product Price Points` — Lookup table resolving the price point on every product and subscription we sync (high)
+- [x] `component-price-points: List All Component Price Points` — Lookup table resolving the price_point_id carried on components and subscriptions (high)
+- [x] `product-price-points: List All Product Price Points` — Lookup table resolving the price point on every product and subscription we sync (high)
- [ ] `invoices: List Invoice Events` — Invoice state transition history (issued, paid, voided, refunded) (medium)
- [ ] `reason-codes: List Reason Codes` — Lookup table resolving cancellation/churn reason codes on subscriptions (medium)
- [ ] `subscription-groups: List Subscription Groups` — Group membership resolving parent/child subscription relationships (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/canonical_descriptions.py
index 957c79efef5e..1ada312d2b4a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/canonical_descriptions.py
@@ -234,4 +234,81 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"refunds": "The refunds associated with the credit note (nested array).",
},
},
+ "subscription_components": {
+ "description": "A component applied to a subscription, with its price point and allocated quantity; the line items joining subscriptions to components.",
+ "docs_url": "https://github.com/maxio-com/ab-python-sdk/blob/main/doc/controllers/subscription-components.md",
+ "columns": {
+ "id": "The id of the component (same as component_id).",
+ "subscription_id": "The id of the subscription the component is applied to.",
+ "component_id": "The id of the component.",
+ "component_handle": "The API handle of the component.",
+ "name": "The component name.",
+ "kind": "The kind of component (metered_component, quantity_based_component, on_off_component, prepaid_usage_component, event_based_component).",
+ "unit_name": "The name of the unit the component's usage is measured in.",
+ "enabled": "For on/off components, whether the component is enabled for the subscription.",
+ "unit_balance": "The current unit balance of the component on the subscription.",
+ "allocated_quantity": "The quantity currently allocated to the subscription.",
+ "currency": "The ISO 4217 currency code of the component pricing.",
+ "pricing_scheme": "The pricing scheme of the component (per_unit, volume, tiered, stairstep).",
+ "recurring": "Whether the component charge recurs on renewal.",
+ "price_point_id": "The id of the price point applied to the component on this subscription.",
+ "price_point_handle": "The API handle of the applied price point.",
+ "price_point_type": "The type of the applied price point (catalog, default, custom).",
+ "price_point_name": "The name of the applied price point.",
+ "product_family_id": "The id of the product family the component belongs to.",
+ "product_family_handle": "The API handle of the product family the component belongs to.",
+ "archived_at": "The timestamp when the component was archived, if it has been.",
+ "created_at": "The timestamp when the component was added to the subscription.",
+ "updated_at": "The timestamp of the last update to the subscription component.",
+ },
+ },
+ "component_price_points": {
+ "description": "A price point for a component, defining how its units are priced; resolves the price_point_id on components and subscription components.",
+ "docs_url": "https://github.com/maxio-com/ab-python-sdk/blob/main/doc/controllers/component-price-points.md",
+ "columns": {
+ "id": "The unique identifier for the price point, assigned by Maxio.",
+ "component_id": "The id of the component the price point belongs to.",
+ "name": "The price point name.",
+ "handle": "The API handle of the price point.",
+ "type": "The type of price point (catalog, default, custom).",
+ "pricing_scheme": "The pricing scheme of the price point (per_unit, volume, tiered, stairstep).",
+ "prices": "The price tiers of the price point (nested array).",
+ "currency_prices": "The prices of the price point in additional currencies (nested array).",
+ "subscription_id": "For custom price points, the id of the subscription the price point belongs to.",
+ "tax_included": "Whether the prices include tax.",
+ "interval": "The numerical billing interval of the price point.",
+ "interval_unit": "The billing interval unit (month or day).",
+ "archived_at": "The timestamp when the price point was archived, if it has been.",
+ "created_at": "The timestamp when the price point was created.",
+ "updated_at": "The timestamp of the last update to the price point.",
+ },
+ },
+ "product_price_points": {
+ "description": "A price point for a product, defining its price and billing interval; resolves the price point on products and subscriptions.",
+ "docs_url": "https://github.com/maxio-com/ab-python-sdk/blob/main/doc/controllers/product-price-points.md",
+ "columns": {
+ "id": "The unique identifier for the price point, assigned by Maxio.",
+ "product_id": "The id of the product the price point belongs to.",
+ "name": "The price point name.",
+ "handle": "The API handle of the price point.",
+ "type": "The type of price point (catalog, default, custom).",
+ "price_in_cents": "The price point price, in integer cents.",
+ "interval": "The numerical billing interval of the price point.",
+ "interval_unit": "The billing interval unit (month or day).",
+ "trial_price_in_cents": "The trial price, in integer cents.",
+ "trial_interval": "The numerical trial interval.",
+ "trial_interval_unit": "The trial interval unit (month or day).",
+ "trial_type": "How the subscription is handled when the trial ends.",
+ "initial_charge_in_cents": "The initial (setup) charge, in integer cents.",
+ "initial_charge_after_trial": "Whether the initial charge is billed after the trial ends.",
+ "expiration_interval": "The numerical expiration interval of the price point.",
+ "expiration_interval_unit": "The expiration interval unit.",
+ "subscription_id": "For custom price points, the id of the subscription the price point belongs to.",
+ "currency_prices": "The prices of the price point in additional currencies (nested array).",
+ "tax_included": "Whether the price includes tax.",
+ "archived_at": "The timestamp when the price point was archived, if it has been.",
+ "created_at": "The timestamp when the price point was created.",
+ "updated_at": "The timestamp of the last update to the price point.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/settings.py
index bf1dcd7a3fd2..92bb260e28c8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/settings.py
@@ -173,6 +173,39 @@ ENDPOINTS: dict[str, MaxioEndpointConfig] = {
"refunds": "true",
},
),
+ "subscription_components": MaxioEndpointConfig(
+ path="/subscriptions_components.json",
+ data_selector="subscriptions_components",
+ # `id` is the component id, so it repeats across subscriptions.
+ primary_keys=["subscription_id", "component_id"],
+ partition_keys=["created_at"],
+ incremental_fields=[_datetime_field("updated_at")],
+ incremental_date_field="updated_at",
+ # The only sort options are `id` and `updated_at`; `id` keeps full-refresh pages
+ # stable while rows are updated mid-sync.
+ sort_params={"sort": "id", "direction": "asc"},
+ incremental_sort_params={"sort": "updated_at", "direction": "asc"},
+ ),
+ "component_price_points": MaxioEndpointConfig(
+ path="/components_price_points.json",
+ data_selector="price_points",
+ primary_keys=["id"],
+ partition_keys=["created_at"],
+ # Date filtering is only available via nested `filter[...]` params — full refresh only.
+ incremental_fields=[],
+ extra_params={"include": "currency_prices"},
+ sort_params={"direction": "asc"},
+ ),
+ "product_price_points": MaxioEndpointConfig(
+ path="/products_price_points.json",
+ data_selector="price_points",
+ primary_keys=["id"],
+ partition_keys=["created_at"],
+ # Date filtering is only available via nested `filter[...]` params — full refresh only.
+ incremental_fields=[],
+ extra_params={"include": "currency_prices"},
+ sort_params={"direction": "asc"},
+ ),
}
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/tests/test_maxio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/tests/test_maxio.py
index c15f7a5c72ac..1a6c3337a314 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/tests/test_maxio.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/maxio/tests/test_maxio.py
@@ -53,7 +53,17 @@ class TestMaxioPaginator:
class TestGetResource:
@pytest.mark.parametrize(
- "endpoint", ["products", "product_families", "coupons", "components", "payment_profiles", "credit_notes"]
+ "endpoint",
+ [
+ "products",
+ "product_families",
+ "coupons",
+ "components",
+ "payment_profiles",
+ "credit_notes",
+ "component_price_points",
+ "product_price_points",
+ ],
)
def test_full_refresh_only_endpoints_never_get_incremental_params(self, endpoint: str) -> None:
# These endpoints advertise no incremental fields; even if the pipeline asked for
@@ -135,18 +145,36 @@ class TestMaxioSourceDrive:
assert [p["page"] for p in sent_params] == [5]
- def test_incremental_run_sends_formatted_watermark(self) -> None:
+ @pytest.mark.parametrize(
+ ("endpoint", "body", "expected_row"),
+ [
+ (
+ "subscriptions",
+ [{"subscription": {"id": 1, "updated_at": "2024-05-02T00:00:00Z"}}],
+ {"id": 1, "updated_at": "2024-05-02T00:00:00Z"},
+ ),
+ (
+ "subscription_components",
+ {"subscriptions_components": [{"id": 7, "subscription_id": 1, "component_id": 7}]},
+ {"id": 7, "subscription_id": 1, "component_id": 7},
+ ),
+ ],
+ )
+ def test_incremental_run_sends_formatted_watermark(
+ self, endpoint: str, body: Any, expected_row: dict[str, Any]
+ ) -> None:
manager = MagicMock(spec=ResumableSourceManager)
manager.can_resume.return_value = False
- sent_params, _ = self._drive(
- "subscriptions",
+ sent_params, pages = self._drive(
+ endpoint,
manager,
- [_make_http_response([{"subscription": {"id": 1, "created_at": "2024-01-01T00:00:00Z"}}])],
+ [_make_http_response(body)],
should_use_incremental_field=True,
db_incremental_field_last_value=datetime(2024, 5, 1, 10, 30, 0, tzinfo=UTC),
)
+ assert pages[0][0] == expected_row
assert sent_params[0]["date_field"] == "updated_at"
assert sent_params[0]["start_datetime"] == "2024-05-01 10:30:00"
assert sent_params[0]["sort"] == "updated_at"