rollbar 2.26.2 → 2.26.4

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.
Files changed (117) hide show
  1. package/.github/workflows/ci.yml +32 -10
  2. package/.lgtm.yml +7 -7
  3. package/.prettierignore +18 -0
  4. package/.vscode/settings.json +39 -0
  5. package/CHANGELOG.md +121 -35
  6. package/Gruntfile.js +51 -71
  7. package/README.md +2 -4
  8. package/bower.json +1 -3
  9. package/defaults.js +17 -5
  10. package/dist/plugins/jquery.min.js +1 -1
  11. package/dist/rollbar.js +5699 -5052
  12. package/dist/rollbar.js.map +1 -1
  13. package/dist/rollbar.min.js +1 -1
  14. package/dist/rollbar.min.js.map +1 -1
  15. package/dist/rollbar.named-amd.js +5704 -5062
  16. package/dist/rollbar.named-amd.js.map +1 -1
  17. package/dist/rollbar.named-amd.min.js +1 -1
  18. package/dist/rollbar.named-amd.min.js.map +1 -1
  19. package/dist/rollbar.noconflict.umd.js +5693 -5052
  20. package/dist/rollbar.noconflict.umd.js.map +1 -1
  21. package/dist/rollbar.noconflict.umd.min.js +1 -1
  22. package/dist/rollbar.noconflict.umd.min.js.map +1 -1
  23. package/dist/rollbar.snippet.js +1 -1
  24. package/dist/rollbar.umd.js +5704 -5063
  25. package/dist/rollbar.umd.js.map +1 -1
  26. package/dist/rollbar.umd.min.js +1 -1
  27. package/dist/rollbar.umd.min.js.map +1 -1
  28. package/docs/extension-exceptions.md +35 -30
  29. package/docs/migration_v0_to_v1.md +41 -38
  30. package/index.d.ts +270 -231
  31. package/karma.conf.js +16 -34
  32. package/package.json +21 -17
  33. package/prettier.config.js +7 -0
  34. package/src/api.js +21 -10
  35. package/src/apiUtility.js +12 -8
  36. package/src/browser/core.js +103 -65
  37. package/src/browser/defaults/scrubFields.js +3 -3
  38. package/src/browser/detection.js +7 -8
  39. package/src/browser/domUtility.js +18 -8
  40. package/src/browser/globalSetup.js +12 -6
  41. package/src/browser/logger.js +1 -1
  42. package/src/browser/plugins/jquery.js +35 -35
  43. package/src/browser/predicates.js +1 -1
  44. package/src/browser/rollbar.js +1 -1
  45. package/src/browser/rollbarWrapper.js +8 -5
  46. package/src/browser/shim.js +43 -19
  47. package/src/browser/snippet_callback.js +6 -4
  48. package/src/browser/telemetry.js +573 -354
  49. package/src/browser/transforms.js +46 -27
  50. package/src/browser/transport/fetch.js +16 -14
  51. package/src/browser/transport/xhr.js +29 -13
  52. package/src/browser/transport.js +82 -25
  53. package/src/browser/url.js +16 -8
  54. package/src/browser/wrapGlobals.js +27 -8
  55. package/src/defaults.js +3 -3
  56. package/src/errorParser.js +14 -11
  57. package/src/merge.js +32 -23
  58. package/src/notifier.js +16 -13
  59. package/src/predicates.js +43 -23
  60. package/src/queue.js +71 -39
  61. package/src/rateLimiter.js +59 -18
  62. package/src/react-native/logger.js +1 -1
  63. package/src/react-native/rollbar.js +59 -55
  64. package/src/react-native/transforms.js +13 -9
  65. package/src/react-native/transport.js +44 -34
  66. package/src/rollbar.js +22 -13
  67. package/src/scrub.js +0 -1
  68. package/src/server/locals.js +69 -39
  69. package/src/server/logger.js +4 -4
  70. package/src/server/parser.js +72 -47
  71. package/src/server/rollbar.js +133 -55
  72. package/src/server/sourceMap/stackTrace.js +33 -18
  73. package/src/server/telemetry/urlHelpers.js +9 -11
  74. package/src/server/telemetry.js +68 -45
  75. package/src/server/transforms.js +37 -21
  76. package/src/server/transport.js +62 -32
  77. package/src/telemetry.js +92 -28
  78. package/src/transforms.js +33 -21
  79. package/src/truncation.js +8 -5
  80. package/src/utility/headers.js +43 -43
  81. package/src/utility/replace.js +9 -0
  82. package/src/utility/traverse.js +1 -1
  83. package/src/utility.js +89 -52
  84. package/test/api.test.js +31 -29
  85. package/test/apiUtility.test.js +43 -44
  86. package/test/browser.core.test.js +141 -131
  87. package/test/browser.domUtility.test.js +52 -35
  88. package/test/browser.predicates.test.js +13 -13
  89. package/test/browser.rollbar.test.js +597 -503
  90. package/test/browser.telemetry.test.js +76 -0
  91. package/test/browser.transforms.test.js +146 -128
  92. package/test/browser.transport.test.js +54 -46
  93. package/test/browser.url.test.js +12 -11
  94. package/test/fixtures/locals.fixtures.js +245 -126
  95. package/test/notifier.test.js +90 -78
  96. package/test/predicates.test.js +260 -214
  97. package/test/queue.test.js +230 -214
  98. package/test/rateLimiter.test.js +50 -42
  99. package/test/react-native.rollbar.test.js +149 -115
  100. package/test/react-native.transforms.test.js +21 -23
  101. package/test/react-native.transport.test.js +23 -11
  102. package/test/server.lambda.test.js +70 -53
  103. package/test/server.locals.test.js +437 -210
  104. package/test/server.parser.test.js +32 -26
  105. package/test/server.predicates.test.js +45 -43
  106. package/test/server.rollbar.test.js +311 -259
  107. package/test/server.telemetry.test.js +208 -83
  108. package/test/server.transforms.test.js +455 -361
  109. package/test/server.transport.test.js +144 -76
  110. package/test/telemetry.test.js +46 -37
  111. package/test/transforms.test.js +68 -66
  112. package/test/truncation.test.js +55 -53
  113. package/test/utility.test.js +266 -222
  114. package/webpack.config.js +46 -43
  115. package/.gitmodules +0 -3
  116. package/browserstack.browsers.js +0 -153
  117. package/browserstack.browsers.json +0 -4384
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "rollbar",
3
- "version": "2.26.2",
3
+ "version": "2.26.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "http://github.com/rollbar/rollbar.js"
7
7
  },
