@webex/internal-plugin-metrics 3.0.0-beta.2 → 3.0.0-beta.200
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 +1 -3
- package/dist/batcher.js +3 -22
- package/dist/batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +56 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +451 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +584 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +225 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +461 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/ClientEvent.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/ClientEvent.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/Event.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/Event.js.map +1 -0
- package/dist/call-diagnostic/generated-types-temp/MediaQualityEvent.js +7 -0
- package/dist/call-diagnostic/generated-types-temp/MediaQualityEvent.js.map +1 -0
- package/dist/client-metrics-batcher.js +1 -7
- package/dist/client-metrics-batcher.js.map +1 -1
- package/dist/config.js +21 -5
- package/dist/config.js.map +1 -1
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +43 -80
- package/dist/metrics.js.map +1 -1
- package/dist/metrics.types.js +7 -0
- package/dist/metrics.types.js.map +1 -0
- package/dist/new-metrics.js +249 -0
- package/dist/new-metrics.js.map +1 -0
- package/dist/types/batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +189 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +348 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +52 -0
- package/dist/types/call-diagnostic/config.d.ts +57 -0
- package/dist/types/call-diagnostic/generated-types-temp/ClientEvent.d.ts +1112 -0
- package/dist/types/call-diagnostic/generated-types-temp/Event.d.ts +4851 -0
- package/dist/types/call-diagnostic/generated-types-temp/MediaQualityEvent.d.ts +2121 -0
- package/dist/types/client-metrics-batcher.d.ts +2 -0
- package/dist/types/config.d.ts +35 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.types.d.ts +92 -0
- package/dist/types/new-metrics.d.ts +119 -0
- package/package.json +12 -8
- package/src/batcher.js +33 -26
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +51 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +408 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +591 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +233 -0
- package/src/call-diagnostic/config.ts +455 -0
- package/src/call-diagnostic/generated-types-temp/ClientEvent.ts +2395 -0
- package/src/call-diagnostic/generated-types-temp/Event.ts +7762 -0
- package/src/call-diagnostic/generated-types-temp/MediaQualityEvent.ts +2321 -0
- package/src/client-metrics-batcher.js +3 -4
- package/src/config.js +25 -5
- package/src/index.ts +39 -0
- package/src/metrics.js +44 -58
- package/src/metrics.types.ts +137 -0
- package/src/new-metrics.ts +223 -0
- package/test/unit/spec/batcher.js +26 -15
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +243 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +474 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +820 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +336 -0
- package/test/unit/spec/client-metrics-batcher.js +26 -15
- package/test/unit/spec/metrics.js +85 -116
- package/test/unit/spec/new-metrics.ts +153 -0
- package/tsconfig.json +6 -0
- package/dist/call-diagnostic-events-batcher.js +0 -70
- package/dist/call-diagnostic-events-batcher.js.map +0 -1
- package/src/call-diagnostic-events-batcher.js +0 -62
- package/src/index.js +0 -17
- package/test/unit/spec/call-diagnostic-events-batcher.js +0 -180
|
@@ -8,6 +8,9 @@ import {Token, Credentials} from '@webex/webex-core';
|
|
|
8
8
|
import FakeTimers from '@sinonjs/fake-timers';
|
|
9
9
|
import sinon from 'sinon';
|
|
10
10
|
import Metrics, {config} from '@webex/internal-plugin-metrics';
|
|
11
|
+
import {BrowserDetection} from '@webex/common';
|
|
12
|
+
|
|
13
|
+
const {getOSVersion} = BrowserDetection();
|
|
11
14
|
|
|
12
15
|
function promiseTick(count) {
|
|
13
16
|
let promise = Promise.resolve();
|
|
@@ -29,35 +32,35 @@ describe('plugin-metrics', () => {
|
|
|
29
32
|
const eventName = 'test_event';
|
|
30
33
|
const mockPayload = {
|
|
31
34
|
fields: {
|
|
32
|
-
testField: 123
|
|
35
|
+
testField: 123,
|
|
33
36
|
},
|
|
34
37
|
tags: {
|
|
35
|
-
testTag: 'tag value'
|
|
38
|
+
testTag: 'tag value',
|
|
36
39
|
},
|
|
37
40
|
metricName: eventName,
|
|
38
41
|
test: 'this field should not be included in final payload',
|
|
39
42
|
type: 'behavioral',
|
|
40
|
-
eventPayload: {value: 'splunk business metric payload'}
|
|
43
|
+
eventPayload: {value: 'splunk business metric payload'},
|
|
41
44
|
};
|
|
42
45
|
const transformedProps = {
|
|
43
46
|
fields: {
|
|
44
|
-
testField: 123
|
|
47
|
+
testField: 123,
|
|
45
48
|
},
|
|
46
49
|
tags: {
|
|
47
|
-
testTag: 'tag value'
|
|
50
|
+
testTag: 'tag value',
|
|
48
51
|
},
|
|
49
52
|
metricName: eventName,
|
|
50
53
|
type: 'behavioral',
|
|
51
|
-
timestamp: Date.now()
|
|
54
|
+
timestamp: Date.now(),
|
|
52
55
|
};
|
|
53
56
|
const preLoginId = '1b90cf5e-27a6-41aa-a208-1f6eb6b9e6b6';
|
|
54
57
|
const preLoginProps = {
|
|
55
|
-
metrics: [transformedProps]
|
|
58
|
+
metrics: [transformedProps],
|
|
56
59
|
};
|
|
57
60
|
const mockCallDiagnosticEvent = {
|
|
58
61
|
originTime: {
|
|
59
|
-
triggered: 'mock triggered timestamp'
|
|
60
|
-
}
|
|
62
|
+
triggered: 'mock triggered timestamp',
|
|
63
|
+
},
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
beforeEach(() => {
|
|
@@ -71,8 +74,8 @@ describe('plugin-metrics', () => {
|
|
|
71
74
|
beforeEach(() => {
|
|
72
75
|
webex = new MockWebex({
|
|
73
76
|
children: {
|
|
74
|
-
metrics: Metrics
|
|
75
|
-
}
|
|
77
|
+
metrics: Metrics,
|
|
78
|
+
},
|
|
76
79
|
});
|
|
77
80
|
|
|
78
81
|
webex.config.metrics = config.metrics;
|
|
@@ -82,7 +85,7 @@ describe('plugin-metrics', () => {
|
|
|
82
85
|
return Promise.resolve({
|
|
83
86
|
statusCode: 204,
|
|
84
87
|
body: undefined,
|
|
85
|
-
options
|
|
88
|
+
options,
|
|
86
89
|
});
|
|
87
90
|
};
|
|
88
91
|
|
|
@@ -94,8 +97,7 @@ describe('plugin-metrics', () => {
|
|
|
94
97
|
...webex.config,
|
|
95
98
|
appName: 'appName',
|
|
96
99
|
appPlatform: 'appPlatform',
|
|
97
|
-
appVersion: 'appVersion'
|
|
98
|
-
|
|
100
|
+
appVersion: 'appVersion',
|
|
99
101
|
};
|
|
100
102
|
webex.config.metrics.type = ['operational'];
|
|
101
103
|
webex.config.metrics.appType = 'sdk';
|
|
@@ -103,7 +105,6 @@ describe('plugin-metrics', () => {
|
|
|
103
105
|
sinon.spy(webex, 'request');
|
|
104
106
|
sinon.spy(metrics, 'postPreLoginMetric');
|
|
105
107
|
sinon.spy(metrics, 'aliasUser');
|
|
106
|
-
sinon.spy(metrics, 'submitCallDiagnosticEvents');
|
|
107
108
|
});
|
|
108
109
|
|
|
109
110
|
describe('#submit()', () => {
|
|
@@ -132,6 +133,67 @@ describe('plugin-metrics', () => {
|
|
|
132
133
|
});
|
|
133
134
|
});
|
|
134
135
|
|
|
136
|
+
describe('#getClientMetricsPayload()', () => {
|
|
137
|
+
it('returns the expected payload', () => {
|
|
138
|
+
webex.credentials.supertoken = new Token(
|
|
139
|
+
{
|
|
140
|
+
access_token: 'a_b_orgid',
|
|
141
|
+
},
|
|
142
|
+
{parent: webex}
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const testPayload = {
|
|
146
|
+
tags: {success: true},
|
|
147
|
+
fields: {perceivedDurationInMillis: 314},
|
|
148
|
+
context: {},
|
|
149
|
+
eventPayload: {value: 'splunk business metric payload'},
|
|
150
|
+
};
|
|
151
|
+
const date = clock.now;
|
|
152
|
+
|
|
153
|
+
const result = metrics.getClientMetricsPayload('test', testPayload);
|
|
154
|
+
|
|
155
|
+
assert.deepEqual(result, {
|
|
156
|
+
context: {
|
|
157
|
+
app: {
|
|
158
|
+
version: undefined,
|
|
159
|
+
},
|
|
160
|
+
locale: 'en-US',
|
|
161
|
+
os: {
|
|
162
|
+
name: 'other',
|
|
163
|
+
version: getOSVersion(),
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
eventPayload: {
|
|
167
|
+
value: 'splunk business metric payload',
|
|
168
|
+
},
|
|
169
|
+
fields: {
|
|
170
|
+
browser_version: '',
|
|
171
|
+
client_id: 'fake',
|
|
172
|
+
os_version: getOSVersion(),
|
|
173
|
+
perceivedDurationInMillis: 314,
|
|
174
|
+
platform: 'Web',
|
|
175
|
+
sdk_version: undefined,
|
|
176
|
+
spark_user_agent: 'webex-js-sdk appName/appVersion appPlatform',
|
|
177
|
+
},
|
|
178
|
+
metricName: 'test',
|
|
179
|
+
tags: {
|
|
180
|
+
browser: '',
|
|
181
|
+
domain: 'whatever',
|
|
182
|
+
os: 'other',
|
|
183
|
+
success: true,
|
|
184
|
+
},
|
|
185
|
+
timestamp: 0,
|
|
186
|
+
type: ['operational'],
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('throws when no event name is specified', () => {
|
|
191
|
+
assert.throws(() => {
|
|
192
|
+
metrics.getClientMetricsPayload();
|
|
193
|
+
}, 'Missing behavioral metric name. Please provide one');
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
135
197
|
describe('#submitClientMetrics()', () => {
|
|
136
198
|
describe('before login', () => {
|
|
137
199
|
it('posts pre-login metric', () => {
|
|
@@ -167,15 +229,18 @@ describe('plugin-metrics', () => {
|
|
|
167
229
|
});
|
|
168
230
|
describe('after login', () => {
|
|
169
231
|
it('submits a metric to clientmetrics', () => {
|
|
170
|
-
webex.credentials.supertoken = new Token(
|
|
171
|
-
|
|
172
|
-
|
|
232
|
+
webex.credentials.supertoken = new Token(
|
|
233
|
+
{
|
|
234
|
+
access_token: 'a_b_orgid',
|
|
235
|
+
},
|
|
236
|
+
{parent: webex}
|
|
237
|
+
);
|
|
173
238
|
|
|
174
239
|
const testPayload = {
|
|
175
240
|
tags: {success: true},
|
|
176
241
|
fields: {perceivedDurationInMillis: 314},
|
|
177
242
|
context: {},
|
|
178
|
-
eventPayload: {value: 'splunk business metric payload'}
|
|
243
|
+
eventPayload: {value: 'splunk business metric payload'},
|
|
179
244
|
};
|
|
180
245
|
const date = clock.now;
|
|
181
246
|
|
|
@@ -197,23 +262,20 @@ describe('plugin-metrics', () => {
|
|
|
197
262
|
assert.property(metric, 'eventPayload');
|
|
198
263
|
|
|
199
264
|
assert.property(metric.tags, 'browser');
|
|
200
|
-
assert.property(metric.tags, 'org_id');
|
|
201
265
|
assert.property(metric.tags, 'os');
|
|
202
266
|
assert.property(metric.tags, 'domain');
|
|
203
|
-
assert.property(metric.tags, 'client_id');
|
|
204
|
-
assert.property(metric.tags, 'user_id');
|
|
205
267
|
|
|
206
268
|
assert.property(metric.fields, 'browser_version');
|
|
207
269
|
assert.property(metric.fields, 'os_version');
|
|
208
270
|
assert.property(metric.fields, 'sdk_version');
|
|
209
271
|
assert.property(metric.fields, 'platform');
|
|
210
272
|
assert.property(metric.fields, 'spark_user_agent');
|
|
273
|
+
assert.property(metric.fields, 'client_id');
|
|
211
274
|
|
|
212
275
|
assert.property(metric.context, 'app');
|
|
213
276
|
assert.property(metric.context, 'locale');
|
|
214
277
|
assert.property(metric.context, 'os');
|
|
215
278
|
|
|
216
|
-
|
|
217
279
|
assert.equal(metric.timestamp, date);
|
|
218
280
|
assert.equal(metric.metricName, 'test');
|
|
219
281
|
assert.equal(metric.tags.success, true);
|
|
@@ -268,98 +330,5 @@ describe('plugin-metrics', () => {
|
|
|
268
330
|
assert.match(params, {alias: true});
|
|
269
331
|
}));
|
|
270
332
|
});
|
|
271
|
-
|
|
272
|
-
describe('#submitCallDiagnosticEvents()', () => {
|
|
273
|
-
it('submits a call diagnostic event', () => {
|
|
274
|
-
const promise = metrics.submitCallDiagnosticEvents(mockCallDiagnosticEvent);
|
|
275
|
-
|
|
276
|
-
return promiseTick(50)
|
|
277
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
278
|
-
.then(() => promise)
|
|
279
|
-
.then(() => {
|
|
280
|
-
assert.calledOnce(webex.request);
|
|
281
|
-
const req = webex.request.args[0][0];
|
|
282
|
-
const metric = req.body.metrics[0];
|
|
283
|
-
|
|
284
|
-
assert.property(metric.eventPayload, 'origin');
|
|
285
|
-
assert.property(metric.eventPayload, 'originTime');
|
|
286
|
-
assert.property(metric.eventPayload.origin, 'buildType');
|
|
287
|
-
assert.property(metric.eventPayload.origin, 'networkType');
|
|
288
|
-
assert.property(metric.eventPayload.originTime, 'sent');
|
|
289
|
-
assert.equal(metric.eventPayload.origin.buildType, 'test');
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('submits a call diagnostic event with buildType set in the payload', () => {
|
|
294
|
-
const promise = metrics.submitCallDiagnosticEvents({
|
|
295
|
-
...mockCallDiagnosticEvent,
|
|
296
|
-
origin: {
|
|
297
|
-
buildType: 'prod'
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
return promiseTick(50)
|
|
302
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
303
|
-
.then(() => promise)
|
|
304
|
-
.then(() => {
|
|
305
|
-
assert.calledOnce(webex.request);
|
|
306
|
-
const req = webex.request.args[0][0];
|
|
307
|
-
const metric = req.body.metrics[0];
|
|
308
|
-
|
|
309
|
-
assert.property(metric.eventPayload, 'origin');
|
|
310
|
-
assert.property(metric.eventPayload, 'originTime');
|
|
311
|
-
assert.property(metric.eventPayload.origin, 'buildType');
|
|
312
|
-
assert.property(metric.eventPayload.origin, 'networkType');
|
|
313
|
-
assert.property(metric.eventPayload.originTime, 'sent');
|
|
314
|
-
assert.equal(metric.eventPayload.origin.buildType, 'prod');
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
xit('submits a call diagnostic event with a test domain', () => {
|
|
319
|
-
global.window.location.hostname = 'test.webex.com';
|
|
320
|
-
|
|
321
|
-
const promise = metrics.submitCallDiagnosticEvents(mockCallDiagnosticEvent);
|
|
322
|
-
|
|
323
|
-
return promiseTick(50)
|
|
324
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
325
|
-
.then(() => promise)
|
|
326
|
-
.then(() => {
|
|
327
|
-
assert.calledOnce(webex.request);
|
|
328
|
-
const req = webex.request.args[0][0];
|
|
329
|
-
const metric = req.body.metrics[0];
|
|
330
|
-
|
|
331
|
-
assert.property(metric.eventPayload, 'origin');
|
|
332
|
-
assert.property(metric.eventPayload, 'originTime');
|
|
333
|
-
assert.property(metric.eventPayload.origin, 'buildType');
|
|
334
|
-
assert.property(metric.eventPayload.origin, 'networkType');
|
|
335
|
-
assert.property(metric.eventPayload.originTime, 'sent');
|
|
336
|
-
assert.equal(metric.eventPayload.origin.buildType, 'test');
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
// Skip because it's current unable to overwrite NODE_ENV
|
|
341
|
-
// However doing `NODE_ENV=test npm run test ...` will get this test case to pass
|
|
342
|
-
xit('submits a call diagnostic event with a NODE_ENV=production', () => {
|
|
343
|
-
process.env.NODE_ENV = 'production';
|
|
344
|
-
|
|
345
|
-
const promise = metrics.submitCallDiagnosticEvents(mockCallDiagnosticEvent);
|
|
346
|
-
|
|
347
|
-
return promiseTick(50)
|
|
348
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
349
|
-
.then(() => promise)
|
|
350
|
-
.then(() => {
|
|
351
|
-
assert.calledOnce(webex.request);
|
|
352
|
-
const req = webex.request.args[0][0];
|
|
353
|
-
const metric = req.body.metrics[0];
|
|
354
|
-
|
|
355
|
-
assert.property(metric.eventPayload, 'origin');
|
|
356
|
-
assert.property(metric.eventPayload, 'originTime');
|
|
357
|
-
assert.property(metric.eventPayload.origin, 'buildType');
|
|
358
|
-
assert.property(metric.eventPayload.origin, 'networkType');
|
|
359
|
-
assert.property(metric.eventPayload.originTime, 'sent');
|
|
360
|
-
assert.equal(metric.eventPayload.origin.buildType, 'prod');
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
333
|
});
|
|
365
334
|
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {assert} from '@webex/test-helper-chai';
|
|
2
|
+
import {NewMetrics} from '@webex/internal-plugin-metrics';
|
|
3
|
+
import MockWebex from '@webex/test-helper-mock-webex';
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
|
|
6
|
+
describe('internal-plugin-metrics', () => {
|
|
7
|
+
describe('new-metrics', () => {
|
|
8
|
+
let webex;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
webex = new MockWebex({
|
|
13
|
+
children: {
|
|
14
|
+
newMetrics: NewMetrics,
|
|
15
|
+
},
|
|
16
|
+
meetings: {
|
|
17
|
+
meetingCollection: {
|
|
18
|
+
get: sinon.stub(),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
webex.emit('ready');
|
|
24
|
+
|
|
25
|
+
webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp = sinon.stub();
|
|
26
|
+
webex.internal.newMetrics.callDiagnosticLatencies.clearTimestamps = sinon.stub();
|
|
27
|
+
webex.internal.newMetrics.callDiagnosticMetrics.submitClientEvent = sinon.stub();
|
|
28
|
+
webex.internal.newMetrics.callDiagnosticMetrics.submitMQE = sinon.stub();
|
|
29
|
+
webex.internal.newMetrics.callDiagnosticMetrics.buildClientEventFetchRequestOptions =
|
|
30
|
+
sinon.stub();
|
|
31
|
+
webex.setTimingsAndFetch = sinon.stub();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('submits Client Event successfully', () => {
|
|
35
|
+
webex.internal.newMetrics.submitClientEvent({
|
|
36
|
+
name: 'client.alert.displayed',
|
|
37
|
+
options: {
|
|
38
|
+
meetingId: '123',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
assert.calledWith(webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp, {
|
|
43
|
+
key: 'client.alert.displayed',
|
|
44
|
+
options: {meetingId: '123'},
|
|
45
|
+
});
|
|
46
|
+
assert.calledWith(webex.internal.newMetrics.callDiagnosticMetrics.submitClientEvent, {
|
|
47
|
+
name: 'client.alert.displayed',
|
|
48
|
+
payload: undefined,
|
|
49
|
+
options: {meetingId: '123'},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('submits MQE successfully', () => {
|
|
54
|
+
webex.internal.newMetrics.submitMQE({
|
|
55
|
+
name: 'client.mediaquality.event',
|
|
56
|
+
//@ts-ignore
|
|
57
|
+
payload: {intervals: [{}]},
|
|
58
|
+
options: {
|
|
59
|
+
meetingId: '123',
|
|
60
|
+
networkType: 'wifi',
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
assert.calledWith(webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp, {
|
|
65
|
+
key: 'client.mediaquality.event',
|
|
66
|
+
});
|
|
67
|
+
assert.calledWith(webex.internal.newMetrics.callDiagnosticMetrics.submitMQE, {
|
|
68
|
+
name: 'client.mediaquality.event',
|
|
69
|
+
//@ts-ignore
|
|
70
|
+
payload: {intervals: [{}]},
|
|
71
|
+
options: {
|
|
72
|
+
meetingId: '123',
|
|
73
|
+
networkType: 'wifi',
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('submits Internal Event successfully', () => {
|
|
79
|
+
webex.internal.newMetrics.submitInternalEvent({
|
|
80
|
+
name: 'client.mediaquality.event',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
assert.calledWith(webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp, {
|
|
84
|
+
key: 'client.mediaquality.event',
|
|
85
|
+
});
|
|
86
|
+
assert.notCalled(webex.internal.newMetrics.callDiagnosticLatencies.clearTimestamps);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('submits Internal Event successfully for clearing the join latencies', () => {
|
|
90
|
+
webex.internal.newMetrics.submitInternalEvent({
|
|
91
|
+
name: 'internal.reset.join.latencies',
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
assert.notCalled(webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp);
|
|
95
|
+
assert.calledOnce(webex.internal.newMetrics.callDiagnosticLatencies.clearTimestamps);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('#buildClientEventFetchRequestOptions', () => {
|
|
99
|
+
it('builds client event fetch options successfully', () => {
|
|
100
|
+
webex.internal.newMetrics.buildClientEventFetchRequestOptions({
|
|
101
|
+
name: 'client.alert.displayed',
|
|
102
|
+
options: {
|
|
103
|
+
meetingId: '123',
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
assert.calledWith(
|
|
108
|
+
webex.internal.newMetrics.callDiagnosticMetrics.buildClientEventFetchRequestOptions,
|
|
109
|
+
{
|
|
110
|
+
name: 'client.alert.displayed',
|
|
111
|
+
payload: undefined,
|
|
112
|
+
options: {meetingId: '123'},
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('#setMetricTimingsAndFetch', () => {
|
|
119
|
+
beforeEach(() => {
|
|
120
|
+
global.fetch = sinon.stub();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('calls fetch with the expected options', () => {
|
|
124
|
+
const now = new Date();
|
|
125
|
+
sinon.useFakeTimers(now.getTime());
|
|
126
|
+
|
|
127
|
+
webex.internal.newMetrics.setMetricTimingsAndFetch({
|
|
128
|
+
body: {metrics: [{eventPayload: {}}]},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const expected = {
|
|
132
|
+
body: {
|
|
133
|
+
metrics: [
|
|
134
|
+
{
|
|
135
|
+
eventPayload: {
|
|
136
|
+
originTime: {
|
|
137
|
+
triggered: now.toISOString(),
|
|
138
|
+
sent: now.toISOString(),
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
sinon.assert.calledOnce(webex.setTimingsAndFetch);
|
|
147
|
+
sinon.assert.calledWith(webex.setTimingsAndFetch, expected);
|
|
148
|
+
|
|
149
|
+
sinon.restore();
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
_Object$defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.default = void 0;
|
|
12
|
-
|
|
13
|
-
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
14
|
-
|
|
15
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
16
|
-
|
|
17
|
-
var _batcher = _interopRequireDefault(require("./batcher"));
|
|
18
|
-
|
|
19
|
-
/*!
|
|
20
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
21
|
-
*/
|
|
22
|
-
var CallDiagnosticEventsBatcher = _batcher.default.extend({
|
|
23
|
-
namespace: 'Metrics',
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {string} webClientDomain
|
|
27
|
-
* @returns {string}
|
|
28
|
-
*/
|
|
29
|
-
getBuildType: function getBuildType(webClientDomain) {
|
|
30
|
-
if (webClientDomain !== null && webClientDomain !== void 0 && webClientDomain.includes('teams.webex.com') || webClientDomain !== null && webClientDomain !== void 0 && webClientDomain.includes('localhost') || webClientDomain !== null && webClientDomain !== void 0 && webClientDomain.includes('127.0.0.1') || process.env.NODE_ENV !== 'production') {
|
|
31
|
-
return 'test';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return process.env.NODE_ENV === 'production' ? 'prod' : 'test';
|
|
35
|
-
},
|
|
36
|
-
prepareItem: function prepareItem(item) {
|
|
37
|
-
var _item$event, _item$event$eventData;
|
|
38
|
-
|
|
39
|
-
// networkType should be a enum value: `wifi`, `ethernet`, `cellular`, or `unknown`.
|
|
40
|
-
// Browsers cannot provide such information right now. However, it is a required field.
|
|
41
|
-
var origin = {
|
|
42
|
-
buildType: this.getBuildType((_item$event = item.event) === null || _item$event === void 0 ? void 0 : (_item$event$eventData = _item$event.eventData) === null || _item$event$eventData === void 0 ? void 0 : _item$event$eventData.webClientDomain),
|
|
43
|
-
networkType: 'unknown'
|
|
44
|
-
};
|
|
45
|
-
item.eventPayload.origin = (0, _assign.default)(origin, item.eventPayload.origin);
|
|
46
|
-
return _promise.default.resolve(item);
|
|
47
|
-
},
|
|
48
|
-
prepareRequest: function prepareRequest(queue) {
|
|
49
|
-
// Add sent timestamp
|
|
50
|
-
queue.forEach(function (item) {
|
|
51
|
-
item.eventPayload.originTime = item.eventPayload.originTime || {};
|
|
52
|
-
item.eventPayload.originTime.sent = new Date().toISOString();
|
|
53
|
-
});
|
|
54
|
-
return _promise.default.resolve(queue);
|
|
55
|
-
},
|
|
56
|
-
submitHttpRequest: function submitHttpRequest(payload) {
|
|
57
|
-
return this.webex.request({
|
|
58
|
-
method: 'POST',
|
|
59
|
-
service: 'metrics',
|
|
60
|
-
resource: 'clientmetrics',
|
|
61
|
-
body: {
|
|
62
|
-
metrics: payload
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
var _default = CallDiagnosticEventsBatcher;
|
|
69
|
-
exports.default = _default;
|
|
70
|
-
//# sourceMappingURL=call-diagnostic-events-batcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CallDiagnosticEventsBatcher","Batcher","extend","namespace","getBuildType","webClientDomain","includes","process","env","NODE_ENV","prepareItem","item","origin","buildType","event","eventData","networkType","eventPayload","resolve","prepareRequest","queue","forEach","originTime","sent","Date","toISOString","submitHttpRequest","payload","webex","request","method","service","resource","body","metrics"],"sources":["call-diagnostic-events-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport Batcher from './batcher';\n\nconst CallDiagnosticEventsBatcher = Batcher.extend({\n namespace: 'Metrics',\n\n /**\n * @param {string} webClientDomain\n * @returns {string}\n */\n getBuildType(webClientDomain) {\n if (\n webClientDomain?.includes('teams.webex.com') ||\n webClientDomain?.includes('localhost') ||\n webClientDomain?.includes('127.0.0.1') ||\n process.env.NODE_ENV !== 'production'\n ) {\n return 'test';\n }\n\n return process.env.NODE_ENV === 'production' ? 'prod' : 'test';\n },\n\n prepareItem(item) {\n // networkType should be a enum value: `wifi`, `ethernet`, `cellular`, or `unknown`.\n // Browsers cannot provide such information right now. However, it is a required field.\n const origin = {\n buildType: this.getBuildType(item.event?.eventData?.webClientDomain),\n networkType: 'unknown'\n };\n\n item.eventPayload.origin = Object.assign(origin, item.eventPayload.origin);\n\n return Promise.resolve(item);\n },\n\n prepareRequest(queue) {\n // Add sent timestamp\n queue.forEach((item) => {\n item.eventPayload.originTime = item.eventPayload.originTime || {};\n item.eventPayload.originTime.sent = new Date().toISOString();\n });\n\n return Promise.resolve(queue);\n },\n\n submitHttpRequest(payload) {\n return this.webex.request({\n method: 'POST',\n service: 'metrics',\n resource: 'clientmetrics',\n body: {\n metrics: payload\n }\n });\n }\n});\n\nexport default CallDiagnosticEventsBatcher;\n"],"mappings":";;;;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,IAAMA,2BAA2B,GAAGC,gBAAA,CAAQC,MAAR,CAAe;EACjDC,SAAS,EAAE,SADsC;;EAGjD;AACF;AACA;AACA;EACEC,YAPiD,wBAOpCC,eAPoC,EAOnB;IAC5B,IACEA,eAAe,SAAf,IAAAA,eAAe,WAAf,IAAAA,eAAe,CAAEC,QAAjB,CAA0B,iBAA1B,KACAD,eADA,aACAA,eADA,eACAA,eAAe,CAAEC,QAAjB,CAA0B,WAA1B,CADA,IAEAD,eAFA,aAEAA,eAFA,eAEAA,eAAe,CAAEC,QAAjB,CAA0B,WAA1B,CAFA,IAGAC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAJ3B,EAKE;MACA,OAAO,MAAP;IACD;;IAED,OAAOF,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAAzB,GAAwC,MAAxC,GAAiD,MAAxD;EACD,CAlBgD;EAoBjDC,WApBiD,uBAoBrCC,IApBqC,EAoB/B;IAAA;;IAChB;IACA;IACA,IAAMC,MAAM,GAAG;MACbC,SAAS,EAAE,KAAKT,YAAL,gBAAkBO,IAAI,CAACG,KAAvB,yEAAkB,YAAYC,SAA9B,0DAAkB,sBAAuBV,eAAzC,CADE;MAEbW,WAAW,EAAE;IAFA,CAAf;IAKAL,IAAI,CAACM,YAAL,CAAkBL,MAAlB,GAA2B,qBAAcA,MAAd,EAAsBD,IAAI,CAACM,YAAL,CAAkBL,MAAxC,CAA3B;IAEA,OAAO,iBAAQM,OAAR,CAAgBP,IAAhB,CAAP;EACD,CA/BgD;EAiCjDQ,cAjCiD,0BAiClCC,KAjCkC,EAiC3B;IACpB;IACAA,KAAK,CAACC,OAAN,CAAc,UAACV,IAAD,EAAU;MACtBA,IAAI,CAACM,YAAL,CAAkBK,UAAlB,GAA+BX,IAAI,CAACM,YAAL,CAAkBK,UAAlB,IAAgC,EAA/D;MACAX,IAAI,CAACM,YAAL,CAAkBK,UAAlB,CAA6BC,IAA7B,GAAoC,IAAIC,IAAJ,GAAWC,WAAX,EAApC;IACD,CAHD;IAKA,OAAO,iBAAQP,OAAR,CAAgBE,KAAhB,CAAP;EACD,CAzCgD;EA2CjDM,iBA3CiD,6BA2C/BC,OA3C+B,EA2CtB;IACzB,OAAO,KAAKC,KAAL,CAAWC,OAAX,CAAmB;MACxBC,MAAM,EAAE,MADgB;MAExBC,OAAO,EAAE,SAFe;MAGxBC,QAAQ,EAAE,eAHc;MAIxBC,IAAI,EAAE;QACJC,OAAO,EAAEP;MADL;IAJkB,CAAnB,CAAP;EAQD;AApDgD,CAAf,CAApC;;eAuDe3B,2B"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import Batcher from './batcher';
|
|
6
|
-
|
|
7
|
-
const CallDiagnosticEventsBatcher = Batcher.extend({
|
|
8
|
-
namespace: 'Metrics',
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} webClientDomain
|
|
12
|
-
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
getBuildType(webClientDomain) {
|
|
15
|
-
if (
|
|
16
|
-
webClientDomain?.includes('teams.webex.com') ||
|
|
17
|
-
webClientDomain?.includes('localhost') ||
|
|
18
|
-
webClientDomain?.includes('127.0.0.1') ||
|
|
19
|
-
process.env.NODE_ENV !== 'production'
|
|
20
|
-
) {
|
|
21
|
-
return 'test';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return process.env.NODE_ENV === 'production' ? 'prod' : 'test';
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
prepareItem(item) {
|
|
28
|
-
// networkType should be a enum value: `wifi`, `ethernet`, `cellular`, or `unknown`.
|
|
29
|
-
// Browsers cannot provide such information right now. However, it is a required field.
|
|
30
|
-
const origin = {
|
|
31
|
-
buildType: this.getBuildType(item.event?.eventData?.webClientDomain),
|
|
32
|
-
networkType: 'unknown'
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
item.eventPayload.origin = Object.assign(origin, item.eventPayload.origin);
|
|
36
|
-
|
|
37
|
-
return Promise.resolve(item);
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
prepareRequest(queue) {
|
|
41
|
-
// Add sent timestamp
|
|
42
|
-
queue.forEach((item) => {
|
|
43
|
-
item.eventPayload.originTime = item.eventPayload.originTime || {};
|
|
44
|
-
item.eventPayload.originTime.sent = new Date().toISOString();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return Promise.resolve(queue);
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
submitHttpRequest(payload) {
|
|
51
|
-
return this.webex.request({
|
|
52
|
-
method: 'POST',
|
|
53
|
-
service: 'metrics',
|
|
54
|
-
resource: 'clientmetrics',
|
|
55
|
-
body: {
|
|
56
|
-
metrics: payload
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export default CallDiagnosticEventsBatcher;
|
package/src/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '@webex/internal-plugin-device';
|
|
6
|
-
|
|
7
|
-
import {registerInternalPlugin} from '@webex/webex-core';
|
|
8
|
-
|
|
9
|
-
import Metrics from './metrics';
|
|
10
|
-
import config from './config';
|
|
11
|
-
|
|
12
|
-
registerInternalPlugin('metrics', Metrics, {
|
|
13
|
-
config
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export {default} from './metrics';
|
|
17
|
-
export {config};
|