: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(hubplanner): sync booking categories, cost categories, project tags and unassigned work (#111298)
Tom Owers8613aacb8259
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 67648bab750a..fb98caf247d3 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@@ -4137,10 +4137,10 @@ Today (13): `billing_rates`, `bookings`, `clients`, `events`, `holidays`, `milesDiffed against: <https://github.com/hubplanner/API/tree/master/Sections>-- [ ] `/categories (booking categories)` — lookup resolving the category ID on every booking we already sync (high)-- [ ] `/costCategories (project cost categories)` — lookup resolving cost category IDs on projects and billing rates (high)-- [ ] `/unassigned-work` — unallocated demand alongside bookings - needed for capacity vs demand analysis (medium)-- [ ] `/project-tag` — lookup resolving project tag IDs for project segmentation (medium)+- [x] `/categories (booking categories)` — lookup resolving the category ID on every booking we already sync (high)+- [x] `/costCategories (project cost categories)` — lookup resolving cost category IDs on projects and billing rates (high)+- [x] `/unassigned-work` — lookup of unassigned-work item labels (requires the Unassigned Work extension) (medium)+- [x] `/project-tag` — lookup resolving project tag IDs for project segmentation (medium)- [ ] `/resource-tag` — lookup resolving resource tag IDs (skills, roles) for resource segmentation (medium)- [ ] `/project/customField/template` — lookup defining the project custom fields whose values ride on the projects table (medium)- [ ] `/resource/customField/template` — lookup defining the resource custom fields whose values ride on the resources table (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/canonical_descriptions.pyindex 34539ff59bd4..0cf7f84b6a69 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/canonical_descriptions.py@@ -161,4 +161,45 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updatedDate": "Date the record was last updated.",},},+ "booking_categories": {+ "description": "Booking categories used to classify bookings, grouped into category groups.",+ "docs_url": "https://github.com/hubplanner/API/blob/master/Sections/booking-categories.md",+ "columns": {+ "_id": "Unique identifier for the booking category.",+ "name": "Booking category name.",+ "gridColor": "Color used to display bookings in this category on the scheduler.",+ "type": "Whether the category is the default in its group (NON_OPTIONAL) or not (CUSTOM).",+ "categoryGroupId": "ID of the category group the category belongs to.",+ "categoryGroupName": "Name of the category group the category belongs to.",+ "createdDate": "Date the booking category was created.",+ "updatedDate": "Date the booking category was last updated.",+ },+ },+ "cost_categories": {+ "description": "Project cost categories used to classify project costs.",+ "docs_url": "https://github.com/hubplanner/API/blob/master/Sections/project-cost-categories.md",+ "columns": {+ "_id": "Unique identifier for the project cost category.",+ "name": "Project cost category name.",+ "createdDate": "Date the project cost category was created.",+ "updatedDate": "Date the project cost category was last updated.",+ },+ },+ "project_tags": {+ "description": "Tags that can be applied to projects.",+ "docs_url": "https://github.com/hubplanner/API/blob/master/Sections/project-tag.md",+ "columns": {+ "_id": "Unique identifier for the project tag.",+ "value": "Project tag value.",+ "category": "Project tag category.",+ },+ },+ "unassigned_work": {+ "description": "Unassigned work items, available when the Unassigned Work extension is enabled.",+ "docs_url": "https://github.com/hubplanner/API/blob/master/Sections/unassigned-work.md",+ "columns": {+ "_id": "Unique identifier for the unassigned work item.",+ "value": "Unassigned work item name.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/settings.pyindex 81f171086f02..9c865c3f3d38 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/settings.py@@ -121,6 +121,32 @@ HUBPLANNER_ENDPOINTS: dict[str, HubPlannerEndpointConfig] = {partition_key="createdDate",incremental_fields=[],),+ "booking_categories": HubPlannerEndpointConfig(+ name="booking_categories",+ path="/categories",+ partition_key="createdDate",+ incremental_fields=[],+ ),+ "cost_categories": HubPlannerEndpointConfig(+ name="cost_categories",+ path="/costCategories",+ partition_key="createdDate",+ incremental_fields=[],+ ),+ # Tags and unassigned work carry no creation timestamp (`_id` and `value` only), so they+ # aren't partitioned.+ "project_tags": HubPlannerEndpointConfig(+ name="project_tags",+ path="/project-tag",+ incremental_fields=[],+ ),+ # Only available when the account has the Unassigned Work extension enabled, so it starts off.+ "unassigned_work": HubPlannerEndpointConfig(+ name="unassigned_work",+ path="/unassigned-work",+ incremental_fields=[],+ should_sync_default=False,+ ),}ENDPOINTS = tuple(HUBPLANNER_ENDPOINTS.keys())@@ -128,3 +154,7 @@ ENDPOINTS = tuple(HUBPLANNER_ENDPOINTS.keys())INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: config.incremental_fields for name, config in HUBPLANNER_ENDPOINTS.items()}++SHOULD_SYNC_DEFAULT: dict[str, bool] = {+ name: config.should_sync_default for name, config in HUBPLANNER_ENDPOINTS.items()+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/source.pyindex 33f27b27c53f..71faa2ff0a07 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/source.py@@ -29,6 +29,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.hubplannerfrom products.warehouse_sources.backend.temporal.data_imports.sources.hubplanner.settings import (ENDPOINTS,INCREMENTAL_FIELDS,+ SHOULD_SYNC_DEFAULT,)from products.warehouse_sources.backend.types import ExternalDataSourceType@@ -96,7 +97,7 @@ Generate a **Read Only** API key in Hub Planner under **Settings → API** (admi# Only bookings and time_entries carry a searchable `updatedDate`, so they're the only# endpoints with incremental fields — build_endpoint_schemas derives incremental/append# support from that (has_incremental == incremental_search_field is not None).- return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names, should_sync_default=SHOULD_SYNC_DEFAULT)def validate_credentials(self,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/tests/test_hubplanner.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/tests/test_hubplanner.pyindex 925bc379415d..647b07bd811a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/tests/test_hubplanner.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hubplanner/tests/test_hubplanner.py@@ -97,12 +97,21 @@ class TestFormatValue:class TestBuildRequestPlan:- def test_full_refresh_endpoint_uses_unsorted_get(self) -> None:+ @parameterized.expand(+ [+ ("projects", "/project"),+ ("booking_categories", "/categories"),+ ("cost_categories", "/costCategories"),+ ("project_tags", "/project-tag"),+ ("unassigned_work", "/unassigned-work"),+ ]+ )+ def test_full_refresh_endpoint_uses_unsorted_get(self, endpoint: str, expected_path: str) -> None:# No `sort` on full-refresh GET: an unsupported sort field would 400 the whole sync.method, path, body, sort_field = _build_request_plan(- HUBPLANNER_ENDPOINTS["projects"], should_use_incremental_field=False, db_incremental_field_last_value=None+ HUBPLANNER_ENDPOINTS[endpoint], should_use_incremental_field=False, db_incremental_field_last_value=None)- assert (method, path, body, sort_field) == ("GET", "/project", None, None)+ assert (method, path, body, sort_field) == ("GET", expected_path, None, None)def test_incremental_endpoint_without_incremental_selected_uses_get(self) -> None:# A user syncing bookings via full refresh should hit the plain GET list, not search.@@ -304,10 +313,11 @@ class TestSourceResponse:assert response.partition_keys == ["createdDate"]assert response.sort_mode == "asc"+ @parameterized.expand([("vacations",), ("project_tags",), ("unassigned_work",)])@mock.patch(CLIENT_SESSION_PATCH)- def test_endpoint_without_partition_key_has_no_partitioning(self, MockSession) -> None:- # Vacations carry no creation timestamp, so they aren't partitioned.- response = hubplanner_source("k", "vacations", team_id=1, job_id="j", resumable_source_manager=_make_manager())+ def test_endpoint_without_partition_key_has_no_partitioning(self, endpoint: str, MockSession) -> None:+ # These endpoints carry no creation timestamp, so they aren't partitioned.+ response = hubplanner_source("k", endpoint, team_id=1, job_id="j", resumable_source_manager=_make_manager())assert response.partition_mode is Noneassert response.partition_keys is None