8
8
  "description": "Effortlessly track and debug errors in your JavaScript applications with Rollbar. This package includes advanced error tracking features and an intuitive interface to help you identify and fix issues more quickly.",
9
- "keywords": ["error", "tracking", "logging", "debugging", "javascript"],
9
+ "keywords": [
10
+ "error",
11
+ "tracking",
12
+ "logging",
13
+ "debugging",
14
+ "javascript"
15
+ ],
10
16
  "license": "MIT",
11
17
  "main": "src/server/rollbar.js",
12
18
  "browser": "dist/rollbar.umd.min.js",
@@ -21,37 +27,35 @@
21
27
  "source-map": "^0.5.7"
22
28
  },
23
29
  "devDependencies": {
24
- "babel-core": "^6.26.3",
30
+ "@babel/core": "^7.22.11",
25
31
  "babel-eslint": "^10.0.3",
26
32
  "babel-loader": "^8.0.4",
27
33
  "bluebird": "^3.3.5",
28
- "browserstack-api": "0.0.5",
29
34
  "chai": "^4.2.0",
30
35
  "chalk": "^1.1.1",
36
+ "coverage-istanbul-loader": "^3.0.5",
31
37
  "eslint": "^6.8.0",
32
38
  "eslint-loader": "^3.0.3",
33
- "express": "^4.16.4",
39
+ "express": "^4.18.2",
34
40
  "glob": "^5.0.14",
35
41
  "grunt": "^1.1.0",
36
42
  "grunt-bumpup": "^0.6.3",
37
43
  "grunt-cli": "^1.3.2",
38
- "grunt-contrib-concat": "~0.3.0",
44
+ "grunt-contrib-concat": "^2.1.0",
39
45
  "grunt-contrib-connect": "^2.1.0",
40
- "grunt-contrib-copy": "~0.5.0",
41
- "grunt-contrib-jshint": "^2.1.0",
46
+ "grunt-contrib-copy": "^1.0.0",
47
+ "grunt-contrib-jshint": "^3.2.0",
42
48
  "grunt-contrib-uglify": "^4.0.0",
43
49
  "grunt-contrib-watch": "^1.1.0",
44
- "grunt-karma": "^3.0.2",
50
+ "grunt-karma": "^4.0.2",
45
51
  "grunt-parallel": "^0.5.1",
46
52
  "grunt-text-replace": "^0.4.0",
47
53
  "grunt-vows": "^0.4.2",
48
- "grunt-webpack": "^3.1.3",
49
- "istanbul-instrumenter-loader": "^3.0.1",
54
+ "grunt-webpack": "^5.0.0",
50
55
  "jade": "~0.27.7",
51
56
  "jasmine-core": "^2.3.4",
52
57
  "jquery-mockjax": "^2.5.0",
53
- "karma": "^5.0.4",
54
- "karma-browserstack-launcher": "^1.5.1",
58
+ "karma": "^6.4.2",
55
59
  "karma-chai": "^0.1.0",
56
60
  "karma-chrome-launcher": "^2.2.0",
57
61
  "karma-expect": "^1.1.0",
@@ -64,12 +68,12 @@
64
68
  "karma-safari-launcher": "^0.1.1",
65
69
  "karma-sinon": "^1.0.4",
66
70
  "karma-sourcemap-loader": "^0.3.5",
67
- "karma-webpack": "^4.0.2",
68
- "mocha": "^7.1.2",
71
+ "karma-webpack": "^5.0.0",
72
+ "mocha": "^10.2.0",
69
73
  "natives": "^1.1.6",
70
74
  "nock": "^11.9.1",
71
75
  "node-libs-browser": "^0.5.2",
72
- "request": "^2.88.0",
76
+ "prettier": "^3.2.5",
73
77
  "requirejs": "^2.1.20",
74
78
  "script-loader": "0.6.1",
75
79
  "sinon": "^8.1.1",
@@ -77,7 +81,7 @@
77
81
  "strict-loader": "^1.2.0",
78
82
  "time-grunt": "^1.0.0",
79
83
  "vows": "^0.8.3",
80
- "webpack": "^4.46.0"
84
+ "webpack": "^5.88.2"
81
85
  },
