@@ -20,6 +20,7 @@ var _window = typeof window !== 'undefined' ? window
20
20
: typeof self !== 'undefined' ? self
21
21
: { } ;
22
22
var _document = _window . document ;
23
+ var _navigator = _window . navigator ;
23
24
24
25
// First, check for JSON support
25
26
// If there is no JSON, we no-op the core features of Raven
@@ -28,6 +29,7 @@ function Raven() {
28
29
this . _hasJSON = ! ! ( typeof JSON === 'object' && JSON . stringify ) ;
29
30
// Raven can run in contexts where there's no document (react-native)
30
31
this . _hasDocument = ! isUndefined ( _document ) ;
32
+ this . _hasNavigator = ! isUndefined ( _navigator ) ;
31
33
this . _lastCapturedException = null ;
32
34
this . _lastEventId = null ;
33
35
this . _globalServer = null ;
@@ -1301,20 +1303,23 @@ Raven.prototype = {
1301
1303
} ,
1302
1304
1303
1305
_getHttpData : function ( ) {
1304
- if ( ! this . _hasDocument || ! _document . location || ! _document . location . href ) {
1305
- return ;
1306
+ if ( ! this . _hasNavigator && ! this . _hasDocument ) return ;
1307
+ var httpData = { } ;
1308
+
1309
+ if ( this . _hasNavigator && _navigator . userAgent ) {
1310
+ httpData . headers = {
1311
+ 'User-Agent' : navigator . userAgent
1312
+ } ;
1306
1313
}
1307
1314
1308
- var httpData = {
1309
- headers : {
1310
- 'User-Agent' : navigator . userAgent
1315
+ if ( this . _hasDocument ) {
1316
+ if ( _document . location && _document . location . href ) {
1317
+ httpData . url = _document . location . href ;
1318
+ }
1319
+ if ( _document . referrer ) {
1320
+ if ( ! httpData . headers ) httpData . headers = { } ;
1321
+ httpData . headers . Referer = _document . referrer ;
1311
1322
}
1312
- } ;
1313
-
1314
- httpData . url = _document . location . href ;
1315
-
1316
- if ( _document . referrer ) {
1317
- httpData . headers . Referer = _document . referrer ;
1318
1323
}
1319
1324
1320
1325
return httpData ;
0 commit comments