feat: Detect and report AJAX payloads#1651
Merged
Merged
Conversation
Supportability Metric Usage Changes:No matching changes found Supportability Metrics .md File Changes:supportability_metrics.md was changed? New supportability metrics require changes to supportability_metrics.md, as well as a new PR to Angler. Please ensure an Angler PR is created and linked to this PR. |
Asset Size Report
Merging this pull request will result in the following asset size changes:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1651 +/- ##
==========================================
- Coverage 89.07% 88.90% -0.17%
==========================================
Files 212 213 +1
Lines 7724 7859 +135
Branches 1604 1654 +50
==========================================
+ Hits 6880 6987 +107
- Misses 751 776 +25
- Partials 93 96 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cwli24
requested changes
Jun 12, 2026
cwli24
reviewed
Jun 12, 2026
cwli24
approved these changes
Jun 12, 2026
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.
Introduces support of AJAX payload capture for XMLHttpRequest and Fetch API calls. When enabled, the browser agent will captures request/response bodies, headers, and query parameters, with automatic detection and parsing of GraphQL operations. Payload capture is configurable to monitor all requests or only failures, with built-in size limits (4KB per attribute) and obfuscation support for sensitive data protection.
New AjaxRequest Attributes
Payload Capture - The Browser Agent can now capture and report request and response payloads for AJAX calls, providing deeper insights into network activity and API interactions.
Configuration:
Enable payload capture using the
ajax.capture_payloadsconfiguration option:'all'- Capture payloads for all AJAX requests'failures'- Capture only failed requests (HTTP errors, network errors, or GraphQL errors)none- Disable payload capture (default)New Attributes on AjaxRequest Events:
When AJAX payloads are captured, new attributes are automatically included on AjaxRequest events:
requestQuery- URL query parametersrequestHeaders,responseHeaders- HTTP headersrequestBody,responseBody- Request and response payloads (text-based formats only: JSON, XML, GraphQL, plain text)GraphQL Detection:
When GraphQL errors are detected, a new additional attribute is automatically included on AjaxRequest events:
operationHasErrors- Indicates if the operation returned errorsAll captured data is automatically truncated to 4KB per attribute and supports obfuscation patterns for sensitive information.
Overview
This PR implements comprehensive AJAX payload capture and reporting functionality for the New Relic Browser Agent. The changes include:
src/features/ajax/aggregate/gql.js)CAPTURE_PAYLOAD_SETTINGSinsrc/features/ajax/constants.js)Key File Changes:
src/features/ajax/aggregate/payloads.js- Core payload parsing and processing logicsrc/features/ajax/aggregate/gql.js- GraphQL-specific payload handlingsrc/features/ajax/instrument/index.js- Enhanced AJAX instrumentation hookstests/specs/ajax/payload_capture.e2e.js- End-to-end payload capture testsRelated Issue(s)
Sister PR to nr-querypack to support testing newrelic/nr-querypack#30
mergedNR-496825
NR-496829
NR-496831
NR-496833
Testing
Unit Tests:
tests/unit/features/ajax/instrument/payloads.test.js)Integration Tests:
tests/assets/ajax/xhr-payloads.html,xhr-payloads-obfuscated.html)tests/assets/ajax/fetch-payloads.html,fetch-payloads-obfuscated.html)tests/specs/ajax/payload_capture.e2e.js)Manual Testing: