@webex/internal-plugin-metrics 3.11.0 → 3.12.0
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 +3 -2
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +11 -2
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
- package/dist/call-diagnostic/config.js +1 -0
- package/dist/call-diagnostic/config.js.map +1 -1
- package/dist/generic-metrics.js +8 -6
- package/dist/generic-metrics.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +56 -20
- package/dist/new-metrics.js.map +1 -1
- package/dist/prelogin-metrics.js +106 -0
- package/dist/prelogin-metrics.js.map +1 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +7 -2
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +5 -0
- package/dist/types/call-diagnostic/config.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/metrics.types.d.ts +2 -2
- package/dist/types/new-metrics.d.ts +12 -0
- package/dist/types/prelogin-metrics.d.ts +47 -0
- package/package.json +11 -11
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +3 -5
- package/src/call-diagnostic/call-diagnostic-metrics.ts +1 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +15 -1
- package/src/call-diagnostic/config.ts +1 -0
- package/src/generic-metrics.ts +6 -6
- package/src/index.ts +2 -0
- package/src/metrics.types.ts +2 -2
- package/src/new-metrics.ts +42 -0
- package/src/prelogin-metrics.ts +94 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +33 -9
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +120 -117
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +35 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +34 -3
- package/test/unit/spec/prelogin-metrics.ts +132 -0
|
@@ -27,6 +27,7 @@ const {
|
|
|
27
27
|
isUnauthorizedError,
|
|
28
28
|
generateClientErrorCodeForIceFailure,
|
|
29
29
|
isSdpOfferCreationError,
|
|
30
|
+
isWebrtcApiNotAvailableError,
|
|
30
31
|
} = CallDiagnosticUtils;
|
|
31
32
|
|
|
32
33
|
describe('internal-plugin-metrics', () => {
|
|
@@ -206,6 +207,29 @@ describe('internal-plugin-metrics', () => {
|
|
|
206
207
|
});
|
|
207
208
|
});
|
|
208
209
|
|
|
210
|
+
describe('isWebrtcApiNotAvailableError', () => {
|
|
211
|
+
type TestWebrtcApiNotAvailableError = {
|
|
212
|
+
code: number;
|
|
213
|
+
message: string;
|
|
214
|
+
name: string;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const error: TestWebrtcApiNotAvailableError = {
|
|
218
|
+
code: 30007,
|
|
219
|
+
name: 'WebrtcApiNotAvailableError',
|
|
220
|
+
message: 'RTCPeerConnection API is not available in this environment',
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
[
|
|
224
|
+
['WebrtcApiNotAvailableError', error, true],
|
|
225
|
+
['generic error', new Error('this is an error'), false],
|
|
226
|
+
].forEach(([errorType, rawError, expected]) => {
|
|
227
|
+
it(`for ${errorType} rawError returns the correct result`, () => {
|
|
228
|
+
assert.strictEqual(isWebrtcApiNotAvailableError(rawError), expected);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
209
233
|
describe('isBrowserMediaErrorName', () => {
|
|
210
234
|
[
|
|
211
235
|
['PermissionDeniedError', true],
|
|
@@ -287,7 +311,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
287
311
|
origin: {
|
|
288
312
|
buildType: 'prod',
|
|
289
313
|
networkType: 'unknown',
|
|
290
|
-
upgradeChannel: expectedUpgradeChannel
|
|
314
|
+
upgradeChannel: expectedUpgradeChannel,
|
|
291
315
|
},
|
|
292
316
|
event: {name: eventName, ...expectedEvent},
|
|
293
317
|
},
|
|
@@ -369,7 +393,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
369
393
|
totalJmt: undefined,
|
|
370
394
|
clientJmt: undefined,
|
|
371
395
|
downloadTime: undefined,
|
|
372
|
-
clickToInterstitialWithUserDelay:
|
|
396
|
+
clickToInterstitialWithUserDelay: undefined,
|
|
373
397
|
totalJMTWithUserDelay: undefined,
|
|
374
398
|
},
|
|
375
399
|
},
|
|
@@ -406,7 +430,6 @@ describe('internal-plugin-metrics', () => {
|
|
|
406
430
|
totalMediaJMT: undefined,
|
|
407
431
|
interstitialToMediaOKJMT: undefined,
|
|
408
432
|
callInitMediaEngineReady: undefined,
|
|
409
|
-
stayLobbyTime: undefined,
|
|
410
433
|
totalMediaJMTWithUserDelay: undefined,
|
|
411
434
|
totalJMTWithUserDelay: undefined,
|
|
412
435
|
},
|
|
@@ -423,6 +446,14 @@ describe('internal-plugin-metrics', () => {
|
|
|
423
446
|
},
|
|
424
447
|
},
|
|
425
448
|
],
|
|
449
|
+
[
|
|
450
|
+
'client.lobby.exited',
|
|
451
|
+
{
|
|
452
|
+
joinTimes: {
|
|
453
|
+
stayLobbyTime: undefined,
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
],
|
|
426
457
|
].forEach(([eventName, expectedEvent]) => {
|
|
427
458
|
it(`returns expected result for ${eventName}`, () => {
|
|
428
459
|
check(eventName as string, expectedEvent, 'gold');
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import PreLoginMetricsBatcher from '../../../src/prelogin-metrics-batcher';
|
|
2
|
+
import {PreLoginMetrics} from '@webex/internal-plugin-metrics';
|
|
3
|
+
import {assert} from '@webex/test-helper-chai';
|
|
4
|
+
import MockWebex from '@webex/test-helper-mock-webex';
|
|
5
|
+
import sinon from 'sinon';
|
|
6
|
+
|
|
7
|
+
describe('internal-plugin-metrics', () => {
|
|
8
|
+
const mockedWebex: MockWebex = new MockWebex();
|
|
9
|
+
const fakedPreLoginMetricsBatcher: typeof PreLoginMetricsBatcher = new PreLoginMetricsBatcher({}, {parent: mockedWebex});
|
|
10
|
+
|
|
11
|
+
describe('prelogin-metrics', () => {
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
sinon.restore();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('Should send metrics to preloginMetricsBatcher', async () => {
|
|
17
|
+
const testEvent = 'test';
|
|
18
|
+
const testId = 'abc123';
|
|
19
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
20
|
+
|
|
21
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
22
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
23
|
+
|
|
24
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: testId, payload: {}});
|
|
25
|
+
|
|
26
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
27
|
+
type: ['business'],
|
|
28
|
+
eventPayload: {metricName: testEvent, value: {preLoginId: testId}},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('Should send metadata to preloginMetricsBatcher', async () => {
|
|
33
|
+
const testEvent = 'test';
|
|
34
|
+
const testId = 'abc123';
|
|
35
|
+
const testMetadata = { 'testKey': 'test-value' };
|
|
36
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
37
|
+
|
|
38
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
39
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
40
|
+
|
|
41
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: testId, payload: {}, metadata: testMetadata});
|
|
42
|
+
|
|
43
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
44
|
+
type: ['business'],
|
|
45
|
+
eventPayload: {metricName: testEvent, value: {preLoginId: testId, ...testMetadata}},
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('Should send payload to preloginMetricsBatcher', async () => {
|
|
50
|
+
const testEvent = 'test';
|
|
51
|
+
const testId = 'abc123';
|
|
52
|
+
const testPayload = { 'testKey': 'test-value' };
|
|
53
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
54
|
+
|
|
55
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
56
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
57
|
+
|
|
58
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: testId, payload: testPayload});
|
|
59
|
+
|
|
60
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
61
|
+
type: ['business'],
|
|
62
|
+
eventPayload: {metricName: testEvent, value: {preLoginId: testId, ...testPayload}},
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('Should fill appType if not defined', async () => {
|
|
67
|
+
const testEvent = 'test';
|
|
68
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
69
|
+
|
|
70
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
71
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
72
|
+
|
|
73
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: 'abc123', payload: {}});
|
|
74
|
+
|
|
75
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
76
|
+
type: ['business'],
|
|
77
|
+
eventPayload: {metricName: testEvent, value: {appType: 'Web Client'}},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('Should add browser details', async () => {
|
|
82
|
+
const testEvent = 'test';
|
|
83
|
+
const testBrowserDetails = { browser: 'Firefox', domain: 'test.example.com' };
|
|
84
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
85
|
+
|
|
86
|
+
sinon.stub(preLoginMetrics, 'getBrowserDetails').returns(testBrowserDetails);
|
|
87
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
88
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
89
|
+
|
|
90
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: 'abc123', payload: {}});
|
|
91
|
+
|
|
92
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
93
|
+
type: ['business'],
|
|
94
|
+
eventPayload: {browserDetails: testBrowserDetails, metricName: testEvent},
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('Should add context', async () => {
|
|
99
|
+
const testEvent = 'test';
|
|
100
|
+
const testContext = { device: { id: 'abc123' }};
|
|
101
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
102
|
+
|
|
103
|
+
sinon.stub(preLoginMetrics, 'getContext').returns(testContext);
|
|
104
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
105
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
106
|
+
|
|
107
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: 'abc123', payload: {}});
|
|
108
|
+
|
|
109
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
110
|
+
type: ['business'],
|
|
111
|
+
eventPayload: {context: testContext, metricName: testEvent},
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('Should add timestamp', async () => {
|
|
116
|
+
const testEvent = 'test';
|
|
117
|
+
const testTime = 1234;
|
|
118
|
+
const preLoginMetrics = new PreLoginMetrics(fakedPreLoginMetricsBatcher, {}, {parent: mockedWebex});
|
|
119
|
+
|
|
120
|
+
sinon.useFakeTimers(testTime);
|
|
121
|
+
sinon.stub(fakedPreLoginMetricsBatcher, 'savePreLoginId');
|
|
122
|
+
const requestSpy = sinon.stub(fakedPreLoginMetricsBatcher, 'request');
|
|
123
|
+
|
|
124
|
+
await preLoginMetrics.submitPreLoginEvent({name: testEvent, preLoginId: 'abc123', payload: {}});
|
|
125
|
+
|
|
126
|
+
assert.calledOnceWithMatch(requestSpy, {
|
|
127
|
+
type: ['business'],
|
|
128
|
+
eventPayload: {metricName: testEvent, timestamp: testTime},
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|