: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 ActiveCampaign deal activity and contact automation tables (#98306)
Tom Owersce780bc1b642
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 964342428896..7a2b9efe7962 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@@ -38,7 +38,7 @@ Note: Source uses a static ENDPOINTS list (products/warehouse_sources/backend/te## ActiveCampaign — gaps-Today (16): `accounts`, `automations`, `campaigns`, `contacts`, `custom_fields`, `deal_groups`, `deal_stages`, `deals`, `ecom_customers`, `ecom_order_products`, `ecom_orders`, `email_activities`, `forms`, `lists`, `segments`, `tags`+Today (18): `accounts`, `automations`, `campaigns`, `contact_automations`, `contacts`, `custom_fields`, `deal_activities`, `deal_groups`, `deal_stages`, `deals`, `ecom_customers`, `ecom_order_products`, `ecom_orders`, `email_activities`, `forms`, `lists`, `segments`, `tags`Diffed against: <https://developers.activecampaign.com/reference/overview>@@ -46,15 +46,22 @@ Diffed against: <https://developers.activecampaign.com/reference/overview>- [x] `ecomOrders` — e-commerce revenue transactions; no commerce data is synced at all today (high)- [x] `ecomOrderProducts` — order line items needed for product-level revenue breakdowns (high)- [x] `ecomCustomers` — resolves the customer IDs carried on ecom orders (high)-- [ ] `dealActivities (GET /deals/{id}/dealActivities)` — deal stage-transition and change history (high)+- [x] `dealActivities (GET /dealActivities)` — deal stage-transition and change history (high)- [ ] `contactActivities (GET /activities)` — contact-level activity timeline across campaigns and automations (high)- [ ] `contactLists (list memberships)` — membership table joining synced contacts to synced lists (high)-- [ ] `contactAutomations` — membership table joining synced contacts to synced automations, with entry/exit state (high)+- [x] `contactAutomations` — membership table joining synced contacts to synced automations, with entry/exit state (high)- [ ] `accountContacts (account-contact association)` — membership table joining synced accounts to synced contacts (medium)- [ ] `users (and groups)` — lookup resolving owner IDs on deals, tasks and notes (medium)- [ ] `notes` — free-text CRM notes attached to contacts, deals and accounts (medium)- [ ] `tasks (with taskTypes / taskOutcomes)` — sales activity volume plus the lookup tables that decode task type and outcome (medium)+Note: `contactActivities` and `contactLists` are left unticked on purpose. Neither has an+account-wide collection route in API v3: `GET /activities` documents "A contact ID is required to+access this endpoint. This endpoint does not support multiple contact IDs with a single call", and+list memberships are only readable at `GET /contacts/{id}/contactLists`. Both would therefore cost+one request per contact per sync, which does not finish on a real contact base. Revisit if+ActiveCampaign adds a collection route.+Note: deal_groups/deal_stages already cover the pipelines and stages lookups. The reference sidebar also exposes campaign messages, campaign link stats, scores, bounce logs, custom object records, conversations, SMS broadcast metrics and the separate e-commerce GraphQL API — all plausible but lower value than the 12 above.## AdRoll — **thin**diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/settings.pyindex 6b95eb04b9df..f9846414ea98 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/settings.py@@ -52,6 +52,12 @@ ACTIVE_CAMPAIGN_ENDPOINTS: dict[str, ActiveCampaignEndpointConfig] = {path="/dealGroups",data_selector="dealGroups",),+ "deal_activities": ActiveCampaignEndpointConfig(+ name="deal_activities",+ path="/dealActivities",+ data_selector="dealActivities",+ partition_key="cdate",+ ),"campaigns": ActiveCampaignEndpointConfig(name="campaigns",path="/campaigns",@@ -82,6 +88,15 @@ ACTIVE_CAMPAIGN_ENDPOINTS: dict[str, ActiveCampaignEndpointConfig] = {path="/automations",data_selector="automations",),+ "contact_automations": ActiveCampaignEndpointConfig(+ name="contact_automations",+ path="/contactAutomations",+ data_selector="contactAutomations",+ partition_key="adddate",+ # `adddate` is the only documented sort on this collection that never changes+ # once a row exists, so it keeps offset pages from shifting mid-sync.+ extra_params={"orders[adddate]": "ASC"},+ ),"custom_fields": ActiveCampaignEndpointConfig(name="custom_fields",path="/fields",@@ -118,4 +133,8 @@ ENDPOINTS = tuple(ACTIVE_CAMPAIGN_ENDPOINTS.keys())# (rather than being silently ignored), we ship every endpoint as full refresh per# the implementing-warehouse-sources guidance. Enable incremental per endpoint only# after confirming the server-side filter against the live API.+# `contact_automations` documents `filters[adddate]` with comparison operators, but a+# row keeps changing after it is added (status, remdate, lastdate all move when the+# contact finishes the automation), so filtering on the entry date would freeze those+# rows at their first-seen state.INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.py b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.pyindex 932bc455efed..2fbaac8eff65 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.py@@ -194,7 +194,9 @@ class TestActiveCampaignSourceResumeBehavior:selector = ACTIVE_CAMPAIGN_ENDPOINTS[endpoint].data_selectorreturn {selector: items, "meta": {"total": total}}- @pytest.mark.parametrize("endpoint", ["contacts", "deals", "lists", "campaigns"])+ @pytest.mark.parametrize(+ "endpoint", ["contacts", "deals", "lists", "campaigns", "deal_activities", "contact_automations"]+ )def test_fresh_run_saves_offset_after_each_non_terminal_page(self, endpoint: str) -> None:manager = MagicMock(spec=ResumableSourceManager)manager.can_resume.return_value = False