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.
@@ -1028,7 +1028,7 @@ module.exports = {
1028
1028
  "use strict";
1029
1029
 
1030
1030
 
1031
- var ErrorStackParser = __webpack_require__(22);
1031
+ var ErrorStackParser = __webpack_require__(24);
1032
1032
 
1033
1033
  var UNKNOWN_FUNCTION = '?';
1034
1034
  var ERR_CLASS_REGEXP = new RegExp('^(([a-zA-Z0-9-_$ ]*): *)?(Uncaught )?([a-zA-Z0-9-_$ ]*): ');
@@ -1349,12 +1349,12 @@ module.exports = rollbar;
1349
1349
 
1350
1350
 
1351
1351
  var Rollbar = __webpack_require__(9);
1352
- var telemeter = __webpack_require__(29);
1353
- var instrumenter = __webpack_require__(30);
1354
- var polyfillJSON = __webpack_require__(33);
1355
- var wrapGlobals = __webpack_require__(35);
1352
+ var telemeter = __webpack_require__(31);
1353
+ var instrumenter = __webpack_require__(32);
1354
+ var polyfillJSON = __webpack_require__(35);
1355
+ var wrapGlobals = __webpack_require__(37);
1356
1356
  var scrub = __webpack_require__(4);
1357
- var truncation = __webpack_require__(36);
1357
+ var truncation = __webpack_require__(38);
1358
1358
 
1359
1359
  Rollbar.setComponents({
1360
1360
  telemeter: telemeter,
@@ -1384,10 +1384,10 @@ var globals = __webpack_require__(19);
1384
1384
  var Transport = __webpack_require__(20);
1385
1385
  var urllib = __webpack_require__(2);
1386
1386
 
1387
- var transforms = __webpack_require__(21);
1388
- var sharedTransforms = __webpack_require__(24);
1389
- var predicates = __webpack_require__(25);
1390
- var sharedPredicates = __webpack_require__(26);
1387
+ var transforms = __webpack_require__(23);
1388
+ var sharedTransforms = __webpack_require__(26);
1389
+ var predicates = __webpack_require__(27);
1390
+ var sharedPredicates = __webpack_require__(28);
1391
1391
  var errorParser = __webpack_require__(3);
1392
1392
 
1393
1393
  function Rollbar(options, client) {
@@ -1916,8 +1916,8 @@ function _gWindow() {
1916
1916
  return ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
1917
1917
  }
1918
1918
 
1919
- var defaults = __webpack_require__(27);
1920
- var scrubFields = __webpack_require__(28);
1919
+ var defaults = __webpack_require__(29);
1920
+ var scrubFields = __webpack_require__(30);
1921
1921
 
1922
1922
  var defaultOptions = {
1923
1923
  version: defaults.version,
@@ -2993,6 +2993,7 @@ function getTransportFromOptions(options, defaults, url) {
2993
2993
  var path = defaults.path;
2994
2994
  var search = defaults.search;
2995
2995
  var timeout = options.timeout;
2996
+ var transport = detectTransport(options)
2996
2997
 
2997
2998
  var proxy = options.proxy;
2998
2999
  if (options.endpoint) {
@@ -3010,16 +3011,26 @@ function getTransportFromOptions(options, defaults, url) {
3010
3011
  port: port,
3011
3012
  path: path,
3012
3013
  search: search,
3013
- proxy: proxy
3014
+ proxy: proxy,
3015
+ transport: transport
3014
3016
  };
3015
3017
  }
3016
3018
 
3019
+ function detectTransport(options) {
3020
+ var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3021
+ var transport = options.defaultTransport || 'xhr';
3022
+ if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
3023
+ if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
3024
+ return transport;
3025
+ }
3026
+
3017
3027
  function transportOptions(transport, method) {
3018
3028
  var protocol = transport.protocol || 'https:';
3019
3029
  var port = transport.port || (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
3020
3030
  var hostname = transport.hostname;
3021
3031
  var path = transport.path;
3022
3032
  var timeout = transport.timeout;
3033
+ var transportAPI = transport.transport;
3023
3034
  if (transport.search) {
3024
3035
  path = path + transport.search;
3025
3036
  }
@@ -3035,7 +3046,8 @@ function transportOptions(transport, method) {
3035
3046
  hostname: hostname,
3036
3047
  path: path,
3037
3048
  port: port,
3038
- method: method
3049
+ method: method,
3050
+ transport: transportAPI
3039
3051
  };
3040
3052
  }
3041
3053
 
@@ -3237,10 +3249,9 @@ module.exports = {
3237
3249
  "use strict";
3238
3250
 
3239
3251
 
3240
- /*global XDomainRequest*/
3241
-
3242
3252
  var _ = __webpack_require__(0);
3243
- var logger = __webpack_require__(1);
3253
+ var makeFetchRequest = __webpack_require__(21);
3254
+ var makeXhrRequest = __webpack_require__(22);
3244
3255
 
3245
3256
  /*
3246
3257
  * accessToken may be embedded in payload but that should not
@@ -3252,6 +3263,7 @@ var logger = __webpack_require__(1);
3252
3263
  * path
3253
3264
  * port
3254
3265
  * method
3266
+ * transport ('xhr' | 'fetch')
3255
3267
  * }
3256
3268
  *
3257
3269
  * params is an object containing key/value pairs. These
@@ -3271,7 +3283,9 @@ Transport.prototype.get = function(accessToken, options, params, callback, reque
3271
3283
 
3272
3284
  var method = 'GET';
3273
3285
  var url = _.formatUrl(options);
3274
- _makeZoneRequest(accessToken, url, method, null, callback, requestFactory, options.timeout);
3286
+ this._makeZoneRequest(
3287
+ accessToken, url, method, null, callback, requestFactory, options.timeout, options.transport
3288
+ );
3275
3289
  }
3276
3290
 
3277
3291
  Transport.prototype.post = function(accessToken, options, payload, callback, requestFactory) {
@@ -3296,7 +3310,9 @@ Transport.prototype.post = function(accessToken, options, payload, callback, req
3296
3310
  var writeData = stringifyResult.value;
3297
3311
  var method = 'POST';
3298
3312
  var url = _.formatUrl(options);
3299
- _makeZoneRequest(accessToken, url, method, writeData, callback, requestFactory, options.timeout);
3313
+ this._makeZoneRequest(
3314
+ accessToken, url, method, writeData, callback, requestFactory, options.timeout, options.transport
3315
+ );
3300
3316
  }
3301
3317
 
3302
3318
  Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayload, callback, requestFactory) {
@@ -3306,7 +3322,9 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3306
3322
 
3307
3323
  var method = 'POST';
3308
3324
  var url = _.formatUrl(options);
3309
- _makeZoneRequest(accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout);
3325
+ this._makeZoneRequest(
3326
+ accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout, options.transport
3327
+ );
3310
3328
  }
3311
3329
 
3312
3330
 
@@ -3314,7 +3332,7 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3314
3332
  // so Angular change detection isn't triggered on each API call.
3315
3333
  // This is the equivalent of runOutsideAngular().
3316
3334
  //
3317
- function _makeZoneRequest() {
3335
+ Transport.prototype._makeZoneRequest = function () {
3318
3336
  var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3319
3337
  var currentZone = gWindow && gWindow.Zone && gWindow.Zone.current;
3320
3338
  var args = Array.prototype.slice.call(arguments);
@@ -3322,10 +3340,24 @@ function _makeZoneRequest() {
3322
3340
  if (currentZone && currentZone._name === 'angular') {
3323
3341
  var rootZone = currentZone._parent;
3324
3342
  rootZone.run(function () {
3325
- _makeRequest.apply(undefined, args);
3343
+ this._makeRequest.apply(undefined, args);
3326
3344
  });
3327
3345
  } else {
3328
- _makeRequest.apply(undefined, args);
3346
+ this._makeRequest.apply(undefined, args);
3347
+ }
3348
+ }
3349
+
3350
+ Transport.prototype._makeRequest = function (
3351
+ accessToken, url, method, data, callback, requestFactory, timeout, transport
3352
+ ) {
3353
+ if (typeof RollbarProxy !== 'undefined') {
3354
+ return _proxyRequest(data, callback);
3355
+ }
3356
+
3357
+ if (transport === 'fetch') {
3358
+ makeFetchRequest(accessToken, url, method, data, callback, timeout)
3359
+ } else {
3360
+ makeXhrRequest(accessToken, url, method, data, callback, requestFactory, timeout)
3329
3361
  }
3330
3362
  }
3331
3363
 
@@ -3341,11 +3373,66 @@ function _proxyRequest(json, callback) {
3341
3373
  );
3342
3374
  }
3343
3375
 
3344
- function _makeRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3345
- if (typeof RollbarProxy !== 'undefined') {
3346
- return _proxyRequest(data, callback);
3376
+ module.exports = Transport;
3377
+
3378
+
3379
+ /***/ }),
3380
+ /* 21 */
3381
+ /***/ (function(module, exports, __webpack_require__) {
3382
+
3383
+ "use strict";
3384
+
3385
+
3386
+ var logger = __webpack_require__(1);
3387
+ var _ = __webpack_require__(0);
3388
+
3389
+ function makeFetchRequest(accessToken, url, method, data, callback, timeout) {
3390
+ var controller;
3391
+ var timeoutId;
3392
+
3393
+ if(_.isFiniteNumber(timeout)) {
3394
+ controller = new AbortController();
3395
+ timeoutId = setTimeout(() => controller.abort(), timeout);
3347
3396
  }
3348
3397
 
3398
+ fetch(url, {
3399
+ method: method,
3400
+ headers: {
3401
+ 'Content-Type': 'application/json',
3402
+ 'X-Rollbar-Access-Token': accessToken,
3403
+ signal: controller && controller.signal
3404
+ },
3405
+ body: data,
3406
+ })
3407
+ .then((response) => {
3408
+ if (timeoutId) clearTimeout(timeoutId);
3409
+ return response.json();
3410
+ })
3411
+ .then((data) => {
3412
+ callback(null, data);
3413
+ })
3414
+ .catch((error) => {
3415
+ logger.error(error.message);
3416
+ callback(error);
3417
+ });
3418
+ }
3419
+
3420
+ module.exports = makeFetchRequest;
3421
+
3422
+
3423
+ /***/ }),
3424
+ /* 22 */
3425
+ /***/ (function(module, exports, __webpack_require__) {
3426
+
3427
+ "use strict";
3428
+
3429
+
3430
+ /*global XDomainRequest*/
3431
+
3432
+ var _ = __webpack_require__(0);
3433
+ var logger = __webpack_require__(1);
3434
+
3435
+ function makeXhrRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3349
3436
  var request;
3350
3437
  if (requestFactory) {
3351
3438
  request = requestFactory();
@@ -3498,11 +3585,11 @@ function _newRetriableError(message, code) {
3498
3585
  return err;
3499
3586
  }
3500
3587
 
3501
- module.exports = Transport;
3588
+ module.exports = makeXhrRequest;
3502
3589
 
3503
3590
 
3504
3591
  /***/ }),
3505
- /* 21 */
3592
+ /* 23 */
3506
3593
  /***/ (function(module, exports, __webpack_require__) {
3507
3594
 
3508
3595
  "use strict";
@@ -3849,7 +3936,7 @@ module.exports = {
3849
3936
 
3850
3937
 
3851
3938
  /***/ }),
3852
- /* 22 */
3939
+ /* 24 */
3853
3940
  /***/ (function(module, exports, __webpack_require__) {
3854
3941
 
3855
3942
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -3858,7 +3945,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3858
3945
 
3859
3946
  /* istanbul ignore next */
3860
3947
  if (true) {
3861
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(23)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3948
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(25)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3862
3949
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
3863
3950
  (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
3864
3951
  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
@@ -3909,21 +3996,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3909
3996
  return filtered.map(function(line) {
3910
3997
  if (line.indexOf('(eval ') > -1) {
3911
3998
  // Throw away eval information until we implement stacktrace.js/stackframe#8
3912
- line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
3999
+ line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(,.*$)/g, '');
3913
4000
  }
3914
- var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
4001
+ var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').replace(/^.*?\s+/, '');
3915
4002
 
3916
4003
  // capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in
3917
4004
  // case it has spaces in it, as the string is split on \s+ later on
3918
- var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
4005
+ var location = sanitizedLine.match(/ (\(.+\)$)/);
3919
4006
 
3920
4007
  // remove the parenthesized location from the line, if it was matched
3921
4008
  sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
3922
4009
 
3923
- var tokens = sanitizedLine.split(/\s+/).slice(1);
3924
- // if a location was matched, pass it to extractLocation() otherwise pop the last token
3925
- var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
3926
- var functionName = tokens.join(' ') || undefined;
4010
+ // if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine
4011
+ // because this line doesn't have function name
4012
+ var locationParts = this.extractLocation(location ? location[1] : sanitizedLine);
4013
+ var functionName = location && sanitizedLine || undefined;
3927
4014
  var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
3928
4015
 
3929
4016
  return new StackFrame({
@@ -4056,7 +4143,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4056
4143
 
4057
4144
 
4058
4145
  /***/ }),
4059
- /* 23 */
4146
+ /* 25 */
4060
4147
  /***/ (function(module, exports, __webpack_require__) {
4061
4148
 
4062
4149
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -4204,7 +4291,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4204
4291
 
4205
4292
 
4206
4293
  /***/ }),
4207
- /* 24 */
4294
+ /* 26 */
4208
4295
  /***/ (function(module, exports, __webpack_require__) {
4209
4296
 
4210
4297
  "use strict";
@@ -4361,7 +4448,7 @@ module.exports = {
4361
4448
 
4362
4449
 
4363
4450
  /***/ }),
4364
- /* 25 */
4451
+ /* 27 */
4365
4452
  /***/ (function(module, exports, __webpack_require__) {
4366
4453
 
4367
4454
  "use strict";
@@ -4382,7 +4469,7 @@ module.exports = {
4382
4469
 
4383
4470
 
4384
4471
  /***/ }),
4385
- /* 26 */
4472
+ /* 28 */
4386
4473
  /***/ (function(module, exports, __webpack_require__) {
4387
4474
 
4388
4475
  "use strict";
@@ -4584,14 +4671,14 @@ module.exports = {
4584
4671
 
4585
4672
 
4586
4673
  /***/ }),
4587
- /* 27 */
4674
+ /* 29 */
4588
4675
  /***/ (function(module, exports, __webpack_require__) {
4589
4676
 
4590
4677
  "use strict";
4591
4678
 
4592
4679
 
4593
4680
  module.exports = {
4594
- version: '2.25.2',
4681
+ version: '2.26.0',
4595
4682
  endpoint: 'api.rollbar.com/api/1/item/',
4596
4683
  logLevel: 'debug',
4597
4684
  reportLevel: 'debug',
@@ -4602,7 +4689,7 @@ module.exports = {
4602
4689
 
4603
4690
 
4604
4691
  /***/ }),
4605
- /* 28 */
4692
+ /* 30 */
4606
4693
  /***/ (function(module, exports, __webpack_require__) {
4607
4694
 
4608
4695
  "use strict";
@@ -4670,7 +4757,7 @@ module.exports = {
4670
4757
 
4671
4758
 
4672
4759
  /***/ }),
4673
- /* 29 */
4760
+ /* 31 */
4674
4761
  /***/ (function(module, exports, __webpack_require__) {
4675
4762
 
4676
4763
  "use strict";
@@ -4856,17 +4943,17 @@ module.exports = Telemeter;
4856
4943
 
4857
4944
 
4858
4945
  /***/ }),
4859
- /* 30 */
4946
+ /* 32 */
4860
4947
  /***/ (function(module, exports, __webpack_require__) {
4861
4948
 
4862
4949
  "use strict";
4863
4950
 
4864
4951
 
4865
4952
  var _ = __webpack_require__(0);
4866
- var headers = __webpack_require__(31);
4953
+ var headers = __webpack_require__(33);
4867
4954
  var scrub = __webpack_require__(4);
4868
4955
  var urlparser = __webpack_require__(2);
4869
- var domUtil = __webpack_require__(32);
4956
+ var domUtil = __webpack_require__(34);
4870
4957
 
4871
4958
  var defaults = {
4872
4959
  network: true,
@@ -5247,6 +5334,9 @@ Instrumenter.prototype.instrumentNetwork = function() {
5247
5334
  if (self.trackHttpErrors()) {
5248
5335
  metadata.stack = (new Error()).stack;
5249
5336
  }
5337
+
5338
+ // Start our handler before returning the promise. This allows resp.clone()
5339
+ // to execute before other handlers touch the response.
5250
5340
  return orig.apply(this, args).then(function (resp) {
5251
5341
  metadata.end_time_ms = _.now();
5252
5342
  metadata.status_code = resp.status;
@@ -5259,6 +5349,7 @@ Instrumenter.prototype.instrumentNetwork = function() {
5259
5349
  if (self.autoInstrument.networkResponseBody) {
5260
5350
  if (typeof resp.text === 'function') { // Response.text() is not implemented on some platforms
5261
5351
  // The response must be cloned to prevent reading (and locking) the original stream.
5352
+ // This must be done before other handlers touch the response.
5262
5353
  body = resp.clone().text(); //returns a Promise
5263
5354
  }
5264
5355
  }
@@ -5634,7 +5725,7 @@ module.exports = Instrumenter;
5634
5725
 
5635
5726
 
5636
5727
  /***/ }),
5637
- /* 31 */
5728
+ /* 33 */
5638
5729
  /***/ (function(module, exports, __webpack_require__) {
5639
5730
 
5640
5731
  "use strict";
@@ -5737,7 +5828,7 @@ module.exports = headers;
5737
5828
 
5738
5829
 
5739
5830
  /***/ }),
5740
- /* 32 */
5831
+ /* 34 */
5741
5832
  /***/ (function(module, exports, __webpack_require__) {
5742
5833
 
5743
5834
  "use strict";
@@ -5876,19 +5967,19 @@ module.exports = {
5876
5967
 
5877
5968
 
5878
5969
  /***/ }),
5879
- /* 33 */
5970
+ /* 35 */
5880
5971
  /***/ (function(module, exports, __webpack_require__) {
5881
5972
 
5882
5973
  "use strict";
5883
5974
 
5884
5975
 
5885
- var polyfillJSON = __webpack_require__(34);
5976
+ var polyfillJSON = __webpack_require__(36);
5886
5977
 
5887
5978
  module.exports = polyfillJSON;
5888
5979
 
5889
5980
 
5890
5981
  /***/ }),
5891
- /* 34 */
5982
+ /* 36 */
5892
5983
  /***/ (function(module, exports) {
5893
5984
 
5894
5985
  // json3.js
@@ -6657,7 +6748,7 @@ module.exports = setupCustomJSON;
6657
6748
 
6658
6749
 
6659
6750
  /***/ }),
6660
- /* 35 */
6751
+ /* 37 */
6661
6752
  /***/ (function(module, exports, __webpack_require__) {
6662
6753
 
6663
6754
  "use strict";
@@ -6707,7 +6798,7 @@ module.exports = wrapGlobals;
6707
6798
 
6708
6799
 
6709
6800
  /***/ }),
6710
- /* 36 */
6801
+ /* 38 */
6711
6802
  /***/ (function(module, exports, __webpack_require__) {
6712
6803
 
6713
6804
  "use strict";