rollbar 2.25.2 → 2.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rollbar.js CHANGED
@@ -1018,7 +1018,7 @@ module.exports = {
1018
1018
  "use strict";
1019
1019
 
1020
1020
 
1021
- var ErrorStackParser = __webpack_require__(21);
1021
+ var ErrorStackParser = __webpack_require__(23);
1022
1022
 
1023
1023
  var UNKNOWN_FUNCTION = '?';
1024
1024
  var ERR_CLASS_REGEXP = new RegExp('^(([a-zA-Z0-9-_$ ]*): *)?(Uncaught )?([a-zA-Z0-9-_$ ]*): ');
@@ -1347,12 +1347,12 @@ module.exports = rollbar;
1347
1347
 
1348
1348
 
1349
1349
  var Rollbar = __webpack_require__(8);
1350
- var telemeter = __webpack_require__(28);
1351
- var instrumenter = __webpack_require__(29);
1352
- var polyfillJSON = __webpack_require__(32);
1353
- var wrapGlobals = __webpack_require__(34);
1350
+ var telemeter = __webpack_require__(30);
1351
+ var instrumenter = __webpack_require__(31);
1352
+ var polyfillJSON = __webpack_require__(34);
1353
+ var wrapGlobals = __webpack_require__(36);
1354
1354
  var scrub = __webpack_require__(4);
1355
- var truncation = __webpack_require__(35);
1355
+ var truncation = __webpack_require__(37);
1356
1356
 
1357
1357
  Rollbar.setComponents({
1358
1358
  telemeter: telemeter,
@@ -1382,10 +1382,10 @@ var globals = __webpack_require__(18);
1382
1382
  var Transport = __webpack_require__(19);
1383
1383
  var urllib = __webpack_require__(2);
1384
1384
 
1385
- var transforms = __webpack_require__(20);
1386
- var sharedTransforms = __webpack_require__(23);
1387
- var predicates = __webpack_require__(24);
1388
- var sharedPredicates = __webpack_require__(25);
1385
+ var transforms = __webpack_require__(22);
1386
+ var sharedTransforms = __webpack_require__(25);
1387
+ var predicates = __webpack_require__(26);
1388
+ var sharedPredicates = __webpack_require__(27);
1389
1389
  var errorParser = __webpack_require__(3);
1390
1390
 
1391
1391
  function Rollbar(options, client) {
@@ -1914,8 +1914,8 @@ function _gWindow() {
1914
1914
  return ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
1915
1915
  }
1916
1916
 
1917
- var defaults = __webpack_require__(26);
1918
- var scrubFields = __webpack_require__(27);
1917
+ var defaults = __webpack_require__(28);
1918
+ var scrubFields = __webpack_require__(29);
1919
1919
 
1920
1920
  var defaultOptions = {
1921
1921
  version: defaults.version,
@@ -2991,6 +2991,7 @@ function getTransportFromOptions(options, defaults, url) {
2991
2991
  var path = defaults.path;
2992
2992
  var search = defaults.search;
2993
2993
  var timeout = options.timeout;
2994
+ var transport = detectTransport(options)
2994
2995
 
2995
2996
  var proxy = options.proxy;
2996
2997
  if (options.endpoint) {
@@ -3008,16 +3009,26 @@ function getTransportFromOptions(options, defaults, url) {
3008
3009
  port: port,
3009
3010
  path: path,
3010
3011
  search: search,
3011
- proxy: proxy
3012
+ proxy: proxy,
3013
+ transport: transport
3012
3014
  };
3013
3015
  }
3014
3016
 
3017
+ function detectTransport(options) {
3018
+ var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3019
+ var transport = options.defaultTransport || 'xhr';
3020
+ if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
3021
+ if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
3022
+ return transport;
3023
+ }
3024
+
3015
3025
  function transportOptions(transport, method) {
3016
3026
  var protocol = transport.protocol || 'https:';
3017
3027
  var port = transport.port || (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
3018
3028
  var hostname = transport.hostname;
3019
3029
  var path = transport.path;
3020
3030
  var timeout = transport.timeout;
3031
+ var transportAPI = transport.transport;
3021
3032
  if (transport.search) {
3022
3033
  path = path + transport.search;
3023
3034
  }
@@ -3033,7 +3044,8 @@ function transportOptions(transport, method) {
3033
3044
  hostname: hostname,
3034
3045
  path: path,
3035
3046
  port: port,
3036
- method: method
3047
+ method: method,
3048
+ transport: transportAPI
3037
3049
  };
3038
3050
  }
3039
3051
 
@@ -3235,10 +3247,9 @@ module.exports = {
3235
3247
  "use strict";
3236
3248
 
3237
3249
 
3238
- /*global XDomainRequest*/
3239
-
3240
3250
  var _ = __webpack_require__(0);
3241
- var logger = __webpack_require__(1);
3251
+ var makeFetchRequest = __webpack_require__(20);
3252
+ var makeXhrRequest = __webpack_require__(21);
3242
3253
 
3243
3254
  /*
3244
3255
  * accessToken may be embedded in payload but that should not
@@ -3250,6 +3261,7 @@ var logger = __webpack_require__(1);
3250
3261
  * path
3251
3262
  * port
3252
3263
  * method
3264
+ * transport ('xhr' | 'fetch')
3253
3265
  * }
3254
3266
  *
3255
3267
  * params is an object containing key/value pairs. These
@@ -3269,7 +3281,9 @@ Transport.prototype.get = function(accessToken, options, params, callback, reque
3269
3281
 
3270
3282
  var method = 'GET';
3271
3283
  var url = _.formatUrl(options);
3272
- _makeZoneRequest(accessToken, url, method, null, callback, requestFactory, options.timeout);
3284
+ this._makeZoneRequest(
3285
+ accessToken, url, method, null, callback, requestFactory, options.timeout, options.transport
3286
+ );
3273
3287
  }
3274
3288
 
3275
3289
  Transport.prototype.post = function(accessToken, options, payload, callback, requestFactory) {
@@ -3294,7 +3308,9 @@ Transport.prototype.post = function(accessToken, options, payload, callback, req
3294
3308
  var writeData = stringifyResult.value;
3295
3309
  var method = 'POST';
3296
3310
  var url = _.formatUrl(options);
3297
- _makeZoneRequest(accessToken, url, method, writeData, callback, requestFactory, options.timeout);
3311
+ this._makeZoneRequest(
3312
+ accessToken, url, method, writeData, callback, requestFactory, options.timeout, options.transport
3313
+ );
3298
3314
  }
3299
3315
 
3300
3316
  Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayload, callback, requestFactory) {
@@ -3304,7 +3320,9 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3304
3320
 
3305
3321
  var method = 'POST';
3306
3322
  var url = _.formatUrl(options);
3307
- _makeZoneRequest(accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout);
3323
+ this._makeZoneRequest(
3324
+ accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout, options.transport
3325
+ );
3308
3326
  }
3309
3327
 
3310
3328
 
@@ -3312,7 +3330,7 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3312
3330
  // so Angular change detection isn't triggered on each API call.
3313
3331
  // This is the equivalent of runOutsideAngular().
3314
3332
  //
3315
- function _makeZoneRequest() {
3333
+ Transport.prototype._makeZoneRequest = function () {
3316
3334
  var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3317
3335
  var currentZone = gWindow && gWindow.Zone && gWindow.Zone.current;
3318
3336
  var args = Array.prototype.slice.call(arguments);
@@ -3320,10 +3338,24 @@ function _makeZoneRequest() {
3320
3338
  if (currentZone && currentZone._name === 'angular') {
3321
3339
  var rootZone = currentZone._parent;
3322
3340
  rootZone.run(function () {
3323
- _makeRequest.apply(undefined, args);
3341
+ this._makeRequest.apply(undefined, args);
3324
3342
  });
3325
3343
  } else {
3326
- _makeRequest.apply(undefined, args);
3344
+ this._makeRequest.apply(undefined, args);
3345
+ }
3346
+ }
3347
+
3348
+ Transport.prototype._makeRequest = function (
3349
+ accessToken, url, method, data, callback, requestFactory, timeout, transport
3350
+ ) {
3351
+ if (typeof RollbarProxy !== 'undefined') {
3352
+ return _proxyRequest(data, callback);
3353
+ }
3354
+
3355
+ if (transport === 'fetch') {
3356
+ makeFetchRequest(accessToken, url, method, data, callback, timeout)
3357
+ } else {
3358
+ makeXhrRequest(accessToken, url, method, data, callback, requestFactory, timeout)
3327
3359
  }
3328
3360
  }
3329
3361
 
@@ -3339,11 +3371,66 @@ function _proxyRequest(json, callback) {
3339
3371
  );
3340
3372
  }
3341
3373
 
3342
- function _makeRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3343
- if (typeof RollbarProxy !== 'undefined') {
3344
- return _proxyRequest(data, callback);
3374
+ module.exports = Transport;
3375
+
3376
+
3377
+ /***/ }),
3378
+ /* 20 */
3379
+ /***/ (function(module, exports, __webpack_require__) {
3380
+
3381
+ "use strict";
3382
+
3383
+
3384
+ var logger = __webpack_require__(1);
3385
+ var _ = __webpack_require__(0);
3386
+
3387
+ function makeFetchRequest(accessToken, url, method, data, callback, timeout) {
3388
+ var controller;
3389
+ var timeoutId;
3390
+
3391
+ if(_.isFiniteNumber(timeout)) {
3392
+ controller = new AbortController();
3393
+ timeoutId = setTimeout(() => controller.abort(), timeout);
3345
3394
  }
3346
3395
 
3396
+ fetch(url, {
3397
+ method: method,
3398
+ headers: {
3399
+ 'Content-Type': 'application/json',
3400
+ 'X-Rollbar-Access-Token': accessToken,
3401
+ signal: controller && controller.signal
3402
+ },
3403
+ body: data,
3404
+ })
3405
+ .then((response) => {
3406
+ if (timeoutId) clearTimeout(timeoutId);
3407
+ return response.json();
3408
+ })
3409
+ .then((data) => {
3410
+ callback(null, data);
3411
+ })
3412
+ .catch((error) => {
3413
+ logger.error(error.message);
3414
+ callback(error);
3415
+ });
3416
+ }
3417
+
3418
+ module.exports = makeFetchRequest;
3419
+
3420
+
3421
+ /***/ }),
3422
+ /* 21 */
3423
+ /***/ (function(module, exports, __webpack_require__) {
3424
+
3425
+ "use strict";
3426
+
3427
+
3428
+ /*global XDomainRequest*/
3429
+
3430
+ var _ = __webpack_require__(0);
3431
+ var logger = __webpack_require__(1);
3432
+
3433
+ function makeXhrRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3347
3434
  var request;
3348
3435
  if (requestFactory) {
3349
3436
  request = requestFactory();
@@ -3496,11 +3583,11 @@ function _newRetriableError(message, code) {
3496
3583
  return err;
3497
3584
  }
3498
3585
 
3499
- module.exports = Transport;
3586
+ module.exports = makeXhrRequest;
3500
3587
 
3501
3588
 
3502
3589
  /***/ }),
3503
- /* 20 */
3590
+ /* 22 */
3504
3591
  /***/ (function(module, exports, __webpack_require__) {
3505
3592
 
3506
3593
  "use strict";
@@ -3847,7 +3934,7 @@ module.exports = {
3847
3934
 
3848
3935
 
3849
3936
  /***/ }),
3850
- /* 21 */
3937
+ /* 23 */
3851
3938
  /***/ (function(module, exports, __webpack_require__) {
3852
3939
 
3853
3940
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -3856,7 +3943,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3856
3943
 
3857
3944
  /* istanbul ignore next */
3858
3945
  if (true) {
3859
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(22)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3946
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(24)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3860
3947
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
3861
3948
  (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
3862
3949
  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
@@ -3907,21 +3994,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3907
3994
  return filtered.map(function(line) {
3908
3995
  if (line.indexOf('(eval ') > -1) {
3909
3996
  // Throw away eval information until we implement stacktrace.js/stackframe#8
3910
- line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
3997
+ line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(,.*$)/g, '');
3911
3998
  }
3912
- var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
3999
+ var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').replace(/^.*?\s+/, '');
3913
4000
 
3914
4001
  // capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in
3915
4002
  // case it has spaces in it, as the string is split on \s+ later on
3916
- var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
4003
+ var location = sanitizedLine.match(/ (\(.+\)$)/);
3917
4004
 
3918
4005
  // remove the parenthesized location from the line, if it was matched
3919
4006
  sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
3920
4007
 
3921
- var tokens = sanitizedLine.split(/\s+/).slice(1);
3922
- // if a location was matched, pass it to extractLocation() otherwise pop the last token
3923
- var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
3924
- var functionName = tokens.join(' ') || undefined;
4008
+ // if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine
4009
+ // because this line doesn't have function name
4010
+ var locationParts = this.extractLocation(location ? location[1] : sanitizedLine);
4011
+ var functionName = location && sanitizedLine || undefined;
3925
4012
  var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
3926
4013
 
3927
4014
  return new StackFrame({
@@ -4054,7 +4141,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4054
4141
 
4055
4142
 
4056
4143
  /***/ }),
4057
- /* 22 */
4144
+ /* 24 */
4058
4145
  /***/ (function(module, exports, __webpack_require__) {
4059
4146
 
4060
4147
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -4202,7 +4289,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4202
4289
 
4203
4290
 
4204
4291
  /***/ }),
4205
- /* 23 */
4292
+ /* 25 */
4206
4293
  /***/ (function(module, exports, __webpack_require__) {
4207
4294
 
4208
4295
  "use strict";
@@ -4359,7 +4446,7 @@ module.exports = {
4359
4446
 
4360
4447
 
4361
4448
  /***/ }),
4362
- /* 24 */
4449
+ /* 26 */
4363
4450
  /***/ (function(module, exports, __webpack_require__) {
4364
4451
 
4365
4452
  "use strict";
@@ -4380,7 +4467,7 @@ module.exports = {
4380
4467
 
4381
4468
 
4382
4469
  /***/ }),
4383
- /* 25 */
4470
+ /* 27 */
4384
4471
  /***/ (function(module, exports, __webpack_require__) {
4385
4472
 
4386
4473
  "use strict";
@@ -4582,14 +4669,14 @@ module.exports = {
4582
4669
 
4583
4670
 
4584
4671
  /***/ }),
4585
- /* 26 */
4672
+ /* 28 */
4586
4673
  /***/ (function(module, exports, __webpack_require__) {
4587
4674
 
4588
4675
  "use strict";
4589
4676
 
4590
4677
 
4591
4678
  module.exports = {
4592
- version: '2.25.2',
4679
+ version: '2.26.0',
4593
4680
  endpoint: 'api.rollbar.com/api/1/item/',
4594
4681
  logLevel: 'debug',
4595
4682
  reportLevel: 'debug',
@@ -4600,7 +4687,7 @@ module.exports = {
4600
4687
 
4601
4688
 
4602
4689
  /***/ }),
4603
- /* 27 */
4690
+ /* 29 */
4604
4691
  /***/ (function(module, exports, __webpack_require__) {
4605
4692
 
4606
4693
  "use strict";
@@ -4668,7 +4755,7 @@ module.exports = {
4668
4755
 
4669
4756
 
4670
4757
  /***/ }),
4671
- /* 28 */
4758
+ /* 30 */
4672
4759
  /***/ (function(module, exports, __webpack_require__) {
4673
4760
 
4674
4761
  "use strict";
@@ -4854,17 +4941,17 @@ module.exports = Telemeter;
4854
4941
 
4855
4942
 
4856
4943
  /***/ }),
4857
- /* 29 */
4944
+ /* 31 */
4858
4945
  /***/ (function(module, exports, __webpack_require__) {
4859
4946
 
4860
4947
  "use strict";
4861
4948
 
4862
4949
 
4863
4950
  var _ = __webpack_require__(0);
4864
- var headers = __webpack_require__(30);
4951
+ var headers = __webpack_require__(32);
4865
4952
  var scrub = __webpack_require__(4);
4866
4953
  var urlparser = __webpack_require__(2);
4867
- var domUtil = __webpack_require__(31);
4954
+ var domUtil = __webpack_require__(33);
4868
4955
 
4869
4956
  var defaults = {
4870
4957
  network: true,
@@ -5245,6 +5332,9 @@ Instrumenter.prototype.instrumentNetwork = function() {
5245
5332
  if (self.trackHttpErrors()) {
5246
5333
  metadata.stack = (new Error()).stack;
5247
5334
  }
5335
+
5336
+ // Start our handler before returning the promise. This allows resp.clone()
5337
+ // to execute before other handlers touch the response.
5248
5338
  return orig.apply(this, args).then(function (resp) {
5249
5339
  metadata.end_time_ms = _.now();
5250
5340
  metadata.status_code = resp.status;
@@ -5257,6 +5347,7 @@ Instrumenter.prototype.instrumentNetwork = function() {
5257
5347
  if (self.autoInstrument.networkResponseBody) {
5258
5348
  if (typeof resp.text === 'function') { // Response.text() is not implemented on some platforms
5259
5349
  // The response must be cloned to prevent reading (and locking) the original stream.
5350
+ // This must be done before other handlers touch the response.
5260
5351
  body = resp.clone().text(); //returns a Promise
5261
5352
  }
5262
5353
  }
@@ -5632,7 +5723,7 @@ module.exports = Instrumenter;
5632
5723
 
5633
5724
 
5634
5725
  /***/ }),
5635
- /* 30 */
5726
+ /* 32 */
5636
5727
  /***/ (function(module, exports, __webpack_require__) {
5637
5728
 
5638
5729
  "use strict";
@@ -5735,7 +5826,7 @@ module.exports = headers;
5735
5826
 
5736
5827
 
5737
5828
  /***/ }),
5738
- /* 31 */
5829
+ /* 33 */
5739
5830
  /***/ (function(module, exports, __webpack_require__) {
5740
5831
 
5741
5832
  "use strict";
@@ -5874,19 +5965,19 @@ module.exports = {
5874
5965
 
5875
5966
 
5876
5967
  /***/ }),
5877
- /* 32 */
5968
+ /* 34 */
5878
5969
  /***/ (function(module, exports, __webpack_require__) {
5879
5970
 
5880
5971
  "use strict";
5881
5972
 
5882
5973
 
5883
- var polyfillJSON = __webpack_require__(33);
5974
+ var polyfillJSON = __webpack_require__(35);
5884
5975
 
5885
5976
  module.exports = polyfillJSON;
5886
5977
 
5887
5978
 
5888
5979
  /***/ }),
5889
- /* 33 */
5980
+ /* 35 */
5890
5981
  /***/ (function(module, exports) {
5891
5982
 
5892
5983
  // json3.js
@@ -6655,7 +6746,7 @@ module.exports = setupCustomJSON;
6655
6746
 
6656
6747
 
6657
6748
  /***/ }),
6658
- /* 34 */
6749
+ /* 36 */
6659
6750
  /***/ (function(module, exports, __webpack_require__) {
6660
6751
 
6661
6752
  "use strict";
@@ -6705,7 +6796,7 @@ module.exports = wrapGlobals;
6705
6796
 
6706
6797
 
6707
6798
  /***/ }),
6708
- /* 35 */
6799
+ /* 37 */
6709
6800
  /***/ (function(module, exports, __webpack_require__) {
6710
6801
 
6711
6802
  "use strict";