Skip to content

Commit

Permalink
Merge pull request #504 from MindscapeHQ/ht/add-client-data
Browse files Browse the repository at this point in the history
Addclient info to rum payload
  • Loading branch information
Hamish-taylor committed Sep 20, 2023
2 parents 5edd4d6 + 9f1d2bc commit fe73f53
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Unused normalize.css file
-->
## [2.28.0]

### Changed

- Adds client provider (version) information
- Adds defaults for timing information payload information


## [2.27.3]

### Changed

- Fixes a rare condition with UMD where we assume rg4js is initialised but it is not, causing an infinite loop.



## [2.27.2]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raygun4js",
"version": "2.27.3",
"version": "2.28.0",
"homepage": "http://raygun.com",
"authors": [
"Mindscape <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"title": "Raygun4js",
"description": "Raygun.com plugin for JavaScript",
"version": "2.27.3",
"version": "2.28.0",
"homepage": "https://github.com/MindscapeHQ/raygun4js",
"author": {
"name": "MindscapeHQ",
Expand Down
2 changes: 1 addition & 1 deletion raygun4js.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>raygun4js</id>
<version>2.27.3</version>
<version>2.28.0</version>
<title>Raygun4js</title>
<authors>Raygun Limited</authors>
<owners>Raygun Limited</owners>
Expand Down
2 changes: 1 addition & 1 deletion src/raygun.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ var raygunFactory = function (window, $, undefined) {
if (type === 'pageView' && options.path) {
_rum.virtualPageLoaded(options.path);
} else if (type === 'customTiming') {
_rum.trackCustomTiming(options.name, options.duration, options.offset, parentResource);
_rum.trackCustomTiming(options.name, options.duration, options.offset || 0, parentResource);
} else if (type === 'customTimings' && options.timings) {
_rum.sendCustomTimings(options.timings, parentResource);
}
Expand Down
2 changes: 1 addition & 1 deletion src/raygun.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
if (value.type && value.path) {
rg.trackEvent(value.type, { path: value.path });
} else if(value.type && value.name && value.duration) {
rg.trackEvent(value.type, { name: value.name, duration: value.duration, offset: value.offset });
rg.trackEvent(value.type, { name: value.name, duration: value.duration, offset: value.offset || 0 });
} else if (value.type && value.timings) {
rg.trackEvent(value.type, { timings: value.timings });
}
Expand Down
19 changes: 13 additions & 6 deletions src/raygun.rum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ var raygunRumFactory = function (window, $, Raygun) {
version: self.version || 'Not supplied',
tags: self.tags,
device: window.raygunUserAgent,
client: { //This is incomplete, it does not add the client data to every payload that is sent
name: "raygun4js",
version: '{{VERSION}}'
},
}));
}

Expand Down Expand Up @@ -602,12 +606,11 @@ var raygunRumFactory = function (window, $, Raygun) {
url: response.baseUrl,
statusCode: response.status,
timing: {
du: maxFiveMinutes(response.duration).toFixed(2),
a: offset.toFixed(2),
du: maxFiveMinutes(response.duration || 0).toFixed(2), //These are hacks to stop a potential situation where duration and/or offset are NaN, this is not a feature and needs to be fixed
a: (offset || 0).toFixed(2),
t: Timings.XHR
},
};

collection.push(attachParentResource(payload, response.parentResource));
}
} while (responses.length > 0);
Expand Down Expand Up @@ -731,7 +734,7 @@ var raygunRumFactory = function (window, $, Raygun) {
t: Timings.Page,
};

data.a = timing.fetchStart;
data.a = timing.fetchStart || 0;

if (timing.domainLookupStart && timing.domainLookupStart > 0) {
data.b = timing.domainLookupStart - data.a;
Expand Down Expand Up @@ -824,7 +827,7 @@ var raygunRumFactory = function (window, $, Raygun) {
var data = {
du: maxFiveMinutes(getTimingDuration(timing)).toFixed(2),
t: getSecondaryTimingType(timing),
a: offset + timing.fetchStart,
a: (offset || 0) + (timing.fetchStart || timing.startTime || 0),
};

if (timing.domainLookupStart && timing.domainLookupStart > 0) {
Expand Down Expand Up @@ -1203,7 +1206,7 @@ var raygunRumFactory = function (window, $, Raygun) {

function sanitizeNaNs(data) {
for (var i in data) {
if (isNaN(data[i]) && typeof data[i] !== 'string') {
if (data[i] === "NaN" || Number.isNaN(data[i])) {
data[i] = 0;
}
}
Expand Down Expand Up @@ -1255,6 +1258,10 @@ var raygunRumFactory = function (window, $, Raygun) {
user: self.user,
version: self.version || 'Not supplied',
device: window.raygunUserAgent,
client: { //This is incomplete, it does not add the client data to every payload that is sent
name: "raygun4js",
version: '{{VERSION}}'
},
tags: self.tags,
data: data,
});
Expand Down

0 comments on commit fe73f53

Please sign in to comment.