Repository navigation
feat(api-logs): relate logged storefront requests to the store or network whose key made them - #143
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Companion to fleetbase/core-api#302. That PR makes core log every route that runs
LogApiRequests, including storefront'sstorefront.apigroup, and adds a request attribute that extensions use to relate ids to the log row.Here,
SetStorefrontSessionputs the resolved store or network public id into that attribute (api_request_log_related). Every logged storefront write, for examplePOST storefront/v1/customers/request-creation-code, then has the store or network inrelated, alongsidecompany_uuid. Before this, nothing on a log row identified which storefront key made the request.Change
SetStorefrontSession::handle()calls a newrelateApiRequestLog($request)aftersetKey(). It appendsstorefront_store_public_id, or failing thatstorefront_network_public_id, to the attribute, keeping any ids already there.LogApiRequest::RELATED_ATTRIBUTE. A core build without that constant ignores the attribute instead of failing every storefront request.Compatibility
company_uuidbut no store or network id.Tests
server/tests/Unit/Http/Middleware/SetStorefrontSessionTest.php:['store_public']in the attribute.network_publicto ids already on the request.The three affected tests fail without the change. php-cs-fixer (repo config) reports nothing to fix.