Fix parts of request metadata being missing from some events #1879
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.
Goal
Request metadata is stored in two places on an Event — some goes in
event.request
and other bits are added as metadata. This is because the Bugsnag API accepts some request data as a top-level field, but we add more data than the API supports so these bits have to go in metadataWe were adding this metadata on the
requestClient
instead of theevent
and were doing so in an on error callback, which is too late to affect the already-created event. This would affect any subsequent events, though, so the data was present in some cases. This was broken when we moved from adding request data when our middleware was called to adding it in a callback, which was done to ensure we reported the final state of the request as other middleware could mutate it