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 Factorial source (#118968)

Tom Owersf755bf760530
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 3abaebd3d332..962aa517b573 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
@@ -4445,11 +4445,11 @@ Diffed against: <https://apidoc.factorialhr.com/reference>
- [x] `ats/hiring_stages and ats/application_phases` — lookup tables resolving the stage/phase id carried on every synced application (high)
- [x] `finance/cost_centers` — lookup table for cost allocation across employees, expenses and projects (high)
- [x] `employee_updates/terminations` — attrition events with dates and reasons; headcount churn is not derivable from the employees snapshot (high)
-- [ ] `employee_updates/new_hires` — hire events for headcount growth and time-to-start reporting (medium)
-- [ ] `finance/cost_center_memberships` — employee-to-cost-center membership needed to attribute cost (medium)
+- [x] `employee_updates/new_hires` — hire events for headcount growth and time-to-start reporting (medium)
+- [x] `finance/cost_center_memberships` — employee-to-cost-center membership needed to attribute cost (medium)
- [x] `ats/candidate_sources` — lookup resolving the source id on candidates; source-of-hire is a core recruiting breakdown (medium)
-- [ ] `attendance/overtime_requests` — overtime volume and approval state per employee (medium)
-- [ ] `job_catalog/roles and job_catalog/levels` — lookup tables for role and level ids used in compensation banding (medium)
+- [x] `attendance/overtime_requests` — overtime volume and approval state per employee (medium)
+- [x] `job_catalog/roles and job_catalog/levels` — lookup tables for role and level ids used in compensation banding (medium)
Note: The reference exposes roughly 140 list endpoints across ATS, attendance, contracts, finance, payroll, performance, procurement, project management, time off, trainings and work schedules; PostHog covers 26. Other notable untapped families: performance review evaluations/scores, banking transactions, finance journal entries/lines, procurement purchase orders, trainings sessions/attendances, shift management, custom field values. The docs hub is readme.io with no downloadable OpenAPI - the resource list was read off the /reference sidebar route slugs (api-2026-07-01).
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md
index ebc43f5ee98c..99937fbeb7c4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md
@@ -54,34 +54,39 @@ Source-local notes for the Factorial (HRIS) connector. See the official referenc
## Synced endpoints (`settings.py`)
-| Table | Path | Partition key |
-| --------------------- | ----------------------------------------------------- | ------------- |
-| employees | `/resources/employees/employees` | created_at |
-| terminations | `/resources/employee_updates/terminations` | — |
-| teams | `/resources/teams/teams` | — |
-| team_memberships | `/resources/teams/memberships` | — |
-| locations | `/resources/locations/locations` | — |
-| legal_entities | `/resources/companies/legal_entities` | — |
-| contract_versions | `/resources/contracts/contract_versions` | created_at |
-| compensations | `/resources/contracts/compensations` | — |
-| leaves | `/resources/timeoff/leaves` | created_at |
-| leave_types | `/resources/timeoff/leave_types` | — |
-| allowances | `/resources/timeoff/allowances` | — |
-| allowance_stats | `/resources/timeoff/allowance_stats` | — |
-| attendance_shifts | `/resources/attendance/shifts` | created_at |
-| worked_times | `/resources/attendance/worked_times` | — |
-| expenses | `/resources/expenses/expenses` | created_at |
-| cost_centers | `/resources/finance/cost_centers` | — |
-| payroll_supplements | `/resources/payroll/supplements` | created_at |
-| flexible_time_records | `/resources/project_management/flexible_time_records` | created_at |
-| time_records | `/resources/project_management/time_records` | — |
-| projects | `/resources/project_management/projects` | — |
-| candidates | `/resources/ats/candidates` | created_at |
-| job_postings | `/resources/ats/job_postings` | — |
-| applications | `/resources/ats/applications` | created_at |
-| application_phases | `/resources/ats/application_phases` | — |
-| hiring_stages | `/resources/ats/hiring_stages` | — |
-| candidate_sources | `/resources/ats/candidate_sources` | — |
+| Table | Path | Partition key |
+| ----------------------- | ----------------------------------------------------- | ------------- |
+| employees | `/resources/employees/employees` | created_at |
+| terminations | `/resources/employee_updates/terminations` | — |
+| new_hires | `/resources/employee_updates/new_hires` | — |
+| teams | `/resources/teams/teams` | — |
+| team_memberships | `/resources/teams/memberships` | — |
+| locations | `/resources/locations/locations` | — |
+| legal_entities | `/resources/companies/legal_entities` | — |
+| contract_versions | `/resources/contracts/contract_versions` | created_at |
+| compensations | `/resources/contracts/compensations` | — |
+| leaves | `/resources/timeoff/leaves` | created_at |
+| leave_types | `/resources/timeoff/leave_types` | — |
+| allowances | `/resources/timeoff/allowances` | — |
+| allowance_stats | `/resources/timeoff/allowance_stats` | — |
+| attendance_shifts | `/resources/attendance/shifts` | created_at |
+| worked_times | `/resources/attendance/worked_times` | — |
+| overtime_requests | `/resources/attendance/overtime_requests` | — |
+| expenses | `/resources/expenses/expenses` | created_at |
+| cost_centers | `/resources/finance/cost_centers` | — |
+| cost_center_memberships | `/resources/finance/cost_center_memberships` | — |
+| payroll_supplements | `/resources/payroll/supplements` | created_at |
+| flexible_time_records | `/resources/project_management/flexible_time_records` | created_at |
+| time_records | `/resources/project_management/time_records` | — |
+| projects | `/resources/project_management/projects` | — |
+| job_catalog_roles | `/resources/job_catalog/roles` | — |
+| job_catalog_levels | `/resources/job_catalog/levels` | — |
+| candidates | `/resources/ats/candidates` | created_at |
+| job_postings | `/resources/ats/job_postings` | — |
+| applications | `/resources/ats/applications` | created_at |
+| application_phases | `/resources/ats/application_phases` | — |
+| hiring_stages | `/resources/ats/hiring_stages` | — |
+| candidate_sources | `/resources/ats/candidate_sources` | — |
Primary key is the `id` column on every list resource. It is serialized as an integer on `2025-04-01` and
`2026-04-01`, and as an opaque string on `2026-07-01` (see Identifier serialization above), so the column type is
@@ -114,7 +119,7 @@ and `time_records` on its own record id. Partition keys are `created_at` where t
(`job_board`, `agency_or_external_recruiter`, `event`, `social_media`, `referral`, …), which is what
source-of-hire reporting breaks down by.
- **`finance/cost_centers`** is the cost allocation lookup. It carries counts of assigned employees but not the
- assignments themselves — those live in `finance/cost_center_memberships`, which is not synced yet.
+ assignments themselves — those live in `finance/cost_center_memberships`.
- **`employee_updates/terminations`** is the attrition feed: one row per leaver with `terminated_on`,
`contract_end_date` and the termination reason. The `employees` snapshot carries only the current state of
each person, so headcount churn over time is not derivable from it.
@@ -123,6 +128,15 @@ and `time_records` on its own record id. Partition keys are `created_at` where t
of that run. Its `id` embeds the reference date and the docs state it cannot be used to re-fetch the row.
The source pins one `reference_date` for the whole walk and carries it in the resume state, so a run that
crosses midnight or resumes the next day cannot write two as-of dates into the same table.
+- **`finance/cost_center_memberships`** returns only active memberships unless `only_active=false` is sent. The
+ source sends it on every page, so ended allocations (with their `end_date`) stay in the table for cost
+ attribution over time.
+- **`attendance/overtime_requests`** marks `include_approval_flow` required, so the source sends it as `"false"`
+ on every page. `created_at` is optional in the spec, so the table is not partitioned.
+- **`employee_updates/new_hires`** is the hire feed that pairs with `terminations`. It carries no
+ `created_at`; `start_date` gives the hire date.
+- **`job_catalog/roles`** and **`job_catalog/levels`** are lookups for the role and level ids. Each level
+ carries its `role_id`.
## Verification status
@@ -136,3 +150,7 @@ lookup/change-feed resources take only optional id filters, so they need no stat
carries a `created_at` column, so none is partitioned. They were **not** curl-verified against a live account (no
API key available). The connection (host, version path, `x-api-key`, 401-on-bad-key) was confirmed with an
unauthenticated curl returning `401`.
+
+`new_hires`, `overtime_requests`, `cost_center_memberships`, `job_catalog_roles` and `job_catalog_levels` were
+checked the same way, against the OpenAPI documents for `2026-04-01` and `2026-07-01` (and the newer `2026-10-01`).
+Each is a GET list route with the same paged envelope. They were also **not** curl-verified against a live account.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/canonical_descriptions.py
index 0b286fdfccc4..0b95ed5da7f7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/canonical_descriptions.py
@@ -372,4 +372,80 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"label": "Display label of the source, translated for Factorial's default sources.",
},
},
+ "new_hires": {
+ "description": "New hire events for people joining the company, with their start date and initial contract details.",
+ "docs_url": _DOCS,
+ "columns": {
+ "id": "Unique identifier for the new hire event.",
+ "status": "Status of the new hire event.",
+ "employee_id": "Identifier of the employee being hired.",
+ "job_title": "Job title of the new hire.",
+ "start_date": "Date the new hire starts working.",
+ "contract_effective_date": "Date the new hire's contract takes effect.",
+ "contract_end_date": "Date the new hire's contract ends, if it is fixed-term.",
+ "salary_amount_in_cents": "Salary amount of the new hire, in cents.",
+ "salary_frequency": "Period the salary amount applies to.",
+ "working_hours": "Contracted working hours of the new hire.",
+ "working_hours_frequency": "Period the working hours apply to.",
+ "manager_id": "Identifier of the new hire's manager.",
+ "legal_entity_id": "Identifier of the legal entity the new hire joins.",
+ "workplace_id": "Identifier of the new hire's workplace.",
+ },
+ },
+ "overtime_requests": {
+ "description": "Overtime requests submitted for employees, with the hours requested and their approval status.",
+ "docs_url": _DOCS,
+ "columns": {
+ "id": "Unique identifier for the overtime request.",
+ "employee_id": "Identifier of the employee the overtime is requested for.",
+ "author_id": "Identifier of the person who created the request.",
+ "approver_id": "Identifier of the person who approved or rejected the request.",
+ "status": "Approval status of the request: `pending`, `approved`, `rejected` or `none`.",
+ "description": "Description of the overtime request.",
+ "reason": "Reason given for the overtime.",
+ "date": "Day the overtime was worked.",
+ "hours_amount_in_cents": "Overtime hours requested, multiplied by 100.",
+ "created_at": "Time at which the request was created.",
+ "is_editable": "Whether the overtime request can still be edited.",
+ },
+ },
+ "cost_center_memberships": {
+ "description": "Assignments of employees to cost centers over time, with the share of each employee allocated to each cost center.",
+ "docs_url": _DOCS,
+ "columns": {
+ "id": "Unique identifier for the cost center membership.",
+ "employee_id": "Identifier of the assigned employee.",
+ "cost_center_id": "Identifier of the cost center.",
+ "start_date": "Date the employee started being assigned to the cost center.",
+ "end_date": "Date the employee stopped being assigned to the cost center, if applicable.",
+ "percentage": "Percentage of the employee allocated to the cost center.",
+ },
+ },
+ "job_catalog_roles": {
+ "description": "Roles defined in the company's job catalog.",
+ "docs_url": _DOCS,
+ "columns": {
+ "id": "Unique identifier for the job catalog role.",
+ "company_id": "Identifier of the company the role belongs to.",
+ "name": "Name of the role.",
+ "description": "Description of the role.",
+ "legal_entities_ids": "Identifiers of the legal entities the role applies to.",
+ "supervisors_ids": "Identifiers of the role's supervisors.",
+ "competencies_ids": "Identifiers of the competencies linked to the role.",
+ "archived": "Whether the role is archived.",
+ },
+ },
+ "job_catalog_levels": {
+ "description": "Levels within each job catalog role, used for career and compensation banding.",
+ "docs_url": _DOCS,
+ "columns": {
+ "id": "Unique identifier for the job catalog level.",
+ "role_id": "Identifier of the role the level belongs to.",
+ "name": "Name of the level.",
+ "role_name": "Name of the role the level belongs to.",
+ "order": "Position of the level within its role.",
+ "archived": "Whether the level is archived.",
+ "is_default": "Whether this is the default level of its role.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/settings.py
index d3f1320dbda4..4ac3beab47ab 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/settings.py
@@ -39,6 +39,10 @@ FACTORIAL_ENDPOINTS: dict[str, FactorialEndpointConfig] = {
name="terminations",
path="/resources/employee_updates/terminations",
),
+ "new_hires": FactorialEndpointConfig(
+ name="new_hires",
+ path="/resources/employee_updates/new_hires",
+ ),
"teams": FactorialEndpointConfig(
name="teams",
path="/resources/teams/teams",
@@ -95,6 +99,13 @@ FACTORIAL_ENDPOINTS: dict[str, FactorialEndpointConfig] = {
# all-zero row per employee per day for everyone else.
params={"include_time_range_category": "false", "include_non_attendable_employees": "false"},
),
+ "overtime_requests": FactorialEndpointConfig(
+ name="overtime_requests",
+ path="/resources/attendance/overtime_requests",
+ # The endpoint requires this flag. The approval flow is a nested per-request structure that
+ # the flat `status` / `approver_id` columns already summarize.
+ params={"include_approval_flow": "false"},
+ ),
"expenses": FactorialEndpointConfig(
name="expenses",
path="/resources/expenses/expenses",
@@ -104,6 +115,13 @@ FACTORIAL_ENDPOINTS: dict[str, FactorialEndpointConfig] = {
name="cost_centers",
path="/resources/finance/cost_centers",
),
+ "cost_center_memberships": FactorialEndpointConfig(
+ name="cost_center_memberships",
+ path="/resources/finance/cost_center_memberships",
+ # The endpoint returns only currently active memberships by default, which would drop the
+ # ended allocations needed to attribute past cost.
+ params={"only_active": "false"},
+ ),
"payroll_supplements": FactorialEndpointConfig(
name="payroll_supplements",
path="/resources/payroll/supplements",
@@ -122,6 +140,14 @@ FACTORIAL_ENDPOINTS: dict[str, FactorialEndpointConfig] = {
name="projects",
path="/resources/project_management/projects",
),
+ "job_catalog_roles": FactorialEndpointConfig(
+ name="job_catalog_roles",
+ path="/resources/job_catalog/roles",
+ ),
+ "job_catalog_levels": FactorialEndpointConfig(
+ name="job_catalog_levels",
+ path="/resources/job_catalog/levels",
+ ),
"candidates": FactorialEndpointConfig(
name="candidates",
path="/resources/ats/candidates",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py
index bd523ddf1b8f..bd21c8e6090b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py
@@ -67,6 +67,42 @@ class TestFactorialSourceResumeBehavior:
class TestEndpointParams:
"""Static endpoint params must survive both the paginator and the page walk."""
+ @pytest.mark.parametrize(
+ ("endpoint", "expected_path", "expected_params"),
+ [
+ (
+ "worked_times",
+ "/api/2026-07-01/resources/attendance/worked_times",
+ {"include_time_range_category": "false", "include_non_attendable_employees": "false"},
+ ),
+ (
+ "overtime_requests",
+ "/api/2026-07-01/resources/attendance/overtime_requests",
+ {"include_approval_flow": "false"},
+ ),
+ (
+ "cost_center_memberships",
+ "/api/2026-07-01/resources/finance/cost_center_memberships",
+ {"only_active": "false"},
+ ),
+ ],
+ )
+ def test_static_params_sent_on_every_page(
+ self, endpoint: str, expected_path: str, expected_params: dict[str, str]
+ ) -> None:
+ responses = [
+ ScriptedResponse(json=_page_body(_full_page(), {"has_next_page": True, "end_cursor": "Mjc="})),
+ ScriptedResponse(json=_page_body([{"id": "x"}], {"has_next_page": False, "end_cursor": None})),
+ ]
+ result = _driver().run(endpoint, responses)
+
+ assert result.raised is None
+ assert len(result.rows) == PAGE_SIZE + 1
+ assert result.params("after_id") == [None, "Mjc="]
+ for name, value in expected_params.items():
+ assert result.params(name) == [value, value]
+ assert set(result.paths) == {expected_path}
+
def test_allowance_stats_pins_one_reference_date_across_pages(self) -> None:
# Factorial recomputes allowance_stats against the date it receives, defaulting to today,
# so a walk that crosses midnight would otherwise mix two as-of dates into one table.