: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 jobnimbus invoices, products, budgets and groups tables (#113301)
Tom Owers289bb19b43d5
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 8aa4d7a5448a..a8daae263e93 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@@ -4591,24 +4591,24 @@ Note: The connector covers only the platform v3 lookup tables plus /search/jql i## JobNimbus — **thin**-Today (9): `activities`, `contacts`, `estimates`, `jobs`, `lead_sources`, `payments`, `tasks`, `users`, `workflows`+Today (13): `activities`, `budgets`, `contacts`, `estimates`, `groups`, `invoices`, `jobs`, `lead_sources`, `payments`, `products`, `tasks`, `users`, `workflows`Diffed against: <https://documenter.gw.postman.com/api/collections/3919598/S11PpG4x?segregateAuth=true&versionTag=latest>-- [ ] `/api1/v2/invoices` — billed revenue per job - the core financial fact table (high)+- [x] `/api1/v2/invoices` — billed revenue per job - the core financial fact table (high)- [x] `/api1/v2/estimates` — quoted value and win/loss analysis against jobs (high)- [x] `/api1/payments` — cash actually collected, needed for AR and collection-rate reporting (high)- [x] `/api1/account/users` — lookup resolving the sales rep / owner / assignee IDs carried on jobs, contacts and tasks (high)- [x] `/api1/account/settings (workflows, statuses, lead sources)` — lookup resolving the workflow, status and lead-source IDs on jobs and contacts (high)- [ ] `/api1/account/settings (custom fields)` — not in the documented settings response (medium)-- [ ] `/api1/v2/products` — product catalog that estimate and invoice line items reference (medium)-- [ ] `/api1/budgets` — job budget vs actual, the input to job-level profitability (medium)+- [x] `/api1/v2/products` — product catalog that estimate and invoice line items reference (medium)+- [x] `/api1/budgets` — job budget vs actual, the input to job-level profitability (medium)- [ ] `/api1/v2/workorders` — scheduled work per job, links crews to jobs (medium)- [ ] `/api1/v2/materialorders` — material cost and supplier ordering per job (medium)-- [ ] `/api1/account/settings?field=groups` — team/group lookup for rolling users up to crews or offices (medium)+- [x] `/api1/account/settings?field=groups` — team/group lookup for rolling users up to crews or offices (medium)- [ ] `/api1/utility/uoms` — unit-of-measure lookup for product and order line items (low)-Note: The doc URL in the payload (documenter.getpostman.com/view/3919598/S11PpG7g) 404s; the live collection is S11PpG4x. The connector exposes 9 of the ~13 GET-able resources, including estimates and payments; invoices and budgets remain the largest financial gaps. File upload endpoints were excluded per the rules.+Note: The doc URL in the payload (documenter.getpostman.com/view/3919598/S11PpG7g) 404s; the live collection is S11PpG4x. The connector now covers invoices, budgets, estimates and payments; work orders and material orders remain the largest job-level gaps. File upload endpoints were excluded per the rules.## Jotform — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/canonical_descriptions.pyindex 275cda90e409..baba7b286b8a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/canonical_descriptions.py@@ -103,6 +103,74 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"date_updated": "When the estimate was last updated (epoch seconds).",},},+ "invoices": {+ "description": "An invoice billed to a customer for a job, with line items, totals, and payments applied.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "jnid": "The unique ID of the invoice.",+ "number": "The invoice number.",+ "customer": "The ID of the customer the invoice belongs to.",+ "status": "The numeric status of the invoice.",+ "status_name": "The status name of the invoice.",+ "cost": "The total cost of the invoice.",+ "margin": "The profit margin of the invoice.",+ "subtotal": "The subtotal amount.",+ "tax": "The tax amount.",+ "total": "The total invoice amount.",+ "total_paid": "The total amount paid against the invoice.",+ "due": "The amount still due on the invoice.",+ "items": "The line items in the invoice.",+ "payments": "The payments applied to the invoice.",+ "related": "The related records (jobs, contacts) the invoice is attached to.",+ "sales_rep": "The ID of the sales rep assigned to the invoice.",+ "date_invoice": "The invoice date (epoch seconds).",+ "date_due": "When the invoice is due (epoch seconds).",+ "date_paid_in_full": "When the invoice was paid in full (epoch seconds).",+ "date_status_change": "When the invoice status last changed (epoch seconds).",+ "date_created": "When the invoice was created (epoch seconds).",+ "date_updated": "When the invoice was last updated (epoch seconds).",+ },+ },+ "products": {+ "description": "A product or service in the account catalog, referenced by estimate and invoice line items.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "jnid": "The unique ID of the product.",+ "name": "The product name.",+ "description": "The product description.",+ "item_type": "The item type, such as material, labor, or labor+material.",+ "uoms": "The units of measure the product is sold in, with material and labor cost and price for each.",+ "suppliers": "The suppliers of the product.",+ "is_active": "Whether the product is active.",+ "tax_exempt": "Whether the product is exempt from tax.",+ "external_id": "The ID of the product in a third-party system it was imported from.",+ "date_created": "When the product was created (epoch seconds).",+ "date_updated": "When the product was last updated (epoch seconds).",+ },+ },+ "budgets": {+ "description": "A job budget with its revenue, costs, commissions, and resulting profit and margin.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "jnid": "The unique ID of the budget.",+ "number": "The budget number.",+ "customer": "The ID of the customer the budget belongs to.",+ "status_name": "The status name of the budget.",+ "revenue": "The budgeted revenue.",+ "costs": "The cost lines in the budget.",+ "total_cost": "The total budgeted cost.",+ "commissions": "The commission lines in the budget.",+ "total_commissions": "The total commissions.",+ "gross_profit": "The gross profit.",+ "gross_margin": "The gross margin percentage.",+ "net_profit": "The net profit after commissions.",+ "net_margin": "The net margin percentage.",+ "related": "The related records (jobs, contacts) the budget is attached to.",+ "date_budget": "The budget date (epoch seconds).",+ "date_created": "When the budget was created (epoch seconds).",+ "date_updated": "When the budget was last updated (epoch seconds).",+ },+ },"users": {"description": "A user or team member of the JobNimbus account.","docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",@@ -134,4 +202,13 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"IsActive": "Whether the lead source is active.",},},+ "groups": {+ "description": "A group of users in the account, such as a team, crew, or office.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "name": "The group name.",+ "managers": "The IDs of the users who manage the group.",+ "members": "The IDs of the users in the group.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/jobnimbus.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/jobnimbus.pyindex ae4b9cc0dbb4..1d1e9b91ddf2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/jobnimbus.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/jobnimbus.py@@ -65,8 +65,9 @@ def jobnimbus_source("name": endpoint,"endpoint": {"path": config.path,+ **({"params": dict(config.params)} if config.params else {}),"data_selector": config.data_selector,- # A 200 body without a `results` list means the response shape changed — fail+ # A 200 body without the selected list means the response shape changed — fail# loud instead of silently syncing 0 rows (or wrapping a stray object as a row)."data_selector_required": True,**({} if config.paginated else {"paginator": "single_page"}),diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/settings.pyindex 87fc6bbe93ab..8603fd24f2fa 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/settings.py@@ -11,7 +11,9 @@ class JobNimbusEndpointConfig:path: str# JobNimbus records carry a globally unique `jnid` (not `id`), so it is a safe primary key.primary_keys: list[str] = field(default_factory=lambda: ["jnid"])- data_selector: str = "results"+ # None selects the whole body, for endpoints that return a bare JSON list.+ data_selector: str | None = "results"+ params: dict[str, str] = field(default_factory=dict)# Account lookups (users, settings) return the whole collection in one body with no `size`/`from`.paginated: bool = True@@ -27,6 +29,9 @@ JOBNIMBUS_ENDPOINTS: dict[str, JobNimbusEndpointConfig] = {"activities": JobNimbusEndpointConfig(name="activities", path="/activities"),"payments": JobNimbusEndpointConfig(name="payments", path="/payments"),"estimates": JobNimbusEndpointConfig(name="estimates", path="/v2/estimates"),+ "invoices": JobNimbusEndpointConfig(name="invoices", path="/v2/invoices"),+ "products": JobNimbusEndpointConfig(name="products", path="/v2/products"),+ "budgets": JobNimbusEndpointConfig(name="budgets", path="/budgets"),"users": JobNimbusEndpointConfig(name="users", path="/account/users", primary_keys=["id"], data_selector="users", paginated=False),@@ -42,6 +47,15 @@ JOBNIMBUS_ENDPOINTS: dict[str, JobNimbusEndpointConfig] = {data_selector="sources",paginated=False,),+ # Groups carry no ID; JobNimbus identifies a group by its name.+ "groups": JobNimbusEndpointConfig(+ name="groups",+ path="/account/settings",+ params={"field": "groups"},+ primary_keys=["name"],+ data_selector=None,+ paginated=False,+ ),}ENDPOINTS = tuple(JOBNIMBUS_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/source.pyindex a04793451ee4..913b068c27e7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/source.py@@ -52,7 +52,7 @@ class JobNimbusSource(ResumableSource[JobNimbusSourceConfig, JobNimbusResumeConfreleaseStatus=ReleaseStatus.ALPHA,caption="""Enter your JobNimbus API key to pull your CRM data into the PostHog Data warehouse.-You can create an API key under **Settings → API** in [JobNimbus](https://app.jobnimbus.com). The key grants access to your contacts, jobs, tasks, activities, estimates, payments, users, and account settings.+You can create an API key under **Settings → API** in [JobNimbus](https://app.jobnimbus.com). The key grants access to your contacts, jobs, tasks, activities, estimates, invoices, payments, budgets, products, users, groups, and account settings.""",iconPath="/static/services/jobnimbus.png",docsUrl="https://posthog.com/docs/cdp/sources/jobnimbus",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/tests/test_jobnimbus.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/tests/test_jobnimbus.pyindex ee074fa57d7e..3ffad6abdddc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/tests/test_jobnimbus.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jobnimbus/tests/test_jobnimbus.py@@ -133,24 +133,39 @@ class TestPagination:@parameterized.expand([- ("users", {"users": [{"id": "u1"}, {"id": "u2"}], "date_updated": 1519413931}, "id", ["u1", "u2"]),+ ("users", {"users": [{"id": "u1"}, {"id": "u2"}], "date_updated": 1519413931}, "id", ["u1", "u2"], {}),("workflows",{"workflows": [{"id": 1, "status": [{"id": 2}]}], "sources": [{"JobSourceId": 9}]},"id",[1],+ {},),("lead_sources",{"workflows": [{"id": 1, "status": [{"id": 2}]}], "sources": [{"JobSourceId": 9}]},"JobSourceId",[9],+ {},+ ),+ (+ "groups",+ [{"name": "Sales", "managers": ["u1"], "members": ["u2"]}, {"name": "Crew A", "members": []}],+ "name",+ ["Sales", "Crew A"],+ {"field": "groups"},),])@mock.patch(CLIENT_SESSION_PATCH)def test_account_lookups_are_fetched_in_one_unpaginated_request(- self, endpoint: str, body: dict[str, Any], key: str, expected: list[Any], MockSession: mock.MagicMock+ self,+ endpoint: str,+ body: Any,+ key: str,+ expected: list[Any],+ expected_params: dict[str, Any],+ MockSession: mock.MagicMock,) -> None:session = MockSession.return_valueparams = _wire(session, [_raw_response(body)])@@ -160,7 +175,7 @@ class TestPagination:assert [r[key] for r in rows] == expectedassert session.send.call_count == 1- assert "size" not in params[0] and "from" not in params[0]+ assert params[0] == expected_paramsmanager.save_state.assert_not_called()@mock.patch(CLIENT_SESSION_PATCH)@@ -203,19 +218,22 @@ class TestErrorHandling:@parameterized.expand([- ("missing_results_key", {"count": 0}),- ("bare_list_body", [{"jnid": "1"}]),+ ("missing_results_key", "contacts", {"count": 0}, "matched nothing"),+ ("bare_list_body", "contacts", [{"jnid": "1"}], "matched nothing"),+ ("groups_settings_object", "groups", {"workflows": [], "sources": []}, "Required a list response body"),])@mock.patch(CLIENT_SESSION_PATCH)- def test_shape_change_fails_loud(self, _name: str, body: Any, MockSession: mock.MagicMock) -> None:- # A 200 body without a `results` list means the response shape changed — fail loud instead of+ def test_shape_change_fails_loud(+ self, _name: str, endpoint: str, body: Any, error: str, MockSession: mock.MagicMock+ ) -> None:+ # A 200 body without the expected list means the response shape changed — fail loud instead of# silently syncing 0 rows or wrapping a stray object as a row.session = MockSession.return_value_wire(session, [_raw_response(body)])- with pytest.raises(ValueError, match="matched nothing"):- _rows(_source(_make_manager()))+ with pytest.raises(ValueError, match=error):+ _rows(_source(_make_manager(), endpoint=endpoint))class TestValidateCredentials: