diff --git a/CHANGELOG.md b/CHANGELOG.md index db1bd9d2..068b2817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --> +## [3.1.3] + +### Changed +- Updated RUM XHR events to include `requestDetails` for the `onBeforeSendRUM` handler. Request details include `url` (including query parameters), `method`, `body` and `responseBody`. These details are stripped from the payload before it's sent to Raygun's servers. + ## [3.1.2] ### Changed diff --git a/bower.json b/bower.json index d9cc173b..081ea1d0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "raygun4js", - "version": "3.1.2", + "version": "3.1.3", "homepage": "http://raygun.com", "authors": [ "Mindscape " diff --git a/package.json b/package.json index 3b78eec4..92ce4751 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ ], "title": "Raygun4js", "description": "Raygun.com plugin for JavaScript", - "version": "3.1.2", + "version": "3.1.3", "homepage": "https://github.com/MindscapeHQ/raygun4js", "author": { "name": "MindscapeHQ", diff --git a/raygun4js.nuspec b/raygun4js.nuspec index c49945ac..f5903d05 100644 --- a/raygun4js.nuspec +++ b/raygun4js.nuspec @@ -2,7 +2,7 @@ raygun4js - 3.1.2 + 3.1.3 Raygun4js Raygun Limited Raygun Limited diff --git a/src/raygun.rum/index.js b/src/raygun.rum/index.js index 5e26d5af..1248926f 100644 --- a/src/raygun.rum/index.js +++ b/src/raygun.rum/index.js @@ -733,10 +733,17 @@ var raygunRumFactory = function (window, $, Raygun) { var xhrStatusesForName = this.xhrStatusMap[url]; if (xhrStatusesForName && xhrStatusesForName.length > 0) { - var request = this.xhrStatusMap[url].shift(); + var xhrStatus = this.xhrStatusMap[url].shift(); - timingData.statusCode = request.status; - timingData.parentResource = request.parentResource; + timingData.statusCode = xhrStatus.response.status; + timingData.parentResource = xhrStatus.parentResource; + + timingData.requestDetails = { + url: xhrStatus.request.requestURL, + method: xhrStatus.request.method, + body: xhrStatus.request.body, + responseBody: xhrStatus.response.body + }; log('found status for timing', timingData.statusCode); if (this.xhrStatusMap[url].length === 0) { @@ -984,7 +991,8 @@ 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') { - payload.eventData[i].data = JSON.stringify(payload.eventData[i].data); + var strippedEventData = stripRequestDetailsFromPayloadEventData(payload.eventData[i].data); + payload.eventData[i].data = JSON.stringify(strippedEventData); } } } @@ -1012,6 +1020,18 @@ var raygunRumFactory = function (window, $, Raygun) { }, (window.raygunUserAgentDataStatus === 1 ? 200 : 0)); } + function stripRequestDetailsFromPayloadEventData(payloadEventData){ + for (var i = 0 ; i < payloadEventData.length; i++) { + var eventDataItem = payloadEventData[i]; + + if (eventDataItem.requestDetails) { + delete eventDataItem.requestDetails; + } + } + + return payloadEventData; + } + function updateUserAgentData(payload) { if (!payload.eventData) { return; } @@ -1174,7 +1194,9 @@ var raygunRumFactory = function (window, $, Raygun) { var requests = this.xhrRequestMap[response.baseUrl]; if (requests && requests.length > 0) { - var parentResource = requests[0].parentResource; + var request = requests[0]; + + var parentResource = request.parentResource; this.xhrRequestMap[response.baseUrl].shift(); @@ -1186,9 +1208,14 @@ var raygunRumFactory = function (window, $, Raygun) { this.xhrStatusMap[response.baseUrl] = []; } - log('adding response to xhr status map', response); - var responseWithParent = attachParentResource(response, parentResource); - this.xhrStatusMap[response.baseUrl].push(responseWithParent); + var requestAndResponse = { + request: request, + response: response + }; + + log('adding request/response to xhr status map', requestAndResponse); + var requestAndResponseWithParent = attachParentResource(requestAndResponse, parentResource); + this.xhrStatusMap[response.baseUrl].push(requestAndResponseWithParent); } else { log('response fired from non-handled request'); }