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 3 missing tables to the JobNimbus source (#118984)

Tom Owers5104dbce74b7
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 581a8a67e6e2..02436886d675 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
@@ -6603,13 +6603,13 @@ Diffed against: <https://documenter.gw.postman.com/api/collections/3919598/S11Pp
- [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/account/settings (custom fields)` — not in the documented settings response (medium). Skipped: the documented settings response has no custom field list, and the API documents only a create call for custom fields.
- [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)
+- [x] `/api1/v2/workorders` — scheduled work per job, links crews to jobs (medium). Added as `work_orders`.
+- [x] `/api1/v2/materialorders` — material cost and supplier ordering per job (medium). Added as `material_orders`.
- [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)
+- [x] `/api1/utility/uoms` — unit-of-measure lookup for product and order line items (low). Added as `units_of_measure` (one row per unit name).
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.
diff --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.py
index baba7b286b8a..f6a9fd47c92b 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
@@ -148,6 +148,52 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"date_updated": "When the product was last updated (epoch seconds).",
},
},
+ "work_orders": {
+ "description": "A work order that schedules work on a job, with line items and the crew or subcontractors assigned.",
+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",
+ "columns": {
+ "jnid": "The unique ID of the work order.",
+ "number": "The work order number.",
+ "customer": "The ID of the JobNimbus account the work order belongs to.",
+ "status": "The numeric status of the work order.",
+ "status_name": "The status name of the work order.",
+ "record_type_name": "The work order type.",
+ "items": "The line items in the work order.",
+ "related": "The related records (jobs, contacts) the work order is attached to.",
+ "owners": "The users assigned to the work order.",
+ "subcontractors": "The subcontractors assigned to the work order.",
+ "sales_rep": "The ID of the sales rep assigned to the work order.",
+ "total_line_item_cost": "The total cost of the line items.",
+ "total_line_item_price": "The total price of the line items.",
+ "date_start": "When the scheduled work starts (epoch seconds).",
+ "date_end": "When the scheduled work ends (epoch seconds).",
+ "date_status_change": "When the work order status last changed (epoch seconds).",
+ "date_created": "When the work order was created (epoch seconds).",
+ "date_updated": "When the work order was last updated (epoch seconds).",
+ },
+ },
+ "material_orders": {
+ "description": "A material order placed with a supplier for a job, with the ordered line items and their cost.",
+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",
+ "columns": {
+ "jnid": "The unique ID of the material order.",
+ "number": "The material order number.",
+ "customer": "The ID of the JobNimbus account the material order belongs to.",
+ "status": "The numeric status of the material order.",
+ "status_name": "The status name of the material order.",
+ "items": "The line items in the material order, with SKU, quantity, unit of measure, cost, and price.",
+ "supplier": "The supplier the order is placed with, and the supplier's order status.",
+ "address": "The delivery address of the material order.",
+ "related": "The related records (jobs, contacts) the material order is attached to.",
+ "sales_rep": "The ID of the sales rep assigned to the material order.",
+ "total_line_item_cost": "The total cost of the line items.",
+ "total_line_item_price": "The total price of the line items.",
+ "date_materialorder": "The material order date (epoch seconds).",
+ "date_status_change": "When the material order status last changed (epoch seconds).",
+ "date_created": "When the material order was created (epoch seconds).",
+ "date_updated": "When the material order 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",
@@ -211,4 +257,11 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"members": "The IDs of the users in the group.",
},
},
+ "units_of_measure": {
+ "description": "The units of measure available for product and order line items.",
+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",
+ "columns": {
+ "uom": "The unit of measure name, such as SQ.",
+ },
+ },
}
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.py
index 1d1e9b91ddf2..52c8eb494e6f 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
@@ -1,4 +1,5 @@
import dataclasses
+from collections.abc import Iterable, Iterator
from typing import Any, Optional
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
@@ -9,6 +10,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
OffsetPaginator,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
@@ -36,6 +38,14 @@ def _headers() -> dict[str, str]:
return {"Accept": "application/json"}
+def _scalar_rows(
+ resource: Resource, column: str, resumable_source_manager: ResumableSourceManager[JobNimbusResumeConfig]
+) -> Iterator[list[dict[str, Any]]]:
+ for page in resource:
+ yield [item if isinstance(item, dict) else {column: item} for item in page]
+ resumable_source_manager.safe_point()
+
+
def jobnimbus_source(
api_key: str,
endpoint: str,
@@ -97,9 +107,14 @@ def jobnimbus_source(
initial_paginator_state=initial_paginator_state,
)
+ def items() -> Iterable[Any]:
+ if config.scalar_column is not None:
+ return _scalar_rows(resource, config.scalar_column, resumable_source_manager)
+ return resource
+
return SourceResponse(
name=endpoint,
- items=lambda: resource,
+ items=items,
primary_keys=config.primary_keys,
partition_count=1,
partition_size=1,
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.py
index 8603fd24f2fa..ea533e05bd3f 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
@@ -16,6 +16,8 @@ class JobNimbusEndpointConfig:
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
+ # Set for endpoints that return a bare list of strings: each string becomes a row under this column.
+ scalar_column: str | None = None
# JobNimbus Open API top-level list endpoints. All are full-refresh only: while records expose
@@ -31,6 +33,8 @@ JOBNIMBUS_ENDPOINTS: dict[str, JobNimbusEndpointConfig] = {
"estimates": JobNimbusEndpointConfig(name="estimates", path="/v2/estimates"),
"invoices": JobNimbusEndpointConfig(name="invoices", path="/v2/invoices"),
"products": JobNimbusEndpointConfig(name="products", path="/v2/products"),
+ "work_orders": JobNimbusEndpointConfig(name="work_orders", path="/v2/workorders"),
+ "material_orders": JobNimbusEndpointConfig(name="material_orders", path="/v2/materialorders"),
"budgets": JobNimbusEndpointConfig(name="budgets", path="/budgets"),
"users": JobNimbusEndpointConfig(
name="users", path="/account/users", primary_keys=["id"], data_selector="users", paginated=False
@@ -56,6 +60,14 @@ JOBNIMBUS_ENDPOINTS: dict[str, JobNimbusEndpointConfig] = {
data_selector=None,
paginated=False,
),
+ "units_of_measure": JobNimbusEndpointConfig(
+ name="units_of_measure",
+ path="/utility/uoms",
+ primary_keys=["uom"],
+ data_selector=None,
+ paginated=False,
+ scalar_column="uom",
+ ),
}
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.py
index a64b5adba077..31167858b70e 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
@@ -55,7 +55,7 @@ class JobNimbusSource(ResumableSource[JobNimbusSourceConfig, JobNimbusResumeConf
releaseStatus=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, invoices, payments, budgets, products, users, groups, 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, work orders, material orders, units of measure, 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.py
index 32fe19d4145f..87acad578306 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
@@ -79,6 +79,7 @@ class TestPagination:
["Sales", "Crew A"],
{"field": "groups"},
),
+ ("units_of_measure", ["SQ", "Items", "LF"], "uom", ["SQ", "Items", "LF"], {}),
]
)
def test_account_lookups_are_fetched_in_one_unpaginated_request(
@@ -119,6 +120,7 @@ class TestErrorHandling:
("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"),
+ ("uoms_object", "units_of_measure", {"uoms": ["SQ"]}, "Required a list response body"),
]
)
def test_shape_change_fails_loud(self, _name: str, endpoint: str, body: Any, error: str) -> None:
@@ -163,7 +165,7 @@ class TestValidateCredentials:
class TestSourceResponse:
@parameterized.expand([(endpoint,) for endpoint in ENDPOINTS])
def test_source_response_shape(self, endpoint: str) -> None:
- if endpoint == "groups":
+ if endpoint in ("groups", "units_of_measure"):
body: Any = []
elif endpoint == "users":
body = {"users": []}