: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 payments, estimates, users and settings tables (#112523)
Tom Owers63e5767cdc86
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 4a93289b4bd3..f8b64b9ac683 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@@ -4564,15 +4564,16 @@ Note: The connector covers only the platform v3 lookup tables plus /search/jql i## JobNimbus — **thin**-Today (4): `activities`, `contacts`, `jobs`, `tasks`+Today (9): `activities`, `contacts`, `estimates`, `jobs`, `lead_sources`, `payments`, `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)-- [ ] `/api1/v2/estimates` — quoted value and win/loss analysis against jobs (high)-- [ ] `/api1/payments` — cash actually collected, needed for AR and collection-rate reporting (high)-- [ ] `/api1/account/users` — lookup resolving the sales rep / owner / assignee IDs carried on jobs, contacts and tasks (high)-- [ ] `/api1/account/settings (workflows, statuses, lead sources, custom fields)` — lookup resolving the workflow, status and lead-source IDs on jobs and contacts (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)- [ ] `/api1/v2/workorders` — scheduled work per job, links crews to jobs (medium)@@ -4580,7 +4581,7 @@ Diffed against: <https://documenter.gw.postman.com/api/collections/3919598/S11Pp- [ ] `/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 4 of the ~13 GET-able resources and, notably, none of the money ones (estimates, invoices, payments, budgets) - for a roofing/contracting CRM that is where nearly all the analytical value is. 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 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.## 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 3807abdbcbef..275cda90e409 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@@ -2,12 +2,12 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.canCanonicalDescriptions,)-# Descriptions sourced from the JobNimbus Open API docs (https://documenter.getpostman.com/view/3919598/S11PpG7g).+# Descriptions sourced from the JobNimbus Open API docs (https://documenter.getpostman.com/view/3919598/S11PpG4x).# Partial coverage is fine — uncovered columns fall back to LLM enrichment.CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"contacts": {"description": "A person or company in your JobNimbus CRM — a lead, customer, or business contact.",- "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG7g",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x","columns": {"jnid": "The unique ID of the contact.","display_name": "The contact's display name.",@@ -23,7 +23,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {},"jobs": {"description": "A job or project tracked in JobNimbus, typically linked to one or more contacts.",- "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG7g",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x","columns": {"jnid": "The unique ID of the job.","name": "The job name.",@@ -37,7 +37,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {},"tasks": {"description": "A to-do or scheduled task linked to a contact or job.",- "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG7g",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x","columns": {"jnid": "The unique ID of the task.","title": "The task title.",@@ -52,7 +52,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {},"activities": {"description": "An activity or note recorded against a contact or job (calls, emails, updates).",- "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG7g",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x","columns": {"jnid": "The unique ID of the activity.","note": "The activity note or message body.",@@ -62,4 +62,76 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"date_updated": "When the activity was last updated (epoch seconds).",},},+ "payments": {+ "description": "A payment collected from a customer, applied against one or more invoices.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "jnid": "The unique ID of the payment.",+ "customer": "The ID of the customer the payment belongs to.",+ "total": "The total payment amount.",+ "credit": "The credit amount applied by the payment.",+ "refunded_amount": "The amount refunded from the payment.",+ "invoices": "The invoices the payment is applied to, with the amount applied to each.",+ "reference": "The payment reference, such as a check number.",+ "date_payment": "When the payment was made (epoch seconds).",+ "sales_rep": "The ID of the sales rep assigned to the payment.",+ "date_created": "When the payment was created (epoch seconds).",+ "date_updated": "When the payment was last updated (epoch seconds).",+ },+ },+ "estimates": {+ "description": "A quote sent to a customer for a job, with line items and totals.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "jnid": "The unique ID of the estimate.",+ "number": "The estimate number.",+ "customer": "The ID of the customer the estimate belongs to.",+ "status": "The numeric status of the estimate.",+ "status_name": "The status name of the estimate.",+ "cost": "The total cost of the estimate.",+ "margin": "The profit margin of the estimate.",+ "subtotal": "The subtotal amount.",+ "tax": "The tax amount.",+ "total": "The total estimate amount.",+ "items": "The line items in the estimate.",+ "related": "The related records (jobs, contacts) the estimate is attached to.",+ "esigned": "Whether the estimate was signed electronically.",+ "date_estimate": "The estimate date (epoch seconds).",+ "date_signed": "When the estimate was signed (epoch seconds).",+ "date_status_change": "When the estimate status last changed (epoch seconds).",+ "date_created": "When the estimate was created (epoch seconds).",+ "date_updated": "When the estimate 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",+ "columns": {+ "id": "The user's ID. Matches the owner, sales rep, and assignee IDs on other records.",+ "first_name": "The user's first name.",+ "last_name": "The user's last name.",+ "email": "The user's email address.",+ "is_active": "Whether the user is active or disabled.",+ },+ },+ "workflows": {+ "description": "A workflow configured in the account, with the statuses it contains.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "id": "The unique ID of the workflow.",+ "name": "The workflow name.",+ "object_type": "The record type the workflow applies to, such as contact or job.",+ "status": "The statuses in the workflow. Their IDs match the status IDs on contacts and jobs.",+ "is_active": "Whether the workflow is active.",+ },+ },+ "lead_sources": {+ "description": "A lead source configured in the account.",+ "docs_url": "https://documenter.getpostman.com/view/3919598/S11PpG4x",+ "columns": {+ "JobSourceId": "The unique ID of the lead source. Matches the source ID on contacts and jobs.",+ "SourceName": "The lead source name.",+ "IsActive": "Whether the lead source is active.",+ },+ },}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 d9c42f1fc57d..ae4b9cc0dbb4 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,10 +65,11 @@ def jobnimbus_source("name": endpoint,"endpoint": {"path": config.path,- "data_selector": "results",+ "data_selector": config.data_selector,# A 200 body without a `results` 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 31c0e535e8aa..87fc6bbe93ab 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@@ -1,14 +1,19 @@-from dataclasses import dataclass, field+from dataclasses import field++from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.types import IncrementalField-@dataclass+@frozenclass JobNimbusEndpointConfig:name: strpath: 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"+ # Account lookups (users, settings) return the whole collection in one body with no `size`/`from`.+ paginated: bool = True# JobNimbus Open API top-level list endpoints. All are full-refresh only: while records expose@@ -20,6 +25,23 @@ JOBNIMBUS_ENDPOINTS: dict[str, JobNimbusEndpointConfig] = {"jobs": JobNimbusEndpointConfig(name="jobs", path="/jobs"),"tasks": JobNimbusEndpointConfig(name="tasks", path="/tasks"),"activities": JobNimbusEndpointConfig(name="activities", path="/activities"),+ "payments": JobNimbusEndpointConfig(name="payments", path="/payments"),+ "estimates": JobNimbusEndpointConfig(name="estimates", path="/v2/estimates"),+ "users": JobNimbusEndpointConfig(+ name="users", path="/account/users", primary_keys=["id"], data_selector="users", paginated=False+ ),+ # Workflows (with their nested statuses) and lead sources both come from the account settings+ # document; each table selects one of its lookup lists.+ "workflows": JobNimbusEndpointConfig(+ name="workflows", path="/account/settings", primary_keys=["id"], data_selector="workflows", paginated=False+ ),+ "lead_sources": JobNimbusEndpointConfig(+ name="lead_sources",+ path="/account/settings",+ primary_keys=["JobSourceId"],+ data_selector="sources",+ 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 29a06bf88b8c..a04793451ee4 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@@ -37,7 +37,7 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.registerclass JobNimbusSource(ResumableSource[JobNimbusSourceConfig, JobNimbusResumeConfig]):lists_tables_without_credentials = True # static endpoint catalog — safe for public docs- api_docs_url = "https://documenter.getpostman.com/view/3919598/S11PpG7g"+ api_docs_url = "https://documenter.getpostman.com/view/3919598/S11PpG4x"@propertydef source_type(self) -> ExternalDataSourceType:@@ -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, and activities.+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.""",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 fd961056252f..ee074fa57d7e 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@@ -13,10 +13,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.jobnimbus.jobnimbus_source,validate_credentials,)-from products.warehouse_sources.backend.temporal.data_imports.sources.jobnimbus.settings import (- ENDPOINTS,- JOBNIMBUS_ENDPOINTS,-)+from products.warehouse_sources.backend.temporal.data_imports.sources.jobnimbus.settings import ENDPOINTS# RESTClient builds its session via make_tracked_session in the rest_client module.CLIENT_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client.make_tracked_session"@@ -134,6 +131,38 @@ class TestPagination:assert params[0]["from"] == PAGE_SIZE+ @parameterized.expand(+ [+ ("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],+ ),+ ]+ )+ @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+ ) -> None:+ session = MockSession.return_value+ params = _wire(session, [_raw_response(body)])++ manager = _make_manager()+ rows = _rows(_source(manager, endpoint=endpoint))++ assert [r[key] for r in rows] == expected+ assert session.send.call_count == 1+ assert "size" not in params[0] and "from" not in params[0]+ manager.save_state.assert_not_called()+@mock.patch(CLIENT_SESSION_PATCH)def test_empty_first_page_yields_nothing(self, MockSession: mock.MagicMock) -> None:session = MockSession.return_value@@ -222,10 +251,5 @@ class TestSourceResponse:def test_source_response_shape(self, endpoint: str, _MockSession: mock.MagicMock) -> None:response = _source(_make_manager(), endpoint=endpoint)assert response.name == endpoint- assert response.primary_keys == ["jnid"]# No stable creation timestamp is guaranteed across every object, so we don't partition.assert response.partition_mode is None-- def test_every_endpoint_uses_jnid_primary_key(self) -> None:- assert all(config.primary_keys == ["jnid"] for config in JOBNIMBUS_ENDPOINTS.values())- assert set(JOBNIMBUS_ENDPOINTS) == set(ENDPOINTS)