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 2 missing tables to the Dodo Payments source (#125238)

Tom Owersf923e81d0b98
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 a9b78701287a..2888a7e53877 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
@@ -3917,8 +3917,8 @@ Diffed against: <https://raw.githubusercontent.com/dodopayments/dodopayments-pyt
- [x] `Credit entitlement ledger (GET /credit-entitlements/{credit_entitlement_id}/balances/{customer_id}/ledger)` — track credit consumption and balance changes by customer and entitlement (high)
- [x] `Credit entitlement grants (GET /credit-entitlements/{credit_entitlement_id}/balances/{customer_id}/grants)` — analyze granted credits, expiry, and remaining quantities by customer (medium)
- [x] `Customer wallets (GET /customers/{customer_id}/wallets)` — measure customer wallet balances and prepaid funds by currency (medium)
-- [ ] `Customer wallet ledger entries (GET /customers/{customer_id}/wallets/ledger-entries)` — reconcile wallet credits and debits with customer payment activity (medium)
-- [ ] `Entitlement grants (GET /entitlements/{id}/grants)` — associate entitlement definitions with customer access grants and subscription references (medium)
+- [x] `Customer wallet ledger entries (GET /customers/{customer_id}/wallets/ledger-entries)` — reconcile wallet credits and debits with customer payment activity (medium)
+- [x] `Entitlement grants (GET /entitlements/{id}/grants)` — associate entitlement definitions with customer access grants and subscription references (medium)
- [x] `Customer emails (GET /customers/{customer_id}/emails)` — analyze transactional email delivery activity by customer and message type (medium)
Note: Extracted every GET path from the official Python SDK operation index and checked selected resource modules and response types. The advertised documentation spec URL returned HTML, so the SDK provided the usable reference. Existing tables cover top-level billing and catalog collections; missing resources need payment, payout, subscription, customer, or entitlement fan-out. Webhooks, payment-method plumbing, invoice PDFs, and duplicate CSV exports were excluded.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/canonical_descriptions.py
index b81a3800752f..e8ac17657ea3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/canonical_descriptions.py
@@ -484,6 +484,60 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "Timestamp when the wallet was last modified.",
},
},
+ "customer_wallet_ledger_entries": {
+ "description": "Credits and debits on each customer's wallet, with the balance before and after each one.",
+ "docs_url": f"{_DOCS_ROOT}/customers/get-customer-wallets-ledger-entries",
+ "columns": {
+ "id": "Unique identifier of the wallet transaction.",
+ "customer_id": "Customer the wallet belongs to.",
+ "business_id": "Identifier of the business that owns the wallet.",
+ "currency": "Currency of the wallet, as an ISO 4217 code.",
+ "amount": "Transaction amount, in the currency's smallest unit.",
+ "is_credit": "Whether the transaction adds funds to the wallet (true) or removes them (false).",
+ "event_type": (
+ "Event that caused the transaction: payment, payment_reversal, refund, refund_reversal, "
+ "dispute, dispute_reversal or merchant_adjustment."
+ ),
+ "before_balance": "Wallet balance before the transaction, in the currency's smallest unit.",
+ "after_balance": "Wallet balance after the transaction, in the currency's smallest unit.",
+ "reason": "Optional reason recorded for the transaction.",
+ "reference_object_id": "Identifier of the object that caused the transaction, such as a payment or refund.",
+ "created_at": "Timestamp when the transaction was recorded.",
+ },
+ },
+ "entitlement_grants": {
+ "description": "Grants of each entitlement to customers, with their delivery and revocation state.",
+ "docs_url": f"{_DOCS_ROOT}/entitlements/list-grants",
+ "columns": {
+ "id": "Unique identifier of the grant.",
+ "entitlement_id": "Identifier of the entitlement this grant was issued from.",
+ "customer_id": "Identifier of the customer the grant was issued to.",
+ "business_id": "Identifier of the business that owns the grant.",
+ "brand_id": "Brand id this grant belongs to.",
+ "status": "Lifecycle status of the grant: Pending, Delivered, Failed or Revoked.",
+ "integration_type": "The integration type of the grant's entitlement (e.g. `license_key`).",
+ "metadata": "Arbitrary key-value metadata recorded on the grant.",
+ "payment_id": "Identifier of the payment that triggered this grant, when applicable.",
+ "subscription_id": "Identifier of the subscription that triggered this grant, when applicable.",
+ "delivered_at": "Timestamp when the grant transitioned to `delivered`, when applicable.",
+ "revoked_at": "Timestamp when the grant transitioned to `revoked`, when applicable.",
+ "revocation_reason": "Reason recorded when the grant was revoked, when applicable.",
+ "error_code": "Machine-readable code reported when delivery failed, when applicable.",
+ "error_message": "Human-readable message reported when delivery failed, when applicable.",
+ "digital_product_delivery": (
+ "Digital-product-delivery payload, present when the entitlement integration is `digital_files`."
+ ),
+ "feature": (
+ "Typed feature payload, present only when the entitlement integration is `feature_flag`; "
+ "`null` for every other integration type."
+ ),
+ "license_key": "License-key delivery payload, present when the entitlement integration is `license_key`.",
+ "oauth_url": "Customer-facing OAuth URL for OAuth-style integrations, when applicable.",
+ "oauth_expires_at": "Timestamp when `oauth_url` stops being valid, when applicable.",
+ "created_at": "Timestamp when the grant was created.",
+ "updated_at": "Timestamp when the grant was last modified.",
+ },
+ },
"customer_emails": {
"description": "Emails Dodo Payments sent to each customer, with their delivery status.",
"docs_url": f"{_DOCS_ROOT}/customers/list-customer-emails",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/settings.py
index f204627625c9..903b4fc27f60 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/settings.py
@@ -250,6 +250,33 @@ DODOPAYMENTS_ENDPOINTS: dict[str, DodoPaymentsEndpointConfig] = {
include_from_parent=[],
),
),
+ # Wallet transactions are immutable, but a customer gets them long after the customer is
+ # created and the ledger takes no date filter, so this is full refresh only. Each row already
+ # carries `customer_id`.
+ "customer_wallet_ledger_entries": DodoPaymentsEndpointConfig(
+ path="/customers/{customer_id}/wallets/ledger-entries",
+ primary_keys=["customer_id", "id"],
+ fanout=DependentEndpointConfig(
+ child_response_actions=SKIP_MISSING_PARENT,
+ parent_name="customers",
+ resolve_param="customer_id",
+ resolve_field="customer_id",
+ include_from_parent=[],
+ ),
+ ),
+ # A grant's `status` moves through delivery and revocation, and there is no date filter, so
+ # this is full refresh only. Each row already carries `entitlement_id`.
+ "entitlement_grants": DodoPaymentsEndpointConfig(
+ path="/entitlements/{id}/grants",
+ primary_keys=["entitlement_id", "id"],
+ fanout=DependentEndpointConfig(
+ child_response_actions=SKIP_MISSING_PARENT,
+ parent_name="entitlements",
+ resolve_param="id",
+ resolve_field="id",
+ include_from_parent=[],
+ ),
+ ),
# A customer gets emails long after the customer is created, so the customer listing cannot
# window them, and an email's delivery `status` changes after it is sent. Full refresh only.
"customer_emails": DodoPaymentsEndpointConfig(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/tests/test_dodopayments.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/tests/test_dodopayments.py
index 8c07c23a3364..b742de819ade 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/tests/test_dodopayments.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dodopayments/tests/test_dodopayments.py
@@ -237,6 +237,21 @@ class TestFanout:
{"customer_id": "cus_1", "currency": "USD", "balance": 500},
{"customer_id": "cus_1", "currency": "USD", "balance": 500},
),
+ (
+ "customer_wallet_ledger_entries",
+ {"customer_id": "cus_1", "created_at": "2024-05-01T00:00:00Z"},
+ "/customers/cus_1/wallets/ledger-entries",
+ {"id": "cwt_1", "customer_id": "cus_1", "currency": "USD", "amount": 250, "is_credit": True},
+ {"id": "cwt_1", "customer_id": "cus_1", "currency": "USD", "amount": 250, "is_credit": True},
+ ),
+ # The parent field is the entitlement's own `id`, bound into a path placeholder also named `id`.
+ (
+ "entitlement_grants",
+ {"id": "ent_1", "name": "Pro license"},
+ "/entitlements/ent_1/grants",
+ {"id": "grant_1", "entitlement_id": "ent_1", "customer_id": "cus_1", "status": "Delivered"},
+ {"id": "grant_1", "entitlement_id": "ent_1", "customer_id": "cus_1", "status": "Delivered"},
+ ),
],
)
def test_child_is_read_per_parent_with_parent_fields(