Skip to content

feat(api-logs): relate logged storefront requests to the store or network whose key made them - #143

Merged
roncodes merged 1 commit into
release/v0.4.25from
fix/relate-api-request-logs
Oct 13, 2026
Merged

roncodes merged 1 commit into
release/v0.4.25from
fix/relate-api-request-logs

Conversation

@roncodes

Copy link
Copy Markdown
Member

What

Companion to fleetbase/core-api#302. That PR makes core log every route that runs LogApiRequests, including storefront's storefront.api group, and adds a request attribute that extensions use to relate ids to the log row.

Here, SetStorefrontSession puts the resolved store or network public id into that attribute (api_request_log_related). Every logged storefront write, for example POST storefront/v1/customers/request-creation-code, then has the store or network in related, alongside company_uuid. Before this, nothing on a log row identified which storefront key made the request.

Change

  • SetStorefrontSession::handle() calls a new relateApiRequestLog($request) after setKey(). It appends storefront_store_public_id, or failing that storefront_network_public_id, to the attribute, keeping any ids already there.
  • The attribute name is a string rather than a reference to core's LogApiRequest::RELATED_ATTRIBUTE. A core build without that constant ignores the attribute instead of failing every storefront request.

Compatibility

  • With a core that doesn't read the attribute, this is a no-op.
  • With core-api#302 but without this PR, storefront writes are logged with company_uuid but no store or network id.

Tests

server/tests/Unit/Http/Middleware/SetStorefrontSessionTest.php:

  • A request with a store key gets ['store_public'] in the attribute.
  • A network key appends network_public to ids already on the request.
  • With no resolved store or network, the attribute is not set.

The three affected tests fail without the change. php-cs-fixer (repo config) reports nothing to fix.

…work whose key made them

SetStorefrontSession adds the resolved store or network public id to the
api_request_log_related request attribute. Core's LogApiRequest adds those ids
to the log's related column, so an api_request_logs row can be traced back to
the storefront and its company. The attribute is spelled out rather than read
from core's LogApiRequest::RELATED_ATTRIBUTE, so an older core ignores it.
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