Skip to content

Commit b2992fa

Browse files
authored
Merge pull request #534 from MindscapeHQ/ob/remove-ping
Remove ping functionality from provider
2 parents 83732ff + a2850f6 commit b2992fa

File tree

5 files changed

+50
-121
lines changed

5 files changed

+50
-121
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Unused normalize.css file
2929
3030
-->
31+
## [3.1.4]
32+
33+
### Removed
34+
- Removed the ping functionality as it's no longer needed as part of the onboarding flow inside the app.
3135

3236
## [3.1.3]
3337

bower.json

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
{
22
"name": "raygun4js",
3-
"version": "3.1.3",
3+
"version": "3.1.4",
44
"homepage": "http://raygun.com",
5-
"authors": [
6-
"Mindscape <[email protected]>"
7-
],
5+
"authors": ["Mindscape <[email protected]>"],
86
"repository": {
97
"type": "git",
108
"url": "git://github.com/MindscapeHQ/raygun4js.git"
119
},
1210
"description": "Official Raygun.com automatic error tracking plugin for JavaScript",
1311
"main": "dist/raygun.js",
14-
"keywords": [
15-
"error",
16-
"tracking",
17-
"reporting",
18-
"raygun"
19-
],
12+
"keywords": ["error", "tracking", "reporting", "raygun"],
2013
"license": "MIT",
21-
"ignore": [
22-
"**/.*",
23-
"node_modules",
24-
"bower_components",
25-
"test",
26-
"tests"
27-
],
28-
"dependencies": {
29-
},
14+
"ignore": ["**/.*", "node_modules", "bower_components", "test", "tests"],
15+
"dependencies": {},
3016
"devDependencies": {
3117
"grunt-contrib-jshint": "~0.11.2",
3218
"grunt-contrib-concat": "~0.1.2",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"title": "Raygun4js",
99
"description": "Raygun.com plugin for JavaScript",
10-
"version": "3.1.3",
10+
"version": "3.1.4",
1111
"homepage": "https://github.com/MindscapeHQ/raygun4js",
1212
"author": {
1313
"name": "MindscapeHQ",

raygun4js.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>raygun4js</id>
5-
<version>3.1.3</version>
5+
<version>3.1.4</version>
66
<title>Raygun4js</title>
77
<authors>Raygun Limited</authors>
88
<owners>Raygun Limited</owners>

src/raygun.loader.js

Lines changed: 39 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @prettier
33
*/
44

5-
(function(window, Raygun) {
5+
(function (window, Raygun) {
66
if (!window['RaygunObject'] || !window[window['RaygunObject']]) {
77
return;
88
}
@@ -19,33 +19,31 @@
1919
crashReportingEnabled = false,
2020
captureUnhandledRejections;
2121

22-
var hasSessionStorage = false;
23-
try {
24-
hasSessionStorage = !!window.sessionStorage;
25-
} catch (e) {
26-
// sessionStorage not available
27-
}
22+
var hasSessionStorage = false;
23+
try {
24+
hasSessionStorage = !!window.sessionStorage;
25+
} catch (e) {
26+
// sessionStorage not available
27+
}
2828

29-
var metadata = {
30-
ping : {
31-
sessionStorageItem : 'raygun4js-successful-ping',
32-
sendPing : true,
33-
failedPings : 0
34-
},
35-
};
3629
var snippetOnErrorSignature = ['function (b,c,d,f,g){', '||(g=new Error(b)),a[e].q=a[e].q||[]'];
3730

3831
errorQueue = window[window['RaygunObject']].q;
3932
var rg = Raygun;
4033

41-
var delayedExecutionFunctions = ['trackEvent', 'send', 'recordBreadcrumb','captureMissingRequests'];
34+
var delayedExecutionFunctions = [
35+
'trackEvent',
36+
'send',
37+
'recordBreadcrumb',
38+
'captureMissingRequests',
39+
];
4240

43-
var parseSnippetOptions = function() {
41+
var parseSnippetOptions = function () {
4442
snippetOptions = window[window['RaygunObject']].o;
4543

46-
for (var i in snippetOptions) {
47-
if (snippetOptions.hasOwnProperty(i)) {
48-
var pair = snippetOptions[i];
44+
for (var i in snippetOptions) {
45+
if (snippetOptions.hasOwnProperty(i)) {
46+
var pair = snippetOptions[i];
4947
if (pair) {
5048
if (delayedExecutionFunctions.indexOf(pair[0]) === -1) {
5149
// Config pair, can execute immediately
@@ -59,15 +57,12 @@
5957
}
6058
};
6159

62-
var executor = function(pair) {
60+
var executor = function (pair) {
6361
var key = pair[0];
6462
var value = pair[1];
6563

6664
if (key) {
6765
switch (key) {
68-
case 'sendPing':
69-
metadata.ping.sendPing = value;
70-
break;
7166
// React Native only
7267
case 'boot':
7368
onLoadHandler();
@@ -175,8 +170,12 @@
175170
case 'trackEvent':
176171
if (value.type && value.path) {
177172
rg.trackEvent(value.type, { path: value.path });
178-
} else if(value.type && value.name && value.duration) {
179-
rg.trackEvent(value.type, { name: value.name, duration: value.duration, offset: value.offset || 0 });
173+
} else if (value.type && value.name && value.duration) {
174+
rg.trackEvent(value.type, {
175+
name: value.name,
176+
duration: value.duration,
177+
offset: value.offset || 0,
178+
});
180179
} else if (value.type && value.timings) {
181180
rg.trackEvent(value.type, { timings: value.timings });
182181
}
@@ -226,7 +225,7 @@
226225
case 'clientIp':
227226
rg.setClientIp(value);
228227
break;
229-
case 'captureMissingRequests':
228+
case 'captureMissingRequests':
230229
rg.captureMissingRequests(value);
231230
break;
232231
case 'captureUnhandledRejections':
@@ -236,81 +235,21 @@
236235
}
237236
};
238237

239-
function ping() {
240-
if(!Raygun.Options || !Raygun.Options._raygunApiKey || !Raygun.Options._raygunApiUrl){
241-
return;
242-
}
243-
244-
var url = Raygun.Options._raygunApiUrl + "/ping?apiKey=" + encodeURIComponent(Raygun.Options._raygunApiKey);
245-
var data = {
246-
crashReportingEnabled: crashReportingEnabled ? true : false,
247-
realUserMonitoringEnabled: realUserMonitoringEnabled ? true : false,
248-
providerName: "raygun4js",
249-
providerVersion: '{{VERSION}}'
250-
};
251-
252-
// Check if we've already pinged with the same data
253-
if (hasSessionStorage) {
254-
var storedData = sessionStorage.getItem(metadata.ping.sessionStorageItem);
255-
if (storedData && storedData === JSON.stringify(data)) {
256-
return;
257-
}
258-
}
259-
260-
fetch(url, {
261-
method: 'POST',
262-
headers: {
263-
'Content-Type': 'application/json'
264-
},
265-
body: JSON.stringify(data)
266-
}).then(function(response) {
267-
if (response.ok) {
268-
if (hasSessionStorage) {
269-
// Record successful ping in local storage
270-
sessionStorage.setItem(metadata.ping.sessionStorageItem, JSON.stringify(data));
271-
}
272-
metadata.ping.failedPings = 0;
273-
} else {
274-
retryPing(metadata.ping.failedPings);
275-
metadata.ping.failedPings++;
276-
}
277-
}).catch(function() {
278-
retryPing(metadata.ping.failedPings);
279-
metadata.ping.failedPings++;
280-
});
281-
}
282-
283-
var retryPing = function(failedPings) {
284-
if (failedPings > 5) {
285-
// Stop retrying after 5 failed attempts
286-
return;
287-
}
288-
289-
// Generates a delay of 10/20/40/80/120 seconds
290-
var backoffDelay = Math.min(
291-
10 * Math.pow(2, metadata.ping.failedPings),
292-
120 // 2 minutes
293-
) * 1000;
294-
295-
// Retry after backoff delay
296-
setTimeout(ping, backoffDelay);
297-
};
298-
299-
var installGlobalExecutor = function() {
300-
window[window['RaygunObject']] = function() {
238+
var installGlobalExecutor = function () {
239+
window[window['RaygunObject']] = function () {
301240
return executor(arguments);
302241
};
303242
window['RaygunInitialized'] = true;
304243
globalExecutorInstalled = true;
305244
};
306245

307-
var onLoadHandler = function() {
246+
var onLoadHandler = function () {
308247
parseSnippetOptions();
309248

310249
if (noConflict) {
311250
rg = Raygun.noConflict();
312251
}
313-
252+
314253
if (apiKey) {
315254
if (!options) {
316255
options = {};
@@ -353,23 +292,23 @@
353292
installGlobalExecutor();
354293
}
355294

356-
if(metadata.ping.sendPing) {
357-
ping(); //call immediately
358-
}
359295
window[window['RaygunObject']].q = errorQueue;
360296
};
361297

362298
if (!Raygun.Utilities.isReactNative()) {
363-
var supportsNavigationTiming = !!window.PerformanceObserver && !!window.PerformanceObserver.supportedEntryTypes && window.PerformanceObserver.supportedEntryTypes.includes('navigation');
299+
var supportsNavigationTiming =
300+
!!window.PerformanceObserver &&
301+
!!window.PerformanceObserver.supportedEntryTypes &&
302+
window.PerformanceObserver.supportedEntryTypes.includes('navigation');
364303
if (document.readyState === 'complete') {
365-
onLoadHandler();
304+
onLoadHandler();
366305
} else if (supportsNavigationTiming) {
367-
//The other 'load' events are called before the PerformanceNavigationTiming is completed resulting in `loadEventEnd` never being set which is needed to calculate the duration of the timing. This observer triggers after the timing is complete.
368-
var observer = new window.PerformanceObserver(function () {
369-
onLoadHandler();
370-
});
306+
//The other 'load' events are called before the PerformanceNavigationTiming is completed resulting in `loadEventEnd` never being set which is needed to calculate the duration of the timing. This observer triggers after the timing is complete.
307+
var observer = new window.PerformanceObserver(function () {
308+
onLoadHandler();
309+
});
371310

372-
observer.observe({ entryTypes: ['navigation'] });
311+
observer.observe({ entryTypes: ['navigation'] });
373312
} else if (window.addEventListener) {
374313
window.addEventListener('load', onLoadHandler);
375314
} else {

0 commit comments

Comments
 (0)