Skip to content

Trip Analysis

This page specifies the post-trip metrics, per-trip report, export boundary, and visibility rules. It draws from Build Spec §5.8.

Sources: Build Spec §5.8, System Architecture §5, API Conventions, Domain Glossary.

1. Purpose and Trigger

When a trip completes, an AnalyzeTrip job computes and stores its Trip Analysis in trip_analytics. The table holds one analysis row per trip.

D2D detour is reported separately so time caused by door-to-door routing is not blamed on the Driver.

2. Metrics

Field Definition
trip_id The analyzed trip; unique in trip_analytics.
overall_delay_minutes Actual arrival time compared with estimated arrival time.
late_departure_minutes Actual departure time compared with scheduled departure time.
unexpected_stops JSON data for stationary periods of more than about 3 minutes away from any scheduled stop.
slow_segments JSON data for stretches well below expected speed.
d2d_detour_minutes D2D detour time, reported separately from other delay causes.
computed_at The time at which the analysis was computed.

The exact meaning of "about 3 minutes" and "well below expected speed" is not defined.

3. Computation Boundaries

  • The job runs when a trip completes.
  • Overall delay compares actual and estimated arrival.
  • Late departure compares actual and scheduled departure.
  • Unexpected-stop detection uses stationary duration and distance from scheduled stops.
  • Slow-segment detection uses observed movement against an expected speed.
  • D2D detour remains a separate metric rather than being attributed to the Driver.

The sources do not define the authoritative timestamps, GPS sampling rules, missing-data behavior, JSON structures, speed baseline, stop radius, or rerun policy.

4. Per-Trip Report

The Fleet Dashboard provides a per-trip analysis view with:

  • A map overlay.
  • A one-line reason summarizing the material causes of delay.

The Build Spec gives this example:

Departed 12m late, 2 unexpected stops (+9m), D2D detour (+6m)

The map layers, summary-selection rules, and wording contract beyond this example are not specified.

5. Reports and Exports

Capability Current contract
Per-trip Dashboard view Specified, including a map overlay and one-line reason.
Aggregate or cross-trip report Not specified.
Scheduled report Not specified.
Data export Not specified.
Export format, columns, filters, and endpoint Not specified.

No CSV, PDF, spreadsheet, or API export behavior is introduced by this spec. Export requirements remain an open question.

6. Visibility and Authorization

  • The documented analysis endpoint is Manager-scoped: GET /company/trips/{id}/analysis.
  • A Manager may access analysis only for a trip belonging to the Manager's Company.
  • Cross-tenant API access returns 404.
  • A suspended Company returns 403 with a clear message.
  • Driver, Passenger, and Platform Admin access to Trip Analysis is not specified.
  • Platform Admin's Filament role does not by itself establish analytics visibility in the current sources.

7. API Contract

All paths are relative to the API base path /api.

Method Path Audience Purpose
GET /company/trips/{id}/analysis Manager Retrieve the computed analysis for a Company trip.

The response must use the API resource conventions, including snake_case fields and ISO-8601 UTC dates. The exact response schema, null handling, and not-yet-computed behavior are not specified. Errors follow { "message": string, "errors"?: Record<string, string[]> }.

8. Localization

Fleet Dashboard analysis labels and the one-line reason follow the Arabic and English requirement. RTL layout applies to the interface, while the map overlay stays LTR. Localization of stored JSON metric details is not specified.

9. Open Questions

  • Metric baselines: What expected arrival, expected speed, and traffic baseline are used?
  • Unexpected stops: What precise duration, stop radius, and minimum movement define an unexpected stop?
  • Slow segments: What speed ratio or threshold qualifies, and how are stops and D2D legs excluded?
  • Source timestamps: Which events define actual departure and actual arrival, and what happens when GPS or timestamp data is missing?
  • JSON schemas: What fields are stored in unexpected_stops and slow_segments?
  • Job behavior: How are retries, duplicate completion events, recomputation, and failure states handled?
  • Report presentation: Which map layers appear, and how is the one-line reason selected and localized?
  • Reporting and exports: Are aggregate reports or exports required, and if so, what formats, filters, columns, and authorization apply?
  • Visibility: Should Drivers, Passengers, or Platform Admin receive any analysis view?
  • Retention: How long are raw location signals and computed Trip Analysis records retained?