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