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.
@@ -1018,7 +1018,7 @@ module.exports = {
1018
1018
  "use strict";
1019
1019
 
1020
1020
 
1021
- var ErrorStackParser = __webpack_require__(22);
1021
+ var ErrorStackParser = __webpack_require__(24);
1022
1022
 
1023
1023
  var UNKNOWN_FUNCTION = '?';
1024
1024
  var ERR_CLASS_REGEXP = new RegExp('^(([a-zA-Z0-9-_$ ]*): *)?(Uncaught )?([a-zA-Z0-9-_$ ]*): ');
@@ -1354,12 +1354,12 @@ module.exports = rollbar;
1354
1354
 
1355
1355
 
1356
1356
  var Rollbar = __webpack_require__(9);
1357
- var telemeter = __webpack_require__(29);
1358
- var instrumenter = __webpack_require__(30);
1359
- var polyfillJSON = __webpack_require__(33);
1360
- var wrapGlobals = __webpack_require__(35);
1357
+ var telemeter = __webpack_require__(31);
1358
+ var instrumenter = __webpack_require__(32);
1359
+ var polyfillJSON = __webpack_require__(35);
1360
+ var wrapGlobals = __webpack_require__(37);
1361
1361
  var scrub = __webpack_require__(4);
1362
- var truncation = __webpack_require__(36);
1362
+ var truncation = __webpack_require__(38);
1363
1363
 
1364
1364
  Rollbar.setComponents({
1365
1365
  telemeter: telemeter,
@@ -1389,10 +1389,10 @@ var globals = __webpack_require__(19);
1389
1389
  var Transport = __webpack_require__(20);
1390
1390
  var urllib = __webpack_require__(2);
1391
1391
 
1392
- var transforms = __webpack_require__(21);
1393
- var sharedTransforms = __webpack_require__(24);
1394
- var predicates = __webpack_require__(25);
1395
- var sharedPredicates = __webpack_require__(26);
1392
+ var transforms = __webpack_require__(23);
1393
+ var sharedTransforms = __webpack_require__(26);
1394
+ var predicates = __webpack_require__(27);
1395
+ var sharedPredicates = __webpack_require__(28);
1396
1396
  var errorParser = __webpack_require__(3);
1397
1397
 
1398
1398
  function Rollbar(options, client) {
@@ -1921,8 +1921,8 @@ function _gWindow() {
1921
1921
  return ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
1922
1922
  }
1923
1923
 
1924
- var defaults = __webpack_require__(27);
1925
- var scrubFields = __webpack_require__(28);
1924
+ var defaults = __webpack_require__(29);
1925
+ var scrubFields = __webpack_require__(30);
1926
1926
 
1927
1927
  var defaultOptions = {
1928
1928
  version: defaults.version,
@@ -2998,6 +2998,7 @@ function getTransportFromOptions(options, defaults, url) {
2998
2998
  var path = defaults.path;
2999
2999
  var search = defaults.search;
3000
3000
  var timeout = options.timeout;
3001
+ var transport = detectTransport(options)
3001
3002
 
3002
3003
  var proxy = options.proxy;
3003
3004
  if (options.endpoint) {
@@ -3015,16 +3016,26 @@ function getTransportFromOptions(options, defaults, url) {
3015
3016
  port: port,
3016
3017
  path: path,
3017
3018
  search: search,
3018
- proxy: proxy
3019
+ proxy: proxy,
3020
+ transport: transport
3019
3021
  };
3020
3022
  }
3021
3023
 
3024
+ function detectTransport(options) {
3025
+ var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3026
+ var transport = options.defaultTransport || 'xhr';
3027
+ if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
3028
+ if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
3029
+ return transport;
3030
+ }
3031
+
3022
3032
  function transportOptions(transport, method) {
3023
3033
  var protocol = transport.protocol || 'https:';
3024
3034
  var port = transport.port || (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
3025
3035
  var hostname = transport.hostname;
3026
3036
  var path = transport.path;
3027
3037
  var timeout = transport.timeout;
3038
+ var transportAPI = transport.transport;
3028
3039
  if (transport.search) {
3029
3040
  path = path + transport.search;
3030
3041
  }
@@ -3040,7 +3051,8 @@ function transportOptions(transport, method) {
3040
3051
  hostname: hostname,
3041
3052
  path: path,
3042
3053
  port: port,
3043
- method: method
3054
+ method: method,
3055
+ transport: transportAPI
3044
3056
  };
3045
3057
  }
3046
3058
 
@@ -3242,10 +3254,9 @@ module.exports = {
3242
3254
  "use strict";
3243
3255
 
3244
3256
 
3245
- /*global XDomainRequest*/
3246
-
3247
3257
  var _ = __webpack_require__(0);
3248
- var logger = __webpack_require__(1);
3258
+ var makeFetchRequest = __webpack_require__(21);
3259
+ var makeXhrRequest = __webpack_require__(22);
3249
3260
 
3250
3261
  /*
3251
3262
  * accessToken may be embedded in payload but that should not
@@ -3257,6 +3268,7 @@ var logger = __webpack_require__(1);
3257
3268
  * path
3258
3269
  * port
3259
3270
  * method
3271
+ * transport ('xhr' | 'fetch')
3260
3272
  * }
3261
3273
  *
3262
3274
  * params is an object containing key/value pairs. These
@@ -3276,7 +3288,9 @@ Transport.prototype.get = function(accessToken, options, params, callback, reque
3276
3288
 
3277
3289
  var method = 'GET';
3278
3290
  var url = _.formatUrl(options);
3279
- _makeZoneRequest(accessToken, url, method, null, callback, requestFactory, options.timeout);
3291
+ this._makeZoneRequest(
3292
+ accessToken, url, method, null, callback, requestFactory, options.timeout, options.transport
3293
+ );
3280
3294
  }
3281
3295
 
3282
3296
  Transport.prototype.post = function(accessToken, options, payload, callback, requestFactory) {
@@ -3301,7 +3315,9 @@ Transport.prototype.post = function(accessToken, options, payload, callback, req
3301
3315
  var writeData = stringifyResult.value;
3302
3316
  var method = 'POST';
3303
3317
  var url = _.formatUrl(options);
3304
- _makeZoneRequest(accessToken, url, method, writeData, callback, requestFactory, options.timeout);
3318
+ this._makeZoneRequest(
3319
+ accessToken, url, method, writeData, callback, requestFactory, options.timeout, options.transport
3320
+ );
3305
3321
  }
3306
3322
 
3307
3323
  Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayload, callback, requestFactory) {
@@ -3311,7 +3327,9 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3311
3327
 
3312
3328
  var method = 'POST';
3313
3329
  var url = _.formatUrl(options);
3314
- _makeZoneRequest(accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout);
3330
+ this._makeZoneRequest(
3331
+ accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout, options.transport
3332
+ );
3315
3333
  }
3316
3334
 
3317
3335
 
@@ -3319,7 +3337,7 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3319
3337
  // so Angular change detection isn't triggered on each API call.
3320
3338
  // This is the equivalent of runOutsideAngular().
3321
3339
  //
3322
- function _makeZoneRequest() {
3340
+ Transport.prototype._makeZoneRequest = function () {
3323
3341
  var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3324
3342
  var currentZone = gWindow && gWindow.Zone && gWindow.Zone.current;
3325
3343
  var args = Array.prototype.slice.call(arguments);
@@ -3327,10 +3345,24 @@ function _makeZoneRequest() {
3327
3345
  if (currentZone && currentZone._name === 'angular') {
3328
3346
  var rootZone = currentZone._parent;
3329
3347
  rootZone.run(function () {
3330
- _makeRequest.apply(undefined, args);
3348
+ this._makeRequest.apply(undefined, args);
3331
3349
  });
3332
3350
  } else {
3333
- _makeRequest.apply(undefined, args);
3351
+ this._makeRequest.apply(undefined, args);
3352
+ }
3353
+ }
3354
+
3355
+ Transport.prototype._makeRequest = function (
3356
+ accessToken, url, method, data, callback, requestFactory, timeout, transport
3357
+ ) {
3358
+ if (typeof RollbarProxy !== 'undefined') {
3359
+ return _proxyRequest(data, callback);
3360
+ }
3361
+
3362
+ if (transport === 'fetch') {
3363
+ makeFetchRequest(accessToken, url, method, data, callback, timeout)
3364
+ } else {
3365
+ makeXhrRequest(accessToken, url, method, data, callback, requestFactory, timeout)
3334
3366
  }
3335
3367
  }
3336
3368
 
@@ -3346,11 +3378,66 @@ function _proxyRequest(json, callback) {
3346
3378
  );
3347
3379
  }
3348
3380
 
3349
- function _makeRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3350
- if (typeof RollbarProxy !== 'undefined') {
3351
- return _proxyRequest(data, callback);
3381
+ module.exports = Transport;
3382
+
3383
+
3384
+ /***/ }),
3385
+ /* 21 */
3386
+ /***/ (function(module, exports, __webpack_require__) {
3387
+
3388
+ "use strict";
3389
+
3390
+
3391
+ var logger = __webpack_require__(1);
3392
+ var _ = __webpack_require__(0);
3393
+
3394
+ function makeFetchRequest(accessToken, url, method, data, callback, timeout) {
3395
+ var controller;
3396
+ var timeoutId;
3397
+
3398
+ if(_.isFiniteNumber(timeout)) {
3399
+ controller = new AbortController();
3400
+ timeoutId = setTimeout(() => controller.abort(), timeout);
3352
3401
  }
3353
3402
 
3403
+ fetch(url, {
3404
+ method: method,
3405
+ headers: {
3406
+ 'Content-Type': 'application/json',
3407
+ 'X-Rollbar-Access-Token': accessToken,
3408
+ signal: controller && controller.signal
3409
+ },
3410
+ body: data,
3411
+ })
3412
+ .then((response) => {
3413
+ if (timeoutId) clearTimeout(timeoutId);
3414
+ return response.json();
3415
+ })
3416
+ .then((data) => {
3417
+ callback(null, data);
3418
+ })
3419
+ .catch((error) => {
3420
+ logger.error(error.message);
3421
+ callback(error);
3422
+ });
3423
+ }
3424
+
3425
+ module.exports = makeFetchRequest;
3426
+
3427
+
3428
+ /***/ }),
3429
+ /* 22 */
3430
+ /***/ (function(module, exports, __webpack_require__) {
3431
+
3432
+ "use strict";
3433
+
3434
+
3435
+ /*global XDomainRequest*/
3436
+
3437
+ var _ = __webpack_require__(0);
3438
+ var logger = __webpack_require__(1);
3439
+
3440
+ function makeXhrRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3354
3441
  var request;
3355
3442
  if (requestFactory) {
3356
3443
  request = requestFactory();
@@ -3503,11 +3590,11 @@ function _newRetriableError(message, code) {
3503
3590
  return err;
3504
3591
  }
3505
3592
 
3506
- module.exports = Transport;
3593
+ module.exports = makeXhrRequest;
3507
3594
 
3508
3595
 
3509
3596
  /***/ }),
3510
- /* 21 */
3597
+ /* 23 */
3511
3598
  /***/ (function(module, exports, __webpack_require__) {
3512
3599
 
3513
3600
  "use strict";
@@ -3854,7 +3941,7 @@ module.exports = {
3854
3941
 
3855
3942
 
3856
3943
  /***/ }),
3857
- /* 22 */
3944
+ /* 24 */
3858
3945
  /***/ (function(module, exports, __webpack_require__) {
3859
3946
 
3860
3947
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -3863,7 +3950,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3863
3950
 
3864
3951
  /* istanbul ignore next */
3865
3952
  if (true) {
3866
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(23)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3953
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(25)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3867
3954
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
3868
3955
  (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
3869
3956
  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
@@ -3914,21 +4001,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3914
4001
  return filtered.map(function(line) {
3915
4002
  if (line.indexOf('(eval ') > -1) {
3916
4003
  // Throw away eval information until we implement stacktrace.js/stackframe#8
3917
- line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
4004
+ line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(,.*$)/g, '');
3918
4005
  }
3919
- var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
4006
+ var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').replace(/^.*?\s+/, '');
3920
4007
 
3921
4008
  // capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in
3922
4009
  // case it has spaces in it, as the string is split on \s+ later on
3923
- var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
4010
+ var location = sanitizedLine.match(/ (\(.+\)$)/);
3924
4011
 
3925
4012
  // remove the parenthesized location from the line, if it was matched
3926
4013
  sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
3927
4014
 
3928
- var tokens = sanitizedLine.split(/\s+/).slice(1);
3929
- // if a location was matched, pass it to extractLocation() otherwise pop the last token
3930
- var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
3931
- var functionName = tokens.join(' ') || undefined;
4015
+ // if a location was matched, pass it to extractLocation() otherwise pass all sanitizedLine
4016
+ // because this line doesn't have function name
4017
+ var locationParts = this.extractLocation(location ? location[1] : sanitizedLine);
4018
+ var functionName = location && sanitizedLine || undefined;
3932
4019
  var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
3933
4020
 
3934
4021
  return new StackFrame({
@@ -4061,7 +4148,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4061
4148
 
4062
4149
 
4063
4150
  /***/ }),
4064
- /* 23 */
4151
+ /* 25 */
4065
4152
  /***/ (function(module, exports, __webpack_require__) {
4066
4153
 
4067
4154
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -4209,7 +4296,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4209
4296
 
4210
4297
 
4211
4298
  /***/ }),
4212
- /* 24 */
4299
+ /* 26 */
4213
4300
  /***/ (function(module, exports, __webpack_require__) {
4214
4301
 
4215
4302
  "use strict";
@@ -4366,7 +4453,7 @@ module.exports = {
4366
4453
 
4367
4454
 
4368
4455
  /***/ }),
4369
- /* 25 */
4456
+ /* 27 */
4370
4457
  /***/ (function(module, exports, __webpack_require__) {
4371
4458
 
4372
4459
  "use strict";
@@ -4387,7 +4474,7 @@ module.exports = {
4387
4474
 
4388
4475
 
4389
4476
  /***/ }),
4390
- /* 26 */
4477
+ /* 28 */
4391
4478
  /***/ (function(module, exports, __webpack_require__) {
4392
4479
 
4393
4480
  "use strict";
@@ -4589,14 +4676,14 @@ module.exports = {
4589
4676
 
4590
4677
 
4591
4678
  /***/ }),
4592
- /* 27 */
4679
+ /* 29 */
4593
4680
  /***/ (function(module, exports, __webpack_require__) {
4594
4681
 
4595
4682
  "use strict";
4596
4683
 
4597
4684
 
4598
4685
  module.exports = {
4599
- version: '2.25.2',
4686
+ version: '2.26.0',
4600
4687
  endpoint: 'api.rollbar.com/api/1/item/',
4601
4688
  logLevel: 'debug',
4602
4689
  reportLevel: 'debug',
@@ -4607,7 +4694,7 @@ module.exports = {
4607
4694
 
4608
4695
 
4609
4696
  /***/ }),
4610
- /* 28 */
4697
+ /* 30 */
4611
4698
  /***/ (function(module, exports, __webpack_require__) {
4612
4699
 
4613
4700
  "use strict";
@@ -4675,7 +4762,7 @@ module.exports = {
4675
4762
 
4676
4763
 
4677
4764
  /***/ }),
4678
- /* 29 */
4765
+ /* 31 */
4679
4766
  /***/ (function(module, exports, __webpack_require__) {
4680
4767
 
4681
4768
  "use strict";
@@ -4861,17 +4948,17 @@ module.exports = Telemeter;
4861
4948
 
4862
4949
 
4863
4950
  /***/ }),
4864
- /* 30 */
4951
+ /* 32 */
4865
4952
  /***/ (function(module, exports, __webpack_require__) {
4866
4953
 
4867
4954
  "use strict";
4868
4955
 
4869
4956
 
4870
4957
  var _ = __webpack_require__(0);
4871
- var headers = __webpack_require__(31);
4958
+ var headers = __webpack_require__(33);
4872
4959
  var scrub = __webpack_require__(4);
4873
4960
  var urlparser = __webpack_require__(2);
4874
- var domUtil = __webpack_require__(32);
4961
+ var domUtil = __webpack_require__(34);
4875
4962
 
4876
4963
  var defaults = {
4877
4964
  network: true,
@@ -5252,6 +5339,9 @@ Instrumenter.prototype.instrumentNetwork = function() {
5252
5339
  if (self.trackHttpErrors()) {
5253
5340
  metadata.stack = (new Error()).stack;
5254
5341
  }
5342
+
5343
+ // Start our handler before returning the promise. This allows resp.clone()
5344
+ // to execute before other handlers touch the response.
5255
5345
  return orig.apply(this, args).then(function (resp) {
5256
5346
  metadata.end_time_ms = _.now();
5257
5347
  metadata.status_code = resp.status;
@@ -5264,6 +5354,7 @@ Instrumenter.prototype.instrumentNetwork = function() {
5264
5354
  if (self.autoInstrument.networkResponseBody) {
5265
5355
  if (typeof resp.text === 'function') { // Response.text() is not implemented on some platforms
5266
5356
  // The response must be cloned to prevent reading (and locking) the original stream.
5357
+ // This must be done before other handlers touch the response.
5267
5358
  body = resp.clone().text(); //returns a Promise
5268
5359
  }
5269
5360
  }
@@ -5639,7 +5730,7 @@ module.exports = Instrumenter;
5639
5730
 
5640
5731
 
5641
5732
  /***/ }),
5642
- /* 31 */
5733
+ /* 33 */
5643
5734
  /***/ (function(module, exports, __webpack_require__) {
5644
5735
 
5645
5736
  "use strict";
@@ -5742,7 +5833,7 @@ module.exports = headers;
5742
5833
 
5743
5834
 
5744
5835
  /***/ }),
5745
- /* 32 */
5836
+ /* 34 */
5746
5837
  /***/ (function(module, exports, __webpack_require__) {
5747
5838
 
5748
5839
  "use strict";
@@ -5881,19 +5972,19 @@ module.exports = {
5881
5972
 
5882
5973
 
5883
5974
  /***/ }),
5884
- /* 33 */
5975
+ /* 35 */
5885
5976
  /***/ (function(module, exports, __webpack_require__) {
5886
5977
 
5887
5978
  "use strict";
5888
5979
 
5889
5980
 
5890
- var polyfillJSON = __webpack_require__(34);
5981
+ var polyfillJSON = __webpack_require__(36);
5891
5982
 
5892
5983
  module.exports = polyfillJSON;
5893
5984
 
5894
5985
 
5895
5986
  /***/ }),
5896
- /* 34 */
5987
+ /* 36 */
5897
5988
  /***/ (function(module, exports) {
5898
5989
 
5899
5990
  // json3.js
@@ -6662,7 +6753,7 @@ module.exports = setupCustomJSON;
6662
6753
 
6663
6754
 
6664
6755
  /***/ }),
6665
- /* 35 */
6756
+ /* 37 */
6666
6757
  /***/ (function(module, exports, __webpack_require__) {
6667
6758
 
6668
6759
  "use strict";
@@ -6712,7 +6803,7 @@ module.exports = wrapGlobals;
6712
6803
 
6713
6804
 
6714
6805
  /***/ }),
6715
- /* 36 */
6806
+ /* 38 */
6716
6807
  /***/ (function(module, exports, __webpack_require__) {
6717
6808
 
6718
6809
  "use strict";