@webex/internal-plugin-metrics 3.0.0 → 3.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +90 -14
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +39 -29
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +10 -3
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
- package/dist/client-metrics-prelogin-batcher.js +32 -0
- package/dist/client-metrics-prelogin-batcher.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +10 -25
- package/dist/metrics.js.map +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +5 -4
- package/dist/new-metrics.js.map +1 -1
- package/dist/prelogin-metrics-batcher.js +1 -1
- package/dist/prelogin-metrics-batcher.js.map +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +41 -8
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +10 -12
- package/dist/types/client-metrics-prelogin-batcher.d.ts +2 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/metrics.types.d.ts +3 -1
- package/package.json +13 -13
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +89 -13
- package/src/call-diagnostic/call-diagnostic-metrics.ts +14 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +17 -3
- package/src/client-metrics-prelogin-batcher.ts +26 -0
- package/src/index.ts +2 -0
- package/src/metrics.js +8 -23
- package/src/metrics.types.ts +12 -1
- package/src/new-metrics.ts +2 -2
- package/src/prelogin-metrics-batcher.ts +1 -1
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +18 -7
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +199 -1
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +122 -24
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +28 -7
- package/test/unit/spec/client-metrics-prelogin-batcher.ts +54 -0
- package/test/unit/spec/metrics.js +9 -31
- package/test/unit/spec/new-metrics.ts +29 -31
- package/test/unit/spec/prelogin-metrics-batcher.ts +6 -3
|
@@ -104,9 +104,15 @@ describe('plugin-metrics', () => {
|
|
|
104
104
|
};
|
|
105
105
|
webex.config.metrics.type = ['operational'];
|
|
106
106
|
webex.config.metrics.appType = 'sdk';
|
|
107
|
+
webex.meetings = {
|
|
108
|
+
config: {
|
|
109
|
+
metrics: {
|
|
110
|
+
clientVersion: '43.0.105'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
107
114
|
|
|
108
115
|
sinon.spy(webex, 'request');
|
|
109
|
-
sinon.spy(metrics, 'postPreLoginMetric');
|
|
110
116
|
sinon.spy(metrics, 'aliasUser');
|
|
111
117
|
});
|
|
112
118
|
|
|
@@ -180,6 +186,7 @@ describe('plugin-metrics', () => {
|
|
|
180
186
|
},
|
|
181
187
|
metricName: 'test',
|
|
182
188
|
tags: {
|
|
189
|
+
appVersion: '43.0.105',
|
|
183
190
|
browser: '',
|
|
184
191
|
domain: 'whatever',
|
|
185
192
|
os: 'other',
|
|
@@ -199,7 +206,7 @@ describe('plugin-metrics', () => {
|
|
|
199
206
|
|
|
200
207
|
describe('#submitClientMetrics()', () => {
|
|
201
208
|
describe('before login', () => {
|
|
202
|
-
it('
|
|
209
|
+
it('clientMetricsPreloginBatcher pre-login metric', () => {
|
|
203
210
|
const date = clock.now;
|
|
204
211
|
const promise = metrics.submitClientMetrics(eventName, mockPayload, preLoginId);
|
|
205
212
|
|
|
@@ -207,8 +214,6 @@ describe('plugin-metrics', () => {
|
|
|
207
214
|
.then(() => clock.tick(config.metrics.batcherWait))
|
|
208
215
|
.then(() => promise)
|
|
209
216
|
.then(() => {
|
|
210
|
-
assert.called(metrics.postPreLoginMetric);
|
|
211
|
-
assert.calledOnce(webex.credentials.getClientToken);
|
|
212
217
|
assert.calledOnce(webex.request);
|
|
213
218
|
const req = webex.request.args[0][0];
|
|
214
219
|
const metric = req.body.metrics[0];
|
|
@@ -296,33 +301,6 @@ describe('plugin-metrics', () => {
|
|
|
296
301
|
});
|
|
297
302
|
});
|
|
298
303
|
|
|
299
|
-
describe('#postPreLoginMetric()', () => {
|
|
300
|
-
it('returns an HttpResponse object', () => {
|
|
301
|
-
const promise = metrics.postPreLoginMetric(preLoginProps, preLoginId);
|
|
302
|
-
|
|
303
|
-
return promiseTick(50)
|
|
304
|
-
.then(() => clock.tick(config.metrics.batcherWait))
|
|
305
|
-
.then(() => promise)
|
|
306
|
-
.then(() => {
|
|
307
|
-
assert.calledOnce(webex.request);
|
|
308
|
-
const req = webex.request.args[0][0];
|
|
309
|
-
const metric = req.body.metrics[0];
|
|
310
|
-
const {headers} = req;
|
|
311
|
-
|
|
312
|
-
assert.property(headers, 'x-prelogin-userid');
|
|
313
|
-
assert.property(metric, 'metricName');
|
|
314
|
-
assert.property(metric, 'tags');
|
|
315
|
-
assert.property(metric, 'fields');
|
|
316
|
-
assert.property(metric, 'timestamp');
|
|
317
|
-
|
|
318
|
-
assert.equal(metric.timestamp, transformedProps.timestamp);
|
|
319
|
-
assert.equal(metric.metricName, eventName);
|
|
320
|
-
assert.equal(metric.tags.testTag, 'tag value');
|
|
321
|
-
assert.equal(metric.fields.testField, 123);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
304
|
describe('#aliasUser()', () => {
|
|
327
305
|
it('returns an HttpResponse object', () =>
|
|
328
306
|
metrics.aliasUser(preLoginId).then(() => {
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import {assert} from '@webex/test-helper-chai';
|
|
2
|
-
import {NewMetrics} from '@webex/internal-plugin-metrics';
|
|
2
|
+
import {NewMetrics, CallDiagnosticLatencies} from '@webex/internal-plugin-metrics';
|
|
3
3
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
4
4
|
import sinon from 'sinon';
|
|
5
5
|
import {Utils} from '@webex/internal-plugin-metrics';
|
|
6
6
|
|
|
7
7
|
describe('internal-plugin-metrics', () => {
|
|
8
8
|
|
|
9
|
+
const mockWebex = () => new MockWebex({
|
|
10
|
+
children: {
|
|
11
|
+
newMetrics: NewMetrics,
|
|
12
|
+
},
|
|
13
|
+
meetings: {
|
|
14
|
+
meetingCollection: {
|
|
15
|
+
get: sinon.stub(),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
request: sinon.stub().resolves({}),
|
|
19
|
+
logger: {
|
|
20
|
+
log: sinon.stub(),
|
|
21
|
+
error: sinon.stub(),
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
9
25
|
describe('check submitClientEvent when webex is not ready', () => {
|
|
10
26
|
let webex;
|
|
11
27
|
//@ts-ignore
|
|
12
|
-
webex =
|
|
13
|
-
children: {
|
|
14
|
-
newMetrics: NewMetrics,
|
|
15
|
-
},
|
|
16
|
-
meetings: {
|
|
17
|
-
meetingCollection: {
|
|
18
|
-
get: sinon.stub(),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
request: sinon.stub().resolves({}),
|
|
22
|
-
logger: {
|
|
23
|
-
log: sinon.stub(),
|
|
24
|
-
error: sinon.stub(),
|
|
25
|
-
}
|
|
26
|
-
});
|
|
28
|
+
webex = mockWebex();
|
|
27
29
|
|
|
28
30
|
it('checks the log', () => {
|
|
29
31
|
webex.internal.newMetrics.submitClientEvent({
|
|
@@ -38,26 +40,22 @@ describe('internal-plugin-metrics', () => {
|
|
|
38
40
|
);
|
|
39
41
|
});
|
|
40
42
|
});
|
|
43
|
+
|
|
44
|
+
describe('new-metrics contstructor', () => {
|
|
45
|
+
it('checks callDiagnosticLatencies is defined before ready emit', () => {
|
|
46
|
+
|
|
47
|
+
const webex = mockWebex();
|
|
48
|
+
|
|
49
|
+
assert.instanceOf(webex.internal.newMetrics.callDiagnosticLatencies, CallDiagnosticLatencies);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
41
53
|
describe('new-metrics', () => {
|
|
42
54
|
let webex;
|
|
43
55
|
|
|
44
56
|
beforeEach(() => {
|
|
45
57
|
//@ts-ignore
|
|
46
|
-
webex =
|
|
47
|
-
children: {
|
|
48
|
-
newMetrics: NewMetrics,
|
|
49
|
-
},
|
|
50
|
-
meetings: {
|
|
51
|
-
meetingCollection: {
|
|
52
|
-
get: sinon.stub(),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
request: sinon.stub().resolves({}),
|
|
56
|
-
logger: {
|
|
57
|
-
log: sinon.stub(),
|
|
58
|
-
error: sinon.stub(),
|
|
59
|
-
}
|
|
60
|
-
});
|
|
58
|
+
webex = mockWebex();
|
|
61
59
|
|
|
62
60
|
webex.emit('ready');
|
|
63
61
|
|
|
@@ -74,6 +74,8 @@ describe('internal-plugin-metrics', () => {
|
|
|
74
74
|
joinTimes: {
|
|
75
75
|
meetingInfoReqResp: undefined,
|
|
76
76
|
clickToInterstitial: undefined,
|
|
77
|
+
refreshCaptchaServiceReqResp: undefined,
|
|
78
|
+
downloadIntelligenceModelsReqResp: undefined,
|
|
77
79
|
},
|
|
78
80
|
name: 'client.interstitial-window.launched',
|
|
79
81
|
},
|
|
@@ -138,7 +140,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
138
140
|
assert.calledOnceWithExactly(
|
|
139
141
|
webex.logger.error,
|
|
140
142
|
'Pre Login Metrics -->',
|
|
141
|
-
`PreLoginMetricsBatcher: @submitHttpRequest#prelogin-
|
|
143
|
+
`PreLoginMetricsBatcher: @submitHttpRequest#prelogin-batch-${expectedBatchId}. Request failed:`,
|
|
142
144
|
`error: formattedError`
|
|
143
145
|
);
|
|
144
146
|
assert.lengthOf(
|
|
@@ -148,7 +150,8 @@ describe('internal-plugin-metrics', () => {
|
|
|
148
150
|
});
|
|
149
151
|
|
|
150
152
|
it('fails if preLoinId is not set', async () => {
|
|
151
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.preLoginId =
|
|
153
|
+
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.preLoginId =
|
|
154
|
+
undefined;
|
|
152
155
|
|
|
153
156
|
const promise =
|
|
154
157
|
webex.internal.newMetrics.callDiagnosticMetrics.submitToCallDiagnosticsPreLogin(
|
|
@@ -176,7 +179,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
176
179
|
|
|
177
180
|
describe('prepareItem', () => {
|
|
178
181
|
it('calls prepareDiagnosticMetricItem correctly', async () => {
|
|
179
|
-
|
|
182
|
+
// avoid setting .sent timestamp
|
|
180
183
|
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.prepareRequest = (q) =>
|
|
181
184
|
Promise.resolve(q);
|
|
182
185
|
|