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 2 missing tables to the Everhour source (#118989)

Tom Owers491db57a998a
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 02436886d675..6156933bcdee 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
@@ -4377,8 +4377,8 @@ Diffed against: <https://everhour.docs.apiary.io/api-description-document>
- [x] `GET /timesheets, GET /users/{user_id}/timesheets` — weekly timesheet approval state and transitions (medium)
- [x] `GET /resource-planner/time-off-types` — lookup resolving time-off type ids on assignments/allocations (medium)
- [x] `GET /allocations` — time-off and capacity allocations per user (medium)
-- [ ] `GET /projects/{project_id}/sections` — lookup resolving the section id on tasks (medium)
-- [ ] `GET /projects/{project_id}/fields` — custom field definitions needed to interpret task custom field values (medium)
+- [x] `GET /projects/{project_id}/sections` — lookup resolving the section id on tasks (medium)
+- [x] `GET /projects/{project_id}/fields` — custom field definitions needed to interpret task custom field values (medium)
- [ ] `GET /dashboards/projects, /dashboards/clients, /dashboards/users` — prebuilt report aggregates by project, client and member (low)
Note: Static endpoint list in get_schemas - no dynamic table discovery. Apiary blueprint is served as API Blueprint markdown, not JSON, at the /api-description-document path.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/canonical_descriptions.py
index 563da0e4f3ae..d79a59d069d9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/canonical_descriptions.py
@@ -67,6 +67,30 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"createdAt": "When the task was created.",
},
},
+ "sections": {
+ "description": "A section that groups the tasks of a project. Resolves the section id carried on tasks.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "id": "Unique identifier for the section.",
+ "name": "Name of the section.",
+ "project": "Identifier of the project the section belongs to.",
+ "position": "Order of the section within its project.",
+ "status": "Section status ('open' or 'archived').",
+ },
+ },
+ "custom_fields": {
+ "description": "A custom field configured on a project. Needed to read the custom field values stored on tasks. Fanned out over every project, with the parent project id injected as `project_id`.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "id": "Unique identifier for the custom field.",
+ "project_id": "Identifier of the parent project this field row was fetched under (injected by the connector).",
+ "name": "Name of the custom field.",
+ "type": "Value type of the field ('number', 'text', 'select' or 'date').",
+ "format": "Display format of the field, such as number, currency or percent, with its decimals and label.",
+ "options": "Allowed options of a 'select' field, each with an id, a name and a colour.",
+ "position": "Order of the field within the project.",
+ },
+ },
"time_records": {
"description": "Individual time entries logged against tasks. Supports incremental sync via the server-side from/to date window.",
"docs_url": _DOCS_URL,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.com-doc.md b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.com-doc.md
index 8338cd462484..b5580a730f9f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.com-doc.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.com-doc.md
@@ -29,7 +29,7 @@ import AlphaRelease from "../\_snippets/alpha-release.mdx"
<AlphaRelease />
-[Everhour](https://everhour.com) is a time-tracking, budgeting, and resource-planning tool for teams. This source syncs your Everhour clients, projects, tasks, team members, time records, invoices, expenses, expense categories, timecards, timesheets, and resource planner assignments, time off types and allocations into the PostHog data warehouse so you can join time-tracking data with your product and revenue data.
+[Everhour](https://everhour.com) is a time-tracking, budgeting, and resource-planning tool for teams. This source syncs your Everhour clients, projects, tasks, project sections, project custom fields, team members, time records, invoices, expenses, expense categories, timecards, timesheets, and resource planner assignments, time off types and allocations into the PostHog data warehouse so you can join time-tracking data with your product and revenue data.
## Prerequisites
@@ -53,7 +53,7 @@ Paste the key into the API key field when connecting the source in PostHog. The
**Time records** support incremental sync: PostHog uses Everhour's server-side `from`/`to` date window to pull only entries on or after the last synced date.
-Every other table syncs as **full refresh**. Clients, projects, users, tasks, invoices, expenses, expense categories, timesheets, time off types, and allocations have no server-side change timestamp to filter on. Timecards and assignments do accept a date filter, but it selects rows by the day they cover rather than the day they changed, so it cannot tell PostHog what is new since the last sync.
+Every other table syncs as **full refresh**. Clients, projects, users, tasks, sections, custom fields, invoices, expenses, expense categories, timesheets, time off types, and allocations have no server-side change timestamp to filter on. Timecards and assignments do accept a date filter, but it selects rows by the day they cover rather than the day they changed, so it cannot tell PostHog what is new since the last sync.
## Configuration
@@ -66,13 +66,13 @@ Every other table syncs as **full refresh**. Clients, projects, users, tasks, in
A few notes:
- **Time values are in seconds.** The `time` field on time records and tasks is a duration in seconds (e.g. `3600` is one hour).
-- **Tasks are fanned out per project.** Each task row carries the parent `project_id` it was fetched under, and the primary key is `(project_id, id)` because a task can belong to more than one project.
+- **Tasks are fanned out per project.** Each task row carries the parent `project_id` it was fetched under, and the primary key is `(project_id, id)` because a task can belong to more than one project. Sections and custom fields are also fetched per project. Custom field rows carry `project_id` too, and their primary key is `(project_id, id)`.
- **Integration IDs are prefixed.** Projects and tasks imported from integrations use a prefixed id (e.g. `as:` for Asana, `jira:` for Jira, `tr:` for Trello).
- **Timecards and time records are different things.** A time record is time logged against a task. A timecard is a clock-in and clock-out for one person on one day. Timecards carry no id of their own, so the table is keyed on `(user, date)`.
- **Invoice line items are nested.** Each invoice row carries its line items in the `invoiceItems` column rather than in a separate table.
- **Assignments cover planned work and time off.** The `type` column tells the two apart, and the rows reach into the future because they describe scheduled work.
- **Timesheets are fetched per person.** Everhour's team-wide timesheet endpoint returns one week at a time, so PostHog reads each member's own timesheet history instead, going back about five years. Each row is one person's week, with its tasks, daily totals, timecards, scheduled time off, and approval history nested inside it.
-- **Lookup tables resolve the ids on other rows.** Expense categories name the `category` on an expense, and time off types name the `timeOffType` on an assignment or an allocation.
+- **Lookup tables resolve the ids on other rows.** Expense categories name the `category` on an expense, time off types name the `timeOffType` on an assignment or an allocation, sections name the section a task sits in, and custom fields describe the custom field values on a task.
- **Allocations are entitlements, not bookings.** A row says how many days off of one type a person has over a period and how many they have used. The time off they actually booked is in assignments.
## Troubleshooting
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.py b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.py
index e6dcb1ea62e8..239b15d5a906 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/everhour.py
@@ -29,8 +29,8 @@ MAX_PAGES_PER_URL = 50_000
# defaults to a narrow recent window).
EARLIEST_FROM_DATE = "2015-01-01"
-# Matches the parent project id in a fan-out tasks URL: /projects/{project_id}/tasks
-_PROJECT_ID_RE = re.compile(r"/projects/([^/?]+)/tasks")
+# Matches the parent project id in a project fan-out URL, e.g. /projects/{project_id}/tasks
+_PROJECT_ID_RE = re.compile(r"/projects/([^/?]+)/")
# The endpoint each fan-out mode draws its parent ids from.
_FAN_OUT_PARENT_ENDPOINTS: dict[FanOut, str] = {"project": "projects", "user": "users"}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/settings.py
index 5e74c63816f8..c4a1ca8723f0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/settings.py
@@ -75,6 +75,20 @@ EVERHOUR_ENDPOINTS: dict[str, EverhourEndpointConfig] = {
primary_keys=["project_id", "id"],
include_parent_id_as="project_id",
),
+ "sections": EverhourEndpointConfig(
+ name="sections",
+ fan_out="project",
+ path_template="/projects/{parent_id}/sections",
+ # Section ids are global (GET /sections/{id}) and every section already names its `project`.
+ ),
+ "custom_fields": EverhourEndpointConfig(
+ name="custom_fields",
+ fan_out="project",
+ path_template="/projects/{parent_id}/fields",
+ # Fields are configured per project, and nothing documents an id as unique to one project.
+ primary_keys=["project_id", "id"],
+ include_parent_id_as="project_id",
+ ),
"time_records": EverhourEndpointConfig(
name="time_records",
fan_out="none",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/tests/test_everhour.py b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/tests/test_everhour.py
index 72ab878cfaee..6adb379a62d4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/tests/test_everhour.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/everhour/tests/test_everhour.py
@@ -112,26 +112,33 @@ class TestBuildInitialUrls:
class TestGetRows:
- def test_fan_out_drains_parents_and_injects_project_id(self) -> None:
+ @pytest.mark.parametrize(
+ "endpoint, child_path, expected_rows",
+ [
+ ("tasks", "tasks", [{"id": "a", "project_id": "ev:1"}, {"id": "b", "project_id": "as:2"}]),
+ ("custom_fields", "fields", [{"id": "a", "project_id": "ev:1"}, {"id": "b", "project_id": "as:2"}]),
+ ("sections", "sections", [{"id": "a"}, {"id": "b"}]),
+ ],
+ )
+ def test_project_fan_out_drains_parents(
+ self, endpoint: str, child_path: str, expected_rows: list[dict[str, Any]]
+ ) -> None:
result = _driver().run(
- "tasks",
+ endpoint,
[
- ScriptedResponse(json=[{"id": "p1"}, {"id": "p2"}]),
+ ScriptedResponse(json=[{"id": "ev:1"}, {"id": "as:2"}]),
ScriptedResponse(json=[{"id": "a"}]),
ScriptedResponse(json=[{"id": "b"}]),
],
)
assert result.raised is None
- assert result.rows == [
- {"id": "a", "project_id": "p1"},
- {"id": "b", "project_id": "p2"},
- ]
+ assert result.rows == expected_rows
# After draining the first parent, state advances to the second parent URL.
saved = result.saved_states[0]
- assert saved.current_url == f"{EVERHOUR_BASE_URL}/projects/p2/tasks?limit=100"
+ assert saved.current_url == f"{EVERHOUR_BASE_URL}/projects/as:2/{child_path}?limit=100"
assert saved.remaining_urls == []
- assert result.paths == ["/projects", "/projects/p1/tasks", "/projects/p2/tasks"]
+ assert result.paths == ["/projects", f"/projects/ev:1/{child_path}", f"/projects/as:2/{child_path}"]
def test_resumes_from_saved_state(self) -> None:
resume_url = f"{EVERHOUR_BASE_URL}/clients?limit=100"