82
86
  "optionalDependencies": {
83
87
  "decache": "^3.0.5"
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @type {import('prettier').Config}
3
+ */
4
+ module.exports = {
5
+ trailingComma: 'all',
6
+ singleQuote: true,
7
+ };
package/src/api.js CHANGED
@@ -7,7 +7,7 @@ var defaultOptions = {
7
7
  search: null,
8
8
  version: '1',
9
9
  protocol: 'https:',
10
- port: 443
10
+ port: 443,
11
11
  };
12
12
 
13
13
  /**
@@ -44,13 +44,16 @@ function Api(options, transport, urllib, truncation, jsonBackup) {
44
44
  * @param data
45
45
  * @param callback
46
46
  */
47
- Api.prototype.postItem = function(data, callback) {
48
- var transportOptions = helpers.transportOptions(this.transportOptions, 'POST');
47
+ Api.prototype.postItem = function (data, callback) {
48
+ var transportOptions = helpers.transportOptions(
49
+ this.transportOptions,
50
+ 'POST',
51
+ );
49
52
  var payload = helpers.buildPayload(this.accessToken, data, this.jsonBackup);
50
53
  var self = this;
51
54
 
52
55
  // ensure the network request is scheduled after the current tick.
53
- setTimeout(function() {
56
+ setTimeout(function () {
54
57
  self.transport.post(self.accessToken, transportOptions, payload, callback);
55
58
  }, 0);
56
59
  };
@@ -60,14 +63,14 @@ Api.prototype.postItem = function(data, callback) {
60
63
  * @param data
61
64
  * @param callback
62
65
  */
63
- Api.prototype.buildJsonPayload = function(data, callback) {
66
+ Api.prototype.buildJsonPayload = function (data, callback) {
64
67
  var payload = helpers.buildPayload(this.accessToken, data, this.jsonBackup);
65
68
 
66
69
  var stringifyResult;
67
70
  if (this.truncation) {
68
71
  stringifyResult = this.truncation.truncate(payload);
69
72
  } else {
70
- stringifyResult = _.stringify(payload)
73
+ stringifyResult = _.stringify(payload);
71
74
  }
72
75
 
73
76
  if (stringifyResult.error) {
@@ -85,12 +88,20 @@ Api.prototype.buildJsonPayload = function(data, callback) {
85
88
  * @param jsonPayload
86
89
  * @param callback
87
90
  */
88
- Api.prototype.postJsonPayload = function(jsonPayload, callback) {
89
- var transportOptions = helpers.transportOptions(this.transportOptions, 'POST');
90
- this.transport.postJsonPayload(this.accessToken, transportOptions, jsonPayload, callback);
91
+ Api.prototype.postJsonPayload = function (jsonPayload, callback) {
92
+ var transportOptions = helpers.transportOptions(
93
+ this.transportOptions,
94
+ 'POST',
95
+ );
96
+ this.transport.postJsonPayload(
97
+ this.accessToken,
98
+ transportOptions,
99
+ jsonPayload,
100
+ callback,
101
+ );
91
102
  };
92
103
 
93
- Api.prototype.configure = function(options) {
104
+ Api.prototype.configure = function (options) {
94
105
  var oldOptions = this.oldOptions;
95
106
  this.options = _.merge(oldOptions, options);
96
107
  this.transportOptions = _getTransport(this.options, this.url);
package/src/apiUtility.js CHANGED
@@ -4,7 +4,7 @@ function buildPayload(accessToken, data, jsonBackup) {
4
4
  if (!_.isType(data.context, 'string')) {
5
5
  var contextResult = _.stringify(data.context, jsonBackup);
6
6
  if (contextResult.error) {
7
- data.context = 'Error: could not serialize \'context\'';
7
+ data.context = "Error: could not serialize 'context'";
8
8
  } else {
9
9
  data.context = contextResult.value || '';
10
10
  }
@@ -14,7 +14,7 @@ function buildPayload(accessToken, data, jsonBackup) {
14
14
  }
15
15
  return {
16
16
  access_token: accessToken,
17
- data: data
17
+ data: data,
18
18
  };
19
19
  }
20
20
 
@@ -25,7 +25,7 @@ function getTransportFromOptions(options, defaults, url) {
25
25
  var path = defaults.path;
26
26
  var search = defaults.search;
27
27
  var timeout = options.timeout;
28
- var transport = detectTransport(options)
28
+ var transport = detectTransport(options);
29
29
 
30
30
  var proxy = options.proxy;
31
31
  if (options.endpoint) {
@@ -44,12 +44,14 @@ function getTransportFromOptions(options, defaults, url) {
44
44
  path: path,
45
45
  search: search,
46
46
  proxy: proxy,
47
- transport: transport
47
+ transport: transport,
48
48
  };
49
49
  }
50
50
 
51
51
  function detectTransport(options) {
52
- var gWindow = ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
52
+ var gWindow =
53
+ (typeof window != 'undefined' && window) ||
54
+ (typeof self != 'undefined' && self);
53
55
  var transport = options.defaultTransport || 'xhr';
54
56
  if (typeof gWindow.fetch === 'undefined') transport = 'xhr';
55
57
  if (typeof gWindow.XMLHttpRequest === 'undefined') transport = 'fetch';
@@ -58,7 +60,9 @@ function detectTransport(options) {
58
60
 
59
61
  function transportOptions(transport, method) {
60
62
  var protocol = transport.protocol || 'https:';
61
- var port = transport.port || (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
63
+ var port =
64
+ transport.port ||
65
+ (protocol === 'http:' ? 80 : protocol === 'https:' ? 443 : undefined);
62
66
  var hostname = transport.hostname;
63
67
  var path = transport.path;
64
68
  var timeout = transport.timeout;
@@ -79,7 +83,7 @@ function transportOptions(transport, method) {
79
83
  path: path,
80
84
  port: port,
81
85
  method: method,
82
- transport: transportAPI
86
+ transport: transportAPI,
83
87
  };
84
88
  }
85
89
 
@@ -100,5 +104,5 @@ module.exports = {
100
104
  buildPayload: buildPayload,
101
105
  getTransportFromOptions: getTransportFromOptions,
102
106
  transportOptions: transportOptions,
103
- appendPathToPath: appendPathToPath
107
+ appendPathToPath: appendPathToPath,
104
108
  };
@@ -28,16 +28,23 @@ function Rollbar(options, client) {
28
28
  if (Telemeter) {
29
29
  this.telemeter = new Telemeter(this.options);
30
30
  }
31
- this.client = client || new Client(this.options, api, logger, this.telemeter, 'browser');
31
+ this.client =
32
+ client || new Client(this.options, api, logger, this.telemeter, 'browser');
32
33
  var gWindow = _gWindow();
33
- var gDocument = (typeof document != 'undefined') && document;
34
+ var gDocument = typeof document != 'undefined' && document;
34
35
  this.isChrome = gWindow.chrome && gWindow.chrome.runtime; // check .runtime to avoid Edge browsers
35
36
  this.anonymousErrorsPending = 0;
36
37
  addTransformsToNotifier(this.client.notifier, this, gWindow);
37
38
  addPredicatesToQueue(this.client.queue);
38
39
  this.setupUnhandledCapture();
39
40
  if (Instrumenter) {
40
- this.instrumenter = new Instrumenter(this.options, this.client.telemeter, this, gWindow, gDocument);
41
+ this.instrumenter = new Instrumenter(
42
+ this.options,
43
+ this.client.telemeter,
44
+ this,
45
+ gWindow,
46
+ gDocument,
47
+ );
41
48
  this.instrumenter.instrument();
42
49
  }
43
50
  _.setupJSON(polyfillJSON);
@@ -47,7 +54,7 @@ function Rollbar(options, client) {
47
54
  }
48
55
 
49
56
  var _instance = null;
50
- Rollbar.init = function(options, client) {
57
+ Rollbar.init = function (options, client) {
51
58
  if (_instance) {
52
59
  return _instance.global(options).configure(options);
53
60
  }
@@ -57,9 +64,9 @@ Rollbar.init = function(options, client) {
57
64
 
58
65
  Rollbar.prototype.components = {};
59
66
 
60
- Rollbar.setComponents = function(components) {
67
+ Rollbar.setComponents = function (components) {
61
68
  Rollbar.prototype.components = components;
62
- }
69
+ };
63
70
 
64
71
  function handleUninitialized(maybeCallback) {
65
72
  var message = 'Rollbar is not initialized';
@@ -69,11 +76,11 @@ function handleUninitialized(maybeCallback) {
69
76
  }
70
77
  }
71
78
 
72
- Rollbar.prototype.global = function(options) {
79
+ Rollbar.prototype.global = function (options) {
73
80
  this.client.global(options);
74
81
  return this;
75
82
  };
76
- Rollbar.global = function(options) {
83
+ Rollbar.global = function (options) {
77
84
  if (_instance) {
78
85
  return _instance.global(options);
79
86
  } else {
@@ -81,20 +88,24 @@ Rollbar.global = function(options) {
81
88
  }
82
89
  };
83
90
 
84
- Rollbar.prototype.configure = function(options, payloadData) {
91
+ Rollbar.prototype.configure = function (options, payloadData) {
85
92
  var oldOptions = this.options;
86
93
  var payload = {};
87
94
  if (payloadData) {
88
- payload = {payload: payloadData};
95
+ payload = { payload: payloadData };
89
96
  }
90
97
  this.options = _.handleOptions(oldOptions, options, payload, logger);
91
- this.options._configuredOptions = _.handleOptions(oldOptions._configuredOptions, options, payload);
98
+ this.options._configuredOptions = _.handleOptions(
99
+ oldOptions._configuredOptions,
100
+ options,
101
+ payload,
102
+ );
92
103
  this.client.configure(this.options, payloadData);
93
104
  this.instrumenter && this.instrumenter.configure(this.options);
94
105
  this.setupUnhandledCapture();
95
106
  return this;
96
107
  };
97
- Rollbar.configure = function(options, payloadData) {
108
+ Rollbar.configure = function (options, payloadData) {
98
109
  if (_instance) {
99
110
  return _instance.configure(options, payloadData);
100
111
  } else {
@@ -102,10 +113,10 @@ Rollbar.configure = function(options, payloadData) {
102
113
  }
103
114
  };
104
115
 
105
- Rollbar.prototype.lastError = function() {
116
+ Rollbar.prototype.lastError = function () {
106
117
  return this.client.lastError;
107
118
  };
108
- Rollbar.lastError = function() {
119
+ Rollbar.lastError = function () {
109
120
  if (_instance) {
110
121
  return _instance.lastError();
111
122
  } else {
@@ -113,13 +124,13 @@ Rollbar.lastError = function() {
113
124
  }
114
125
  };
115
126
 
116
- Rollbar.prototype.log = function() {
127
+ Rollbar.prototype.log = function () {
117
128
  var item = this._createItem(arguments);
118
129
  var uuid = item.uuid;
119
130
  this.client.log(item);
120
- return {uuid: uuid};
131
+ return { uuid: uuid };
121
132
  };
122
- Rollbar.log = function() {
133
+ Rollbar.log = function () {
123
134
  if (_instance) {
124
135
  return _instance.log.apply(_instance, arguments);
125
136
  } else {
@@ -128,13 +139,13 @@ Rollbar.log = function() {
128
139
  }
129
140
  };
130
141
 
131
- Rollbar.prototype.debug = function() {
142
+ Rollbar.prototype.debug = function () {
132
143
  var item = this._createItem(arguments);
133
144
  var uuid = item.uuid;
134
145
  this.client.debug(item);
135
- return {uuid: uuid};
146
+ return { uuid: uuid };
136
147
  };
137
- Rollbar.debug = function() {
148
+ Rollbar.debug = function () {
138
149
  if (_instance) {
139
150
  return _instance.debug.apply(_instance, arguments);
140
151
  } else {
@@ -143,13 +154,13 @@ Rollbar.debug = function() {
143
154
  }
144
155
  };
145
156
 
146
- Rollbar.prototype.info = function() {
157
+ Rollbar.prototype.info = function () {
147
158
  var item = this._createItem(arguments);
148
159
  var uuid = item.uuid;
149
160
  this.client.info(item);
150
- return {uuid: uuid};
161
+ return { uuid: uuid };
151
162
  };
152
- Rollbar.info = function() {
163
+ Rollbar.info = function () {
153
164
  if (_instance) {
154
165
  return _instance.info.apply(_instance, arguments);
155
166
  } else {
@@ -158,13 +169,13 @@ Rollbar.info = function() {
158
169
  }
159
170
  };
160
171
 
161
- Rollbar.prototype.warn = function() {
172
+ Rollbar.prototype.warn = function () {
162
173
  var item = this._createItem(arguments);
163
174
  var uuid = item.uuid;
164
175
  this.client.warn(item);
165
- return {uuid: uuid};
176
+ return { uuid: uuid };
166
177
  };
167
- Rollbar.warn = function() {
178
+ Rollbar.warn = function () {
168
179
  if (_instance) {
169
180
  return _instance.warn.apply(_instance, arguments);
170
181
  } else {
@@ -173,13 +184,13 @@ Rollbar.warn = function() {
173
184
  }
174
185
  };
175
186
 
176
- Rollbar.prototype.warning = function() {
187
+ Rollbar.prototype.warning = function () {
177
188
  var item = this._createItem(arguments);
178
189
  var uuid = item.uuid;
179
190
  this.client.warning(item);
180
- return {uuid: uuid};
191
+ return { uuid: uuid };
181
192
  };
182
- Rollbar.warning = function() {
193
+ Rollbar.warning = function () {
183
194
  if (_instance) {
184
195
  return _instance.warning.apply(_instance, arguments);
185
196
  } else {
@@ -188,13 +199,13 @@ Rollbar.warning = function() {
188
199
  }
189
200
  };
190
201
 
191
- Rollbar.prototype.error = function() {
202
+ Rollbar.prototype.error = function () {
192
203
  var item = this._createItem(arguments);
193
204
  var uuid = item.uuid;
194
205
  this.client.error(item);
195
- return {uuid: uuid};
206
+ return { uuid: uuid };
196
207
  };
197
- Rollbar.error = function() {
208
+ Rollbar.error = function () {
198
209
  if (_instance) {
199
210
  return _instance.error.apply(_instance, arguments);
200
211
  } else {
@@ -203,13 +214,13 @@ Rollbar.error = function() {
203
214
  }
204
215
  };
205
216
 
206
- Rollbar.prototype.critical = function() {
217
+ Rollbar.prototype.critical = function () {
207
218
  var item = this._createItem(arguments);
208
219
  var uuid = item.uuid;
209
220
  this.client.critical(item);
210
- return {uuid: uuid};
221
+ return { uuid: uuid };
211
222
  };
212
- Rollbar.critical = function() {
223
+ Rollbar.critical = function () {
213
224
  if (_instance) {
214
225
  return _instance.critical.apply(_instance, arguments);
215
226
  } else {
@@ -218,10 +229,10 @@ Rollbar.critical = function() {
218
229
  }
219
230
  };
220
231
 
221
- Rollbar.prototype.buildJsonPayload = function(item) {
232
+ Rollbar.prototype.buildJsonPayload = function (item) {
222
233
  return this.client.buildJsonPayload(item);
223
234
  };
224
- Rollbar.buildJsonPayload = function() {
235
+ Rollbar.buildJsonPayload = function () {
225
236
  if (_instance) {
226
237
  return _instance.buildJsonPayload.apply(_instance, arguments);
227
238
  } else {
@@ -229,10 +240,10 @@ Rollbar.buildJsonPayload = function() {
229
240
  }
230
241
  };
231
242
 
232
- Rollbar.prototype.sendJsonPayload = function(jsonPayload) {
243
+ Rollbar.prototype.sendJsonPayload = function (jsonPayload) {
233
244
  return this.client.sendJsonPayload(jsonPayload);
234
245
  };
235
- Rollbar.sendJsonPayload = function() {
246
+ Rollbar.sendJsonPayload = function () {
236
247
  if (_instance) {
237
248
  return _instance.sendJsonPayload.apply(_instance, arguments);
238
249
  } else {
@@ -240,7 +251,7 @@ Rollbar.sendJsonPayload = function() {
240
251
  }
241
252
  };
242
253
 
243
- Rollbar.prototype.setupUnhandledCapture = function() {
254
+ Rollbar.prototype.setupUnhandledCapture = function () {
244
255
  var gWindow = _gWindow();
245
256
 
246
257
  if (!this.unhandledExceptionsInitialized) {
@@ -253,14 +264,24 @@ Rollbar.prototype.setupUnhandledCapture = function() {
253
264
  }
254
265
  }
255
266
  if (!this.unhandledRejectionsInitialized) {
256
- if (this.options.captureUnhandledRejections || this.options.handleUnhandledRejections) {
267
+ if (
268
+ this.options.captureUnhandledRejections ||
269
+ this.options.handleUnhandledRejections
270
+ ) {
257
271
  globals.captureUnhandledRejections(gWindow, this);
258
272
  this.unhandledRejectionsInitialized = true;
259
273
  }
260
274
  }
261
275
  };
262
276
 
263
- Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno, error, context) {
277
+ Rollbar.prototype.handleUncaughtException = function (
278
+ message,
279
+ url,
280
+ lineno,
281
+ colno,
282
+ error,
283
+ context,
284
+ ) {
264
285
  if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) {
265
286
  return;
266
287
  }
@@ -269,7 +290,12 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
269
290
  // If error is undefined, we have a different caller.
270
291
  // Chrome also sends errors from web workers with null error, but does not invoke
271
292
  // prepareStackTrace() for these. Test for empty url to skip them.
272
- if (this.options.inspectAnonymousErrors && this.isChrome && error === null && url === '') {
293
+ if (
294
+ this.options.inspectAnonymousErrors &&
295
+ this.isChrome &&
296
+ error === null &&
297
+ url === ''
298
+ ) {
273
299
  return 'anonymous';
274
300
  }
275
301
 
@@ -282,7 +308,7 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
282
308
  error,
283
309
  'onerror',
284
310
  'uncaught exception',
285
- errorParser
311
+ errorParser,
286
312
  );
287
313
  if (_.isError(error)) {
288
314
  item = this._createItem([message, error, context]);
@@ -311,13 +337,14 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno
311
337
  *
312
338
  * In config options, set inspectAnonymousErrors to enable.
313
339
  */
314
- Rollbar.prototype.handleAnonymousErrors = function() {
340
+ Rollbar.prototype.handleAnonymousErrors = function () {
315
341
  if (!this.options.inspectAnonymousErrors || !this.isChrome) {
316
342
  return;
317
343
  }
318
344
 
319
345
  var r = this;
320
- function prepareStackTrace(error, _stack) { // eslint-disable-line no-unused-vars
346
+ function prepareStackTrace(error, _stack) {
347
+ // eslint-disable-line no-unused-vars
321
348
  if (r.options.inspectAnonymousErrors) {
322
349
  if (r.anonymousErrorsPending) {
323
350
  // This is the only known way to detect that onerror saw an anonymous error.
@@ -355,10 +382,13 @@ Rollbar.prototype.handleAnonymousErrors = function() {
355
382
  this.options.inspectAnonymousErrors = false;
356
383
  this.error('anonymous error handler failed', e);
357
384
  }
358
- }
385
+ };
359
386
 
360
- Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
361
- if (!this.options.captureUnhandledRejections && !this.options.handleUnhandledRejections) {
387
+ Rollbar.prototype.handleUnhandledRejection = function (reason, promise) {
388
+ if (
389
+ !this.options.captureUnhandledRejections &&
390
+ !this.options.handleUnhandledRejections
391
+ ) {
362
392
  return;
363
393
  }
364
394
 
@@ -373,7 +403,8 @@ Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
373
403
  }
374
404
  }
375
405
  }
376
- var context = (reason && reason._rollbarContext) || (promise && promise._rollbarContext);
406
+ var context =
407
+ (reason && reason._rollbarContext) || (promise && promise._rollbarContext);
377
408
 
378
409
  var item;
379
410
  if (_.isError(reason)) {
@@ -388,7 +419,7 @@ Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
388
419
  null,
389
420
  'unhandledrejection',
390
421
  '',
391
- errorParser
422
+ errorParser,
392
423
  );
393
424
  }
394
425
  item.level = this.options.uncaughtErrorLevel;
@@ -398,13 +429,15 @@ Rollbar.prototype.handleUnhandledRejection = function(reason, promise) {
398
429
  this.client.log(item);
399
430
  };
400
431
 
401
- Rollbar.prototype.wrap = function(f, context, _before) {
432
+ Rollbar.prototype.wrap = function (f, context, _before) {
402
433
  try {
403
434
  var ctxFn;
404
- if(_.isFunction(context)) {
435
+ if (_.isFunction(context)) {
405
436
  ctxFn = context;
406
437
  } else {
407
- ctxFn = function() { return context || {}; };
438
+ ctxFn = function () {
439
+ return context || {};
440
+ };
408
441
  }
409
442
 
410
443
  if (!_.isFunction(f)) {
@@ -422,7 +455,7 @@ Rollbar.prototype.wrap = function(f, context, _before) {
422
455
  }
423
456
  try {
424
457
  return f.apply(this, arguments);
425
- } catch(exc) {
458
+ } catch (exc) {
426
459
  var e = exc;
427
460
  if (e && window._rollbarWrappedError !== e) {
428
461
  if (_.isType(e, 'string')) {
@@ -454,7 +487,7 @@ Rollbar.prototype.wrap = function(f, context, _before) {
454
487
  return f;
455
488
  }
456
489
  };
457
- Rollbar.wrap = function(f, context) {
490
+ Rollbar.wrap = function (f, context) {
458
491
  if (_instance) {
459
492
  return _instance.wrap(f, context);
460
493
  } else {
@@ -462,11 +495,11 @@ Rollbar.wrap = function(f, context) {
462
495
  }
463
496
  };
464
497
 
465
- Rollbar.prototype.captureEvent = function() {
498
+ Rollbar.prototype.captureEvent = function () {
466
499
  var event = _.createTelemetryEvent(arguments);
467
500
  return this.client.captureEvent(event.type, event.metadata, event.level);
468
501
  };
469
- Rollbar.captureEvent = function() {
502
+ Rollbar.captureEvent = function () {
470
503
  if (_instance) {
471
504
  return _instance.captureEvent.apply(_instance, arguments);
472
505
  } else {
@@ -475,14 +508,14 @@ Rollbar.captureEvent = function() {
475
508
  };
476
509
 
477
510
  // The following two methods are used internally and are not meant for public use
478
- Rollbar.prototype.captureDomContentLoaded = function(e, ts) {
511
+ Rollbar.prototype.captureDomContentLoaded = function (e, ts) {
479
512
  if (!ts) {
480
513
  ts = new Date();
481
514
  }
482
515
  return this.client.captureDomContentLoaded(ts);
483
516
  };
484
517
 
485
- Rollbar.prototype.captureLoad = function(e, ts) {
518
+ Rollbar.prototype.captureLoad = function (e, ts) {
486
519
  if (!ts) {
487
520
  ts = new Date();
488
521
  }
@@ -522,11 +555,13 @@ function addPredicatesToQueue(queue) {
522
555
  .addPredicate(sharedPredicates.messageIsIgnored(logger));
523
556
  }
524
557
 
525
- Rollbar.prototype.loadFull = function() {
526
- logger.info('Unexpected Rollbar.loadFull() called on a Notifier instance. This can happen when Rollbar is loaded multiple times.');
558
+ Rollbar.prototype.loadFull = function () {
559
+ logger.info(
560
+ 'Unexpected Rollbar.loadFull() called on a Notifier instance. This can happen when Rollbar is loaded multiple times.',
561
+ );
527
562
  };
528
563
 
529
- Rollbar.prototype._createItem = function(args) {
564
+ Rollbar.prototype._createItem = function (args) {
530
565
  return _.createItem(args, logger, this);
531
566
  };
532
567
 
@@ -540,7 +575,10 @@ function _getFirstFunction(args) {
540
575
  }
541
576
 
542
577
  function _gWindow() {
543
- return ((typeof window != 'undefined') && window) || ((typeof self != 'undefined') && self);
578
+ return (
579
+ (typeof window != 'undefined' && window) ||
580
+ (typeof self != 'undefined' && self)
581
+ );
544
582
  }
545
583
 
546
584
  var defaults = require('../defaults');
@@ -561,7 +599,7 @@ var defaultOptions = {
561
599
  captureIp: true,
562
600
  inspectAnonymousErrors: true,
563
601
  ignoreDuplicateErrors: true,
564
- wrapGlobalEventHandlers: false
602
+ wrapGlobalEventHandlers: false,
565
603
  };
566
604
 
567
605
  module.exports = Rollbar;