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 5 missing tables to the FieldPulse source (#116530)

Tom Owers3048c9d19e78
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 9622a8aeb0db..e2b09f5a68c6 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
@@ -4509,10 +4509,10 @@ Today (6): `customers`, `estimates`, `invoices`, `jobs`, `payments`, `projects`
Diffed against: <https://help.fieldpulse.com/openapi/fieldpulse-api.json>
-- [ ] `Company users (GET /users)` — resolve customer assignees and job member IDs for technician productivity and revenue attribution (high)
-- [ ] `Job status workflows and statuses (GET /jobs/status-workflows; GET /jobs/status-workflow-statuses)` — resolve status_workflow_id and status_id on jobs for completion and workload analysis (high)
-- [ ] `Pipeline statuses (GET /pipeline-status)` — resolve pipeline_status_id on customers for sales funnel and conversion analysis (high)
-- [ ] `Lead sources (GET /lead-source)` — resolve lead_source_id on customers to measure acquisition channels and resulting revenue (high)
+- [x] `Company users (GET /users)` — resolve customer assignees and job member IDs for technician productivity and revenue attribution (high)
+- [x] `Job status workflows and statuses (GET /jobs/status-workflows; GET /jobs/status-workflow-statuses)` — resolve status_workflow_id and status_id on jobs for completion and workload analysis (high)
+- [x] `Pipeline statuses (GET /pipeline-status)` — resolve pipeline_status_id on customers for sales funnel and conversion analysis (high)
+- [x] `Lead sources (GET /lead-source)` — resolve lead_source_id on customers to measure acquisition channels and resulting revenue (high)
- [ ] `Company teams (GET /teams)` — resolve team assignments on jobs and customers to compare team performance (high)
- [ ] `Invoice items (GET /items)` — resolve item references and compare products, costs, and billed quantities across invoices (high)
- [ ] `Tags (GET /tags)` — resolve customer tag IDs into named segments for conversion and revenue analysis (high)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/canonical_descriptions.py
index 5440728b9659..76568da8e438 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/canonical_descriptions.py
@@ -33,4 +33,29 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"docs_url": "https://help.fieldpulse.com/api-reference/projects/retrieve-projects-list",
"columns": {},
},
+ "users": {
+ "description": "Users of the company account, such as technicians and office staff.",
+ "docs_url": "https://help.fieldpulse.com/api-reference/users/retrieve-users-list",
+ "columns": {},
+ },
+ "job_status_workflows": {
+ "description": "Status workflows that define the sequence of statuses a job moves through.",
+ "docs_url": "https://help.fieldpulse.com/api-reference/jobs/retrieve-job-status-workflows-list",
+ "columns": {},
+ },
+ "job_status_workflow_statuses": {
+ "description": "Statuses that belong to the job status workflows.",
+ "docs_url": "https://help.fieldpulse.com/api-reference/jobs/retrieve-job-status-workflow-statuses-list",
+ "columns": {},
+ },
+ "pipeline_statuses": {
+ "description": "Pipeline statuses that track a customer through the sales pipeline.",
+ "docs_url": "https://help.fieldpulse.com/api-reference/pipeline-status/retrieve-pipeline-statuses-list",
+ "columns": {},
+ },
+ "lead_sources": {
+ "description": "Lead sources that record how a customer found the company.",
+ "docs_url": "https://help.fieldpulse.com/api-reference/lead-source/retrieve-lead-sources-list",
+ "columns": {},
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/fieldpulse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/fieldpulse.py
index 2f112a3233af..df28c675f785 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/fieldpulse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/fieldpulse.py
@@ -12,6 +12,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import APIKeyAuth
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
+ PageNumberPaginator,
SinglePagePaginator,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import RESTClient
@@ -28,6 +29,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.fieldpulse
AUTH_ERROR,
BASE_URL,
ENDPOINTS,
+ ENDPOINTS_WITHOUT_DOCUMENTED_PAGING,
PAGE_SIZE,
PRIMARY_KEYS,
)
@@ -49,6 +51,26 @@ def _normalize_rate_limit_header(response: Response, *args: object, **kwargs: ob
return response
+class RepeatedPagePaginator(PageNumberPaginator):
+ """Stops when the API returns the same page again.
+
+ An endpoint that ignores `page` returns its first page for each request, so the usual
+ stop on an empty page never occurs.
+ """
+
+ def __init__(self) -> None:
+ super().__init__(base_page=1, total_path=None)
+ self._previous_page: list[Any] | None = None
+
+ def update_state(self, response: Response, data: list[Any] | None = None) -> None:
+ if data and data == self._previous_page:
+ # The client yields this list after this call, so emptying it drops the duplicate rows.
+ data.clear()
+ else:
+ self._previous_page = list(data) if data else None
+ super().update_state(response, data)
+
+
def _session(api_key: str) -> Session:
session = make_tracked_session(redact_values=(api_key,))
session.hooks["response"].append(_normalize_rate_limit_header)
@@ -117,10 +139,15 @@ def fieldpulse_source(
)
resumable_source_manager.safe_point()
+ paginator: PaginatorConfig = (
+ RepeatedPagePaginator()
+ if endpoint in ENDPOINTS_WITHOUT_DOCUMENTED_PAGING
+ else cast(PaginatorConfig, {"type": "page_number", "base_page": 1, "total_path": None})
+ )
client_config: ClientConfig = {
"base_url": BASE_URL,
"auth": {"type": "api_key", "name": "x-api-key", "api_key": api_key, "location": "header"},
- "paginator": cast(PaginatorConfig, {"type": "page_number", "base_page": 1, "total_path": None}),
+ "paginator": paginator,
"allow_redirects": False,
"session": _session(api_key),
"request_timeout": REQUEST_TIMEOUT,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/settings.py
index 6482d6c52d79..d27eaec63b62 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/settings.py
@@ -11,7 +11,15 @@ ENDPOINTS = {
"invoices": "invoices",
"payments": "payments",
"projects": "projects",
+ "users": "users",
+ "job_status_workflows": "jobs/status-workflows",
+ "job_status_workflow_statuses": "jobs/status-workflow-statuses",
+ "pipeline_statuses": "pipeline-status",
+ "lead_sources": "lead-source",
}
-INCREMENTAL_FIELDS = {name: [incremental_field("updated_at")] for name in ENDPOINTS}
+INCREMENTAL_ENDPOINTS = ("customers", "jobs", "estimates", "invoices", "payments", "projects")
+INCREMENTAL_FIELDS = {name: [incremental_field("updated_at")] for name in INCREMENTAL_ENDPOINTS}
+# The API reference lists no `page` parameter for these endpoints.
+ENDPOINTS_WITHOUT_DOCUMENTED_PAGING = frozenset({"users", "job_status_workflows", "job_status_workflow_statuses"})
PRIMARY_KEYS = ["id"]
AUTH_ERROR = "FieldPulse rejected the API key. Contact [email protected] to check that your key is active."
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/tests/test_fieldpulse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/tests/test_fieldpulse.py
index 00aa71a8e3bb..141378738664 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/tests/test_fieldpulse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fieldpulse/tests/test_fieldpulse.py
@@ -95,6 +95,56 @@ def test_requests_and_pagination(
]
[email protected]("endpoint", ["users", "job_status_workflows", "job_status_workflow_statuses"])
+ "pages,expected_items,expected_pages",
+ [
+ pytest.param(
+ [[{"id": 1}, {"id": 2}], [{"id": 1}, {"id": 2}]],
+ [[{"id": 1}, {"id": 2}]],
+ ["1", "2"],
+ id="page_parameter_ignored",
+ ),
+ pytest.param(
+ [[{"id": 1}], [{"id": 2}], []],
+ [[{"id": 1}], [{"id": 2}]],
+ ["1", "2", "3"],
+ id="page_parameter_honored",
+ ),
+ pytest.param(
+ [[{"id": 1}], [{"id": 2}], [{"id": 2}]],
+ [[{"id": 1}], [{"id": 2}]],
+ ["1", "2", "3"],
+ id="last_page_repeats",
+ ),
+ pytest.param(
+ [{"id": 1, "name": "Default"}, {"id": 1, "name": "Default"}],
+ [[{"id": 1, "name": "Default"}]],
+ ["1", "2"],
+ id="single_record_response",
+ ),
+ pytest.param([[]], [], ["1"], id="no_rows"),
+ ],
+)
+def test_endpoints_without_documented_paging_stop_on_a_repeated_page(
+ endpoint: str,
+ pages: list[Any],
+ expected_items: list[list[dict[str, Any]]],
+ expected_pages: list[str],
+) -> None:
+ result = driver().run(
+ endpoint,
+ [ScriptedResponse(json={"error": False, "response": page}) for page in pages],
+ )
+
+ assert result.raised is None
+ assert result.items == expected_items
+ assert result.params("page") == expected_pages
+ for request in result.requests:
+ assert request.param("sort[0][attribute]") == "id"
+ assert not any(key.startswith("filter[") for key in request.query)
+
+
@pytest.mark.parametrize("saved_bound", [None, "2026-01-01T00:00:00+00:00"])
def test_resume_preserves_original_filter(saved_bound: str | None) -> None:
result = driver().run(