Skip to content

feat(api-logs): log writes to the public invoice routes like the public API - #34

Merged
roncodes merged 1 commit into
release/v0.0.13from
fix/log-public-api-requests
Oct 13, 2026
Merged

roncodes merged 1 commit into
release/v0.0.13from
fix/log-public-api-requests

Conversation

@roncodes

Copy link
Copy Markdown
Member

What

Ledger's client-facing requests weren't written to api_request_logs.

  • Public wallet API (ledger/v1/wallet/..., API key auth): already runs core's fleetbase.api group, which includes LogApiRequests. Core skipped it because it only logged v1/... URIs. fix(api-logs): log every route that opts in to LogApiRequests and let extensions relate ids core-api#302 fixes that for every route that runs the middleware, so this needs no ledger change.
  • Customer invoice routes (ledger/public/invoices/..., no auth): ran no middleware at all, so paying an invoice was never logged. They now run LogApiRequests.

Not logged, on purpose:

  • Webhooks (ledger/webhooks/{driver}): inbound gateway callbacks, not client requests.
  • Internal routes (ledger/int/v1/...): console traffic. Core skips any route with an int segment.

As everywhere, LogApiRequests logs only writes (POST, PUT, PATCH, DELETE), so on the invoice routes that means POST invoices/{public_id}/pay.

Change

  • server/src/routes.php: the public invoice group runs Fleetbase\Http\Middleware\LogApiRequests.
  • scripts/pest-bootstrap.php: the RouteRegistrar test stub records each route's group middleware as a fourth element of the route tuple.
  • RELEASE.md: a bug-fix entry and an upgrade note that this takes effect with core-api#302.

Compatibility

  • Without core-api#302, ledger requests stay unlogged: core only logs v1/... URIs there.
  • Invoice payments carry no session, so their log rows have no company_uuid. They show up in the database but not in a company's console log view. The invoice public id is in the logged path.

Tests

server/tests/Routes/RouteRegistrationTest.php adds a test of which middleware each route group runs:

  • the public wallet API runs fleetbase.api
  • the customer invoice routes run LogApiRequests
  • webhooks run none
  • internal routes run fleetbase.protected

It fails without the routes change. The route tests pass, and php-cs-fixer (repo config) reports nothing to fix.

Locally, the full suite has 7 failing invoice-settings tests. They fail the same way on release/v0.0.13 without this change, because of this machine's out-of-date server_vendor.

…ic API

The customer invoice routes (ledger/public/...) ran no middleware, so paying an
invoice was never written to the API request logs. They now run LogApiRequests.
The public wallet API (ledger/v1/...) already runs it through fleetbase.api and
is logged once core-api logs every route that opts in (fleetbase/core-api#302).
Webhooks and internal routes stay unlogged.

The route registrar test stub now records each route's group middleware.
@roncodes
roncodes merged commit f7de767 into release/v0.0.13 Oct 13, 2026
@roncodes
roncodes deleted the fix/log-public-api-requests branch October 13, 2026 06:35
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