Skip to content

fix(events): publish driver-assigned records on driver.{id} - #311

Merged
roncodes merged 1 commit into
release/v1.6.71from
fix/driver-channel-for-assigned-orders
Oct 15, 2026
Merged

roncodes merged 1 commit into
release/v1.6.71from
fix/driver-channel-for-assigned-orders

Conversation

@roncodes

@roncodes roncodes commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Problem

Fleetbase publishes resource events on {type}.{id} channels. Lifecycle events for records assigned to a driver (order.created, order.dispatched, order.driver_assigned, order.completed, … and anything with a driver_assigned_uuid) went only to a separate relationship channel, driverAssigned.{uuid} / driverAssigned.{public_id}.

Root cause: ResourceLifecycleEvent::addRelationshipSpecificChannels() builds the channel prefix from the relationship name (driverAssigned) rather than the model type (driver).

Clients that follow the convention listen on driver.{public_id} and never get these events. Examples: the Navigator v3 driver app (useDriverChannel: "FleetOps broadcasts … order assignment, dispatch … to driver.{public_id}") and the console scheduler board. The driver's location, geofence and FleetOps OrderChanged / OrderDriverUnassigned events already go to driver.*, so the order lifecycle events were the only ones missing.

Change

  • The driverAssigned relationship now publishes to driver.{public_id} and driver.{uuid} as well as driverAssigned.*. Both ids are used, as for every other channel.
  • broadcastOn() now returns each channel name once (uniqueChannels(), first one wins). This drops duplicates such as company.{uuid} coming from both the session and the model. SocketClusterService::filterChannels() already removed duplicates at publish time; this makes the list the event declares match.

Compatibility

driverAssigned.* is kept and marked deprecated in a code comment. Nothing in this monorepo, Navigator, or the storefront app subscribes to it, but the v1.6.70 release notes advertised it ("Order lifecycle events reach driverAssigned.{driver uuid} again", #306), so external clients may rely on it. It can be removed in a later release.

No authorization changes: drivers (self channel), console users and API credentials (company match) can already subscribe to driver.{id}.

Tests

  • EventsAndExceptionsTest: relationship channel tests now assert driver.{uuid} / driver.{public_id} alongside driverAssigned.*. New tests check that no channel name repeats and that uniqueChannels() keeps order.
  • Full pest suite passes locally (2183 tests). php-cs-fixer is clean on both files.
  • FleetOps EventContractsTest, NotificationAndMailContractsTest, FuelEfficiencyAndCanceledHandlersTest and OrderFailedChannelsTest pass against this branch.

No FleetOps change is needed: its own events already use driver.*.

Docs: fleetbase/fleetbase.io#134 (follow-up to the merged #133) points readers at driver.{public_id}. Merge it after this ships.

Lifecycle events for records assigned to a driver (orders, and anything
with a driver_assigned_uuid) went only to driverAssigned.{uuid} and
driverAssigned.{public_id}. Clients that follow the {type}.{id}
convention, such as the Navigator driver app and the console scheduler,
listen on driver.{public_id} and never received them.

They now also go to driver.{public_id} and driver.{uuid}, where the
driver's location and geofence events already arrive. driverAssigned.*
is still published for existing subscribers and is marked deprecated.
broadcastOn() now returns each channel name once.
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7ccac14) to head (8e8ec02).

Additional details and impacted files
@@             Coverage Diff             @@
##                main      #311   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity      8881      8884    +3     
===========================================
  Files            472       472           
  Lines          27918     27929   +11     
===========================================
+ Hits           27918     27929   +11     
Flag Coverage Δ
backend 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roncodes roncodes mentioned this pull request Oct 15, 2026
@roncodes
roncodes changed the base branch from main to release/v1.6.71 October 15, 2026 06:58
@roncodes
roncodes merged commit 96adddf into release/v1.6.71 Oct 15, 2026
7 checks passed
@roncodes
roncodes deleted the fix/driver-channel-for-assigned-orders branch October 15, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant