Skip to content

Commit

Permalink
Update request details to be under a single key in the event data.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattByers committed Nov 25, 2024
1 parent c5e6079 commit 305d910
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions src/raygun.rum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,13 @@ var raygunRumFactory = function (window, $, Raygun) {

timingData.statusCode = xhrStatus.response.status;
timingData.parentResource = xhrStatus.parentResource;
timingData.requestBody = xhrStatus.request.body;
timingData.requestUrl = xhrStatus.request.requestURL;
timingData.requestMethod = xhrStatus.request.method;
timingData.responseBody = xhrStatus.response.body;

timingData.requestDetails = {
url: xhrStatus.request.requestURL,
method: xhrStatus.request.method,
body: xhrStatus.request.body,
response: xhrStatus.response.body
};

log('found status for timing', timingData.statusCode);
if (this.xhrStatusMap[url].length === 0) {
Expand Down Expand Up @@ -988,7 +991,7 @@ var raygunRumFactory = function (window, $, Raygun) {
if (!!payload.eventData) {
for (var i = 0; i < payload.eventData.length; i++) {
if (!!payload.eventData[i].data && typeof payload.eventData[i].data !== 'string') {
var strippedEventData = stripRequestAndResponseFromPayloadEventData(payload.eventData[i].data);
var strippedEventData = stripRequestDetailsFromPayloadEventData(payload.eventData[i].data);
payload.eventData[i].data = JSON.stringify(strippedEventData);
}
}
Expand Down Expand Up @@ -1017,24 +1020,12 @@ var raygunRumFactory = function (window, $, Raygun) {
}, (window.raygunUserAgentDataStatus === 1 ? 200 : 0));
}

function stripRequestAndResponseFromPayloadEventData(payloadEventData){
function stripRequestDetailsFromPayloadEventData(payloadEventData){
for (var i = 0 ; i < payloadEventData.length; i++) {
var eventDataItem = payloadEventData[i];

if (eventDataItem.requestUrl) {
delete eventDataItem.requestUrl;
}

if (eventDataItem.requestBody) {
delete eventDataItem.requestBody;
}

if (eventDataItem.requestMethod) {
delete eventDataItem.requestMethod;
}

if (eventDataItem.responseBody) {
delete eventDataItem.responseBody;
if (eventDataItem.requestDetails) {
delete eventDataItem.requestDetails;
}
}

Expand Down

0 comments on commit 305d910

Please sign in to comment.