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.
- package/.github/workflows/ci.yml +32 -10
- package/.lgtm.yml +7 -7
- package/.prettierignore +18 -0
- package/.vscode/settings.json +39 -0
- package/CHANGELOG.md +121 -35
- package/Gruntfile.js +51 -71
- package/README.md +2 -4
- package/bower.json +1 -3
- package/defaults.js +17 -5
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +5699 -5052
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.js +1 -1
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +5704 -5062
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +1 -1
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +5693 -5052
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +1 -1
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +5704 -5063
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +1 -1
- package/dist/rollbar.umd.min.js.map +1 -1
- package/docs/extension-exceptions.md +35 -30
- package/docs/migration_v0_to_v1.md +41 -38
- package/index.d.ts +270 -231
- package/karma.conf.js +16 -34
- package/package.json +21 -17
- package/prettier.config.js +7 -0
- package/src/api.js +21 -10
- package/src/apiUtility.js +12 -8
- package/src/browser/core.js +103 -65
- package/src/browser/defaults/scrubFields.js +3 -3
- package/src/browser/detection.js +7 -8
- package/src/browser/domUtility.js +18 -8
- package/src/browser/globalSetup.js +12 -6
- package/src/browser/logger.js +1 -1
- package/src/browser/plugins/jquery.js +35 -35
- package/src/browser/predicates.js +1 -1
- package/src/browser/rollbar.js +1 -1
- package/src/browser/rollbarWrapper.js +8 -5
- package/src/browser/shim.js +43 -19
- package/src/browser/snippet_callback.js +6 -4
- package/src/browser/telemetry.js +573 -354
- package/src/browser/transforms.js +46 -27
- package/src/browser/transport/fetch.js +16 -14
- package/src/browser/transport/xhr.js +29 -13
- package/src/browser/transport.js +82 -25
- package/src/browser/url.js +16 -8
- package/src/browser/wrapGlobals.js +27 -8
- package/src/defaults.js +3 -3
- package/src/errorParser.js +14 -11
- package/src/merge.js +32 -23
- package/src/notifier.js +16 -13
- package/src/predicates.js +43 -23
- package/src/queue.js +71 -39
- package/src/rateLimiter.js +59 -18
- package/src/react-native/logger.js +1 -1
- package/src/react-native/rollbar.js +59 -55
- package/src/react-native/transforms.js +13 -9
- package/src/react-native/transport.js +44 -34
- package/src/rollbar.js +22 -13
- package/src/scrub.js +0 -1
- package/src/server/locals.js +69 -39
- package/src/server/logger.js +4 -4
- package/src/server/parser.js +72 -47
- package/src/server/rollbar.js +133 -55
- package/src/server/sourceMap/stackTrace.js +33 -18
- package/src/server/telemetry/urlHelpers.js +9 -11
- package/src/server/telemetry.js +68 -45
- package/src/server/transforms.js +37 -21
- package/src/server/transport.js +62 -32
- package/src/telemetry.js +92 -28
- package/src/transforms.js +33 -21
- package/src/truncation.js +8 -5
- package/src/utility/headers.js +43 -43
- package/src/utility/replace.js +9 -0
- package/src/utility/traverse.js +1 -1
- package/src/utility.js +89 -52
- package/test/api.test.js +31 -29
- package/test/apiUtility.test.js +43 -44
- package/test/browser.core.test.js +141 -131
- package/test/browser.domUtility.test.js +52 -35
- package/test/browser.predicates.test.js +13 -13
- package/test/browser.rollbar.test.js +597 -503
- package/test/browser.telemetry.test.js +76 -0
- package/test/browser.transforms.test.js +146 -128
- package/test/browser.transport.test.js +54 -46
- package/test/browser.url.test.js +12 -11
- package/test/fixtures/locals.fixtures.js +245 -126
- package/test/notifier.test.js +90 -78
- package/test/predicates.test.js +260 -214
- package/test/queue.test.js +230 -214
- package/test/rateLimiter.test.js +50 -42
- package/test/react-native.rollbar.test.js +149 -115
- package/test/react-native.transforms.test.js +21 -23
- package/test/react-native.transport.test.js +23 -11
- package/test/server.lambda.test.js +70 -53
- package/test/server.locals.test.js +437 -210
- package/test/server.parser.test.js +32 -26
- package/test/server.predicates.test.js +45 -43
- package/test/server.rollbar.test.js +311 -259
- package/test/server.telemetry.test.js +208 -83
- package/test/server.transforms.test.js +455 -361
- package/test/server.transport.test.js +144 -76
- package/test/telemetry.test.js +46 -37
- package/test/transforms.test.js +68 -66
- package/test/truncation.test.js +55 -53
- package/test/utility.test.js +266 -222
- package/webpack.config.js +46 -43
- package/.gitmodules +0 -3
- package/browserstack.browsers.js +0 -153
- package/browserstack.browsers.json +0 -4384
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
var assert = require('assert');
|
|
4
4
|
var util = require('util');
|
|
@@ -6,101 +6,156 @@ var vows = require('vows');
|
|
|
6
6
|
var Transport = require('../src/server/transport');
|
|
7
7
|
var t = new Transport();
|
|
8
8
|
|
|
9
|
-
vows
|
|
9
|
+
vows
|
|
10
|
+
.describe('transport')
|
|
10
11
|
.addBatch({
|
|
11
|
-
|
|
12
|
+
post: {
|
|
12
13
|
'base data': {
|
|
13
|
-
topic: function() {
|
|
14
|
+
topic: function () {
|
|
14
15
|
return {
|
|
15
16
|
accessToken: 'abc123',
|
|
16
17
|
options: {},
|
|
17
18
|
payload: {
|
|
18
19
|
access_token: 'abc123',
|
|
19
|
-
data: {a: 1}
|
|
20
|
-
}
|
|
20
|
+
data: { a: 1 },
|
|
21
|
+
},
|
|
21
22
|
};
|
|
22
23
|
},
|
|
23
24
|
'with no payload': {
|
|
24
|
-
topic: function(data) {
|
|
25
|
-
var factory = transportFactory(
|
|
26
|
-
|
|
25
|
+
topic: function (data) {
|
|
26
|
+
var factory = transportFactory(
|
|
27
|
+
null,
|
|
28
|
+
'{"err": null, "result":"all good"}',
|
|
29
|
+
);
|
|
30
|
+
t.post(
|
|
31
|
+
data.accessToken,
|
|
32
|
+
data.options,
|
|
33
|
+
null,
|
|
34
|
+
this.callback,
|
|
35
|
+
factory,
|
|
36
|
+
);
|
|
27
37
|
},
|
|
28
|
-
'should have an error': function(err, resp) {
|
|
38
|
+
'should have an error': function (err, resp) {
|
|
29
39
|
assert.ok(err);
|
|
30
|
-
}
|
|
40
|
+
},
|
|
31
41
|
},
|
|
32
42
|
'with a payload and no error': {
|
|
33
|
-
topic: function(data) {
|
|
34
|
-
var factory = transportFactory(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
topic: function (data) {
|
|
44
|
+
var factory = transportFactory(
|
|
45
|
+
null,
|
|
46
|
+
'{"err": null, "result":{"uuid":"42def", "message":"all good"}}',
|
|
47
|
+
function () {
|
|
48
|
+
assert.equal(
|
|
49
|
+
this.options.headers['Content-Type'],
|
|
50
|
+
'application/json',
|
|
51
|
+
);
|
|
52
|
+
assert.isNumber(this.options.headers['Content-Length']);
|
|
53
|
+
assert(this.options.headers['Content-Length'] > 0);
|
|
54
|
+
assert.equal(
|
|
55
|
+
this.options.headers['X-Rollbar-Access-Token'],
|
|
56
|
+
data.accessToken,
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
t.post(
|
|
61
|
+
data.accessToken,
|
|
62
|
+
data.options,
|
|
63
|
+
data.payload,
|
|
64
|
+
this.callback,
|
|
65
|
+
factory,
|
|
66
|
+
);
|
|
42
67
|
},
|
|
43
|
-
'should not error': function(err, resp) {
|
|
68
|
+
'should not error': function (err, resp) {
|
|
44
69
|
assert.ifError(err);
|
|
45
70
|
},
|
|
46
|
-
'should have the right response data': function(err, resp) {
|
|
71
|
+
'should have the right response data': function (err, resp) {
|
|
47
72
|
assert.equal(resp.message, 'all good');
|
|
48
|
-
}
|
|
73
|
+
},
|
|
49
74
|
},
|
|
50
75
|
'with a payload and an error in the response': {
|
|
51
|
-
topic: function(data) {
|
|
52
|
-
var factory = transportFactory(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
topic: function (data) {
|
|
77
|
+
var factory = transportFactory(
|
|
78
|
+
null,
|
|
79
|
+
'{"err": "bork", "message":"things broke"}',
|
|
80
|
+
function () {
|
|
81
|
+
assert.equal(
|
|
82
|
+
this.options.headers['Content-Type'],
|
|
83
|
+
'application/json',
|
|
84
|
+
);
|
|
85
|
+
assert.isNumber(this.options.headers['Content-Length']);
|
|
86
|
+
assert(this.options.headers['Content-Length'] > 0);
|
|
87
|
+
assert.equal(
|
|
88
|
+
this.options.headers['X-Rollbar-Access-Token'],
|
|
89
|
+
data.accessToken,
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
t.post(
|
|
94
|
+
data.accessToken,
|
|
95
|
+
data.options,
|
|
96
|
+
data.payload,
|
|
97
|
+
this.callback,
|
|
98
|
+
factory,
|
|
99
|
+
);
|
|
60
100
|
},
|
|
61
|
-
'should error': function(err, resp) {
|
|
101
|
+
'should error': function (err, resp) {
|
|
62
102
|
assert.ok(err);
|
|
63
103
|
},
|
|
64
|
-
'should have the message somewhere': function(err, resp) {
|
|
104
|
+
'should have the message somewhere': function (err, resp) {
|
|
65
105
|
assert.match(err.message, /things broke/);
|
|
66
106
|
},
|
|
67
|
-
'should not have a response': function(err, resp) {
|
|
107
|
+
'should not have a response': function (err, resp) {
|
|
68
108
|
assert.ifError(resp);
|
|
69
|
-
}
|
|
109
|
+
},
|
|
70
110
|
},
|
|
71
111
|
'with a payload and an error during sending': {
|
|
72
|
-
topic: function(data) {
|
|
73
|
-
var factory = transportFactory(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
112
|
+
topic: function (data) {
|
|
113
|
+
var factory = transportFactory(
|
|
114
|
+
new Error('bork'),
|
|
115
|
+
null,
|
|
116
|
+
function () {
|
|
117
|
+
assert.equal(
|
|
118
|
+
this.options.headers['Content-Type'],
|
|
119
|
+
'application/json',
|
|
120
|
+
);
|
|
121
|
+
assert.isNumber(this.options.headers['Content-Length']);
|
|
122
|
+
assert(this.options.headers['Content-Length'] > 0);
|
|
123
|
+
assert.equal(
|
|
124
|
+
this.options.headers['X-Rollbar-Access-Token'],
|
|
125
|
+
data.accessToken,
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
t.post(
|
|
130
|
+
data.accessToken,
|
|
131
|
+
data.options,
|
|
132
|
+
data.payload,
|
|
133
|
+
this.callback,
|
|
134
|
+
factory,
|
|
135
|
+
);
|
|
81
136
|
},
|
|
82
|
-
'should error': function(err, resp) {
|
|
137
|
+
'should error': function (err, resp) {
|
|
83
138
|
assert.ok(err);
|
|
84
139
|
},
|
|
85
|
-
'should have the message somewhere': function(err, resp) {
|
|
140
|
+
'should have the message somewhere': function (err, resp) {
|
|
86
141
|
assert.match(err.message, /bork/);
|
|
87
142
|
},
|
|
88
|
-
'should not have a response': function(err, resp) {
|
|
143
|
+
'should not have a response': function (err, resp) {
|
|
89
144
|
assert.ifError(resp);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
145
|
+
},
|
|
146
|
+
},
|
|
92
147
|
},
|
|
93
148
|
'with rate limiting': {
|
|
94
|
-
topic: function() {
|
|
149
|
+
topic: function () {
|
|
95
150
|
return new Transport();
|
|
96
151
|
},
|
|
97
|
-
'should transmit non-rate limited requests': function(t) {
|
|
152
|
+
'should transmit non-rate limited requests': function (t) {
|
|
98
153
|
var response = new TestResponse({
|
|
99
154
|
statusCode: 200,
|
|
100
155
|
headers: {
|
|
101
156
|
'x-rate-limit-remaining': '1',
|
|
102
|
-
'x-rate-limit-remaining-seconds': '100'
|
|
103
|
-
}
|
|
157
|
+
'x-rate-limit-remaining-seconds': '100',
|
|
158
|
+
},
|
|
104
159
|
});
|
|
105
160
|
var error;
|
|
106
161
|
|
|
@@ -108,35 +163,48 @@ vows.describe('transport')
|
|
|
108
163
|
|
|
109
164
|
t.handleResponse(response);
|
|
110
165
|
|
|
111
|
-
var factory = transportFactory(
|
|
112
|
-
|
|
166
|
+
var factory = transportFactory(
|
|
167
|
+
null,
|
|
168
|
+
'{"err": null, "result": "all good"}',
|
|
169
|
+
);
|
|
170
|
+
t.post(
|
|
171
|
+
'token',
|
|
172
|
+
{},
|
|
173
|
+
'payload',
|
|
174
|
+
function (err) {
|
|
175
|
+
error = err;
|
|
176
|
+
},
|
|
177
|
+
factory,
|
|
178
|
+
);
|
|
113
179
|
|
|
114
180
|
assert.equal(error, null);
|
|
115
181
|
assert.isTrue(Math.floor(Date.now() / 1000) >= t.rateLimitExpires);
|
|
116
182
|
},
|
|
117
|
-
'should drop rate limited requests and set timeout': function(t) {
|
|
183
|
+
'should drop rate limited requests and set timeout': function (t) {
|
|
118
184
|
var response = new TestResponse({
|
|
119
185
|
statusCode: 429,
|
|
120
186
|
headers: {
|
|
121
187
|
'x-rate-limit-remaining': '0',
|
|
122
|
-
'x-rate-limit-remaining-seconds': '100'
|
|
123
|
-
}
|
|
188
|
+
'x-rate-limit-remaining-seconds': '100',
|
|
189
|
+
},
|
|
124
190
|
});
|
|
125
191
|
var error;
|
|
126
192
|
|
|
127
193
|
t.handleResponse(response);
|
|
128
194
|
|
|
129
|
-
t.post('token', {}, 'payload', function(err){
|
|
195
|
+
t.post('token', {}, 'payload', function (err) {
|
|
196
|
+
error = err;
|
|
197
|
+
});
|
|
130
198
|
|
|
131
199
|
assert.match(error.message, /Exceeded rate limit/);
|
|
132
200
|
assert.isTrue(Math.floor(Date.now() / 1000) < t.rateLimitExpires);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
136
204
|
})
|
|
137
|
-
.export(module, {error: false});
|
|
205
|
+
.export(module, { error: false });
|
|
138
206
|
|
|
139
|
-
var TestTransport = function(options, error, response, assertions) {
|
|
207
|
+
var TestTransport = function (options, error, response, assertions) {
|
|
140
208
|
this.options = options;
|
|
141
209
|
this.error = error;
|
|
142
210
|
this.response = response;
|
|
@@ -144,7 +212,7 @@ var TestTransport = function(options, error, response, assertions) {
|
|
|
144
212
|
this.requestCallback = null;
|
|
145
213
|
this.assertions = assertions;
|
|
146
214
|
};
|
|
147
|
-
var TestRequest = function(error, response, transport) {
|
|
215
|
+
var TestRequest = function (error, response, transport) {
|
|
148
216
|
this.error = error;
|
|
149
217
|
this.responseData = response;
|
|
150
218
|
this.data = [];
|
|
@@ -152,18 +220,18 @@ var TestRequest = function(error, response, transport) {
|
|
|
152
220
|
this.transport = transport;
|
|
153
221
|
this.response = null;
|
|
154
222
|
};
|
|
155
|
-
TestTransport.prototype.request = function(opts, cb) {
|
|
223
|
+
TestTransport.prototype.request = function (opts, cb) {
|
|
156
224
|
this.requestOpts = opts;
|
|
157
225
|
this.requestCallback = cb;
|
|
158
226
|
return new TestRequest(this.error, this.response, this);
|
|
159
227
|
};
|
|
160
|
-
TestRequest.prototype.write = function(data) {
|
|
228
|
+
TestRequest.prototype.write = function (data) {
|
|
161
229
|
this.data.push(data);
|
|
162
230
|
};
|
|
163
|
-
TestRequest.prototype.on = function(event, cb) {
|
|
231
|
+
TestRequest.prototype.on = function (event, cb) {
|
|
164
232
|
this.events[event] = cb;
|
|
165
233
|
};
|
|
166
|
-
TestRequest.prototype.end = function() {
|
|
234
|
+
TestRequest.prototype.end = function () {
|
|
167
235
|
if (this.transport.assertions) {
|
|
168
236
|
this.transport.assertions();
|
|
169
237
|
}
|
|
@@ -182,20 +250,20 @@ TestRequest.prototype.end = function() {
|
|
|
182
250
|
}
|
|
183
251
|
}
|
|
184
252
|
};
|
|
185
|
-
var TestResponse = function(options = {}) {
|
|
253
|
+
var TestResponse = function (options = {}) {
|
|
186
254
|
this.encoding = null;
|
|
187
255
|
this.events = {};
|
|
188
256
|
this.headers = options.headers || {};
|
|
189
257
|
this.statusCode = options.statusCode || 200;
|
|
190
258
|
};
|
|
191
|
-
TestResponse.prototype.setEncoding = function(s) {
|
|
259
|
+
TestResponse.prototype.setEncoding = function (s) {
|
|
192
260
|
this.encoding = s;
|
|
193
|
-
}
|
|
194
|
-
TestResponse.prototype.on = function(event, cb) {
|
|
261
|
+
};
|
|
262
|
+
TestResponse.prototype.on = function (event, cb) {
|
|
195
263
|
this.events[event] = cb;
|
|
196
264
|
};
|
|
197
|
-
var transportFactory = function(error, response, assertions) {
|
|
198
|
-
return function(options) {
|
|
265
|
+
var transportFactory = function (error, response, assertions) {
|
|
266
|
+
return function (options) {
|
|
199
267
|
return new TestTransport(options, error, response, assertions);
|
|
200
268
|
};
|
|
201
269
|
};
|
package/test/telemetry.test.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
var Telemeter = require('../src/telemetry');
|
|
7
7
|
|
|
8
|
-
describe('Telemetry()', function() {
|
|
9
|
-
it('should have all of the expected methods', function(done) {
|
|
8
|
+
describe('Telemetry()', function () {
|
|
9
|
+
it('should have all of the expected methods', function (done) {
|
|
10
10
|
var options = {};
|
|
11
11
|
var t = new Telemeter(options);
|
|
12
12
|
expect(t).to.have.property('copyEvents');
|
|
@@ -20,12 +20,12 @@ describe('Telemetry()', function() {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
describe('capture', function() {
|
|
24
|
-
it('should return a valid telemetry event', function(done) {
|
|
23
|
+
describe('capture', function () {
|
|
24
|
+
it('should return a valid telemetry event', function (done) {
|
|
25
25
|
var options = {};
|
|
26
26
|
var t = new Telemeter(options);
|
|
27
27
|
var now = +new Date();
|
|
28
|
-
var event = t.capture('network', {url: 'a.com'}, 'debug');
|
|
28
|
+
var event = t.capture('network', { url: 'a.com' }, 'debug');
|
|
29
29
|
expect(event.timestamp_ms - now).to.be.below(500);
|
|
30
30
|
expect(event.type).to.equal('network');
|
|
31
31
|
expect(event.level).to.equal('debug');
|
|
@@ -35,10 +35,10 @@ describe('capture', function() {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
describe('captureEvent', function() {
|
|
39
|
-
it('should return a valid telemetry event', function(done) {
|
|
38
|
+
describe('captureEvent', function () {
|
|
39
|
+
it('should return a valid telemetry event', function (done) {
|
|
40
40
|
var t = new Telemeter();
|
|
41
|
-
var event = t.captureEvent('log', {message: 'bar'}, 'info');
|
|
41
|
+
var event = t.captureEvent('log', { message: 'bar' }, 'info');
|
|
42
42
|
expect(event.type).to.equal('log');
|
|
43
43
|
expect(event.level).to.equal('info');
|
|
44
44
|
expect(event.body.message).to.equal('bar');
|
|
@@ -47,32 +47,41 @@ describe('captureEvent', function() {
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
describe('filterTelemetry', function() {
|
|
51
|
-
it(
|
|
50
|
+
describe('filterTelemetry', function () {
|
|
51
|
+
it("should filter out events that don't match the test", function (done) {
|
|
52
52
|
var options = {
|
|
53
|
-
filterTelemetry: function(e) {
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
filterTelemetry: function (e) {
|
|
54
|
+
return (
|
|
55
|
+
e.type === 'network' &&
|
|
56
|
+
(e.body.subtype === 'xhr' || e.body.subtype === 'fetch') &&
|
|
57
|
+
e.body.url.indexOf('https://spammer.com') === 0
|
|
58
|
+
);
|
|
59
|
+
},
|
|
58
60
|
};
|
|
59
61
|
var t = new Telemeter(options);
|
|
60
|
-
var evt = t.capture(
|
|
62
|
+
var evt = t.capture(
|
|
63
|
+
'network',
|
|
64
|
+
{ url: 'https://spammer.com', subtype: 'xhr' },
|
|
65
|
+
'debug',
|
|
66
|
+
);
|
|
61
67
|
expect(evt).to.be(false);
|
|
62
68
|
|
|
63
69
|
done();
|
|
64
70
|
});
|
|
65
71
|
|
|
66
|
-
it('should filter out events in copy even if they are modified after capture', function(done) {
|
|
72
|
+
it('should filter out events in copy even if they are modified after capture', function (done) {
|
|
67
73
|
var options = {
|
|
68
|
-
filterTelemetry: function(e) {
|
|
69
|
-
return e.type === 'network'
|
|
70
|
-
|
|
71
|
-
}
|
|
74
|
+
filterTelemetry: function (e) {
|
|
75
|
+
return e.type === 'network' && e.body.statusCode === 200;
|
|
76
|
+
},
|
|
72
77
|
};
|
|
73
78
|
var t = new Telemeter(options);
|
|
74
|
-
var evt = t.capture('network', {url: 'https://spammer.com'}, 'debug');
|
|
75
|
-
var evt2 = t.capture(
|
|
79
|
+
var evt = t.capture('network', { url: 'https://spammer.com' }, 'debug');
|
|
80
|
+
var evt2 = t.capture(
|
|
81
|
+
'network',
|
|
82
|
+
{ url: 'https://spammer.com', statusCode: 404 },
|
|
83
|
+
'debug',
|
|
84
|
+
);
|
|
76
85
|
expect(evt).not.to.be(false);
|
|
77
86
|
expect(evt2).not.to.be(false);
|
|
78
87
|
var events = t.copyEvents();
|
|
@@ -88,50 +97,50 @@ describe('filterTelemetry', function() {
|
|
|
88
97
|
});
|
|
89
98
|
});
|
|
90
99
|
|
|
91
|
-
describe('configure', function() {
|
|
92
|
-
it('should truncate events to new max', function(done) {
|
|
93
|
-
var options = {maxTelemetryEvents: 5};
|
|
100
|
+
describe('configure', function () {
|
|
101
|
+
it('should truncate events to new max', function (done) {
|
|
102
|
+
var options = { maxTelemetryEvents: 5 };
|
|
94
103
|
var t = new Telemeter(options);
|
|
95
104
|
|
|
96
105
|
for (var i = 0; i < 7; i++) {
|
|
97
|
-
t.capture('network', {url: 'a.com'}, 'debug');
|
|
106
|
+
t.capture('network', { url: 'a.com' }, 'debug');
|
|
98
107
|
}
|
|
99
108
|
|
|
100
109
|
expect(t.queue.length).to.equal(5);
|
|
101
|
-
t.configure({maxTelemetryEvents: 3});
|
|
110
|
+
t.configure({ maxTelemetryEvents: 3 });
|
|
102
111
|
expect(t.queue.length).to.equal(3);
|
|
103
112
|
done();
|
|
104
113
|
});
|
|
105
|
-
it('should lengthen events to allow new max', function(done) {
|
|
106
|
-
var options = {maxTelemetryEvents: 3};
|
|
114
|
+
it('should lengthen events to allow new max', function (done) {
|
|
115
|
+
var options = { maxTelemetryEvents: 3 };
|
|
107
116
|
var t = new Telemeter(options);
|
|
108
117
|
|
|
109
118
|
for (var i = 0; i < 7; i++) {
|
|
110
|
-
t.capture('network', {url: 'a.com'}, 'debug');
|
|
119
|
+
t.capture('network', { url: 'a.com' }, 'debug');
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
expect(t.queue.length).to.equal(3);
|
|
114
|
-
t.configure({maxTelemetryEvents: 5});
|
|
123
|
+
t.configure({ maxTelemetryEvents: 5 });
|
|
115
124
|
expect(t.queue.length).to.equal(3);
|
|
116
125
|
for (var i = 0; i < 7; i++) {
|
|
117
|
-
t.capture('network', {url: 'a.com'}, 'debug');
|
|
126
|
+
t.capture('network', { url: 'a.com' }, 'debug');
|
|
118
127
|
}
|
|
119
128
|
expect(t.queue.length).to.equal(5);
|
|
120
129
|
done();
|
|
121
130
|
});
|
|
122
|
-
it('does not drop existing options that are not passed to configure', function(done) {
|
|
123
|
-
var options = {maxTelemetryEvents: 3};
|
|
131
|
+
it('does not drop existing options that are not passed to configure', function (done) {
|
|
132
|
+
var options = { maxTelemetryEvents: 3 };
|
|
124
133
|
var t = new Telemeter(options);
|
|
125
134
|
|
|
126
135
|
for (var i = 0; i < 7; i++) {
|
|
127
|
-
t.capture('network', {url: 'a.com'}, 'debug');
|
|
136
|
+
t.capture('network', { url: 'a.com' }, 'debug');
|
|
128
137
|
}
|
|
129
138
|
|
|
130
139
|
expect(t.queue.length).to.equal(3);
|
|
131
140
|
t.configure({});
|
|
132
141
|
expect(t.queue.length).to.equal(3);
|
|
133
142
|
for (var i = 0; i < 7; i++) {
|
|
134
|
-
t.capture('network', {url: 'a.com'}, 'debug');
|
|
143
|
+
t.capture('network', { url: 'a.com' }, 'debug');
|
|
135
144
|
}
|
|
136
145
|
expect(t.queue.length).to.equal(3);
|
|
137
146
|
done();
|