: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(charthop): add comp band, comp history, and time off policy tables (#102228)
Tom Owers0f9213cc433a
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 29b89af34fa3..daf2b003e13b 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@@ -1360,14 +1360,14 @@ Note: developers.maxio.com is an APIMatic SPA that returns a 121-byte shell to c## ChartHop — gaps-Today (8): `changes`, `group_types`, `groups`, `job_codes`, `job_levels`, `jobs`, `persons`, `time_off`+Today (11): `changes`, `comp_bands`, `compensation_history`, `group_types`, `groups`, `job_codes`, `job_levels`, `jobs`, `persons`, `time_off`, `time_off_policies`Diffed against: <https://api.charthop.com/swagger.json>-- [ ] `/v1/org/{orgId}/timeoff/policy` — lookup resolving the policy ids already carried on the synced time_off rows (high)-- [ ] `/v1/org/{orgId}/timeoff/policy/balances` — accrued vs used balance per person per policy - the number HR actually reports on (high)-- [ ] `/v1/org/{orgId}/change/compensation-history` — compensation change history per person, the analytical spine for pay-equity and raise analysis (high)-- [ ] `/v1/org/{orgId}/band` — comp band lookup that resolves the band a job/job_level sits in (high)+- [x] `/v1/org/{orgId}/timeoff/policy` — lookup resolving the policy ids already carried on the synced time_off rows (high)+- [ ] `/v1/org/{orgId}/timeoff/policy/balances` — accrued vs used balance per person per policy - the number HR actually reports on (high) — the vendor spec declares no response schema for this path (one of 7 bare `{"type": "object"}` GETs out of 556) and it takes no `limit`/`from` pagination params, so the row shape, the id fields, and how the walk terminates are all unverifiable; left open pending a real response sample+- [x] `/v1/org/{orgId}/change/compensation-history` — compensation change history per person, the analytical spine for pay-equity and raise analysis (high)+- [x] `/v1/org/{orgId}/band` — comp band lookup that resolves the band a job/job_level sits in (high)- [ ] `/v1/org/{orgId}/timeoff-ledger/data` — per-entry accrual/usage ledger behind the balances (medium)- [ ] `/v1/org/{orgId}/comp-review` — compensation review cycles and their in-cycle changes (medium)- [ ] `/v1/org/{orgId}/stockgrant` — equity grants per person - missing half of total compensation (medium)@@ -1377,7 +1377,7 @@ Diffed against: <https://api.charthop.com/swagger.json>- [ ] `/v1/user` — lookup mapping ChartHop user accounts to person ids for adoption analysis (medium)- [ ] `/v1/org/{orgId}/scenario` — headcount planning scenarios, needed to compare planned vs actual hiring (medium)-Note: Full OpenAPI 3 spec (2 MB, 541 paths) is served unauthenticated at api.charthop.com/swagger.json. PostHog covers the core org-chart entities but none of the compensation, performance, or time-off ledger surface.+Note: Full OpenAPI 3 spec (2 MB, 541 paths) is served unauthenticated at api.charthop.com/swagger.json. PostHog covers the core org-chart entities, comp bands, comp change history, and time-off policies. Still uncovered: equity grants, comp review cycles, the performance surface, and the time-off ledger.## ChartMogul — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/canonical_descriptions.pyindex 0d00f56afe70..5de8487a1351 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/canonical_descriptions.py@@ -155,4 +155,100 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"requestAt": "Requested at timestamp, often the same as createAt.",},},+ "time_off_policies": {+ "description": "Time off policies configured for the organization, one row per policy. Resolves the policy ids carried on time_off rows.",+ "docs_url": "https://api.charthop.com/swagger#/timeoff/findTimeOffPolicies",+ "columns": {+ "id": "Globally unique id of the time off policy.",+ "orgId": "Org that the policy belongs to.",+ "name": "Internal policy name.",+ "displayName": "External policy name displayed to users.",+ "description": "Policy description.",+ "guidelines": "Policy guidelines.",+ "color": "Color used to represent the policy.",+ "emoji": "Emoji used to represent the policy.",+ "type": "Type of policy (e.g. PTO, VACATION, SICK, PARENTAL).",+ "status": "Whether the policy is active or inactive.",+ "allocationType": "Whether the time off is accrued, received upfront, or unlimited.",+ "annualAllocation": "Number of days allocated annually.",+ "accrualConfig": "Configuration for how time off is accrued.",+ "maxConsecutiveDaysPerRequest": "Optional max number of days allowed per request.",+ "minBalance": "Optional minimum balance.",+ "enableCarryOverBalance": "Whether carry over balance is enabled.",+ "maxCarryOverBalance": "Optional maximum carry over balance.",+ "carryOverExpirationDate": "Month and day of carry over expiration.",+ "carryOverExpirationMonths": "Months after the carry over date that carry over expires.",+ "enablePartialDayRequests": "Whether half day requests are allowed.",+ "partialDayGranularity": "Level of granularity partial day requests can be made down to.",+ "enablePartialDayPeriod": "Whether periods of time (e.g. AM, PM) can be specified for partial days.",+ "disableRequests": "Whether time off requests are disabled for this policy.",+ "noteRequired": "Whether a note is required for time off requests.",+ "enableManagerRequests": "Whether managers can request, edit, and delete time off for their reports on this policy.",+ "filter": "CQL used to determine which jobs the policy applies to.",+ "holidayCalendarId": "Associated holiday calendar; days on it are not deducted from the balance.",+ "respectPersonCalendar": "When true, a holiday calendar applied to the person takes precedence over the policy's holidayCalendarId.",+ "disableProratedAllocation": "Whether limited allocation policies are prorated by person start date.",+ "prorationRounding": "Rounding method for prorating calculations.",+ "yearStartDate": "Month and day of policy year rollover. Defaults to January 1.",+ "policyFromDate": "Date the policy's balance and accrual settings come into effect.",+ "policyUntilDate": "First date after the policy's balance and accrual settings end (exclusive).",+ "workDays": "Days of the week that count against the balance. Defaults to Monday through Friday.",+ "createAt": "Created timestamp.",+ "updateAt": "Updated timestamp.",+ "deleteAt": "Deleted timestamp.",+ },+ },+ "comp_bands": {+ "description": "Compensation bands configured for the organization, one row per band. Resolves the band a job or job level sits in.",+ "docs_url": "https://api.charthop.com/swagger#/band/findCompBands",+ "columns": {+ "id": "Globally unique id.",+ "orgId": "Parent organization id.",+ "label": "Human-readable name of the band.",+ "color": "Hex color associated with the band level.",+ "baseCompMin": "Minimum base compensation for the band.",+ "baseCompMid": "Midpoint base compensation for the band.",+ "baseCompMax": "Maximum base compensation for the band.",+ "baseSpread": "Spread percent used to calculate base comp from the midpoint.",+ "baseInterval": "Interval of base compensation, hourly or annual.",+ "baseTargetPay": "Base target pay associated with open jobs at this band level.",+ "baseTargetPayPercentile": "Target pay for open jobs at this band level, as a percentile of [min, max].",+ "jobTierOneField": "First job tier associated with the comp band.",+ "jobTierTwoField": "Second job tier associated with the comp band.",+ "jobTierThreeField": "Third job tier associated with the comp band.",+ "jobLevel": "Job level associated with the comp band.",+ "equityTargetShares": "Target equity for the band, in shares.",+ "equityTargetPercentOfBase": "Target equity for the band, as a percentage of base.",+ "equityTargetValue": "Target equity for the band, as a monetary value in the org's currency.",+ "equityRefreshShares": "Refresh grant equity for the band, in shares.",+ "equityRefreshPercentOfBase": "Refresh grant equity for the band, as a percentage of base.",+ "equityRefreshValue": "Refresh grant equity for the band, as a monetary value in the org's currency.",+ "variableValue": "Variable compensation for the band.",+ "variablePercentOfBase": "Variable compensation for the band, as a percentage of base.",+ "startingSalary": "Default starting salary for this band.",+ "createAt": "Created timestamp.",+ "updateAt": "Last updated timestamp.",+ "deleteAt": "Deleted timestamp.",+ "createDate": "When the band starts existing in org history.",+ "deleteDate": "When the band stops existing in org history.",+ },+ },+ "compensation_history": {+ "description": "Enriched compensation change history, one row per comp change, with the person, job, and pay values as of the change date.",+ "docs_url": "https://api.charthop.com/swagger#/change/compensationHistory",+ "columns": {+ "changeId": "Id of the change that produced this row.",+ "personId": "Person id at the time of the change.",+ "jobId": "Job id at the time of the change.",+ "date": "Date the comp change took effect.",+ "name": "Person's full name (first last).",+ "workEmail": "Person's work email.",+ "title": "Job title as of the change date.",+ "basePay": "Annualized base pay as of the change date.",+ "variablePay": "Annualized variable target pay as of the change date.",+ "total": "Base plus variable pay, only when both share a currency.",+ "department": "Department group as of the change date.",+ "manager": "Manager (person) as of the change date.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/settings.pyindex f323e0e8f7a4..1e4066a13147 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/settings.py@@ -106,6 +106,28 @@ CHARTHOP_ENDPOINTS: dict[str, ChartHopEndpointConfig] = {name="time_off",path="/v1/org/{org_id}/timeoff",),+ "time_off_policies": ChartHopEndpointConfig(+ name="time_off_policies",+ path="/v1/org/{org_id}/timeoff/policy",+ ),+ "comp_bands": ChartHopEndpointConfig(+ name="comp_bands",+ path="/v1/org/{org_id}/band",+ # Bands are a lookup: a job or job level can still reference a retired band, so keep+ # deleted rows (they carry deleteAt/deleteDate) to leave those references resolvable.+ extra_params={"includeDeleted": "true"},+ ),+ "compensation_history": ChartHopEndpointConfig(+ name="compensation_history",+ path="/v1/org/{org_id}/change/compensation-history",+ # No ``id`` on the row. A change is scoped to a job, so pairing the two keeps the key+ # unique even if one change ever emits a row per affected job.+ primary_key=["changeId", "jobId"],+ # Full refresh despite the endpoint's ``startDate`` filter: it only returns rows in+ # descending date order (no ``desc`` param to flip it), and the vendor spec leaves the+ # row's ``date`` type undeclared, so neither the watermark nor a datetime partition can+ # be trusted here. One row per comp change keeps a full re-read cheap.+ ),}ENDPOINTS = tuple(CHARTHOP_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/tests/test_charthop.py b/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/tests/test_charthop.pyindex 4ee79d8157bf..98cdee45c845 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/tests/test_charthop.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/charthop/tests/test_charthop.py@@ -216,31 +216,68 @@ class TestPagination:assert urls[0] == f"{CHARTHOP_BASE_URL}{expected_path}"assert params[0][expected_param] == "2026-01-15"+ @parameterized.expand(+ [+ ("jobs", "jobs"),+ ("time_off_policies", "time_off_policies"),+ ("comp_bands", "comp_bands"),+ # compensation-history does accept a startDate filter, but only serves descending+ # rows, so it stays full refresh — a watermark must never reach the request.+ ("compensation_history", "compensation_history"),+ ]+ )@mock.patch(CLIENT_SESSION_PATCH)- def test_full_refresh_endpoint_never_sends_date_filter(self, MockSession) -> None:+ def test_full_refresh_endpoint_never_sends_date_filter(self, _name: str, endpoint: str, MockSession) -> None:session = MockSession.return_valueparams, _urls = _wire(session, [_response([{"id": "1"}])])_rows(_source(- "jobs",+ endpoint,_make_manager(),should_use_incremental_field=True,db_incremental_field_last_value=date(2026, 1, 15),))- assert "date" not in params[0]+ assert not {"date", "fromDate", "startDate"} & set(params[0])+ @parameterized.expand(+ [+ # Ex-employees, so departures stay queryable.+ ("persons", "persons", "includeAll"),+ # Retired bands, so jobs referencing them stay resolvable.+ ("comp_bands", "comp_bands", "includeDeleted"),+ ]+ )@mock.patch(CLIENT_SESSION_PATCH)- def test_persons_includes_ex_employees(self, MockSession) -> None:+ def test_static_params_sent_on_every_page(self, _name: str, endpoint: str, param: str, MockSession) -> None:session = MockSession.return_value- params, _urls = _wire(session, [_response([])])+ params, _urls = _wire(session, [_response([{"id": "1"}], next_token="1"), _response([{"id": "2"}])])- rows = _rows(_source("persons", _make_manager()))+ _rows(_source(endpoint, _make_manager()))- assert rows == []- assert params[0]["includeAll"] == "true"+ assert all(page_params[param] == "true" for page_params in params)++ @parameterized.expand(+ [+ ("time_off_policies", "time_off_policies", "/v1/org/org-1/timeoff/policy"),+ ("comp_bands", "comp_bands", "/v1/org/org-1/band"),+ ("compensation_history", "compensation_history", "/v1/org/org-1/change/compensation-history"),+ ]+ )+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_endpoints_without_a_v2_path_stay_on_v1_under_the_v2_pin(+ self, _name: str, endpoint: str, expected_path: str, MockSession+ ) -> None:+ # ChartHop only serves these under /v1, so the default v2 pin must fall through to the+ # base path rather than rewriting the version segment.+ session = MockSession.return_value+ _params, urls = _wire(session, [_response([])])++ _rows(_source(endpoint, _make_manager(), api_version=CHARTHOP_V2))++ assert urls[0] == f"{CHARTHOP_BASE_URL}{expected_path}"@parameterized.expand([(401,), (403,)])@mock.patch(CLIENT_SESSION_PATCH)@@ -303,7 +340,9 @@ class TestChartHopSource:assert response.partition_mode is Noneassert response.partition_keys is None- def test_all_endpoints_buildable(self) -> None:+ def test_all_endpoints_buildable_with_a_primary_key(self) -> None:+ # Catches a path template whose placeholder no longer formats, and an endpoint added+ # without a merge key (which would seed duplicate rows on every sync).for endpoint in ENDPOINTS:response = _source(endpoint, _make_manager())- assert response.primary_keys == ["id"]+ assert response.primary_keys