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 6 missing tables to the Campfire source (#116826)

Tom Owerse9b87230ccda
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 cad3c59a3f96..ee945a8a3194 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
@@ -2174,10 +2174,10 @@ Diffed against: <https://docs.campfire.ai/llms.txt>
- [x] `revenue-recognition/list-contract-subscriptions` — subscription schedules per contract, needed for ARR/MRR and rev-rec waterfalls (high)
- [x] `revenue-recognition/list-contract-customers` — lookup table resolving the customer IDs carried on contracts, invoices and revenue transactions (high)
- [x] `settings/list-chart-entities` — legal entity lookup - every transaction carries an entity ID and multi-entity consolidation is unusable without it (high)
-- [ ] `company-objects/list-custom-dimensions (+ list-custom-dimension-groups)` — the breakdown dimensions tagged on chart transactions and journal entries (medium)
-- [ ] `revenue-recognition/list-contract-milestones` — milestone-based recognition triggers on contracts we sync (medium)
-- [ ] `core-accounting/list-fixed-assets` — fixed asset register and depreciation, a whole ledger area currently absent (medium)
-- [ ] `core-accounting/list-budgets (+ list-budget-accounts)` — budget vs actual reporting against chart_of_accounts we already have (medium)
+- [x] `company-objects/list-custom-dimensions (+ list-custom-dimension-groups)` — the breakdown dimensions tagged on chart transactions and journal entries (medium)
+- [x] `revenue-recognition/list-contract-milestones` — milestone-based recognition triggers on contracts we sync (medium)
+- [x] `core-accounting/list-fixed-assets` — fixed asset register and depreciation, a whole ledger area currently absent (medium)
+- [x] `core-accounting/list-budgets (+ list-budget-accounts)` — budget vs actual reporting against chart_of_accounts we already have (medium)
- [ ] `revenue-recognition/list-prepaid-commits (+ list-prepaid-commit-consumption)` — committed spend and drawdown, core usage-based revenue analytics (medium)
- [ ] `revenue-recognition/list-contract-usage-revenue` — usage-driven revenue rows that reconcile to revenue_transactions (medium)
- [ ] `core-accounting/list-intercompany-journal-entries` — intercompany JEs are excluded from the journal_entries table today (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/canonical_descriptions.py
index 95f0a2221763..550c9e66f8f7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/canonical_descriptions.py
@@ -310,4 +310,134 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"last_modified_at": "Timestamp of the last modification to the customer record.",
},
},
+ "contract_milestones": {
+ "description": "Milestones on revenue contracts. Each milestone recognizes a fixed amount on its milestone date and creates an associated revenue transaction.",
+ "docs_url": "https://docs.campfire.ai/api-reference/revenue-recognition/list-contract-milestones",
+ "columns": {
+ "id": "Unique identifier for the milestone.",
+ "contract": "ID of the contract the milestone belongs to.",
+ "milestone_name": "Name of the milestone.",
+ "milestone_date": "Date the milestone is reached and its revenue is recognized.",
+ "amount": "Amount of the milestone.",
+ "quantity": "Quantity of the milestone's product.",
+ "rate": "Rate per unit of the milestone's product.",
+ "product": "ID of the product the milestone sells.",
+ "product_name": "Name of the product the milestone sells.",
+ "product_bundle_name": "Name of the product bundle the milestone belongs to.",
+ "billing_cadence": "How often the milestone is billed (one_time, monthly, quarterly, biannual or annual).",
+ "billing_timing": "Whether the milestone is billed in advance or in arrears.",
+ "first_invoice_date": "Date of the first invoice for the milestone.",
+ "department": "ID of the department the milestone is assigned to.",
+ "department_name": "Name of the department the milestone is assigned to.",
+ "tags": "Custom dimensions tagged on the milestone.",
+ "revenue_transaction_id": "ID of the revenue transaction created for the milestone.",
+ "is_deleted": "Whether the milestone has been deleted.",
+ "deleted_at": "Timestamp when the milestone was deleted.",
+ "created_at": "Timestamp when the milestone was created.",
+ "last_modified_at": "Timestamp of the last modification to the milestone.",
+ },
+ },
+ "custom_dimensions": {
+ "description": "Custom dimensions (transaction tags) used to break down transactions, journal entries and other records beyond account and department.",
+ "docs_url": "https://docs.campfire.ai/api-reference/company-objects/list-custom-dimensions",
+ "columns": {
+ "id": "Unique identifier for the custom dimension.",
+ "name": "Name of the custom dimension.",
+ "group": "ID of the custom dimension group the dimension belongs to.",
+ "group_name": "Name of the custom dimension group the dimension belongs to.",
+ "parent": "ID of the parent custom dimension, for nested dimensions.",
+ "parent_name": "Name of the parent custom dimension.",
+ "is_active": "Whether the custom dimension is active.",
+ "is_system": "Whether Campfire created and manages the custom dimension.",
+ "is_deleted": "Whether the custom dimension has been deleted.",
+ "deleted_at": "Timestamp when the custom dimension was deleted.",
+ "created_at": "Timestamp when the custom dimension was created.",
+ "last_modified_at": "Timestamp of the last modification to the custom dimension.",
+ },
+ },
+ "custom_dimension_groups": {
+ "description": "Groups that organize custom dimensions (transaction tags), such as a project or billable group.",
+ "docs_url": "https://docs.campfire.ai/api-reference/company-objects/list-custom-dimension-groups",
+ "columns": {
+ "id": "Unique identifier for the custom dimension group.",
+ "name": "Name of the custom dimension group.",
+ "slug": "URL-safe identifier of the custom dimension group.",
+ "is_system": "Whether Campfire created and manages the group.",
+ "system_type": "Type of a system group (project or billable), or null for a user-created group.",
+ "created_at": "Timestamp when the group was created.",
+ "last_modified_at": "Timestamp of the last modification to the group.",
+ },
+ },
+ "fixed_assets": {
+ "description": "The fixed asset register, with each asset's accounts, depreciation schedule, disposals, transfers, impairments and net book value.",
+ "docs_url": "https://docs.campfire.ai/api-reference/core-accounting/list-fixed-assets",
+ "columns": {
+ "id": "Unique identifier for the fixed asset.",
+ "name": "Name of the fixed asset.",
+ "description": "Description of the fixed asset.",
+ "status": "Status of the fixed asset (ACTIVE, PAUSED, DEPRECIATED or DISPOSED).",
+ "entity": "ID of the entity that owns the fixed asset.",
+ "asset_class": "ID of the fixed asset class.",
+ "asset_class_name": "Name of the fixed asset class.",
+ "purchase_date": "Date the fixed asset was purchased.",
+ "initial_value": "Purchase value of the fixed asset.",
+ "salvage_value": "Expected value of the fixed asset at the end of its useful life.",
+ "net_book_value": "Current value of the fixed asset after depreciation.",
+ "currency": "Currency of the fixed asset.",
+ "useful_life": "Useful life of the fixed asset.",
+ "depreciation_start_date": "Date depreciation of the fixed asset starts.",
+ "depreciation_end_date": "Date depreciation of the fixed asset ends.",
+ "depreciated_until": "Date up to which depreciation has been booked.",
+ "depreciations": "Depreciation entries booked for the fixed asset.",
+ "disposals": "Disposals recorded for the fixed asset.",
+ "is_non_depreciable": "Whether the fixed asset is not depreciated.",
+ "asset_account": "ID of the GL account that holds the fixed asset.",
+ "depreciation_expense_account": "ID of the GL account that depreciation expense is posted to.",
+ "accumulated_depreciation_account": "ID of the GL account that accumulated depreciation is posted to.",
+ "vendor": "ID of the vendor the fixed asset was purchased from.",
+ "department": "ID of the department the fixed asset is assigned to.",
+ "is_deleted": "Whether the fixed asset has been deleted.",
+ "deleted_at": "Timestamp when the fixed asset was deleted.",
+ "created_at": "Timestamp when the fixed asset was created.",
+ "last_modified_at": "Timestamp of the last modification to the fixed asset.",
+ },
+ },
+ "budgets": {
+ "description": "Budgets, each covering a date range for an entity or department at a set cadence. The amounts per account and period are in budget_accounts.",
+ "docs_url": "https://docs.campfire.ai/api-reference/core-accounting/list-budgets",
+ "columns": {
+ "id": "Unique identifier for the budget.",
+ "name": "Name of the budget.",
+ "description": "Description of the budget.",
+ "cadence": "Length of each budget period.",
+ "start_date": "First date the budget covers.",
+ "end_date": "Last date the budget covers.",
+ "periods": "Number of periods in the budget.",
+ "breakdown_type": "How the budget is broken down (standard for account-based, department_row for department rows).",
+ "currency": "Currency of the budget.",
+ "entity": "ID of the entity the budget belongs to.",
+ "department": "ID of the department the budget belongs to.",
+ "is_deleted": "Whether the budget has been deleted.",
+ "deleted_at": "Timestamp when the budget was deleted.",
+ "created_at": "Timestamp when the budget was created.",
+ "last_modified_at": "Timestamp of the last modification to the budget.",
+ },
+ },
+ "budget_accounts": {
+ "description": "Budgeted amounts per GL account and period for each budget.",
+ "docs_url": "https://docs.campfire.ai/api-reference/core-accounting/list-budget-accounts",
+ "columns": {
+ "id": "Unique identifier for the budget line.",
+ "budget": "ID of the budget the line belongs to.",
+ "account": "ID of the GL account the amount is budgeted for.",
+ "account_name": "Name of the GL account the amount is budgeted for.",
+ "period": "Budget period the amount applies to.",
+ "amount": "Budgeted amount.",
+ "department": "ID of the department the amount is budgeted for.",
+ "is_deleted": "Whether the budget line has been deleted.",
+ "deleted_at": "Timestamp when the budget line was deleted.",
+ "created_at": "Timestamp when the budget line was created.",
+ "last_modified_at": "Timestamp of the last modification to the budget line.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/settings.py
index 9903cf4c12e2..d79cf7c11d61 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/settings.py
@@ -192,6 +192,65 @@ CAMPFIRE_ENDPOINTS: dict[str, CampfireEndpointConfig] = {
incremental_fields=LAST_MODIFIED_AT_FIELD,
partition_key="created_at",
),
+ # Milestones hang off a contract like subscriptions do, but the child listing is paginated.
+ "contract_milestones": CampfireEndpointConfig(
+ name="contract_milestones",
+ path="/rr/api/v1/contracts/{contract_id}/milestones",
+ incremental_fields=LAST_MODIFIED_AT_FIELD,
+ partition_key="created_at",
+ primary_keys=["contract", "id"],
+ fanout=DependentEndpointConfig(
+ parent_name="contracts",
+ resolve_param="contract_id",
+ resolve_field="id",
+ include_from_parent=[],
+ parent_params={"limit": DEFAULT_PAGE_SIZE},
+ child_params={"limit": DEFAULT_PAGE_SIZE},
+ ),
+ ),
+ # Custom dimensions are Campfire's transaction tags. Inactive tags still label historical
+ # transactions, so they are requested too.
+ "custom_dimensions": CampfireEndpointConfig(
+ name="custom_dimensions",
+ path="/coa/api/tag",
+ incremental_fields=LAST_MODIFIED_AT_FIELD,
+ partition_key="created_at",
+ extra_params={"include_inactive": "true"},
+ ),
+ "custom_dimension_groups": CampfireEndpointConfig(
+ name="custom_dimension_groups",
+ path="/coa/api/tag-group",
+ incremental_fields=LAST_MODIFIED_AT_FIELD,
+ partition_key="created_at",
+ ),
+ "fixed_assets": CampfireEndpointConfig(
+ name="fixed_assets",
+ path="/coa/api/fixed-asset",
+ incremental_fields=LAST_MODIFIED_AT_FIELD,
+ partition_key="created_at",
+ ),
+ "budgets": CampfireEndpointConfig(
+ name="budgets",
+ path="/coa/api/budgets",
+ incremental_fields=LAST_MODIFIED_AT_FIELD,
+ partition_key="created_at",
+ ),
+ # Budget lines are only reachable per budget and come back as one bare array.
+ "budget_accounts": CampfireEndpointConfig(
+ name="budget_accounts",
+ path="/coa/api/budgets/{budget_pk}/accounts",
+ incremental_fields=LAST_MODIFIED_AT_FIELD,
+ partition_key="created_at",
+ paginated=False,
+ primary_keys=["budget", "id"],
+ fanout=DependentEndpointConfig(
+ parent_name="budgets",
+ resolve_param="budget_pk",
+ resolve_field="id",
+ include_from_parent=[],
+ parent_params={"limit": DEFAULT_PAGE_SIZE},
+ ),
+ ),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/tests/test_campfire.py b/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/tests/test_campfire.py
index 90e81a7998cc..89b164afabb1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/tests/test_campfire.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/campfire/tests/test_campfire.py
@@ -79,12 +79,19 @@ class TestValidateNextUrl:
class TestFirstRequestParams:
"""The first request carries the page size, cursor opt-in, static params, and incremental filter."""
- def test_windowed_endpoints_request_all_time(self) -> None:
- # Without all_time=true these endpoints silently default to roughly the last six months.
- for endpoint in ("chart_transactions", "journal_entries"):
- result = _driver().run(endpoint, [_response({"results": [], "next": None})])
- assert result.raised is None
- assert result.requests[0].param("all_time") == "true", endpoint
+ @parameterized.expand(
+ [
+ # Without all_time=true these endpoints silently default to roughly the last six months.
+ ("chart_transactions_all_time", "chart_transactions", "all_time", "true"),
+ ("journal_entries_all_time", "journal_entries", "all_time", "true"),
+ # Inactive tags still label historical transactions, and the API hides them by default.
+ ("custom_dimensions_include_inactive", "custom_dimensions", "include_inactive", "true"),
+ ]
+ )
+ def test_static_params_on_first_request(self, _name: str, endpoint: str, param: str, value: str) -> None:
+ result = _driver().run(endpoint, [_response({"results": [], "next": None})])
+ assert result.raised is None
+ assert result.requests[0].param(param) == value
def test_cursor_endpoints_send_empty_cursor(self) -> None:
result = _driver().run("bill_payments", [_response({"results": [], "next": None})])
@@ -231,7 +238,7 @@ class TestIncrementalConfig:
class TestFanout:
- """`contract_subscriptions` is only reachable per contract, so it walks `contracts` first."""
+ """Fan-out children are only reachable per parent, so they walk the parent listing first."""
def _responses(self) -> list[ScriptedResponse]:
return [
@@ -240,6 +247,61 @@ class TestFanout:
_response([{"id": 2, "contract": 22}]),
]
+ @parameterized.expand(
+ [
+ (
+ "contract_subscriptions",
+ "/rr/api/v1/contracts",
+ [[{"id": 1, "contract": 11}], [{"id": 2, "contract": 22}]],
+ ["/rr/api/v1/contracts/11/subscriptions", "/rr/api/v1/contracts/22/subscriptions"],
+ ),
+ (
+ "contract_milestones",
+ "/rr/api/v1/contracts",
+ [
+ {"count": 1, "next": None, "results": [{"id": 1, "contract": 11}]},
+ {"count": 1, "next": None, "results": [{"id": 2, "contract": 22}]},
+ ],
+ ["/rr/api/v1/contracts/11/milestones", "/rr/api/v1/contracts/22/milestones"],
+ ),
+ (
+ "budget_accounts",
+ "/coa/api/budgets",
+ [[{"id": 1, "budget": 11}], [{"id": 2, "budget": 22}]],
+ ["/coa/api/budgets/11/accounts", "/coa/api/budgets/22/accounts"],
+ ),
+ ]
+ )
+ def test_walks_each_parent_and_checkpoints_it(
+ self, endpoint: str, parent_path: str, child_bodies: list[Any], child_paths: list[str]
+ ) -> None:
+ result = _driver().run(
+ endpoint,
+ [
+ _response({"count": 2, "next": None, "results": [{"id": 11}, {"id": 22}]}),
+ *[_response(body) for body in child_bodies],
+ ],
+ )
+ assert result.raised is None
+ assert result.paths == [parent_path, *child_paths]
+ assert [row["id"] for row in result.rows] == [1, 2]
+ assert result.saved_states[-1].completed == child_paths
+
+ def test_paginated_child_follows_next_link_within_a_parent(self) -> None:
+ page2 = f"{CAMPFIRE_BASE_URL}/rr/api/v1/contracts/11/milestones?limit=500&offset=500"
+ result = _driver().run(
+ "contract_milestones",
+ [
+ _response({"count": 1, "next": None, "results": [{"id": 11}]}),
+ _response({"count": 2, "next": page2, "results": [{"id": 1, "contract": 11}]}),
+ _response({"count": 2, "next": None, "results": [{"id": 2, "contract": 11}]}),
+ ],
+ )
+ assert result.raised is None
+ assert result.requests[1].param("limit") == "500"
+ assert result.urls[2] == page2
+ assert [row["id"] for row in result.rows] == [1, 2]
+
def test_child_requests_carry_the_watermark(self) -> None:
result = _driver().run(
"contract_subscriptions",
@@ -269,14 +331,6 @@ class TestFanout:
assert result.raised is None
assert result.requests[1].param("last_modified_at__gte") == "1970-01-01T00:00:00Z"
- def test_checkpoints_each_finished_contract(self) -> None:
- result = _driver().run("contract_subscriptions", self._responses())
- assert result.raised is None
- assert result.saved_states[-1].completed == [
- "/rr/api/v1/contracts/11/subscriptions",
- "/rr/api/v1/contracts/22/subscriptions",
- ]
-
def test_resumes_past_contracts_already_synced(self) -> None:
result = _driver().run(
"contract_subscriptions",