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 4 missing tables to the Fleetio source (#117185)

Tom Owersb0cae74a2c8a
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 11976a085fc2..47fa0cee3b99 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
@@ -4743,10 +4743,10 @@ Diffed against: <https://developer.fleetio.com/sitemap.xml>
- [x] `service_tasks` — lookup resolving the task IDs referenced by service entries, work orders and service reminders (high)
- [x] `vendors` — lookup resolving vendor IDs on service entries, fuel entries and purchase orders (high)
- [x] `purchase_orders (and purchase_order_line_items)` — parts procurement transactions and their line items; parts are synced but never their purchases (medium)
-- [ ] `faults` — diagnostic trouble code events streamed off vehicles - a primary reliability signal (medium)
-- [ ] `location_entries` — vehicle location history, enabling utilization and route analysis (medium)
-- [ ] `service_reminders` — upcoming and overdue maintenance state, the operational counterpart to the synced service entries (medium)
-- [ ] `inventory_journal_entries` — parts inventory movements; parts are synced only as current stock levels (medium)
+- [x] `faults` — diagnostic trouble code events streamed off vehicles - a primary reliability signal (medium)
+- [x] `location_entries` — vehicle location history, enabling utilization and route analysis (medium)
+- [x] `service_reminders` — upcoming and overdue maintenance state, the operational counterpart to the synced service entries (medium)
+- [x] `inventory_journal_entries` — parts inventory movements; parts are synced only as current stock levels (medium)
Note: No OpenAPI file is published; the resource list came from the Docusaurus sitemap, which enumerates every documented endpoint page (index/show/create/update per resource) under /docs/api/2023-03-01/. Also unsynced but lower value: equipment and equipment_assignments, submitted_inspection_forms, issue_priorities, fuel_types, groups, labels, places, tires, vehicle/contact renewal reminders and types, part_locations, comments, vmrs_reason_for_repairs.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/canonical_descriptions.py
index b0844a944391..271dbb0f8c9f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/canonical_descriptions.py
@@ -344,4 +344,88 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"subtotal": "The pre-tax subtotal for this line item.",
},
},
+ "faults": {
+ "description": "A diagnostic trouble code reported for a vehicle, with how often it occurred and when it last occurred.",
+ "docs_url": "https://developer.fleetio.com/docs/api/faults",
+ "columns": {
+ **_COMMON_COLUMNS,
+ "vehicle_id": "Identifier of the vehicle that reported the fault.",
+ "code": "The diagnostic trouble code.",
+ "count": "The number of times the fault has occurred.",
+ "description": "A short description of the problem.",
+ "external_id": "An external identifier for the fault, if applicable.",
+ "last_occurred_at": "Timestamp when the fault last occurred.",
+ "name": "The name or label of the fault.",
+ "status": "The status of the fault.",
+ "source": "The source or origin of the fault.",
+ "fault_rule_id": "Identifier of the fault rule that matches the fault, if any.",
+ "vehicle_archived_at": "Timestamp when the vehicle was archived, if applicable.",
+ "is_sample": "Whether the fault is sample data.",
+ },
+ },
+ "service_reminders": {
+ "description": "A recurring maintenance schedule for a service task on a vehicle, with when it is next due and whether it is overdue.",
+ "docs_url": "https://developer.fleetio.com/docs/api/service-reminders",
+ "columns": {
+ **_COMMON_COLUMNS,
+ "active": "Whether the service reminder is active.",
+ "vehicle_id": "Identifier of the vehicle the reminder applies to.",
+ "service_task_id": "Identifier of the service task the reminder schedules.",
+ "service_reminder_status": "The status of the reminder, such as upcoming, due soon, or overdue.",
+ "time_interval": "The number of time units, per `time_frequency`, between occurrences.",
+ "time_frequency": "The unit of `time_interval`, such as days, weeks, or months.",
+ "primary_meter_interval": "The primary meter interval between occurrences.",
+ "secondary_meter_interval": "The secondary meter interval between occurrences.",
+ "next_due_at": "Timestamp when the reminder is next due.",
+ "due_soon_at": "Timestamp when the reminder becomes due soon.",
+ "next_due_primary_meter_value": "The primary meter value at which the reminder is next due.",
+ "next_due_secondary_meter_value": "The secondary meter value at which the reminder is next due.",
+ "forecasted_next_due_at": "The forecasted timestamp when the reminder is next due.",
+ "forecasted_due_soon_at": "The forecasted timestamp when the reminder becomes due soon.",
+ "snooze_until": "Timestamp until which the reminder is snoozed.",
+ "vehicle_archived_at": "Timestamp when the vehicle was archived, if applicable.",
+ "comments_count": "Number of comments on the reminder.",
+ "watchers_count": "Number of people watching the reminder.",
+ },
+ },
+ "inventory_journal_entries": {
+ "description": "A change to the stock of a part at a part location, such as a purchase, a use on a work order, a transfer, or a manual adjustment.",
+ "docs_url": "https://developer.fleetio.com/docs/api/inventory-journal-entries",
+ "columns": {
+ **_COMMON_COLUMNS,
+ "user_id": "Identifier of the user who made the change.",
+ "part_id": "Identifier of the part whose stock changed.",
+ "part_location_detail_id": "Identifier of the part's stock record at a part location.",
+ "previous_quantity": "The quantity of the part before the change.",
+ "current_quantity": "The quantity of the part after the change.",
+ "adjustment_quantity": "The quantity by which the stock changed.",
+ "adjustment_type": "The type of change that created the entry.",
+ "inventory_adjustment_reason_id": "Identifier of the inventory adjustment reason, if any.",
+ "transfer_part_location_id": "Identifier of the part location the part was transferred to, for a transfer.",
+ "purchase_order_line_item_id": "Identifier of the purchase order line item, for a purchase.",
+ "work_order_id": "Identifier of the work order, for a part used on a work order.",
+ "work_order_part_line_item_id": "Identifier of the work order part line item, for a part used on a work order.",
+ "vendor_id": "Identifier of the vendor, for a purchase.",
+ "comments_count": "Number of comments on the entry.",
+ },
+ },
+ "location_entries": {
+ "description": "A recorded location of a vehicle at a point in time.",
+ "docs_url": "https://developer.fleetio.com/docs/api/location-entries",
+ "columns": {
+ **_COMMON_COLUMNS,
+ "vehicle_id": "Identifier of the vehicle this location entry belongs to.",
+ "date": "Timestamp when the location was recorded.",
+ "item_type": "The type of object the location entry is associated with.",
+ "item_id": "Identifier of the object the location entry is associated with.",
+ "locatable_type": "The type of object that created the location entry, if applicable.",
+ "locatable_id": "Identifier of the object that created the location entry, if applicable.",
+ "contact_id": "Identifier of the contact associated with the location entry, if any.",
+ "address": "The full address of the recorded location.",
+ "address_components": "The parts of the address of the recorded location.",
+ "is_current": "Whether this is the most recent location entry for the vehicle.",
+ "location": "A string representation of the recorded location.",
+ "geolocation": "The coordinates of the recorded location.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/settings.py
index 4d9231b75948..49670b4fe802 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/settings.py
@@ -72,6 +72,31 @@ FLEETIO_ENDPOINTS: dict[str, FleetioEndpointConfig] = {
"vehicle_types": FleetioEndpointConfig(name="vehicle_types", path="/vehicle_types"),
"service_tasks": FleetioEndpointConfig(name="service_tasks", path="/service_tasks"),
"vendors": FleetioEndpointConfig(name="vendors", path="/vendors"),
+ "faults": FleetioEndpointConfig(name="faults", path="/faults"),
+ "service_reminders": FleetioEndpointConfig(name="service_reminders", path="/service_reminders", path_version="v2"),
+ "inventory_journal_entries": FleetioEndpointConfig(
+ name="inventory_journal_entries", path="/inventory_journal_entries"
+ ),
+ # From 2024-06-30 Fleetio only lists location entries per vehicle, so fan out over vehicles.
+ # The list action takes a `filter[updated_at]`, but fan-out rows arrive grouped by vehicle, so
+ # no ascending watermark holds across the table: full refresh only.
+ "location_entries": FleetioEndpointConfig(
+ name="location_entries",
+ path="/vehicles/{vehicle_id}/location_entries",
+ incremental_fields=[],
+ primary_keys=["vehicle_id", "id"],
+ fanout=DependentEndpointConfig(
+ parent_name="vehicles",
+ resolve_param="vehicle_id",
+ resolve_field="id",
+ # The entry carries `vehicle_id` itself, but the field is not required by the schema,
+ # so take it from the parent row to keep the composite primary key populated.
+ include_from_parent=["id"],
+ parent_field_renames={"id": "vehicle_id"},
+ parent_params={"sort[created_at]": "asc"},
+ child_params={"sort[id]": "asc"},
+ ),
+ ),
# Line items are only listed per service entry, so fan out over the service entries endpoint.
# The list action takes no `filter` param — only `sort[id]` — so this is full refresh only.
"service_entry_line_items": FleetioEndpointConfig(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio.py
index 206753359d24..e31146ed652b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio.py
@@ -182,3 +182,27 @@ class TestPurchaseOrderLineItemsFanout:
assert [row["purchase_order_number"] for row in result.rows] == [4002]
assert result.paths == ["/api/purchase_orders", "/api/purchase_orders/4002/purchase_order_line_items"]
assert any(state.completed is not None and completed in state.completed for state in result.saved_states)
+
+
+class TestLocationEntriesFanout:
+ @parameterized.expand(
+ [
+ (FLEETIO_LEGACY_VERSION, "/api/v1/vehicles", "/api/v1/vehicles/7/location_entries"),
+ (FLEETIO_VERSION_2025_05_05, "/api/vehicles", "/api/vehicles/7/location_entries"),
+ ]
+ )
+ def test_lists_entries_per_vehicle_and_keys_them_by_the_parent(
+ self, api_version: str, parent_path: str, child_path: str
+ ) -> None:
+ result = _driver().run(
+ "location_entries",
+ [
+ _response([{"id": 7}], None),
+ _response([{"id": 501, "location": "40.0,-75.0"}, {"id": 502, "vehicle_id": 7}], None),
+ ],
+ api_version=api_version,
+ )
+
+ assert result.raised is None
+ assert result.paths == [parent_path, child_path]
+ assert [(row["vehicle_id"], row["id"]) for row in result.rows] == [(7, 501), (7, 502)]