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
@@ -9,31 +9,31 @@ var t = new Transport(truncation);
9
9
  var utility = require('../src/utility');
10
10
  utility.setupJSON();
11
11
 
12
- describe('post', function() {
12
+ describe('post', function () {
13
13
  var accessToken = 'abc123';
14
14
  var options = {
15
15
  hostname: 'api.rollbar.com',
16
16
  protocol: 'https',
17
17
  path: '/api/1/item/',
18
- timeout: 2000
18
+ timeout: 2000,
19
19
  };
20
20
  var payload = {
21
21
  access_token: accessToken,
22
- data: {a: 1}
22
+ data: { a: 1 },
23
23
  };
24
- it('should handle a failure to make a request', function(done) {
25
- var requestFactory = function() {
24
+ it('should handle a failure to make a request', function (done) {
25
+ var requestFactory = function () {
26
26
  return null;
27
27
  };
28
- var callback = function(err, resp) {
28
+ var callback = function (err, resp) {
29
29
  expect(err).to.be.ok();
30
30
  done(resp);
31
31
  };
32
32
  t.post(accessToken, options, payload, callback, requestFactory);
33
33
  });
34
- it('should callback with the right value on success', function(done) {
34
+ it('should callback with the right value on success', function (done) {
35
35
  var requestFactory = requestGenerator('{"err": null, "result": true}', 200);
36
- var callback = function(err, resp) {
36
+ var callback = function (err, resp) {
37
37
  expect(resp).to.be.ok();
38
38
  expect(resp.result).to.be.ok();
39
39
  expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
@@ -41,10 +41,11 @@ describe('post', function() {
41
41
  };
42
42
  t.post(accessToken, options, payload, callback, requestFactory.getInstance);
43
43
  });
44
- it('should callback with the server error if 403', function(done) {
45
- var response = '{"err": "bad request", "result": null, "message": "fail whale"}'
44
+ it('should callback with the server error if 403', function (done) {
45
+ var response =
46
+ '{"err": "bad request", "result": null, "message": "fail whale"}';
46
47
  var requestFactory = requestGenerator(response, 403);
47
- var callback = function(err, resp) {
48
+ var callback = function (err, resp) {
48
49
  expect(resp).to.not.be.ok();
49
50
  expect(err.message).to.eql('403');
50
51
  expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
@@ -52,10 +53,11 @@ describe('post', function() {
52
53
  };
53
54
  t.post(accessToken, options, payload, callback, requestFactory.getInstance);
54
55
  });
55
- it('should callback with the server error if 500', function(done) {
56
- var response = '{"err": "bad request", "result": null, "message": "500!!!"}'
56
+ it('should callback with the server error if 500', function (done) {
57
+ var response =
58
+ '{"err": "bad request", "result": null, "message": "500!!!"}';
57
59
  var requestFactory = requestGenerator(response, 500);
58
- var callback = function(err, resp) {
60
+ var callback = function (err, resp) {
59
61
  expect(resp).to.not.be.ok();
60
62
  expect(err.message).to.eql('500');
61
63
  expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
@@ -63,10 +65,10 @@ describe('post', function() {
63
65
  };
64
66
  t.post(accessToken, options, payload, callback, requestFactory.getInstance);
65
67
  });
66
- it('should callback with a retriable error with a weird status', function(done) {
67
- var response = '{"err": "bad request"}'
68
+ it('should callback with a retriable error with a weird status', function (done) {
69
+ var response = '{"err": "bad request"}';
68
70
  var requestFactory = requestGenerator(response, 12005);
69
- var callback = function(err, resp) {
71
+ var callback = function (err, resp) {
70
72
  expect(resp).to.not.be.ok();
71
73
  expect(err.message).to.match(/connection failure/);
72
74
  expect(err.code).to.eql('ENOTFOUND');
@@ -75,10 +77,10 @@ describe('post', function() {
75
77
  };
76
78
  t.post(accessToken, options, payload, callback, requestFactory.getInstance);
77
79
  });
78
- it('should callback with some error if normal sending throws', function(done) {
79
- var response = '{"err": "bad request"}'
80
+ it('should callback with some error if normal sending throws', function (done) {
81
+ var response = '{"err": "bad request"}';
80
82
  var requestFactory = requestGenerator(response, 500, true);
81
- var callback = function(err, resp) {
83
+ var callback = function (err, resp) {
82
84
  expect(resp).to.not.be.ok();
83
85
  expect(err.message).to.match(/Cannot find a method to transport/);
84
86
  expect(requestFactory.getInstance().timeout).to.equal(options.timeout);
@@ -86,7 +88,7 @@ describe('post', function() {
86
88
  };
87
89
  t.post(accessToken, options, payload, callback, requestFactory.getInstance);
88
90
  });
89
- describe('post', function() {
91
+ describe('post', function () {
90
92
  beforeEach(function (done) {
91
93
  window.fetchStub = sinon.stub(window, 'fetch');
92
94
  window.server = sinon.createFakeServer();
@@ -99,26 +101,32 @@ describe('post', function() {
99
101
  });
100
102
 
101
103
  function stubFetchResponse() {
102
- window.fetch.returns(Promise.resolve(new Response(
103
- JSON.stringify({ err: 0, message: 'OK', result: { uuid: uuid }}),
104
- { status: 200, statusText: 'OK', headers: { 'Content-Type': 'application/json' }}
105
- )));
104
+ window.fetch.returns(
105
+ Promise.resolve(
106
+ new Response(
107
+ JSON.stringify({ err: 0, message: 'OK', result: { uuid: uuid } }),
108
+ {
109
+ status: 200,
110
+ statusText: 'OK',
111
+ headers: { 'Content-Type': 'application/json' },
112
+ },
113
+ ),
114
+ ),
115
+ );
106
116
  }
107
117
 
108
118
  function stubXhrResponse() {
109
- window.server.respondWith(
110
- [
111
- 200,
112
- { 'Content-Type': 'application/json' },
113
- '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}'
114
- ]
115
- );
119
+ window.server.respondWith([
120
+ 200,
121
+ { 'Content-Type': 'application/json' },
122
+ '{"err": 0, "result":{ "uuid": "d4c7acef55bf4c9ea95e4fe9428a8287"}}',
123
+ ]);
116
124
  }
117
125
 
118
126
  var uuid = 'd4c7acef55bf4c9ea95e4fe9428a8287';
119
127
 
120
- it('should use fetch when requested', function(done) {
121
- var callback = function(err, resp) {
128
+ it('should use fetch when requested', function (done) {
129
+ var callback = function (err, resp) {
122
130
  expect(window.fetchStub.called).to.be.ok();
123
131
  expect(server.requests.length).to.eql(0);
124
132
  done(err);
@@ -129,8 +137,8 @@ describe('post', function() {
129
137
  options.transport = 'fetch';
130
138
  t.post(accessToken, options, payload, callback);
131
139
  });
132
- it('should use xhr when requested', function(done) {
133
- var callback = function(err, resp) {
140
+ it('should use xhr when requested', function (done) {
141
+ var callback = function (err, resp) {
134
142
  expect(window.fetchStub.called).to.not.be.ok();
135
143
  expect(server.requests.length).to.eql(1);
136
144
  done(err);
@@ -140,14 +148,14 @@ describe('post', function() {
140
148
  server.requests.length = 0;
141
149
  options.transport = 'xhr';
142
150
  t.post(accessToken, options, payload, callback);
143
- setTimeout(function() {
151
+ setTimeout(function () {
144
152
  server.respond();
145
153
  }, 1);
146
154
  });
147
155
  });
148
156
  });
149
157
 
150
- var TestRequest = function(response, status, shouldThrowOnSend) {
158
+ var TestRequest = function (response, status, shouldThrowOnSend) {
151
159
  this.method = null;
152
160
  this.url = null;
153
161
  this.async = false;
@@ -159,15 +167,15 @@ var TestRequest = function(response, status, shouldThrowOnSend) {
159
167
  this.readyState = 0;
160
168
  this.shouldThrowOnSend = shouldThrowOnSend;
161
169
  };
162
- TestRequest.prototype.open = function(m, u, a) {
170
+ TestRequest.prototype.open = function (m, u, a) {
163
171
  this.method = m;
164
172
  this.url = u;
165
173
  this.async = a;
166
174
  };
167
- TestRequest.prototype.setRequestHeader = function(key, value) {
175
+ TestRequest.prototype.setRequestHeader = function (key, value) {
168
176
  this.headers.push([key, value]);
169
177
  };
170
- TestRequest.prototype.send = function(data) {
178
+ TestRequest.prototype.send = function (data) {
171
179
  if (this.shouldThrowOnSend) {
172
180
  throw 'Bork Bork';
173
181
  }
@@ -178,14 +186,14 @@ TestRequest.prototype.send = function(data) {
178
186
  }
179
187
  };
180
188
 
181
- var requestGenerator = function(response, status, shouldThrow) {
189
+ var requestGenerator = function (response, status, shouldThrow) {
182
190
  var request;
183
191
  return {
184
- getInstance: function() {
185
- if(!request) {
192
+ getInstance: function () {
193
+ if (!request) {
186
194
  request = new TestRequest(response, status, shouldThrow);
187
195
  }
188
196
  return request;
189
- }
190
- }
197
+ },
198
+ };
191
199
  };
@@ -5,13 +5,13 @@
5
5
 
6
6
  var url = require('../src/browser/url');
7
7
 
8
- describe('parse', function() {
9
- it('should return an object full of nulls for a blank url', function() {
8
+ describe('parse', function () {
9
+ it('should return an object full of nulls for a blank url', function () {
10
10
  var u = '';
11
11
  var parsed = url.parse(u);
12
12
  expect(parsed).to.be.ok();
13
13
  });
14
- it('should get the protocol', function() {
14
+ it('should get the protocol', function () {
15
15
  var http = 'http://something.com';
16
16
  var parsedHttp = url.parse(http);
17
17
  expect(parsedHttp.protocol).to.eql('http:');
@@ -19,8 +19,9 @@ describe('parse', function() {
19
19
  var parsedFile = url.parse(file);
20
20
  expect(parsedFile.protocol).to.eql('file:');
21
21
  });
22
- it('should get everything if it is there', function() {
23
- var u = 'https://me:you@fake.example.co.uk:85/a/path/object//with/crap?a=b&c=d#hashy!';
22
+ it('should get everything if it is there', function () {
23
+ var u =
24
+ 'https://me:you@fake.example.co.uk:85/a/path/object//with/crap?a=b&c=d#hashy!';
24
25
  var p = url.parse(u);
25
26
  expect(p.protocol).to.eql('https:');
26
27
  expect(p.auth).to.eql('me:you');
@@ -33,7 +34,7 @@ describe('parse', function() {
33
34
  expect(p.query).to.eql('a=b&c=d');
34
35
  expect(p.hash).to.eql('#hashy!');
35
36
  });
36
- it('should get stuff even if some things are missing', function() {
37
+ it('should get stuff even if some things are missing', function () {
37
38
  var u = 'https://fake.example.co.uk/a/path/object//with/crap#hashy!';
38
39
  var p = url.parse(u);
39
40
  expect(p.protocol).to.eql('https:');
@@ -47,7 +48,7 @@ describe('parse', function() {
47
48
  expect(p.query).to.not.be.ok();
48
49
  expect(p.hash).to.eql('#hashy!');
49
50
  });
50
- it('should get stuff even the path is missing', function() {
51
+ it('should get stuff even the path is missing', function () {
51
52
  var u = 'https://fake.example.co.uk#hashy!';
52
53
  var p = url.parse(u);
53
54
  expect(p.protocol).to.eql('https:');
@@ -61,7 +62,7 @@ describe('parse', function() {
61
62
  expect(p.query).to.not.be.ok();
62
63
  expect(p.hash).to.eql('#hashy!');
63
64
  });
64
- it('should get stuff with a query and no path', function() {
65
+ it('should get stuff with a query and no path', function () {
65
66
  var u = 'https://fake.example.co.uk?a=b';
66
67
  var p = url.parse(u);
67
68
  expect(p.protocol).to.eql('https:');
@@ -75,7 +76,7 @@ describe('parse', function() {
75
76
  expect(p.query).to.eql('a=b');
76
77
  expect(p.hash).to.not.be.ok();
77
78
  });
78
- it('should get stuff with a query and blank path', function() {
79
+ it('should get stuff with a query and blank path', function () {
79
80
  var u = 'https://fake.example.co.uk/?a=b';
80
81
  var p = url.parse(u);
81
82
  expect(p.protocol).to.eql('https:');
@@ -89,7 +90,7 @@ describe('parse', function() {
89
90
  expect(p.query).to.eql('a=b');
90
91
  expect(p.hash).to.not.be.ok();
91
92
  });
92
- it('should get stuff with a missing protocol', function() {
93
+ it('should get stuff with a missing protocol', function () {
93
94
  var u = '//fake.example.co.uk/v1/#hashash';
94
95
  var p = url.parse(u);
95
96
  expect(p.protocol).to.not.be.ok();
@@ -103,7 +104,7 @@ describe('parse', function() {
103
104
  expect(p.query).to.not.be.ok();
104
105
  expect(p.hash).to.eql('#hashash');
105
106
  });
106
- it('should handle missing protocol without slashes', function() {
107
+ it('should handle missing protocol without slashes', function () {
107
108
  var u = 'api.rollbar.com/api/1';
108
109
  var p = url.parse(u);
109
110
  expect(p.protocol).to.not.be.ok();