@webex/internal-plugin-metrics 3.0.0-beta.33 → 3.0.0-beta.331
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/batcher.js +2 -1
- package/dist/batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +65 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +456 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +819 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +337 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +610 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/client-metrics-batcher.js +2 -1
- package/dist/client-metrics-batcher.js.map +1 -1
- package/dist/config.js +22 -2
- package/dist/config.js.map +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +30 -30
- 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 +333 -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 +194 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +417 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +96 -0
- package/dist/types/call-diagnostic/config.d.ts +172 -0
- package/dist/types/client-metrics-batcher.d.ts +2 -0
- package/dist/types/config.d.ts +36 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.types.d.ts +104 -0
- package/dist/types/new-metrics.d.ts +139 -0
- package/dist/types/utils.d.ts +6 -0
- package/dist/utils.js +27 -0
- package/dist/utils.js.map +1 -0
- package/package.json +13 -8
- package/src/batcher.js +1 -0
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +75 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +419 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +864 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +362 -0
- package/src/call-diagnostic/config.ts +666 -0
- package/src/client-metrics-batcher.js +1 -0
- package/src/config.js +20 -0
- package/src/index.ts +43 -0
- package/src/metrics.js +25 -27
- package/src/metrics.types.ts +160 -0
- package/src/new-metrics.ts +317 -0
- package/src/utils.ts +17 -0
- package/test/unit/spec/batcher.js +2 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +452 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +506 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +2035 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +565 -0
- package/test/unit/spec/client-metrics-batcher.js +2 -0
- package/test/unit/spec/metrics.js +66 -97
- package/test/unit/spec/new-metrics.ts +267 -0
- package/test/unit/spec/utils.ts +22 -0
- package/tsconfig.json +6 -0
- package/dist/call-diagnostic-events-batcher.js +0 -60
- 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 -195
|
@@ -0,0 +1,2035 @@
|
|
|
1
|
+
import sinon from 'sinon';
|
|
2
|
+
import {assert} from '@webex/test-helper-chai';
|
|
3
|
+
import {WebexHttpError} from '@webex/webex-core';
|
|
4
|
+
|
|
5
|
+
import CallDiagnosticMetrics from '../../../../src/call-diagnostic/call-diagnostic-metrics';
|
|
6
|
+
import CallDiagnosticLatencies from '../../../../src/call-diagnostic/call-diagnostic-metrics-latencies';
|
|
7
|
+
import * as Utils from '../../../../src/call-diagnostic/call-diagnostic-metrics.util';
|
|
8
|
+
import {BrowserDetection} from '@webex/common';
|
|
9
|
+
import {getOSNameInternal} from '@webex/internal-plugin-metrics';
|
|
10
|
+
import uuid from 'uuid';
|
|
11
|
+
import {omit} from 'lodash';
|
|
12
|
+
import CONFIG from '../../../../src/config';
|
|
13
|
+
|
|
14
|
+
//@ts-ignore
|
|
15
|
+
global.window = {location: {hostname: 'whatever'}};
|
|
16
|
+
|
|
17
|
+
const {getOSName, getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();
|
|
18
|
+
const userAgent = `webex-js-sdk/test-webex-version client=Cantina; (os=${getOSName()}/${
|
|
19
|
+
getOSVersion().split('.')[0]
|
|
20
|
+
})`;
|
|
21
|
+
|
|
22
|
+
describe('internal-plugin-metrics', () => {
|
|
23
|
+
describe('CallDiagnosticMetrics', () => {
|
|
24
|
+
var now = new Date();
|
|
25
|
+
|
|
26
|
+
let cd: CallDiagnosticMetrics;
|
|
27
|
+
|
|
28
|
+
const fakeMeeting = {
|
|
29
|
+
id: '1',
|
|
30
|
+
correlationId: 'correlationId',
|
|
31
|
+
callStateForMetrics: {},
|
|
32
|
+
environment: 'meeting_evn',
|
|
33
|
+
locusUrl: 'locus/url',
|
|
34
|
+
locusInfo: {
|
|
35
|
+
fullState: {
|
|
36
|
+
lastActive: 'lastActive',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
meetingInfo: {},
|
|
40
|
+
getCurUserType: () => 'host',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const fakeMeeting2 = {
|
|
44
|
+
...fakeMeeting,
|
|
45
|
+
id: '2',
|
|
46
|
+
correlationId: 'correlationId2',
|
|
47
|
+
callStateForMetrics: {loginType: 'fakeLoginType'},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const fakeMeetings = {
|
|
51
|
+
1: fakeMeeting,
|
|
52
|
+
2: fakeMeeting2,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let webex;
|
|
56
|
+
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
webex = {
|
|
59
|
+
canAuthorize: true,
|
|
60
|
+
version: 'webex-version',
|
|
61
|
+
internal: {
|
|
62
|
+
services: {
|
|
63
|
+
get: () => 'locus-url',
|
|
64
|
+
},
|
|
65
|
+
metrics: {
|
|
66
|
+
submitClientMetrics: sinon.stub(),
|
|
67
|
+
config: {...CONFIG.metrics},
|
|
68
|
+
},
|
|
69
|
+
newMetrics: {
|
|
70
|
+
postPreLoginMetric: sinon.stub(),
|
|
71
|
+
},
|
|
72
|
+
device: {
|
|
73
|
+
userId: 'userId',
|
|
74
|
+
url: 'deviceUrl',
|
|
75
|
+
orgId: 'orgId',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
meetings: {
|
|
79
|
+
config: {
|
|
80
|
+
metrics: {
|
|
81
|
+
clientType: 'TEAMS_CLIENT',
|
|
82
|
+
subClientType: 'WEB_APP',
|
|
83
|
+
clientName: 'Cantina',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
meetingCollection: {
|
|
87
|
+
get: (id) => fakeMeetings[id],
|
|
88
|
+
},
|
|
89
|
+
geoHintInfo: {
|
|
90
|
+
clientAddress: '1.3.4.5',
|
|
91
|
+
countryCode: 'UK',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
credentials: {
|
|
95
|
+
isUnverifiedGuest: false,
|
|
96
|
+
},
|
|
97
|
+
prepareFetchOptions: sinon.stub().callsFake((opts: any) => ({...opts, foo: 'bar'})),
|
|
98
|
+
request: sinon.stub().resolves({body: {}}),
|
|
99
|
+
logger: {
|
|
100
|
+
log: sinon.stub(),
|
|
101
|
+
error: sinon.stub(),
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
webex.internal.newMetrics.callDiagnosticLatencies = new CallDiagnosticLatencies(
|
|
106
|
+
{},
|
|
107
|
+
{parent: webex}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
sinon.createSandbox();
|
|
111
|
+
sinon.useFakeTimers(now.getTime());
|
|
112
|
+
cd = new CallDiagnosticMetrics({}, {parent: webex});
|
|
113
|
+
sinon.stub(uuid, 'v4').returns('my-fake-id');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
afterEach(() => {
|
|
117
|
+
sinon.restore();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('#validator', () => {
|
|
121
|
+
it('should have a validator function defined', () => {
|
|
122
|
+
assert.isDefined(cd.validator);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('#getOrigin', () => {
|
|
127
|
+
it('should build origin correctly', () => {
|
|
128
|
+
sinon.stub(Utils, 'anonymizeIPAddress').returns('1.1.1.1');
|
|
129
|
+
|
|
130
|
+
//@ts-ignore
|
|
131
|
+
const res = cd.getOrigin(
|
|
132
|
+
{subClientType: 'WEB_APP', clientType: 'TEAMS_CLIENT'},
|
|
133
|
+
fakeMeeting.id
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
assert.deepEqual(res, {
|
|
137
|
+
clientInfo: {
|
|
138
|
+
browser: getBrowserName(),
|
|
139
|
+
browserVersion: getBrowserVersion(),
|
|
140
|
+
clientType: 'TEAMS_CLIENT',
|
|
141
|
+
clientVersion: 'webex-js-sdk/webex-version',
|
|
142
|
+
localNetworkPrefix: '1.1.1.1',
|
|
143
|
+
os: getOSNameInternal(),
|
|
144
|
+
osVersion: getOSVersion(),
|
|
145
|
+
subClientType: 'WEB_APP',
|
|
146
|
+
},
|
|
147
|
+
environment: 'meeting_evn',
|
|
148
|
+
name: 'endpoint',
|
|
149
|
+
networkType: 'unknown',
|
|
150
|
+
userAgent,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should build origin correctly with newEnvironment and createLaunchMethod', () => {
|
|
155
|
+
sinon.stub(Utils, 'anonymizeIPAddress').returns('1.1.1.1');
|
|
156
|
+
|
|
157
|
+
//@ts-ignore
|
|
158
|
+
const res = cd.getOrigin(
|
|
159
|
+
{
|
|
160
|
+
subClientType: 'WEB_APP',
|
|
161
|
+
clientType: 'TEAMS_CLIENT',
|
|
162
|
+
newEnvironment: 'test-new-env',
|
|
163
|
+
clientLaunchMethod: 'url-handler',
|
|
164
|
+
},
|
|
165
|
+
fakeMeeting.id
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
assert.deepEqual(res, {
|
|
169
|
+
clientInfo: {
|
|
170
|
+
browser: getBrowserName(),
|
|
171
|
+
browserVersion: getBrowserVersion(),
|
|
172
|
+
clientType: 'TEAMS_CLIENT',
|
|
173
|
+
clientVersion: 'webex-js-sdk/webex-version',
|
|
174
|
+
localNetworkPrefix: '1.1.1.1',
|
|
175
|
+
os: getOSNameInternal(),
|
|
176
|
+
osVersion: getOSVersion(),
|
|
177
|
+
subClientType: 'WEB_APP',
|
|
178
|
+
clientLaunchMethod: 'url-handler',
|
|
179
|
+
},
|
|
180
|
+
environment: 'meeting_evn',
|
|
181
|
+
newEnvironment: 'test-new-env',
|
|
182
|
+
name: 'endpoint',
|
|
183
|
+
networkType: 'unknown',
|
|
184
|
+
userAgent,
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should build origin correctly and environment can be passed in options', () => {
|
|
189
|
+
sinon.stub(Utils, 'anonymizeIPAddress').returns('1.1.1.1');
|
|
190
|
+
|
|
191
|
+
//@ts-ignore
|
|
192
|
+
const res = cd.getOrigin(
|
|
193
|
+
{
|
|
194
|
+
subClientType: 'WEB_APP',
|
|
195
|
+
clientType: 'TEAMS_CLIENT',
|
|
196
|
+
clientLaunchMethod: 'url-handler',
|
|
197
|
+
environment: 'test-env',
|
|
198
|
+
},
|
|
199
|
+
fakeMeeting.id
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
assert.deepEqual(res, {
|
|
203
|
+
clientInfo: {
|
|
204
|
+
browser: getBrowserName(),
|
|
205
|
+
browserVersion: getBrowserVersion(),
|
|
206
|
+
clientType: 'TEAMS_CLIENT',
|
|
207
|
+
clientVersion: 'webex-js-sdk/webex-version',
|
|
208
|
+
localNetworkPrefix: '1.1.1.1',
|
|
209
|
+
os: getOSNameInternal(),
|
|
210
|
+
osVersion: getOSVersion(),
|
|
211
|
+
subClientType: 'WEB_APP',
|
|
212
|
+
clientLaunchMethod: 'url-handler',
|
|
213
|
+
},
|
|
214
|
+
environment: 'test-env',
|
|
215
|
+
name: 'endpoint',
|
|
216
|
+
networkType: 'unknown',
|
|
217
|
+
userAgent,
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('should build origin correctly with no meeting', () => {
|
|
222
|
+
sinon.stub(Utils, 'anonymizeIPAddress').returns('1.1.1.1');
|
|
223
|
+
|
|
224
|
+
//@ts-ignore
|
|
225
|
+
const res = cd.getOrigin();
|
|
226
|
+
|
|
227
|
+
assert.deepEqual(res, {
|
|
228
|
+
clientInfo: {
|
|
229
|
+
browser: getBrowserName(),
|
|
230
|
+
browserVersion: getBrowserVersion(),
|
|
231
|
+
clientType: 'TEAMS_CLIENT',
|
|
232
|
+
clientVersion: 'webex-js-sdk/webex-version',
|
|
233
|
+
localNetworkPrefix: '1.1.1.1',
|
|
234
|
+
os: getOSNameInternal(),
|
|
235
|
+
osVersion: getOSVersion(),
|
|
236
|
+
subClientType: 'WEB_APP',
|
|
237
|
+
},
|
|
238
|
+
name: 'endpoint',
|
|
239
|
+
networkType: 'unknown',
|
|
240
|
+
userAgent,
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('builds origin correctly, when overriding clientVersion', () => {
|
|
245
|
+
webex.meetings.config.metrics.clientVersion = '43.9.0.1234';
|
|
246
|
+
|
|
247
|
+
//@ts-ignore
|
|
248
|
+
const res = cd.getOrigin(
|
|
249
|
+
{subClientType: 'WEB_APP', clientType: 'TEAMS_CLIENT'},
|
|
250
|
+
fakeMeeting.id
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
assert.deepEqual(res, {
|
|
254
|
+
clientInfo: {
|
|
255
|
+
browser: getBrowserName(),
|
|
256
|
+
browserVersion: getBrowserVersion(),
|
|
257
|
+
clientType: 'TEAMS_CLIENT',
|
|
258
|
+
clientVersion: '43.9.0.1234',
|
|
259
|
+
localNetworkPrefix: '1.3.4.0',
|
|
260
|
+
majorVersion: 43,
|
|
261
|
+
minorVersion: 9,
|
|
262
|
+
os: getOSNameInternal(),
|
|
263
|
+
osVersion: getOSVersion(),
|
|
264
|
+
subClientType: 'WEB_APP',
|
|
265
|
+
},
|
|
266
|
+
environment: 'meeting_evn',
|
|
267
|
+
name: 'endpoint',
|
|
268
|
+
networkType: 'unknown',
|
|
269
|
+
userAgent,
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('#getIdentifiers', () => {
|
|
275
|
+
it('should build identifiers correctly', () => {
|
|
276
|
+
const res = cd.getIdentifiers({
|
|
277
|
+
mediaConnections: [
|
|
278
|
+
{mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
|
|
279
|
+
],
|
|
280
|
+
meeting: fakeMeeting,
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
assert.deepEqual(res, {
|
|
284
|
+
correlationId: 'correlationId',
|
|
285
|
+
deviceId: 'deviceUrl',
|
|
286
|
+
locusId: 'url',
|
|
287
|
+
locusStartTime: 'lastActive',
|
|
288
|
+
locusUrl: 'locus/url',
|
|
289
|
+
mediaAgentAlias: 'mediaAgentAlias',
|
|
290
|
+
mediaAgentGroupId: 'mediaAgentGroupId',
|
|
291
|
+
orgId: 'orgId',
|
|
292
|
+
userId: 'userId',
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('should build identifiers correctly with a meeting that has meetingInfo with a webexConferenceIdStr and globalMeetingId, and that should take precedence over the options passed to it', () => {
|
|
297
|
+
const res = cd.getIdentifiers({
|
|
298
|
+
mediaConnections: [
|
|
299
|
+
{mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
|
|
300
|
+
],
|
|
301
|
+
webexConferenceIdStr: 'webexConferenceIdStr',
|
|
302
|
+
globalMeetingId: 'globalMeetingId',
|
|
303
|
+
meeting: {
|
|
304
|
+
...fakeMeeting,
|
|
305
|
+
meetingInfo: {
|
|
306
|
+
...fakeMeeting.meetingInfo,
|
|
307
|
+
confID: 'webexConferenceIdStr1',
|
|
308
|
+
meetingId: 'globalMeetingId1',
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
assert.deepEqual(res, {
|
|
314
|
+
correlationId: 'correlationId',
|
|
315
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
316
|
+
globalMeetingId: 'globalMeetingId1',
|
|
317
|
+
deviceId: 'deviceUrl',
|
|
318
|
+
locusId: 'url',
|
|
319
|
+
locusStartTime: 'lastActive',
|
|
320
|
+
locusUrl: 'locus/url',
|
|
321
|
+
mediaAgentAlias: 'mediaAgentAlias',
|
|
322
|
+
mediaAgentGroupId: 'mediaAgentGroupId',
|
|
323
|
+
orgId: 'orgId',
|
|
324
|
+
userId: 'userId',
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('should build identifiers correctly with a meeting that has meetingInfo with a webexConferenceIdStr and globalMeetingId, and that should take precedence over the options passed to it', () => {
|
|
329
|
+
const res = cd.getIdentifiers({
|
|
330
|
+
mediaConnections: [
|
|
331
|
+
{mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
|
|
332
|
+
],
|
|
333
|
+
webexConferenceIdStr: 'webexConferenceIdStr',
|
|
334
|
+
globalMeetingId: 'globalMeetingId',
|
|
335
|
+
meeting: {
|
|
336
|
+
...fakeMeeting,
|
|
337
|
+
meetingInfo: {
|
|
338
|
+
...fakeMeeting.meetingInfo,
|
|
339
|
+
confIdStr: 'webexConferenceIdStr1',
|
|
340
|
+
meetingId: 'globalMeetingId1',
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
assert.deepEqual(res, {
|
|
346
|
+
correlationId: 'correlationId',
|
|
347
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
348
|
+
globalMeetingId: 'globalMeetingId1',
|
|
349
|
+
deviceId: 'deviceUrl',
|
|
350
|
+
locusId: 'url',
|
|
351
|
+
locusStartTime: 'lastActive',
|
|
352
|
+
locusUrl: 'locus/url',
|
|
353
|
+
mediaAgentAlias: 'mediaAgentAlias',
|
|
354
|
+
mediaAgentGroupId: 'mediaAgentGroupId',
|
|
355
|
+
orgId: 'orgId',
|
|
356
|
+
userId: 'userId',
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('should build identifiers correctly with a meeting that has meetingInfo with siteName', () => {
|
|
361
|
+
const res = cd.getIdentifiers({
|
|
362
|
+
mediaConnections: [
|
|
363
|
+
{mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
|
|
364
|
+
],
|
|
365
|
+
webexConferenceIdStr: 'webexConferenceIdStr',
|
|
366
|
+
globalMeetingId: 'globalMeetingId',
|
|
367
|
+
meeting: {
|
|
368
|
+
...fakeMeeting,
|
|
369
|
+
meetingInfo: {
|
|
370
|
+
...fakeMeeting.meetingInfo,
|
|
371
|
+
confIdStr: 'webexConferenceIdStr1',
|
|
372
|
+
meetingId: 'globalMeetingId1',
|
|
373
|
+
siteName: 'siteName1',
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
assert.deepEqual(res, {
|
|
379
|
+
correlationId: 'correlationId',
|
|
380
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
381
|
+
globalMeetingId: 'globalMeetingId1',
|
|
382
|
+
deviceId: 'deviceUrl',
|
|
383
|
+
locusId: 'url',
|
|
384
|
+
locusStartTime: 'lastActive',
|
|
385
|
+
locusUrl: 'locus/url',
|
|
386
|
+
mediaAgentAlias: 'mediaAgentAlias',
|
|
387
|
+
mediaAgentGroupId: 'mediaAgentGroupId',
|
|
388
|
+
orgId: 'orgId',
|
|
389
|
+
userId: 'userId',
|
|
390
|
+
webexSiteName: 'siteName1',
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should build identifiers correctly given webexConferenceIdStr', () => {
|
|
395
|
+
const res = cd.getIdentifiers({
|
|
396
|
+
correlationId: 'correlationId',
|
|
397
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
assert.deepEqual(res, {
|
|
401
|
+
correlationId: 'correlationId',
|
|
402
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
403
|
+
deviceId: 'deviceUrl',
|
|
404
|
+
locusUrl: 'locus-url',
|
|
405
|
+
orgId: 'orgId',
|
|
406
|
+
userId: 'userId',
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it('should build identifiers correctly given globalMeetingId', () => {
|
|
411
|
+
const res = cd.getIdentifiers({
|
|
412
|
+
correlationId: 'correlationId',
|
|
413
|
+
globalMeetingId: 'globalMeetingId1',
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
assert.deepEqual(res, {
|
|
417
|
+
correlationId: 'correlationId',
|
|
418
|
+
globalMeetingId: 'globalMeetingId1',
|
|
419
|
+
deviceId: 'deviceUrl',
|
|
420
|
+
locusUrl: 'locus-url',
|
|
421
|
+
orgId: 'orgId',
|
|
422
|
+
userId: 'userId',
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it('should build identifiers correctly given correlationId', () => {
|
|
427
|
+
const res = cd.getIdentifiers({
|
|
428
|
+
correlationId: 'correlationId',
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
assert.deepEqual(res, {
|
|
432
|
+
correlationId: 'correlationId',
|
|
433
|
+
deviceId: 'deviceUrl',
|
|
434
|
+
locusUrl: 'locus-url',
|
|
435
|
+
orgId: 'orgId',
|
|
436
|
+
userId: 'userId',
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it('should throw Error if correlationId is missing', () => {
|
|
441
|
+
assert.throws(() =>
|
|
442
|
+
cd.getIdentifiers({
|
|
443
|
+
mediaConnections: [
|
|
444
|
+
{mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
|
|
445
|
+
],
|
|
446
|
+
meeting: {...fakeMeeting, correlationId: undefined},
|
|
447
|
+
})
|
|
448
|
+
);
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it('should build identifiers correctly given preLoginId and no device userId available', () => {
|
|
452
|
+
webex.internal.device.userId = undefined;
|
|
453
|
+
|
|
454
|
+
const res = cd.getIdentifiers({
|
|
455
|
+
correlationId: 'correlationId',
|
|
456
|
+
preLoginId: 'preLoginId',
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
assert.deepEqual(res, {
|
|
460
|
+
correlationId: 'correlationId',
|
|
461
|
+
locusUrl: 'locus-url',
|
|
462
|
+
deviceId: 'deviceUrl',
|
|
463
|
+
orgId: 'orgId',
|
|
464
|
+
userId: 'preLoginId',
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it('should prepare diagnostic event successfully', () => {
|
|
470
|
+
const options = {meetingId: fakeMeeting.id};
|
|
471
|
+
const getOriginStub = sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
472
|
+
const clearEmptyKeysRecursivelyStub = sinon.stub(Utils, 'clearEmptyKeysRecursively');
|
|
473
|
+
|
|
474
|
+
const res = cd.prepareDiagnosticEvent(
|
|
475
|
+
{
|
|
476
|
+
canProceed: false,
|
|
477
|
+
identifiers: {
|
|
478
|
+
correlationId: 'id',
|
|
479
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
480
|
+
globalMeetingId: 'globalMeetingId1',
|
|
481
|
+
},
|
|
482
|
+
name: 'client.alert.displayed',
|
|
483
|
+
},
|
|
484
|
+
options
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
assert.calledWith(getOriginStub, options, options.meetingId);
|
|
488
|
+
assert.calledOnce(clearEmptyKeysRecursivelyStub);
|
|
489
|
+
assert.deepEqual(res, {
|
|
490
|
+
event: {
|
|
491
|
+
canProceed: false,
|
|
492
|
+
identifiers: {
|
|
493
|
+
correlationId: 'id',
|
|
494
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
495
|
+
globalMeetingId: 'globalMeetingId1',
|
|
496
|
+
},
|
|
497
|
+
name: 'client.alert.displayed',
|
|
498
|
+
},
|
|
499
|
+
eventId: 'my-fake-id',
|
|
500
|
+
origin: {
|
|
501
|
+
origin: 'fake-origin',
|
|
502
|
+
},
|
|
503
|
+
originTime: {
|
|
504
|
+
sent: 'not_defined_yet',
|
|
505
|
+
triggered: now.toISOString(),
|
|
506
|
+
},
|
|
507
|
+
senderCountryCode: 'UK',
|
|
508
|
+
version: 1,
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
describe('#submitClientEvent', () => {
|
|
513
|
+
it('should submit client event successfully with meetingId', () => {
|
|
514
|
+
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
515
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
516
|
+
const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
|
|
517
|
+
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
518
|
+
const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
|
|
519
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
520
|
+
const validatorSpy = sinon.spy(cd, 'validator');
|
|
521
|
+
const options = {
|
|
522
|
+
meetingId: fakeMeeting.id,
|
|
523
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
cd.submitClientEvent({
|
|
527
|
+
name: 'client.alert.displayed',
|
|
528
|
+
options,
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
assert.calledWith(getIdentifiersSpy, {
|
|
532
|
+
meeting: fakeMeeting,
|
|
533
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
534
|
+
webexConferenceIdStr: undefined,
|
|
535
|
+
globalMeetingId: undefined,
|
|
536
|
+
});
|
|
537
|
+
assert.notCalled(generateClientEventErrorPayloadSpy);
|
|
538
|
+
assert.calledWith(
|
|
539
|
+
prepareDiagnosticEventSpy,
|
|
540
|
+
{
|
|
541
|
+
canProceed: true,
|
|
542
|
+
eventData: {
|
|
543
|
+
webClientDomain: 'whatever',
|
|
544
|
+
},
|
|
545
|
+
identifiers: {
|
|
546
|
+
correlationId: 'correlationId',
|
|
547
|
+
deviceId: 'deviceUrl',
|
|
548
|
+
locusId: 'url',
|
|
549
|
+
locusStartTime: 'lastActive',
|
|
550
|
+
locusUrl: 'locus/url',
|
|
551
|
+
mediaAgentAlias: 'alias',
|
|
552
|
+
mediaAgentGroupId: '1',
|
|
553
|
+
orgId: 'orgId',
|
|
554
|
+
userId: 'userId',
|
|
555
|
+
},
|
|
556
|
+
loginType: 'login-ci',
|
|
557
|
+
name: 'client.alert.displayed',
|
|
558
|
+
userType: 'host',
|
|
559
|
+
isConvergedArchitectureEnabled: undefined,
|
|
560
|
+
webexSubServiceType: undefined,
|
|
561
|
+
},
|
|
562
|
+
options
|
|
563
|
+
);
|
|
564
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
565
|
+
event: {
|
|
566
|
+
canProceed: true,
|
|
567
|
+
eventData: {
|
|
568
|
+
webClientDomain: 'whatever',
|
|
569
|
+
},
|
|
570
|
+
identifiers: {
|
|
571
|
+
correlationId: 'correlationId',
|
|
572
|
+
deviceId: 'deviceUrl',
|
|
573
|
+
locusId: 'url',
|
|
574
|
+
locusStartTime: 'lastActive',
|
|
575
|
+
locusUrl: 'locus/url',
|
|
576
|
+
mediaAgentAlias: 'alias',
|
|
577
|
+
mediaAgentGroupId: '1',
|
|
578
|
+
orgId: 'orgId',
|
|
579
|
+
userId: 'userId',
|
|
580
|
+
},
|
|
581
|
+
loginType: 'login-ci',
|
|
582
|
+
name: 'client.alert.displayed',
|
|
583
|
+
userType: 'host',
|
|
584
|
+
isConvergedArchitectureEnabled: undefined,
|
|
585
|
+
webexSubServiceType: undefined,
|
|
586
|
+
},
|
|
587
|
+
eventId: 'my-fake-id',
|
|
588
|
+
origin: {
|
|
589
|
+
origin: 'fake-origin',
|
|
590
|
+
},
|
|
591
|
+
originTime: {
|
|
592
|
+
sent: 'not_defined_yet',
|
|
593
|
+
triggered: now.toISOString(),
|
|
594
|
+
},
|
|
595
|
+
senderCountryCode: 'UK',
|
|
596
|
+
version: 1,
|
|
597
|
+
});
|
|
598
|
+
assert.calledWith(validatorSpy, {
|
|
599
|
+
type: 'ce',
|
|
600
|
+
event: {
|
|
601
|
+
event: {
|
|
602
|
+
canProceed: true,
|
|
603
|
+
eventData: {
|
|
604
|
+
webClientDomain: 'whatever',
|
|
605
|
+
},
|
|
606
|
+
identifiers: {
|
|
607
|
+
correlationId: 'correlationId',
|
|
608
|
+
deviceId: 'deviceUrl',
|
|
609
|
+
locusId: 'url',
|
|
610
|
+
locusStartTime: 'lastActive',
|
|
611
|
+
locusUrl: 'locus/url',
|
|
612
|
+
mediaAgentAlias: 'alias',
|
|
613
|
+
mediaAgentGroupId: '1',
|
|
614
|
+
orgId: 'orgId',
|
|
615
|
+
userId: 'userId',
|
|
616
|
+
},
|
|
617
|
+
loginType: 'login-ci',
|
|
618
|
+
name: 'client.alert.displayed',
|
|
619
|
+
userType: 'host',
|
|
620
|
+
isConvergedArchitectureEnabled: undefined,
|
|
621
|
+
webexSubServiceType: undefined,
|
|
622
|
+
},
|
|
623
|
+
eventId: 'my-fake-id',
|
|
624
|
+
origin: {
|
|
625
|
+
origin: 'fake-origin',
|
|
626
|
+
},
|
|
627
|
+
originTime: {
|
|
628
|
+
sent: 'not_defined_yet',
|
|
629
|
+
triggered: now.toISOString(),
|
|
630
|
+
},
|
|
631
|
+
senderCountryCode: 'UK',
|
|
632
|
+
version: 1,
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
637
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
638
|
+
'call-diagnostic-events -> ',
|
|
639
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
640
|
+
`name: client.alert.displayed`,
|
|
641
|
+
]);
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
it('should submit client event successfully with correlationId, webexConferenceIdStr and globalMeetingId', () => {
|
|
645
|
+
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
646
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
647
|
+
const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
|
|
648
|
+
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
649
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
650
|
+
|
|
651
|
+
const options = {
|
|
652
|
+
correlationId: 'correlationId',
|
|
653
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
654
|
+
globalMeetingId: 'globalMeetingId1',
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
cd.submitClientEvent({
|
|
658
|
+
name: 'client.alert.displayed',
|
|
659
|
+
options,
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
assert.calledWith(getIdentifiersSpy, {
|
|
663
|
+
correlationId: 'correlationId',
|
|
664
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
665
|
+
globalMeetingId: 'globalMeetingId1',
|
|
666
|
+
preLoginId: undefined,
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
assert.notCalled(generateClientEventErrorPayloadSpy);
|
|
670
|
+
assert.calledWith(
|
|
671
|
+
prepareDiagnosticEventSpy,
|
|
672
|
+
{
|
|
673
|
+
canProceed: true,
|
|
674
|
+
eventData: {
|
|
675
|
+
webClientDomain: 'whatever',
|
|
676
|
+
},
|
|
677
|
+
identifiers: {
|
|
678
|
+
correlationId: 'correlationId',
|
|
679
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
680
|
+
globalMeetingId: 'globalMeetingId1',
|
|
681
|
+
deviceId: 'deviceUrl',
|
|
682
|
+
locusUrl: 'locus-url',
|
|
683
|
+
orgId: 'orgId',
|
|
684
|
+
userId: 'userId',
|
|
685
|
+
},
|
|
686
|
+
loginType: 'login-ci',
|
|
687
|
+
name: 'client.alert.displayed',
|
|
688
|
+
},
|
|
689
|
+
options
|
|
690
|
+
);
|
|
691
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
692
|
+
event: {
|
|
693
|
+
canProceed: true,
|
|
694
|
+
eventData: {
|
|
695
|
+
webClientDomain: 'whatever',
|
|
696
|
+
},
|
|
697
|
+
identifiers: {
|
|
698
|
+
correlationId: 'correlationId',
|
|
699
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
700
|
+
globalMeetingId: 'globalMeetingId1',
|
|
701
|
+
deviceId: 'deviceUrl',
|
|
702
|
+
locusUrl: 'locus-url',
|
|
703
|
+
orgId: 'orgId',
|
|
704
|
+
userId: 'userId',
|
|
705
|
+
},
|
|
706
|
+
loginType: 'login-ci',
|
|
707
|
+
name: 'client.alert.displayed',
|
|
708
|
+
},
|
|
709
|
+
eventId: 'my-fake-id',
|
|
710
|
+
origin: {
|
|
711
|
+
origin: 'fake-origin',
|
|
712
|
+
},
|
|
713
|
+
originTime: {
|
|
714
|
+
sent: 'not_defined_yet',
|
|
715
|
+
triggered: now.toISOString(),
|
|
716
|
+
},
|
|
717
|
+
senderCountryCode: 'UK',
|
|
718
|
+
version: 1,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
722
|
+
|
|
723
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
724
|
+
'call-diagnostic-events -> ',
|
|
725
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
726
|
+
`name: client.alert.displayed`,
|
|
727
|
+
]);
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
it('should submit client event successfully with preLoginId', () => {
|
|
731
|
+
webex.internal.device.userId = undefined;
|
|
732
|
+
|
|
733
|
+
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
734
|
+
const submitToCallDiagnosticsPreLoginSpy = sinon.spy(cd, 'submitToCallDiagnosticsPreLogin');
|
|
735
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
736
|
+
const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
|
|
737
|
+
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
738
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
739
|
+
|
|
740
|
+
const options = {
|
|
741
|
+
correlationId: 'correlationId',
|
|
742
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
743
|
+
globalMeetingId: 'globalMeetingId1',
|
|
744
|
+
preLoginId: 'myPreLoginId',
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
cd.submitClientEvent({
|
|
748
|
+
name: 'client.alert.displayed',
|
|
749
|
+
options,
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
assert.calledWith(getIdentifiersSpy, {
|
|
753
|
+
correlationId: 'correlationId',
|
|
754
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
755
|
+
globalMeetingId: 'globalMeetingId1',
|
|
756
|
+
preLoginId: 'myPreLoginId',
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
assert.notCalled(generateClientEventErrorPayloadSpy);
|
|
760
|
+
assert.calledWith(
|
|
761
|
+
prepareDiagnosticEventSpy,
|
|
762
|
+
{
|
|
763
|
+
canProceed: true,
|
|
764
|
+
eventData: {
|
|
765
|
+
webClientDomain: 'whatever',
|
|
766
|
+
},
|
|
767
|
+
identifiers: {
|
|
768
|
+
correlationId: 'correlationId',
|
|
769
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
770
|
+
globalMeetingId: 'globalMeetingId1',
|
|
771
|
+
deviceId: 'deviceUrl',
|
|
772
|
+
locusUrl: 'locus-url',
|
|
773
|
+
orgId: 'orgId',
|
|
774
|
+
userId: 'myPreLoginId',
|
|
775
|
+
},
|
|
776
|
+
loginType: 'login-ci',
|
|
777
|
+
name: 'client.alert.displayed',
|
|
778
|
+
},
|
|
779
|
+
options
|
|
780
|
+
);
|
|
781
|
+
assert.notCalled(submitToCallDiagnosticsSpy);
|
|
782
|
+
assert.calledWith(submitToCallDiagnosticsPreLoginSpy, {
|
|
783
|
+
event: {
|
|
784
|
+
canProceed: true,
|
|
785
|
+
eventData: {
|
|
786
|
+
webClientDomain: 'whatever',
|
|
787
|
+
},
|
|
788
|
+
identifiers: {
|
|
789
|
+
correlationId: 'correlationId',
|
|
790
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
791
|
+
globalMeetingId: 'globalMeetingId1',
|
|
792
|
+
deviceId: 'deviceUrl',
|
|
793
|
+
locusUrl: 'locus-url',
|
|
794
|
+
orgId: 'orgId',
|
|
795
|
+
userId: 'myPreLoginId',
|
|
796
|
+
},
|
|
797
|
+
loginType: 'login-ci',
|
|
798
|
+
name: 'client.alert.displayed',
|
|
799
|
+
},
|
|
800
|
+
eventId: 'my-fake-id',
|
|
801
|
+
origin: {buildType: 'test', networkType: 'unknown', origin: 'fake-origin'},
|
|
802
|
+
originTime: {
|
|
803
|
+
triggered: now.toISOString(),
|
|
804
|
+
sent: now.toISOString(),
|
|
805
|
+
},
|
|
806
|
+
senderCountryCode: 'UK',
|
|
807
|
+
version: 1,
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
it('should use meeting loginType if present and meetingId provided', () => {
|
|
812
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
813
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
814
|
+
const options = {
|
|
815
|
+
meetingId: fakeMeeting2.id,
|
|
816
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
cd.submitClientEvent({
|
|
820
|
+
name: 'client.alert.displayed',
|
|
821
|
+
options,
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
825
|
+
event: {
|
|
826
|
+
canProceed: true,
|
|
827
|
+
eventData: {
|
|
828
|
+
webClientDomain: 'whatever',
|
|
829
|
+
},
|
|
830
|
+
identifiers: {
|
|
831
|
+
correlationId: 'correlationId2',
|
|
832
|
+
deviceId: 'deviceUrl',
|
|
833
|
+
locusId: 'url',
|
|
834
|
+
locusStartTime: 'lastActive',
|
|
835
|
+
locusUrl: 'locus/url',
|
|
836
|
+
mediaAgentAlias: 'alias',
|
|
837
|
+
mediaAgentGroupId: '1',
|
|
838
|
+
orgId: 'orgId',
|
|
839
|
+
userId: 'userId',
|
|
840
|
+
},
|
|
841
|
+
loginType: 'fakeLoginType',
|
|
842
|
+
name: 'client.alert.displayed',
|
|
843
|
+
userType: 'host',
|
|
844
|
+
isConvergedArchitectureEnabled: undefined,
|
|
845
|
+
webexSubServiceType: undefined,
|
|
846
|
+
},
|
|
847
|
+
eventId: 'my-fake-id',
|
|
848
|
+
origin: {
|
|
849
|
+
origin: 'fake-origin',
|
|
850
|
+
},
|
|
851
|
+
originTime: {
|
|
852
|
+
sent: 'not_defined_yet',
|
|
853
|
+
triggered: now.toISOString(),
|
|
854
|
+
},
|
|
855
|
+
senderCountryCode: 'UK',
|
|
856
|
+
version: 1,
|
|
857
|
+
});
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
it('it should include errors if provided with meetingId', () => {
|
|
861
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
862
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
863
|
+
|
|
864
|
+
const options = {
|
|
865
|
+
meetingId: fakeMeeting.id,
|
|
866
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
867
|
+
globalMeetingId: 'globalMeetingId1',
|
|
868
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
869
|
+
rawError: {
|
|
870
|
+
body: {
|
|
871
|
+
errorCode: 2409005,
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
};
|
|
875
|
+
|
|
876
|
+
cd.submitClientEvent({
|
|
877
|
+
name: 'client.alert.displayed',
|
|
878
|
+
options,
|
|
879
|
+
});
|
|
880
|
+
|
|
881
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
882
|
+
event: {
|
|
883
|
+
canProceed: true,
|
|
884
|
+
eventData: {
|
|
885
|
+
webClientDomain: 'whatever',
|
|
886
|
+
},
|
|
887
|
+
identifiers: {
|
|
888
|
+
correlationId: 'correlationId',
|
|
889
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
890
|
+
globalMeetingId: 'globalMeetingId1',
|
|
891
|
+
deviceId: 'deviceUrl',
|
|
892
|
+
locusId: 'url',
|
|
893
|
+
locusStartTime: 'lastActive',
|
|
894
|
+
locusUrl: 'locus/url',
|
|
895
|
+
mediaAgentAlias: 'alias',
|
|
896
|
+
mediaAgentGroupId: '1',
|
|
897
|
+
orgId: 'orgId',
|
|
898
|
+
userId: 'userId',
|
|
899
|
+
},
|
|
900
|
+
errors: [
|
|
901
|
+
{
|
|
902
|
+
category: 'expected',
|
|
903
|
+
errorDescription: 'StartRecordingFailed',
|
|
904
|
+
fatal: true,
|
|
905
|
+
name: 'other',
|
|
906
|
+
shownToUser: false,
|
|
907
|
+
serviceErrorCode: 2409005,
|
|
908
|
+
errorCode: 4029,
|
|
909
|
+
rawErrorMessage: undefined,
|
|
910
|
+
},
|
|
911
|
+
],
|
|
912
|
+
loginType: 'login-ci',
|
|
913
|
+
name: 'client.alert.displayed',
|
|
914
|
+
userType: 'host',
|
|
915
|
+
isConvergedArchitectureEnabled: undefined,
|
|
916
|
+
webexSubServiceType: undefined,
|
|
917
|
+
},
|
|
918
|
+
eventId: 'my-fake-id',
|
|
919
|
+
origin: {
|
|
920
|
+
origin: 'fake-origin',
|
|
921
|
+
},
|
|
922
|
+
originTime: {
|
|
923
|
+
sent: 'not_defined_yet',
|
|
924
|
+
triggered: now.toISOString(),
|
|
925
|
+
},
|
|
926
|
+
senderCountryCode: 'UK',
|
|
927
|
+
version: 1,
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
931
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
932
|
+
'call-diagnostic-events -> ',
|
|
933
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
934
|
+
`name: client.alert.displayed`,
|
|
935
|
+
]);
|
|
936
|
+
|
|
937
|
+
assert.deepEqual(webexLoggerLogCalls[1].args, [
|
|
938
|
+
'call-diagnostic-events -> ',
|
|
939
|
+
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
940
|
+
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
|
|
941
|
+
]);
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
it('it send the raw error message if meetingId provided', () => {
|
|
945
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
946
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
947
|
+
|
|
948
|
+
const options = {
|
|
949
|
+
meetingId: fakeMeeting.id,
|
|
950
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
951
|
+
rawError: new Error('bad times'),
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
cd.submitClientEvent({
|
|
955
|
+
name: 'client.alert.displayed',
|
|
956
|
+
options,
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
console.log(submitToCallDiagnosticsSpy.getCalls()[0].args[0].event.errors);
|
|
960
|
+
|
|
961
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
962
|
+
event: {
|
|
963
|
+
canProceed: true,
|
|
964
|
+
eventData: {
|
|
965
|
+
webClientDomain: 'whatever',
|
|
966
|
+
},
|
|
967
|
+
identifiers: {
|
|
968
|
+
correlationId: 'correlationId',
|
|
969
|
+
deviceId: 'deviceUrl',
|
|
970
|
+
locusId: 'url',
|
|
971
|
+
locusStartTime: 'lastActive',
|
|
972
|
+
locusUrl: 'locus/url',
|
|
973
|
+
mediaAgentAlias: 'alias',
|
|
974
|
+
mediaAgentGroupId: '1',
|
|
975
|
+
orgId: 'orgId',
|
|
976
|
+
userId: 'userId',
|
|
977
|
+
},
|
|
978
|
+
errors: [
|
|
979
|
+
{
|
|
980
|
+
fatal: true,
|
|
981
|
+
shownToUser: false,
|
|
982
|
+
name: 'other',
|
|
983
|
+
category: 'other',
|
|
984
|
+
errorCode: 9999,
|
|
985
|
+
serviceErrorCode: 9999,
|
|
986
|
+
errorDescription: 'UnknownError',
|
|
987
|
+
rawErrorMessage: 'bad times',
|
|
988
|
+
},
|
|
989
|
+
],
|
|
990
|
+
loginType: 'login-ci',
|
|
991
|
+
name: 'client.alert.displayed',
|
|
992
|
+
userType: 'host',
|
|
993
|
+
isConvergedArchitectureEnabled: undefined,
|
|
994
|
+
webexSubServiceType: undefined,
|
|
995
|
+
},
|
|
996
|
+
eventId: 'my-fake-id',
|
|
997
|
+
origin: {
|
|
998
|
+
origin: 'fake-origin',
|
|
999
|
+
},
|
|
1000
|
+
originTime: {
|
|
1001
|
+
sent: 'not_defined_yet',
|
|
1002
|
+
triggered: now.toISOString(),
|
|
1003
|
+
},
|
|
1004
|
+
senderCountryCode: 'UK',
|
|
1005
|
+
version: 1,
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
1009
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
1010
|
+
'call-diagnostic-events -> ',
|
|
1011
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
1012
|
+
`name: client.alert.displayed`,
|
|
1013
|
+
]);
|
|
1014
|
+
|
|
1015
|
+
assert.deepEqual(webexLoggerLogCalls[1].args, [
|
|
1016
|
+
'call-diagnostic-events -> ',
|
|
1017
|
+
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
1018
|
+
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
|
|
1019
|
+
]);
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
it('it should send the raw error message if provided with correlationId', () => {
|
|
1023
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
1024
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
1025
|
+
|
|
1026
|
+
const options = {
|
|
1027
|
+
correlationId: 'correlationId',
|
|
1028
|
+
rawError: new Error('bad times'),
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
cd.submitClientEvent({
|
|
1032
|
+
name: 'client.alert.displayed',
|
|
1033
|
+
options,
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
1037
|
+
event: {
|
|
1038
|
+
canProceed: true,
|
|
1039
|
+
eventData: {
|
|
1040
|
+
webClientDomain: 'whatever',
|
|
1041
|
+
},
|
|
1042
|
+
identifiers: {
|
|
1043
|
+
correlationId: 'correlationId',
|
|
1044
|
+
deviceId: 'deviceUrl',
|
|
1045
|
+
locusUrl: 'locus-url',
|
|
1046
|
+
orgId: 'orgId',
|
|
1047
|
+
userId: 'userId',
|
|
1048
|
+
},
|
|
1049
|
+
errors: [
|
|
1050
|
+
{
|
|
1051
|
+
fatal: true,
|
|
1052
|
+
shownToUser: false,
|
|
1053
|
+
name: 'other',
|
|
1054
|
+
category: 'other',
|
|
1055
|
+
errorCode: 9999,
|
|
1056
|
+
serviceErrorCode: 9999,
|
|
1057
|
+
errorDescription: 'UnknownError',
|
|
1058
|
+
rawErrorMessage: 'bad times',
|
|
1059
|
+
},
|
|
1060
|
+
],
|
|
1061
|
+
loginType: 'login-ci',
|
|
1062
|
+
name: 'client.alert.displayed',
|
|
1063
|
+
},
|
|
1064
|
+
eventId: 'my-fake-id',
|
|
1065
|
+
origin: {
|
|
1066
|
+
origin: 'fake-origin',
|
|
1067
|
+
},
|
|
1068
|
+
originTime: {
|
|
1069
|
+
sent: 'not_defined_yet',
|
|
1070
|
+
triggered: now.toISOString(),
|
|
1071
|
+
},
|
|
1072
|
+
senderCountryCode: 'UK',
|
|
1073
|
+
version: 1,
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
1077
|
+
|
|
1078
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
1079
|
+
'call-diagnostic-events -> ',
|
|
1080
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
1081
|
+
`name: client.alert.displayed`,
|
|
1082
|
+
]);
|
|
1083
|
+
|
|
1084
|
+
assert.deepEqual(webexLoggerLogCalls[1].args, [
|
|
1085
|
+
'call-diagnostic-events -> ',
|
|
1086
|
+
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
1087
|
+
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
|
|
1088
|
+
]);
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
it('it should include errors if provided with correlationId', () => {
|
|
1092
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
1093
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
1094
|
+
|
|
1095
|
+
const options = {
|
|
1096
|
+
correlationId: 'correlationId',
|
|
1097
|
+
rawError: {
|
|
1098
|
+
body: {
|
|
1099
|
+
errorCode: 2409005,
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
cd.submitClientEvent({
|
|
1105
|
+
name: 'client.alert.displayed',
|
|
1106
|
+
options,
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
1110
|
+
event: {
|
|
1111
|
+
canProceed: true,
|
|
1112
|
+
eventData: {
|
|
1113
|
+
webClientDomain: 'whatever',
|
|
1114
|
+
},
|
|
1115
|
+
identifiers: {
|
|
1116
|
+
correlationId: 'correlationId',
|
|
1117
|
+
deviceId: 'deviceUrl',
|
|
1118
|
+
locusUrl: 'locus-url',
|
|
1119
|
+
orgId: 'orgId',
|
|
1120
|
+
userId: 'userId',
|
|
1121
|
+
},
|
|
1122
|
+
errors: [
|
|
1123
|
+
{
|
|
1124
|
+
category: 'expected',
|
|
1125
|
+
errorDescription: 'StartRecordingFailed',
|
|
1126
|
+
fatal: true,
|
|
1127
|
+
name: 'other',
|
|
1128
|
+
shownToUser: false,
|
|
1129
|
+
serviceErrorCode: 2409005,
|
|
1130
|
+
errorCode: 4029,
|
|
1131
|
+
rawErrorMessage: undefined,
|
|
1132
|
+
},
|
|
1133
|
+
],
|
|
1134
|
+
loginType: 'login-ci',
|
|
1135
|
+
name: 'client.alert.displayed',
|
|
1136
|
+
},
|
|
1137
|
+
eventId: 'my-fake-id',
|
|
1138
|
+
origin: {
|
|
1139
|
+
origin: 'fake-origin',
|
|
1140
|
+
},
|
|
1141
|
+
originTime: {
|
|
1142
|
+
sent: 'not_defined_yet',
|
|
1143
|
+
triggered: now.toISOString(),
|
|
1144
|
+
},
|
|
1145
|
+
senderCountryCode: 'UK',
|
|
1146
|
+
version: 1,
|
|
1147
|
+
});
|
|
1148
|
+
|
|
1149
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
1150
|
+
|
|
1151
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
1152
|
+
'call-diagnostic-events -> ',
|
|
1153
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
1154
|
+
`name: client.alert.displayed`,
|
|
1155
|
+
]);
|
|
1156
|
+
|
|
1157
|
+
assert.deepEqual(webexLoggerLogCalls[1].args, [
|
|
1158
|
+
'call-diagnostic-events -> ',
|
|
1159
|
+
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
1160
|
+
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
|
|
1161
|
+
]);
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
it('should include errors in payload if provided via payload', () => {
|
|
1165
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
1166
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
1167
|
+
|
|
1168
|
+
const options = {
|
|
1169
|
+
meetingId: fakeMeeting.id,
|
|
1170
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
cd.submitClientEvent({
|
|
1174
|
+
name: 'client.alert.displayed',
|
|
1175
|
+
payload: {
|
|
1176
|
+
errors: [
|
|
1177
|
+
{
|
|
1178
|
+
name: 'locus.response',
|
|
1179
|
+
fatal: true,
|
|
1180
|
+
category: 'signaling',
|
|
1181
|
+
shownToUser: false,
|
|
1182
|
+
},
|
|
1183
|
+
],
|
|
1184
|
+
},
|
|
1185
|
+
options,
|
|
1186
|
+
});
|
|
1187
|
+
|
|
1188
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
1189
|
+
event: {
|
|
1190
|
+
canProceed: true,
|
|
1191
|
+
eventData: {
|
|
1192
|
+
webClientDomain: 'whatever',
|
|
1193
|
+
},
|
|
1194
|
+
identifiers: {
|
|
1195
|
+
correlationId: 'correlationId',
|
|
1196
|
+
deviceId: 'deviceUrl',
|
|
1197
|
+
locusId: 'url',
|
|
1198
|
+
locusStartTime: 'lastActive',
|
|
1199
|
+
locusUrl: 'locus/url',
|
|
1200
|
+
mediaAgentAlias: 'alias',
|
|
1201
|
+
mediaAgentGroupId: '1',
|
|
1202
|
+
orgId: 'orgId',
|
|
1203
|
+
userId: 'userId',
|
|
1204
|
+
},
|
|
1205
|
+
errors: [
|
|
1206
|
+
{
|
|
1207
|
+
name: 'locus.response',
|
|
1208
|
+
fatal: true,
|
|
1209
|
+
category: 'signaling',
|
|
1210
|
+
shownToUser: false,
|
|
1211
|
+
},
|
|
1212
|
+
],
|
|
1213
|
+
loginType: 'login-ci',
|
|
1214
|
+
name: 'client.alert.displayed',
|
|
1215
|
+
userType: 'host',
|
|
1216
|
+
isConvergedArchitectureEnabled: undefined,
|
|
1217
|
+
webexSubServiceType: undefined,
|
|
1218
|
+
},
|
|
1219
|
+
eventId: 'my-fake-id',
|
|
1220
|
+
origin: {
|
|
1221
|
+
origin: 'fake-origin',
|
|
1222
|
+
},
|
|
1223
|
+
originTime: {
|
|
1224
|
+
sent: 'not_defined_yet',
|
|
1225
|
+
triggered: now.toISOString(),
|
|
1226
|
+
},
|
|
1227
|
+
senderCountryCode: 'UK',
|
|
1228
|
+
version: 1,
|
|
1229
|
+
});
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
it('should throw if meetingId nor correlationId not provided', () => {
|
|
1233
|
+
assert.throws(() =>
|
|
1234
|
+
cd.submitClientEvent({
|
|
1235
|
+
name: 'client.alert.displayed',
|
|
1236
|
+
})
|
|
1237
|
+
);
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
it('should send behavioral event if meetingId provided but meeting is undefined', () => {
|
|
1241
|
+
webex.meetings.meetingCollection.get = sinon.stub().returns(undefined);
|
|
1242
|
+
cd.submitClientEvent({name: 'client.alert.displayed', options: {meetingId: 'meetingId'}});
|
|
1243
|
+
assert.calledWith(
|
|
1244
|
+
webex.internal.metrics.submitClientMetrics,
|
|
1245
|
+
'js_sdk_call_diagnostic_event_failed_to_send',
|
|
1246
|
+
{
|
|
1247
|
+
fields: {meetingId: 'meetingId', name: 'client.alert.displayed'},
|
|
1248
|
+
}
|
|
1249
|
+
);
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
it('should submit client to diagnostic when no preLoginId provided', () => {
|
|
1253
|
+
const testEvent = {name: 'client.alert.displayed', options: {meetingId: 'meetingId'}};
|
|
1254
|
+
sinon.stub(cd, 'prepareClientEvent').returns(testEvent);
|
|
1255
|
+
sinon.stub(cd, 'submitToCallDiagnostics');
|
|
1256
|
+
sinon.stub(cd, 'submitToCallDiagnosticsPreLogin');
|
|
1257
|
+
//@ts-ignore
|
|
1258
|
+
cd.submitClientEvent(testEvent);
|
|
1259
|
+
assert.calledWith(cd.submitToCallDiagnostics, testEvent);
|
|
1260
|
+
assert.notCalled(cd.submitToCallDiagnosticsPreLogin);
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
it('should submit event to prelogin when preLoginId provided', () => {
|
|
1264
|
+
const testEvent = {name: 'client.alert.displayed', options: {preLoginId: 'preLoginId'}};
|
|
1265
|
+
sinon.stub(cd, 'prepareClientEvent').returns(testEvent);
|
|
1266
|
+
sinon.stub(cd, 'submitToCallDiagnosticsPreLogin');
|
|
1267
|
+
sinon.stub(cd, 'submitToCallDiagnostics');
|
|
1268
|
+
//@ts-ignore
|
|
1269
|
+
cd.submitClientEvent(testEvent);
|
|
1270
|
+
assert.calledWith(cd.submitToCallDiagnosticsPreLogin, testEvent);
|
|
1271
|
+
assert.notCalled(cd.submitToCallDiagnostics);
|
|
1272
|
+
});
|
|
1273
|
+
});
|
|
1274
|
+
|
|
1275
|
+
it('should send request to call diagnostic batcher', () => {
|
|
1276
|
+
const requestStub = sinon.stub();
|
|
1277
|
+
//@ts-ignore
|
|
1278
|
+
cd.callDiagnosticEventsBatcher = {request: requestStub};
|
|
1279
|
+
//@ts-ignore
|
|
1280
|
+
cd.submitToCallDiagnostics({event: 'test'});
|
|
1281
|
+
assert.calledWith(requestStub, {eventPayload: {event: 'test'}, type: ['diagnostic-event']});
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
describe('#submitMQE', () => {
|
|
1285
|
+
it('submits the event correctly', () => {
|
|
1286
|
+
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
1287
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
1288
|
+
const getErrorPayloadForClientErrorCodeSpy = sinon.spy(
|
|
1289
|
+
cd,
|
|
1290
|
+
'getErrorPayloadForClientErrorCode'
|
|
1291
|
+
);
|
|
1292
|
+
const validatorSpy = sinon.spy(cd, 'validator');
|
|
1293
|
+
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
1294
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
1295
|
+
const options = {
|
|
1296
|
+
networkType: 'wifi' as const,
|
|
1297
|
+
meetingId: fakeMeeting.id,
|
|
1298
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
1299
|
+
globalMeetingId: 'globalMeetingId1',
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
cd.submitMQE({
|
|
1303
|
+
name: 'client.mediaquality.event',
|
|
1304
|
+
payload: {
|
|
1305
|
+
//@ts-ignore
|
|
1306
|
+
intervals: [{}],
|
|
1307
|
+
},
|
|
1308
|
+
options,
|
|
1309
|
+
});
|
|
1310
|
+
|
|
1311
|
+
assert.calledWith(getIdentifiersSpy, {
|
|
1312
|
+
meeting: fakeMeeting,
|
|
1313
|
+
mediaConnections: undefined,
|
|
1314
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
1315
|
+
globalMeetingId: 'globalMeetingId1',
|
|
1316
|
+
});
|
|
1317
|
+
assert.notCalled(getErrorPayloadForClientErrorCodeSpy);
|
|
1318
|
+
assert.calledWith(
|
|
1319
|
+
prepareDiagnosticEventSpy,
|
|
1320
|
+
{
|
|
1321
|
+
name: 'client.mediaquality.event',
|
|
1322
|
+
canProceed: true,
|
|
1323
|
+
identifiers: {
|
|
1324
|
+
correlationId: 'correlationId',
|
|
1325
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
1326
|
+
globalMeetingId: 'globalMeetingId1',
|
|
1327
|
+
userId: 'userId',
|
|
1328
|
+
deviceId: 'deviceUrl',
|
|
1329
|
+
orgId: 'orgId',
|
|
1330
|
+
locusUrl: 'locus/url',
|
|
1331
|
+
locusId: 'url',
|
|
1332
|
+
locusStartTime: 'lastActive',
|
|
1333
|
+
},
|
|
1334
|
+
eventData: {webClientDomain: 'whatever'},
|
|
1335
|
+
intervals: [{}],
|
|
1336
|
+
sourceMetadata: {
|
|
1337
|
+
applicationSoftwareType: 'webex-js-sdk',
|
|
1338
|
+
applicationSoftwareVersion: 'webex-version',
|
|
1339
|
+
mediaEngineSoftwareType: 'browser',
|
|
1340
|
+
mediaEngineSoftwareVersion: getOSVersion(),
|
|
1341
|
+
startTime: now.toISOString(),
|
|
1342
|
+
},
|
|
1343
|
+
},
|
|
1344
|
+
options
|
|
1345
|
+
);
|
|
1346
|
+
|
|
1347
|
+
assert.calledWith(validatorSpy, {
|
|
1348
|
+
type: 'mqe',
|
|
1349
|
+
event: {
|
|
1350
|
+
eventId: 'my-fake-id',
|
|
1351
|
+
version: 1,
|
|
1352
|
+
origin: {origin: 'fake-origin'},
|
|
1353
|
+
originTime: {triggered: now.toISOString(), sent: 'not_defined_yet'},
|
|
1354
|
+
senderCountryCode: 'UK',
|
|
1355
|
+
event: {
|
|
1356
|
+
name: 'client.mediaquality.event',
|
|
1357
|
+
canProceed: true,
|
|
1358
|
+
identifiers: {
|
|
1359
|
+
correlationId: 'correlationId',
|
|
1360
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
1361
|
+
globalMeetingId: 'globalMeetingId1',
|
|
1362
|
+
userId: 'userId',
|
|
1363
|
+
deviceId: 'deviceUrl',
|
|
1364
|
+
orgId: 'orgId',
|
|
1365
|
+
locusUrl: 'locus/url',
|
|
1366
|
+
locusId: 'url',
|
|
1367
|
+
locusStartTime: 'lastActive',
|
|
1368
|
+
},
|
|
1369
|
+
eventData: {webClientDomain: 'whatever'},
|
|
1370
|
+
intervals: [{}],
|
|
1371
|
+
sourceMetadata: {
|
|
1372
|
+
applicationSoftwareType: 'webex-js-sdk',
|
|
1373
|
+
applicationSoftwareVersion: 'webex-version',
|
|
1374
|
+
mediaEngineSoftwareType: 'browser',
|
|
1375
|
+
mediaEngineSoftwareVersion: getOSVersion(),
|
|
1376
|
+
startTime: now.toISOString(),
|
|
1377
|
+
},
|
|
1378
|
+
},
|
|
1379
|
+
},
|
|
1380
|
+
});
|
|
1381
|
+
|
|
1382
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
1383
|
+
eventId: 'my-fake-id',
|
|
1384
|
+
version: 1,
|
|
1385
|
+
origin: {origin: 'fake-origin'},
|
|
1386
|
+
originTime: {triggered: now.toISOString(), sent: 'not_defined_yet'},
|
|
1387
|
+
senderCountryCode: 'UK',
|
|
1388
|
+
event: {
|
|
1389
|
+
name: 'client.mediaquality.event',
|
|
1390
|
+
canProceed: true,
|
|
1391
|
+
identifiers: {
|
|
1392
|
+
correlationId: 'correlationId',
|
|
1393
|
+
webexConferenceIdStr: 'webexConferenceIdStr1',
|
|
1394
|
+
globalMeetingId: 'globalMeetingId1',
|
|
1395
|
+
userId: 'userId',
|
|
1396
|
+
deviceId: 'deviceUrl',
|
|
1397
|
+
orgId: 'orgId',
|
|
1398
|
+
locusUrl: 'locus/url',
|
|
1399
|
+
locusId: 'url',
|
|
1400
|
+
locusStartTime: 'lastActive',
|
|
1401
|
+
},
|
|
1402
|
+
eventData: {webClientDomain: 'whatever'},
|
|
1403
|
+
intervals: [{}],
|
|
1404
|
+
sourceMetadata: {
|
|
1405
|
+
applicationSoftwareType: 'webex-js-sdk',
|
|
1406
|
+
applicationSoftwareVersion: 'webex-version',
|
|
1407
|
+
mediaEngineSoftwareType: 'browser',
|
|
1408
|
+
mediaEngineSoftwareVersion: getOSVersion(),
|
|
1409
|
+
startTime: now.toISOString(),
|
|
1410
|
+
},
|
|
1411
|
+
},
|
|
1412
|
+
});
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
it('throws if meeting id not provided', () => {
|
|
1416
|
+
assert.throws(() =>
|
|
1417
|
+
cd.submitMQE({
|
|
1418
|
+
name: 'client.mediaquality.event',
|
|
1419
|
+
payload: {
|
|
1420
|
+
//@ts-ignore
|
|
1421
|
+
intervals: [{}],
|
|
1422
|
+
},
|
|
1423
|
+
//@ts-ignore
|
|
1424
|
+
options: {meetingId: undefined, networkType: 'wifi'},
|
|
1425
|
+
})
|
|
1426
|
+
);
|
|
1427
|
+
});
|
|
1428
|
+
|
|
1429
|
+
it('should send behavioral event if meeting is undefined', () => {
|
|
1430
|
+
webex.meetings.meetingCollection.get = sinon.stub().returns(undefined);
|
|
1431
|
+
cd.submitMQE({
|
|
1432
|
+
name: 'client.mediaquality.event',
|
|
1433
|
+
payload: {
|
|
1434
|
+
//@ts-ignore
|
|
1435
|
+
intervals: [{}],
|
|
1436
|
+
},
|
|
1437
|
+
options: {meetingId: 'meetingId'},
|
|
1438
|
+
});
|
|
1439
|
+
assert.calledWith(
|
|
1440
|
+
webex.internal.metrics.submitClientMetrics,
|
|
1441
|
+
'js_sdk_call_diagnostic_event_failed_to_send',
|
|
1442
|
+
{
|
|
1443
|
+
fields: {meetingId: 'meetingId', name: 'client.mediaquality.event'},
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
});
|
|
1447
|
+
});
|
|
1448
|
+
|
|
1449
|
+
describe('#getErrorPayloadForClientErrorCode', () => {
|
|
1450
|
+
it('it should grab the payload for client error code correctly', () => {
|
|
1451
|
+
const res = cd.getErrorPayloadForClientErrorCode({
|
|
1452
|
+
clientErrorCode: 4008,
|
|
1453
|
+
serviceErrorCode: 10000,
|
|
1454
|
+
});
|
|
1455
|
+
assert.deepEqual(res, {
|
|
1456
|
+
category: 'signaling',
|
|
1457
|
+
errorDescription: 'NewLocusError',
|
|
1458
|
+
fatal: true,
|
|
1459
|
+
name: 'other',
|
|
1460
|
+
shownToUser: false,
|
|
1461
|
+
errorCode: 4008,
|
|
1462
|
+
serviceErrorCode: 10000,
|
|
1463
|
+
rawErrorMessage: undefined,
|
|
1464
|
+
});
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
it('should include rawErrorMessage if provided', () => {
|
|
1468
|
+
const res = cd.getErrorPayloadForClientErrorCode({
|
|
1469
|
+
clientErrorCode: 4008,
|
|
1470
|
+
serviceErrorCode: 10000,
|
|
1471
|
+
rawErrorMessage: 'bad times',
|
|
1472
|
+
});
|
|
1473
|
+
assert.deepEqual(res, {
|
|
1474
|
+
category: 'signaling',
|
|
1475
|
+
errorDescription: 'NewLocusError',
|
|
1476
|
+
fatal: true,
|
|
1477
|
+
name: 'other',
|
|
1478
|
+
shownToUser: false,
|
|
1479
|
+
errorCode: 4008,
|
|
1480
|
+
serviceErrorCode: 10000,
|
|
1481
|
+
rawErrorMessage: 'bad times',
|
|
1482
|
+
});
|
|
1483
|
+
});
|
|
1484
|
+
|
|
1485
|
+
it('should generate the correct payload for client error 4009', () => {
|
|
1486
|
+
const res = cd.getErrorPayloadForClientErrorCode({
|
|
1487
|
+
clientErrorCode: 4009,
|
|
1488
|
+
serviceErrorCode: undefined,
|
|
1489
|
+
});
|
|
1490
|
+
assert.deepEqual(res, {
|
|
1491
|
+
category: 'network',
|
|
1492
|
+
errorDescription: 'NetworkUnavailable',
|
|
1493
|
+
fatal: true,
|
|
1494
|
+
name: 'other',
|
|
1495
|
+
shownToUser: false,
|
|
1496
|
+
errorCode: 4009,
|
|
1497
|
+
serviceErrorCode: undefined,
|
|
1498
|
+
rawErrorMessage: undefined,
|
|
1499
|
+
});
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
it('it should return undefined if trying to get payload for client error code that doesnt exist', () => {
|
|
1503
|
+
const res = cd.getErrorPayloadForClientErrorCode({
|
|
1504
|
+
clientErrorCode: 123456,
|
|
1505
|
+
serviceErrorCode: 100000,
|
|
1506
|
+
});
|
|
1507
|
+
assert.deepEqual(res, undefined);
|
|
1508
|
+
});
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
describe('#generateClientEventErrorPayload', () => {
|
|
1512
|
+
const defaultExpectedRes = {
|
|
1513
|
+
category: 'expected',
|
|
1514
|
+
errorDescription: 'StartRecordingFailed',
|
|
1515
|
+
fatal: true,
|
|
1516
|
+
name: 'other',
|
|
1517
|
+
shownToUser: false,
|
|
1518
|
+
errorCode: 4029,
|
|
1519
|
+
serviceErrorCode: 2409005,
|
|
1520
|
+
rawErrorMessage: 'bad times',
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
const checkNameError = (payload: any, isExpectedToBeCalled: boolean) => {
|
|
1524
|
+
const res = cd.generateClientEventErrorPayload(payload);
|
|
1525
|
+
const expectedResult = {
|
|
1526
|
+
category: 'expected',
|
|
1527
|
+
errorDescription: 'CameraPermissionDenied',
|
|
1528
|
+
fatal: true,
|
|
1529
|
+
name: 'other',
|
|
1530
|
+
shownToUser: false,
|
|
1531
|
+
serviceErrorCode: undefined,
|
|
1532
|
+
errorCode: 4032,
|
|
1533
|
+
errorData: {errorName: payload.name},
|
|
1534
|
+
rawErrorMessage: payload.message,
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
if (isExpectedToBeCalled) {
|
|
1538
|
+
assert.deepEqual(res, expectedResult);
|
|
1539
|
+
} else {
|
|
1540
|
+
assert.notDeepEqual(res, expectedResult);
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
it('should generate media event error payload if rawError has a media error name', () => {
|
|
1545
|
+
checkNameError({name: 'PermissionDeniedError', message: 'bad times'}, true);
|
|
1546
|
+
});
|
|
1547
|
+
|
|
1548
|
+
it('should not generate media event error payload if rawError has a name that is not recognized', () => {
|
|
1549
|
+
checkNameError({name: 'SomeRandomError', message: 'bad times'}, false);
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
const checkCodeError = (payload: any, expetedRes: any) => {
|
|
1553
|
+
const res = cd.generateClientEventErrorPayload(payload);
|
|
1554
|
+
assert.deepEqual(res, expetedRes);
|
|
1555
|
+
};
|
|
1556
|
+
it('should generate event error payload correctly', () => {
|
|
1557
|
+
checkCodeError({body: {errorCode: 2409005}, message: 'bad times'}, defaultExpectedRes);
|
|
1558
|
+
});
|
|
1559
|
+
|
|
1560
|
+
it('should generate event error payload correctly if rawError has body.code', () => {
|
|
1561
|
+
checkCodeError({body: {code: 2409005}, message: 'bad times'}, defaultExpectedRes);
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
it('should generate event error payload correctly if rawError has body.reason.reasonCode', () => {
|
|
1565
|
+
checkCodeError(
|
|
1566
|
+
{body: {reason: {reasonCode: 2409005}}, message: 'bad times'},
|
|
1567
|
+
defaultExpectedRes
|
|
1568
|
+
);
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1571
|
+
it('should generate event error payload correctly if rawError has error.body.errorCode', () => {
|
|
1572
|
+
checkCodeError(
|
|
1573
|
+
{error: {body: {errorCode: 2409005}}, message: 'bad times'},
|
|
1574
|
+
defaultExpectedRes
|
|
1575
|
+
);
|
|
1576
|
+
});
|
|
1577
|
+
|
|
1578
|
+
const checkLocusError = (payload: any, isExpectedToBeCalled: boolean) => {
|
|
1579
|
+
const res = cd.generateClientEventErrorPayload(payload);
|
|
1580
|
+
const expectedResult = {
|
|
1581
|
+
category: 'signaling',
|
|
1582
|
+
errorDescription: 'NewLocusError',
|
|
1583
|
+
fatal: true,
|
|
1584
|
+
name: 'other',
|
|
1585
|
+
shownToUser: false,
|
|
1586
|
+
serviceErrorCode: 2400000,
|
|
1587
|
+
errorCode: 4008,
|
|
1588
|
+
rawErrorMessage: 'bad times',
|
|
1589
|
+
};
|
|
1590
|
+
|
|
1591
|
+
if (isExpectedToBeCalled) {
|
|
1592
|
+
assert.deepEqual(res, expectedResult);
|
|
1593
|
+
} else {
|
|
1594
|
+
assert.notDeepEqual(res, expectedResult);
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
it('should return default new locus event error payload correctly if locus error is recognized', () => {
|
|
1599
|
+
checkLocusError({body: {errorCode: 2400000}, message: 'bad times'}, true);
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
it('should not return default new locus event error payload correctly if locus is not recognized', () => {
|
|
1603
|
+
checkLocusError({body: {errorCode: 1400000}, message: 'bad times'}, false);
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1606
|
+
const checkMeetingInfoError = (payload: any, isExpectedToBeCalled: boolean) => {
|
|
1607
|
+
const res = cd.generateClientEventErrorPayload(payload);
|
|
1608
|
+
const expectedResult = {
|
|
1609
|
+
category: 'signaling',
|
|
1610
|
+
errorDescription: 'MeetingInfoLookupError',
|
|
1611
|
+
fatal: true,
|
|
1612
|
+
name: 'other',
|
|
1613
|
+
shownToUser: false,
|
|
1614
|
+
serviceErrorCode: undefined,
|
|
1615
|
+
errorCode: 4100,
|
|
1616
|
+
rawErrorMessage: 'bad times',
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
if (isExpectedToBeCalled) {
|
|
1620
|
+
assert.deepEqual(res, expectedResult);
|
|
1621
|
+
} else {
|
|
1622
|
+
assert.notDeepEqual(res, expectedResult);
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1626
|
+
it('should return default meeting info lookup error payload if data.meetingInfo was found on error body', () => {
|
|
1627
|
+
checkMeetingInfoError(
|
|
1628
|
+
{body: {data: {meetingInfo: 'something'}}, message: 'bad times'},
|
|
1629
|
+
true
|
|
1630
|
+
);
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
it('should return default meeting info lookup error payload if body.url contains wbxappapi', () => {
|
|
1634
|
+
checkMeetingInfoError(
|
|
1635
|
+
{body: {url: '1234567-wbxappapiabcdefg'}, message: 'bad times'},
|
|
1636
|
+
true
|
|
1637
|
+
);
|
|
1638
|
+
});
|
|
1639
|
+
|
|
1640
|
+
it('should not return default meeting info lookup error payload if body.url does not contain wbxappapi and data.meetingInfo was not found on error body', () => {
|
|
1641
|
+
checkMeetingInfoError(
|
|
1642
|
+
{body: {data: '1234567-wbxappapiabcdefg'}, message: 'bad times'},
|
|
1643
|
+
false
|
|
1644
|
+
);
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
it('should return NetworkError code for a NetworkOrCORSERror', () => {
|
|
1648
|
+
const res = cd.generateClientEventErrorPayload(
|
|
1649
|
+
new WebexHttpError.NetworkOrCORSError({
|
|
1650
|
+
url: 'https://example.com',
|
|
1651
|
+
statusCode: 0,
|
|
1652
|
+
body: {},
|
|
1653
|
+
options: {headers: {}, url: 'https://example.com'},
|
|
1654
|
+
})
|
|
1655
|
+
);
|
|
1656
|
+
assert.deepEqual(res, {
|
|
1657
|
+
category: 'network',
|
|
1658
|
+
errorDescription: 'NetworkError',
|
|
1659
|
+
fatal: true,
|
|
1660
|
+
name: 'other',
|
|
1661
|
+
shownToUser: false,
|
|
1662
|
+
serviceErrorCode: undefined,
|
|
1663
|
+
errorCode: 1026,
|
|
1664
|
+
rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
|
|
1665
|
+
});
|
|
1666
|
+
});
|
|
1667
|
+
|
|
1668
|
+
it('should override custom properties for a NetworkOrCORSERror', () => {
|
|
1669
|
+
const error = new WebexHttpError.NetworkOrCORSError({
|
|
1670
|
+
url: 'https://example.com',
|
|
1671
|
+
statusCode: 0,
|
|
1672
|
+
body: {},
|
|
1673
|
+
options: {headers: {}, url: 'https://example.com'},
|
|
1674
|
+
});
|
|
1675
|
+
|
|
1676
|
+
error.payloadOverrides = {
|
|
1677
|
+
shownToUser: true,
|
|
1678
|
+
category: 'expected',
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
const res = cd.generateClientEventErrorPayload(error);
|
|
1682
|
+
assert.deepEqual(res, {
|
|
1683
|
+
category: 'expected',
|
|
1684
|
+
errorDescription: 'NetworkError',
|
|
1685
|
+
fatal: true,
|
|
1686
|
+
name: 'other',
|
|
1687
|
+
shownToUser: true,
|
|
1688
|
+
serviceErrorCode: undefined,
|
|
1689
|
+
errorCode: 1026,
|
|
1690
|
+
rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
|
|
1691
|
+
});
|
|
1692
|
+
});
|
|
1693
|
+
|
|
1694
|
+
it('should return AuthenticationFailed code for an Unauthorized error', () => {
|
|
1695
|
+
const res = cd.generateClientEventErrorPayload(
|
|
1696
|
+
new WebexHttpError.Unauthorized({
|
|
1697
|
+
url: 'https://example.com',
|
|
1698
|
+
statusCode: 0,
|
|
1699
|
+
body: {},
|
|
1700
|
+
options: {headers: {}, url: 'https://example.com'},
|
|
1701
|
+
})
|
|
1702
|
+
);
|
|
1703
|
+
assert.deepEqual(res, {
|
|
1704
|
+
category: 'network',
|
|
1705
|
+
errorDescription: 'AuthenticationFailed',
|
|
1706
|
+
fatal: true,
|
|
1707
|
+
name: 'other',
|
|
1708
|
+
shownToUser: false,
|
|
1709
|
+
serviceErrorCode: undefined,
|
|
1710
|
+
errorCode: 1010,
|
|
1711
|
+
rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
|
|
1712
|
+
});
|
|
1713
|
+
});
|
|
1714
|
+
|
|
1715
|
+
it('should override custom properties for an Unauthorized error', () => {
|
|
1716
|
+
const error = new WebexHttpError.Unauthorized({
|
|
1717
|
+
url: 'https://example.com',
|
|
1718
|
+
statusCode: 0,
|
|
1719
|
+
body: {},
|
|
1720
|
+
options: {headers: {}, url: 'https://example.com'},
|
|
1721
|
+
});
|
|
1722
|
+
|
|
1723
|
+
error.payloadOverrides = {
|
|
1724
|
+
shownToUser: true,
|
|
1725
|
+
category: 'expected',
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
const res = cd.generateClientEventErrorPayload(error);
|
|
1729
|
+
assert.deepEqual(res, {
|
|
1730
|
+
category: 'expected',
|
|
1731
|
+
errorDescription: 'AuthenticationFailed',
|
|
1732
|
+
fatal: true,
|
|
1733
|
+
name: 'other',
|
|
1734
|
+
shownToUser: true,
|
|
1735
|
+
serviceErrorCode: undefined,
|
|
1736
|
+
errorCode: 1010,
|
|
1737
|
+
rawErrorMessage: '{}\nundefined https://example.com\nWEBEX_TRACKING_ID: undefined\n',
|
|
1738
|
+
});
|
|
1739
|
+
});
|
|
1740
|
+
|
|
1741
|
+
it('should return unknown error otherwise', () => {
|
|
1742
|
+
const res = cd.generateClientEventErrorPayload({somethgin: 'new', message: 'bad times'});
|
|
1743
|
+
assert.deepEqual(res, {
|
|
1744
|
+
category: 'other',
|
|
1745
|
+
errorDescription: 'UnknownError',
|
|
1746
|
+
fatal: true,
|
|
1747
|
+
name: 'other',
|
|
1748
|
+
shownToUser: false,
|
|
1749
|
+
serviceErrorCode: 9999,
|
|
1750
|
+
errorCode: 9999,
|
|
1751
|
+
rawErrorMessage: 'bad times',
|
|
1752
|
+
});
|
|
1753
|
+
});
|
|
1754
|
+
|
|
1755
|
+
it('should generate event error payload correctly for locus error 2423012', () => {
|
|
1756
|
+
const res = cd.generateClientEventErrorPayload({
|
|
1757
|
+
body: {errorCode: 2423012},
|
|
1758
|
+
message: 'bad times',
|
|
1759
|
+
});
|
|
1760
|
+
assert.deepEqual(res, {
|
|
1761
|
+
category: 'expected',
|
|
1762
|
+
errorDescription: 'FraudDetection',
|
|
1763
|
+
fatal: true,
|
|
1764
|
+
name: 'locus.response',
|
|
1765
|
+
shownToUser: true,
|
|
1766
|
+
serviceErrorCode: 2423012,
|
|
1767
|
+
errorCode: 12000,
|
|
1768
|
+
rawErrorMessage: 'bad times',
|
|
1769
|
+
});
|
|
1770
|
+
});
|
|
1771
|
+
it('should generate event error payload correctly for locus error 2409062', () => {
|
|
1772
|
+
const res = cd.generateClientEventErrorPayload({
|
|
1773
|
+
body: {errorCode: 2409062},
|
|
1774
|
+
message: 'bad times',
|
|
1775
|
+
});
|
|
1776
|
+
assert.deepEqual(res, {
|
|
1777
|
+
category: 'expected',
|
|
1778
|
+
errorDescription: 'E2EENotSupported',
|
|
1779
|
+
fatal: true,
|
|
1780
|
+
name: 'locus.response',
|
|
1781
|
+
shownToUser: true,
|
|
1782
|
+
serviceErrorCode: 2409062,
|
|
1783
|
+
errorCode: 12002,
|
|
1784
|
+
rawErrorMessage: 'bad times',
|
|
1785
|
+
});
|
|
1786
|
+
});
|
|
1787
|
+
|
|
1788
|
+
it('should generate event error payload correctly for locus error 2423021', () => {
|
|
1789
|
+
const res = cd.generateClientEventErrorPayload({
|
|
1790
|
+
body: {errorCode: 2423021},
|
|
1791
|
+
message: 'bad times',
|
|
1792
|
+
});
|
|
1793
|
+
assert.deepEqual(res, {
|
|
1794
|
+
category: 'expected',
|
|
1795
|
+
errorDescription: 'LocusLobbyFullCMR',
|
|
1796
|
+
fatal: true,
|
|
1797
|
+
name: 'locus.response',
|
|
1798
|
+
shownToUser: true,
|
|
1799
|
+
serviceErrorCode: 2423021,
|
|
1800
|
+
errorCode: 12001,
|
|
1801
|
+
rawErrorMessage: 'bad times',
|
|
1802
|
+
});
|
|
1803
|
+
});
|
|
1804
|
+
});
|
|
1805
|
+
|
|
1806
|
+
describe('#getCurLoginType', () => {
|
|
1807
|
+
it('returns login-ci if not unverified guest', () => {
|
|
1808
|
+
webex.credentials.isUnverifiedGuest = false;
|
|
1809
|
+
assert.deepEqual(cd.getCurLoginType(), 'login-ci');
|
|
1810
|
+
});
|
|
1811
|
+
it('returns unverified guest', () => {
|
|
1812
|
+
webex.credentials.isUnverifiedGuest = true;
|
|
1813
|
+
assert.deepEqual(cd.getCurLoginType(), 'unverified-guest');
|
|
1814
|
+
});
|
|
1815
|
+
});
|
|
1816
|
+
|
|
1817
|
+
describe('#getSubServiceType', () => {
|
|
1818
|
+
it('returns subServicetype as PMR when PMR meeting', () => {
|
|
1819
|
+
fakeMeeting.meetingInfo = {
|
|
1820
|
+
webexScheduled: false,
|
|
1821
|
+
pmr: true,
|
|
1822
|
+
enableEvent: false,
|
|
1823
|
+
};
|
|
1824
|
+
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'PMR');
|
|
1825
|
+
});
|
|
1826
|
+
|
|
1827
|
+
it('returns subServicetype as ScheduledMeeting when regular meeting', () => {
|
|
1828
|
+
fakeMeeting.meetingInfo = {
|
|
1829
|
+
webexScheduled: true,
|
|
1830
|
+
pmr: false,
|
|
1831
|
+
enableEvent: false,
|
|
1832
|
+
};
|
|
1833
|
+
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'ScheduledMeeting');
|
|
1834
|
+
});
|
|
1835
|
+
|
|
1836
|
+
it('returns subServicetype as Webinar when meeting is Webinar', () => {
|
|
1837
|
+
fakeMeeting.meetingInfo = {
|
|
1838
|
+
webexScheduled: true,
|
|
1839
|
+
pmr: false,
|
|
1840
|
+
enableEvent: true,
|
|
1841
|
+
};
|
|
1842
|
+
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'Webinar');
|
|
1843
|
+
});
|
|
1844
|
+
|
|
1845
|
+
it('returns subServicetype as undefined when correct parameters are not found', () => {
|
|
1846
|
+
fakeMeeting.meetingInfo = {};
|
|
1847
|
+
assert.deepEqual(cd.getSubServiceType(fakeMeeting), undefined);
|
|
1848
|
+
});
|
|
1849
|
+
});
|
|
1850
|
+
|
|
1851
|
+
describe('#getIsConvergedArchitectureEnabled', () => {
|
|
1852
|
+
it('returns true if converged architecture is enabled', () => {
|
|
1853
|
+
fakeMeeting.meetingInfo = {enableConvergedArchitecture: true};
|
|
1854
|
+
assert.deepEqual(cd.getIsConvergedArchitectureEnabled({meetingId: fakeMeeting.id}), true);
|
|
1855
|
+
});
|
|
1856
|
+
it('returns false if converged architecture is not enabled', () => {
|
|
1857
|
+
fakeMeeting.meetingInfo = {enableConvergedArchitecture: false};
|
|
1858
|
+
assert.deepEqual(cd.getIsConvergedArchitectureEnabled({meetingId: fakeMeeting.id}), false);
|
|
1859
|
+
});
|
|
1860
|
+
it('returns undefined if converged architecture is not defined', () => {
|
|
1861
|
+
fakeMeeting.meetingInfo = {};
|
|
1862
|
+
assert.deepEqual(
|
|
1863
|
+
cd.getIsConvergedArchitectureEnabled({meetingId: fakeMeeting.id}),
|
|
1864
|
+
undefined
|
|
1865
|
+
);
|
|
1866
|
+
});
|
|
1867
|
+
});
|
|
1868
|
+
|
|
1869
|
+
describe('#buildClientEventFetchRequestOptions', () => {
|
|
1870
|
+
[undefined, 'myPreLoginId'].forEach((preLoginId) => {
|
|
1871
|
+
it('returns expected options without preLoginId', async () => {
|
|
1872
|
+
const options = {
|
|
1873
|
+
meetingId: fakeMeeting.id,
|
|
1874
|
+
preLoginId,
|
|
1875
|
+
};
|
|
1876
|
+
|
|
1877
|
+
const triggered = new Date();
|
|
1878
|
+
const fetchOptions = await cd.buildClientEventFetchRequestOptions({
|
|
1879
|
+
name: 'client.exit.app',
|
|
1880
|
+
payload: {trigger: 'user-interaction', canProceed: false},
|
|
1881
|
+
options,
|
|
1882
|
+
});
|
|
1883
|
+
|
|
1884
|
+
assert.deepEqual(fetchOptions.body, {
|
|
1885
|
+
metrics: [
|
|
1886
|
+
{
|
|
1887
|
+
eventPayload: {
|
|
1888
|
+
event: {
|
|
1889
|
+
canProceed: false,
|
|
1890
|
+
eventData: {
|
|
1891
|
+
webClientDomain: 'whatever',
|
|
1892
|
+
},
|
|
1893
|
+
identifiers: {
|
|
1894
|
+
correlationId: 'correlationId',
|
|
1895
|
+
deviceId: 'deviceUrl',
|
|
1896
|
+
locusId: 'url',
|
|
1897
|
+
locusStartTime: 'lastActive',
|
|
1898
|
+
locusUrl: 'locus/url',
|
|
1899
|
+
orgId: 'orgId',
|
|
1900
|
+
userId: 'userId',
|
|
1901
|
+
},
|
|
1902
|
+
loginType: 'login-ci',
|
|
1903
|
+
name: 'client.exit.app',
|
|
1904
|
+
trigger: 'user-interaction',
|
|
1905
|
+
userType: 'host',
|
|
1906
|
+
isConvergedArchitectureEnabled: undefined,
|
|
1907
|
+
webexSubServiceType: undefined,
|
|
1908
|
+
},
|
|
1909
|
+
eventId: 'my-fake-id',
|
|
1910
|
+
origin: {
|
|
1911
|
+
buildType: 'test',
|
|
1912
|
+
clientInfo: {
|
|
1913
|
+
clientType: 'TEAMS_CLIENT',
|
|
1914
|
+
clientVersion: 'webex-js-sdk/webex-version',
|
|
1915
|
+
localNetworkPrefix:
|
|
1916
|
+
Utils.anonymizeIPAddress(webex.meetings.geoHintInfo?.clientAddress) ||
|
|
1917
|
+
undefined,
|
|
1918
|
+
os: getOSNameInternal() || 'unknown',
|
|
1919
|
+
osVersion: getOSVersion(),
|
|
1920
|
+
subClientType: 'WEB_APP',
|
|
1921
|
+
},
|
|
1922
|
+
environment: 'meeting_evn',
|
|
1923
|
+
name: 'endpoint',
|
|
1924
|
+
networkType: 'unknown',
|
|
1925
|
+
userAgent,
|
|
1926
|
+
},
|
|
1927
|
+
originTime: {
|
|
1928
|
+
sent: 'not_defined_yet',
|
|
1929
|
+
triggered: triggered.toISOString(),
|
|
1930
|
+
},
|
|
1931
|
+
senderCountryCode: webex.meetings.geoHintInfo?.countryCode,
|
|
1932
|
+
version: 1,
|
|
1933
|
+
},
|
|
1934
|
+
type: ['diagnostic-event'],
|
|
1935
|
+
},
|
|
1936
|
+
],
|
|
1937
|
+
});
|
|
1938
|
+
|
|
1939
|
+
const rest = omit(fetchOptions, 'body');
|
|
1940
|
+
|
|
1941
|
+
if (preLoginId) {
|
|
1942
|
+
assert.deepEqual(rest, {
|
|
1943
|
+
foo: 'bar',
|
|
1944
|
+
method: 'POST',
|
|
1945
|
+
resource: 'clientmetrics-prelogin',
|
|
1946
|
+
service: 'metrics',
|
|
1947
|
+
waitForServiceTimeout: CONFIG.metrics.waitForServiceTimeout,
|
|
1948
|
+
headers: {
|
|
1949
|
+
authorization: false,
|
|
1950
|
+
'x-prelogin-userid': preLoginId,
|
|
1951
|
+
},
|
|
1952
|
+
});
|
|
1953
|
+
} else {
|
|
1954
|
+
assert.deepEqual(rest, {
|
|
1955
|
+
foo: 'bar',
|
|
1956
|
+
method: 'POST',
|
|
1957
|
+
resource: 'clientmetrics',
|
|
1958
|
+
service: 'metrics',
|
|
1959
|
+
headers: {},
|
|
1960
|
+
waitForServiceTimeout: CONFIG.metrics.waitForServiceTimeout,
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
1965
|
+
|
|
1966
|
+
assert.deepEqual(webexLoggerLogCalls[0].args, [
|
|
1967
|
+
'call-diagnostic-events -> ',
|
|
1968
|
+
'CallDiagnosticMetrics: @buildClientEventFetchRequestOptions. Building request options object for fetch()...',
|
|
1969
|
+
`name: client.exit.app`,
|
|
1970
|
+
]);
|
|
1971
|
+
});
|
|
1972
|
+
});
|
|
1973
|
+
});
|
|
1974
|
+
|
|
1975
|
+
describe('#submitToCallDiagnosticsPreLogin', async () => {
|
|
1976
|
+
it('should call webex.request with expected options', async () => {
|
|
1977
|
+
sinon.spy(Utils, 'prepareDiagnosticMetricItem');
|
|
1978
|
+
await cd.submitToCallDiagnosticsPreLogin(
|
|
1979
|
+
{
|
|
1980
|
+
//@ts-ignore
|
|
1981
|
+
event: {name: 'client.alert.displayed', canProceed: true},
|
|
1982
|
+
//@ts-ignore
|
|
1983
|
+
originTime: {triggered: 'now'},
|
|
1984
|
+
},
|
|
1985
|
+
'my-id'
|
|
1986
|
+
);
|
|
1987
|
+
|
|
1988
|
+
assert.calledWith(Utils.prepareDiagnosticMetricItem, webex, {
|
|
1989
|
+
eventPayload: {
|
|
1990
|
+
event: {name: 'client.alert.displayed', canProceed: true},
|
|
1991
|
+
originTime: {triggered: 'now', sent: now.toISOString()},
|
|
1992
|
+
origin: {buildType: 'test', networkType: 'unknown'},
|
|
1993
|
+
},
|
|
1994
|
+
type: ['diagnostic-event'],
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
assert.calledWith(
|
|
1998
|
+
webex.internal.newMetrics.postPreLoginMetric,
|
|
1999
|
+
{
|
|
2000
|
+
eventPayload: {
|
|
2001
|
+
event: {
|
|
2002
|
+
name: 'client.alert.displayed',
|
|
2003
|
+
canProceed: true,
|
|
2004
|
+
},
|
|
2005
|
+
originTime: {
|
|
2006
|
+
sent: now.toISOString(),
|
|
2007
|
+
triggered: 'now',
|
|
2008
|
+
},
|
|
2009
|
+
origin: {
|
|
2010
|
+
buildType: 'test',
|
|
2011
|
+
networkType: 'unknown',
|
|
2012
|
+
},
|
|
2013
|
+
},
|
|
2014
|
+
type: ['diagnostic-event'],
|
|
2015
|
+
},
|
|
2016
|
+
'my-id'
|
|
2017
|
+
);
|
|
2018
|
+
});
|
|
2019
|
+
});
|
|
2020
|
+
|
|
2021
|
+
describe('#isServiceErrorExpected', () => {
|
|
2022
|
+
it('returns true for code mapped to "expected"', () => {
|
|
2023
|
+
assert.isTrue(cd.isServiceErrorExpected(2423012));
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
it('returns false for code mapped to "signaling"', () => {
|
|
2027
|
+
assert.isFalse(cd.isServiceErrorExpected(400001));
|
|
2028
|
+
});
|
|
2029
|
+
|
|
2030
|
+
it('returns false for unmapped code', () => {
|
|
2031
|
+
assert.isFalse(cd.isServiceErrorExpected(999999));
|
|
2032
|
+
});
|
|
2033
|
+
});
|
|
2034
|
+
});
|
|
2035
|
+
});
|