rollbar 2.25.2 → 2.26.1

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/README.md CHANGED
@@ -1,11 +1,27 @@
1
- # Rollbar.js
1
+ <p align="center">
2
+ <img alt="rollbar-logo" src="https://user-images.githubusercontent.com/3300063/207964480-54eda665-d6fe-4527-ba51-b0ab3f41f10b.png" />
3
+ </p>
2
4
 
5
+ <h1 align="center">Rollbar.js</h1>
6
+
7
+ <p align="center">
8
+ <strong>Proactively discover, predict, and resolve errors in real-time with <a href="https://rollbar.com">Rollbar’s</a> error monitoring platform. <a href="https://rollbar.com/signup/">Start tracking errors today</a>!</strong>
9
+ </p>
3
10
 
4
11
  ![Build Status](https://github.com/rollbar/rollbar.js/workflows/Rollbar.js%20CI/badge.svg?tag=latest)
5
12
  [![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/context:javascript)
6
13
  [![Total Alerts](https://img.shields.io/lgtm/alerts/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/alerts)
7
14
 
8
- Rollbar.js is the Javascript SDK for [Rollbar](https://rollbar.com). It supports both Node.js and client-side Javascript, including frameworks such as React, Angular, Ember, and more.
15
+
16
+ ---
17
+
18
+ ## Key benefits of using Rollbar.js are:
19
+ - **Cross platform:** Rollbar.js supports both server-side and client-side Javascript, including frameworks such as <a href="https://docs.rollbar.com/docs/react-ts">React</a>, <a href="https://docs.rollbar.com/docs/angular">Angular</a>, <a href="https://docs.rollbar.com/docs/nodejs#using-express">Express</a>, <a href="https://docs.rollbar.com/docs/nextjs">Next.js</a> and more.
20
+ - **Telemetry:** The telemetry timeline provides a list of “breadcrumbs” events that can help developers understand and fix problems in their client-side javascript. <a href="https://docs.rollbar.com/docs/rollbarjs-telemetry">Learn more about telemetry</a>.
21
+ - **Automatic error grouping:** Rollbar aggregates Occurrences caused by the same error into Items that represent application issues. <a href="https://docs.rollbar.com/docs/grouping-occurrences">Learn more about reducing log noise</a>.
22
+ - **Advanced search:** Filter items by many different properties. <a href="https://docs.rollbar.com/docs/search-items">Learn more about search</a>.
23
+ - **Customizable notifications:** Rollbar supports several messaging and incident management tools where your team can get notified about errors and important events by real-time alerts. <a href="https://docs.rollbar.com/docs/notifications">Learn more about Rollbar notifications</a>.
24
+
9
25
 
10
26
  ## Setup Instructions
11
27
 
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) {
@@ -1877,6 +1877,7 @@ function addTransformsToNotifier(notifier, rollbar, gWindow) {
1877
1877
  .addTransform(sharedTransforms.addTelemetryData)
1878
1878
  .addTransform(sharedTransforms.addConfigToPayload)
1879
1879
  .addTransform(transforms.addScrubber(rollbar.scrub))
1880
+ .addTransform(sharedTransforms.addPayloadOptions)
1880
1881
  .addTransform(sharedTransforms.userTransform(logger))
1881
1882
  .addTransform(sharedTransforms.addConfiguredOptions)
1882
1883
  .addTransform(sharedTransforms.addDiagnosticKeys)
@@ -1914,8 +1915,8 @@ function _gWindow() {
1914
1915
  return ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
1915
1916
  }
1916
1917
 
1917
- var defaults = __webpack_require__(26);
1918
- var scrubFields = __webpack_require__(27);
1918
+ var defaults = __webpack_require__(28);
1919
+ var scrubFields = __webpack_require__(29);
1919
1920
 
1920
1921
  var defaultOptions = {
1921
1922
  version: defaults.version,
@@ -2991,6 +2992,7 @@ function getTransportFromOptions(options, defaults, url) {
2991
2992
  var path = defaults.path;
2992
2993
  var search = defaults.search;
2993
2994
  var timeout = options.timeout;
2995
+ var transport = detectTransport(options)
2994
2996
 
2995
2997
  var proxy = options.proxy;
2996
2998
  if (options.endpoint) {
@@ -3008,16 +3010,26 @@ function getTransportFromOptions(options, defaults, url) {
3008
3010
  port: port,
3009
3011
  path: path,
3010
3012
  search: search,
3011
- proxy: proxy
3013
+ proxy: proxy,
3014
+ transport: transport
3012
3015
  };
3013
3016
  }
3014
3017
 
3018
+ function detectTransport(options) {
3019
+ var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3020
+ var transport = options.defaultTransport || 'xhr';
3021
+ if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
3022
+ if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
3023
+ return transport;
3024
+ }
3025
+
3015
3026
  function transportOptions(transport, method) {
3016
3027
  var protocol = transport.protocol || 'https:';
3017
3028
  var port = transport.port || (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
3018
3029
  var hostname = transport.hostname;
3019
3030
  var path = transport.path;
3020
3031
  var timeout = transport.timeout;
3032
+ var transportAPI = transport.transport;
3021
3033
  if (transport.search) {
3022
3034
  path = path + transport.search;
3023
3035
  }
@@ -3033,7 +3045,8 @@ function transportOptions(transport, method) {
3033
3045
  hostname: hostname,
3034
3046
  path: path,
3035
3047
  port: port,
3036
- method: method
3048
+ method: method,
3049
+ transport: transportAPI
3037
3050
  };
3038
3051
  }
3039
3052
 
@@ -3235,10 +3248,9 @@ module.exports = {
3235
3248
  "use strict";
3236
3249
 
3237
3250
 
3238
- /*global XDomainRequest*/
3239
-
3240
3251
  var _ = __webpack_require__(0);
3241
- var logger = __webpack_require__(1);
3252
+ var makeFetchRequest = __webpack_require__(20);
3253
+ var makeXhrRequest = __webpack_require__(21);
3242
3254
 
3243
3255
  /*
3244
3256
  * accessToken may be embedded in payload but that should not
@@ -3250,6 +3262,7 @@ var logger = __webpack_require__(1);
3250
3262
  * path
3251
3263
  * port
3252
3264
  * method
3265
+ * transport ('xhr' | 'fetch')
3253
3266
  * }
3254
3267
  *
3255
3268
  * params is an object containing key/value pairs. These
@@ -3269,7 +3282,9 @@ Transport.prototype.get = function(accessToken, options, params, callback, reque
3269
3282
 
3270
3283
  var method = 'GET';
3271
3284
  var url = _.formatUrl(options);
3272
- _makeZoneRequest(accessToken, url, method, null, callback, requestFactory, options.timeout);
3285
+ this._makeZoneRequest(
3286
+ accessToken, url, method, null, callback, requestFactory, options.timeout, options.transport
3287
+ );
3273
3288
  }
3274
3289
 
3275
3290
  Transport.prototype.post = function(accessToken, options, payload, callback, requestFactory) {
@@ -3294,7 +3309,9 @@ Transport.prototype.post = function(accessToken, options, payload, callback, req
3294
3309
  var writeData = stringifyResult.value;
3295
3310
  var method = 'POST';
3296
3311
  var url = _.formatUrl(options);
3297
- _makeZoneRequest(accessToken, url, method, writeData, callback, requestFactory, options.timeout);
3312
+ this._makeZoneRequest(
3313
+ accessToken, url, method, writeData, callback, requestFactory, options.timeout, options.transport
3314
+ );
3298
3315
  }
3299
3316
 
3300
3317
  Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayload, callback, requestFactory) {
@@ -3304,7 +3321,9 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3304
3321
 
3305
3322
  var method = 'POST';
3306
3323
  var url = _.formatUrl(options);
3307
- _makeZoneRequest(accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout);
3324
+ this._makeZoneRequest(
3325
+ accessToken, url, method, jsonPayload, callback, requestFactory, options.timeout, options.transport
3326
+ );
3308
3327
  }
3309
3328
 
3310
3329
 
@@ -3312,18 +3331,33 @@ Transport.prototype.postJsonPayload = function (accessToken, options, jsonPayloa
3312
3331
  // so Angular change detection isn't triggered on each API call.
3313
3332
  // This is the equivalent of runOutsideAngular().
3314
3333
  //
3315
- function _makeZoneRequest() {
3334
+ Transport.prototype._makeZoneRequest = function () {
3316
3335
  var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
3317
3336
  var currentZone = gWindow && gWindow.Zone && gWindow.Zone.current;
3318
3337
  var args = Array.prototype.slice.call(arguments);
3319
3338
 
3320
3339
  if (currentZone && currentZone._name === 'angular') {
3321
3340
  var rootZone = currentZone._parent;
3341
+ var self = this;
3322
3342
  rootZone.run(function () {
3323
- _makeRequest.apply(undefined, args);
3343
+ self._makeRequest.apply(undefined, args);
3324
3344
  });
3325
3345
  } else {
3326
- _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)
3327
3361
  }
3328
3362
  }
3329
3363
 
@@ -3339,11 +3373,66 @@ function _proxyRequest(json, callback) {
3339
3373
  );
3340
3374
  }
3341
3375
 
3342
- function _makeRequest(accessToken, url, method, data, callback, requestFactory, timeout) {
3343
- if (typeof RollbarProxy !== 'undefined') {
3344
- return _proxyRequest(data, callback);
3376
+ module.exports = Transport;
3377
+
3378
+
3379
+ /***/ }),
3380
+ /* 20 */
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(function () {controller.abort()}, timeout);
3345
3396
  }
3346
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(function (response) {
3408
+ if (timeoutId) clearTimeout(timeoutId);
3409
+ return response.json();
3410
+ })
3411
+ .then(function (data) {
3412
+ callback(null, data);
3413
+ })
3414
+ .catch(function (error) {
3415
+ logger.error(error.message);
3416
+ callback(error);
3417
+ });
3418
+ }
3419
+
3420
+ module.exports = makeFetchRequest;
3421
+
3422
+
3423
+ /***/ }),
3424
+ /* 21 */
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) {
3347
3436
  var request;
3348
3437
  if (requestFactory) {
3349
3438
  request = requestFactory();
@@ -3496,11 +3585,11 @@ function _newRetriableError(message, code) {
3496
3585
  return err;
3497
3586
  }
3498
3587
 
3499
- module.exports = Transport;
3588
+ module.exports = makeXhrRequest;
3500
3589
 
3501
3590
 
3502
3591
  /***/ }),
3503
- /* 20 */
3592
+ /* 22 */
3504
3593
  /***/ (function(module, exports, __webpack_require__) {
3505
3594
 
3506
3595
  "use strict";
@@ -3847,7 +3936,7 @@ module.exports = {
3847
3936
 
3848
3937
 
3849
3938
  /***/ }),
3850
- /* 21 */
3939
+ /* 23 */
3851
3940
  /***/ (function(module, exports, __webpack_require__) {
3852
3941
 
3853
3942
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -3856,7 +3945,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3856
3945
 
3857
3946
  /* istanbul ignore next */
3858
3947
  if (true) {
3859
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(22)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3948
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(24)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
3860
3949
  __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
3861
3950
  (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
3862
3951
  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
@@ -3907,21 +3996,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
3907
3996
  return filtered.map(function(line) {
3908
3997
  if (line.indexOf('(eval ') > -1) {
3909
3998
  // Throw away eval information until we implement stacktrace.js/stackframe#8
3910
- line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
3999
+ line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^()]*)|(,.*$)/g, '');
3911
4000
  }
3912
- var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
4001
+ var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').replace(/^.*?\s+/, '');
3913
4002
 
3914
4003
  // capture and preseve the parenthesized location "(/foo/my bar.js:12:87)" in
3915
4004
  // case it has spaces in it, as the string is split on \s+ later on
3916
- var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
4005
+ var location = sanitizedLine.match(/ (\(.+\)$)/);
3917
4006
 
3918
4007
  // remove the parenthesized location from the line, if it was matched
3919
4008
  sanitizedLine = location ? sanitizedLine.replace(location[0], '') : sanitizedLine;
3920
4009
 
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;
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;
3925
4014
  var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
3926
4015
 
3927
4016
  return new StackFrame({
@@ -4054,7 +4143,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4054
4143
 
4055
4144
 
4056
4145
  /***/ }),
4057
- /* 22 */
4146
+ /* 24 */
4058
4147
  /***/ (function(module, exports, __webpack_require__) {
4059
4148
 
4060
4149
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(root, factory) {
@@ -4202,7 +4291,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4202
4291
 
4203
4292
 
4204
4293
  /***/ }),
4205
- /* 23 */
4294
+ /* 25 */
4206
4295
  /***/ (function(module, exports, __webpack_require__) {
4207
4296
 
4208
4297
  "use strict";
@@ -4211,12 +4300,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
4211
4300
  var _ = __webpack_require__(0);
4212
4301
 
4213
4302
  function itemToPayload(item, options, callback) {
4214
- var payloadOptions = options.payload || {};
4215
- if (payloadOptions.body) {
4216
- delete payloadOptions.body;
4217
- }
4303
+ var data = item.data;
4218
4304
 
4219
- var data = _.merge(item.data, payloadOptions);
4220
4305
  if (item._isUncaught) {
4221
4306
  data._isUncaught = true;
4222
4307
  }
@@ -4226,6 +4311,16 @@ function itemToPayload(item, options, callback) {
4226
4311
  callback(null, data);
4227
4312
  }
4228
4313
 
4314
+ function addPayloadOptions(item, options, callback) {
4315
+ var payloadOptions = options.payload || {};
4316
+ if (payloadOptions.body) {
4317
+ delete payloadOptions.body;
4318
+ }
4319
+
4320
+ item.data = _.merge(item.data, payloadOptions);
4321
+ callback(null, item);
4322
+ }
4323
+
4229
4324
  function addTelemetryData(item, options, callback) {
4230
4325
  if (item.telemetryEvents) {
4231
4326
  _.set(item, 'data.body.telemetry', item.telemetryEvents);
@@ -4349,6 +4444,7 @@ function addDiagnosticKeys(item, options, callback) {
4349
4444
 
4350
4445
  module.exports = {
4351
4446
  itemToPayload: itemToPayload,
4447
+ addPayloadOptions: addPayloadOptions,
4352
4448
  addTelemetryData: addTelemetryData,
4353
4449
  addMessageWithError: addMessageWithError,
4354
4450
  userTransform: userTransform,
@@ -4359,7 +4455,7 @@ module.exports = {
4359
4455
 
4360
4456
 
4361
4457
  /***/ }),
4362
- /* 24 */
4458
+ /* 26 */
4363
4459
  /***/ (function(module, exports, __webpack_require__) {
4364
4460
 
4365
4461
  "use strict";
@@ -4380,7 +4476,7 @@ module.exports = {
4380
4476
 
4381
4477
 
4382
4478
  /***/ }),
4383
- /* 25 */
4479
+ /* 27 */
4384
4480
  /***/ (function(module, exports, __webpack_require__) {
4385
4481
 
4386
4482
  "use strict";
@@ -4582,14 +4678,14 @@ module.exports = {
4582
4678
 
4583
4679
 
4584
4680
  /***/ }),
4585
- /* 26 */
4681
+ /* 28 */
4586
4682
  /***/ (function(module, exports, __webpack_require__) {
4587
4683
 
4588
4684
  "use strict";
4589
4685
 
4590
4686
 
4591
4687
  module.exports = {
4592
- version: '2.25.2',
4688
+ version: '2.26.1',
4593
4689
  endpoint: 'api.rollbar.com/api/1/item/',
4594
4690
  logLevel: 'debug',
4595
4691
  reportLevel: 'debug',
@@ -4600,7 +4696,7 @@ module.exports = {
4600
4696
 
4601
4697
 
4602
4698
  /***/ }),
4603
- /* 27 */
4699
+ /* 29 */
4604
4700
  /***/ (function(module, exports, __webpack_require__) {
4605
4701
 
4606
4702
  "use strict";
@@ -4668,7 +4764,7 @@ module.exports = {
4668
4764
 
4669
4765
 
4670
4766
  /***/ }),
4671
- /* 28 */
4767
+ /* 30 */
4672
4768
  /***/ (function(module, exports, __webpack_require__) {
4673
4769
 
4674
4770
  "use strict";
@@ -4854,17 +4950,17 @@ module.exports = Telemeter;
4854
4950
 
4855
4951
 
4856
4952
  /***/ }),
4857
- /* 29 */
4953
+ /* 31 */
4858
4954
  /***/ (function(module, exports, __webpack_require__) {
4859
4955
 
4860
4956
  "use strict";
4861
4957
 
4862
4958
 
4863
4959
  var _ = __webpack_require__(0);
4864
- var headers = __webpack_require__(30);
4960
+ var headers = __webpack_require__(32);
4865
4961
  var scrub = __webpack_require__(4);
4866
4962
  var urlparser = __webpack_require__(2);
4867
- var domUtil = __webpack_require__(31);
4963
+ var domUtil = __webpack_require__(33);
4868
4964
 
4869
4965
  var defaults = {
4870
4966
  network: true,
@@ -5245,6 +5341,9 @@ Instrumenter.prototype.instrumentNetwork = function() {
5245
5341
  if (self.trackHttpErrors()) {
5246
5342
  metadata.stack = (new Error()).stack;
5247
5343
  }
5344
+
5345
+ // Start our handler before returning the promise. This allows resp.clone()
5346
+ // to execute before other handlers touch the response.
5248
5347
  return orig.apply(this, args).then(function (resp) {
5249
5348
  metadata.end_time_ms = _.now();
5250
5349
  metadata.status_code = resp.status;
@@ -5257,6 +5356,7 @@ Instrumenter.prototype.instrumentNetwork = function() {
5257
5356
  if (self.autoInstrument.networkResponseBody) {
5258
5357
  if (typeof resp.text === 'function') { // Response.text() is not implemented on some platforms
5259
5358
  // The response must be cloned to prevent reading (and locking) the original stream.
5359
+ // This must be done before other handlers touch the response.
5260
5360
  body = resp.clone().text(); //returns a Promise
5261
5361
  }
5262
5362
  }
@@ -5632,7 +5732,7 @@ module.exports = Instrumenter;
5632
5732
 
5633
5733
 
5634
5734
  /***/ }),
5635
- /* 30 */
5735
+ /* 32 */
5636
5736
  /***/ (function(module, exports, __webpack_require__) {
5637
5737
 
5638
5738
  "use strict";
@@ -5735,7 +5835,7 @@ module.exports = headers;
5735
5835
 
5736
5836
 
5737
5837
  /***/ }),
5738
- /* 31 */
5838
+ /* 33 */
5739
5839
  /***/ (function(module, exports, __webpack_require__) {
5740
5840
 
5741
5841
  "use strict";
@@ -5874,19 +5974,19 @@ module.exports = {
5874
5974
 
5875
5975
 
5876
5976
  /***/ }),
5877
- /* 32 */
5977
+ /* 34 */
5878
5978
  /***/ (function(module, exports, __webpack_require__) {
5879
5979
 
5880
5980
  "use strict";
5881
5981
 
5882
5982
 
5883
- var polyfillJSON = __webpack_require__(33);
5983
+ var polyfillJSON = __webpack_require__(35);
5884
5984
 
5885
5985
  module.exports = polyfillJSON;
5886
5986
 
5887
5987
 
5888
5988
  /***/ }),
5889
- /* 33 */
5989
+ /* 35 */
5890
5990
  /***/ (function(module, exports) {
5891
5991
 
5892
5992
  // json3.js
@@ -6655,7 +6755,7 @@ module.exports = setupCustomJSON;
6655
6755
 
6656
6756
 
6657
6757
  /***/ }),
6658
- /* 34 */
6758
+ /* 36 */
6659
6759
  /***/ (function(module, exports, __webpack_require__) {
6660
6760
 
6661
6761
  "use strict";
@@ -6705,7 +6805,7 @@ module.exports = wrapGlobals;
6705
6805
 
6706
6806
 
6707
6807
  /***/ }),
6708
- /* 35 */
6808
+ /* 37 */
6709
6809
  /***/ (function(module, exports, __webpack_require__) {
6710
6810
 
6711
6811
  "use strict";