Skip to content

Commit 76024ea

Browse files
authored
Merge pull request #323 from MindscapeHQ/tl/fix-rum-crash-in-rn
Fix RUM crash in React Native
2 parents 9bfb04b + 045a229 commit 76024ea

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* v2.15.2
22
- Include all dist files in npm package instead of just main file
3+
- Don't run RUM in React Native to prevent a crash, RUM does not support React Native
34

45
* v2.15.1
56
- Fix error in Raygun4JS UMD build with raygunNetworkTrackingFactory being undefined

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
},
4646
"scripts": {
4747
"test-local": "LOCAL=true node_modules/.bin/wdio wdio.conf.js",
48-
"test": "node_modules/.bin/wdio wdio.conf.js",
49-
"prepublish": "grunt build"
48+
"test": "node_modules/.bin/wdio wdio.conf.js"
5049
},
5150
"dependencies": {},
5251
"keywords": [

src/raygun.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,18 @@ var raygunFactory = function(window, $, undefined) {
483483
_rum.attach();
484484
};
485485

486-
if (_loadedFrom === 'onLoad') {
487-
startRum();
488-
} else {
489-
if (window.addEventListener) {
490-
window.addEventListener('load', startRum);
486+
if (!Raygun.Utilities.isReactNative()) {
487+
if (_loadedFrom === 'onLoad') {
488+
startRum();
491489
} else {
492-
window.attachEvent('onload', startRum);
490+
if (window.addEventListener) {
491+
window.addEventListener('load', startRum);
492+
} else {
493+
window.attachEvent('onload', startRum);
494+
}
493495
}
496+
} else {
497+
Raygun.Utilities.log('Not enabling RUM because Raygun4JS has detected a React Native environment, see #310 on Github');
494498
}
495499
}
496500

0 commit comments

Comments
 (0)