@webex/internal-plugin-metrics 3.8.0-next.2 → 3.8.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/call-diagnostic/call-diagnostic-metrics.js +71 -32
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/config.js +27 -2
- package/dist/call-diagnostic/config.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +15 -4
- package/dist/new-metrics.js.map +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +17 -22
- package/dist/types/call-diagnostic/config.d.ts +11 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/metrics.types.d.ts +7 -1
- package/dist/types/new-metrics.d.ts +10 -3
- package/package.json +12 -12
- package/src/call-diagnostic/call-diagnostic-metrics.ts +66 -42
- package/src/call-diagnostic/config.ts +26 -0
- package/src/index.ts +2 -0
- package/src/metrics.types.ts +8 -1
- package/src/new-metrics.ts +21 -4
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +301 -35
- package/test/unit/spec/new-metrics.ts +27 -3
|
@@ -61,6 +61,11 @@ describe('internal-plugin-metrics', () => {
|
|
|
61
61
|
sessionCorrelationId: 'sessionCorrelationId3',
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
const fakeMeeting4 = {
|
|
65
|
+
...fakeMeeting,
|
|
66
|
+
id: '4',
|
|
67
|
+
isoLocalClientMeetingJoinTime: 'testTimeString',
|
|
68
|
+
}
|
|
64
69
|
const fakeMeeting5 = {
|
|
65
70
|
...fakeMeeting,
|
|
66
71
|
id: '5',
|
|
@@ -74,6 +79,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
74
79
|
1: fakeMeeting,
|
|
75
80
|
2: fakeMeeting2,
|
|
76
81
|
3: fakeMeeting3,
|
|
82
|
+
4: fakeMeeting4,
|
|
77
83
|
5: fakeMeeting5,
|
|
78
84
|
};
|
|
79
85
|
|
|
@@ -1080,12 +1086,149 @@ describe('internal-plugin-metrics', () => {
|
|
|
1080
1086
|
]);
|
|
1081
1087
|
});
|
|
1082
1088
|
|
|
1089
|
+
it('should submit client event successfully with meetingId which has a meetingJoinedTime', () => {
|
|
1090
|
+
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
1091
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
1092
|
+
const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
|
|
1093
|
+
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
1094
|
+
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
1095
|
+
const validatorSpy = sinon.spy(cd, 'validator');
|
|
1096
|
+
const options = {
|
|
1097
|
+
meetingId: fakeMeeting4.id,
|
|
1098
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
cd.submitClientEvent({
|
|
1102
|
+
name: 'client.alert.displayed',
|
|
1103
|
+
options,
|
|
1104
|
+
});
|
|
1105
|
+
|
|
1106
|
+
assert.called(getIdentifiersSpy);
|
|
1107
|
+
assert.calledWith(getIdentifiersSpy, {
|
|
1108
|
+
meeting: {...fakeMeeting4},
|
|
1109
|
+
mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
|
|
1110
|
+
webexConferenceIdStr: undefined,
|
|
1111
|
+
globalMeetingId: undefined,
|
|
1112
|
+
sessionCorrelationId: undefined,
|
|
1113
|
+
});
|
|
1114
|
+
assert.notCalled(generateClientEventErrorPayloadSpy);
|
|
1115
|
+
assert.calledWith(
|
|
1116
|
+
prepareDiagnosticEventSpy,
|
|
1117
|
+
{
|
|
1118
|
+
meetingJoinedTime: fakeMeeting4.isoLocalClientMeetingJoinTime,
|
|
1119
|
+
canProceed: true,
|
|
1120
|
+
eventData: {
|
|
1121
|
+
webClientDomain: 'whatever',
|
|
1122
|
+
},
|
|
1123
|
+
identifiers: {
|
|
1124
|
+
correlationId: 'correlationId',
|
|
1125
|
+
deviceId: 'deviceUrl',
|
|
1126
|
+
locusId: 'url',
|
|
1127
|
+
locusStartTime: 'lastActive',
|
|
1128
|
+
locusUrl: 'locus/url',
|
|
1129
|
+
mediaAgentAlias: 'alias',
|
|
1130
|
+
mediaAgentGroupId: '1',
|
|
1131
|
+
orgId: 'orgId',
|
|
1132
|
+
userId: 'userId',
|
|
1133
|
+
},
|
|
1134
|
+
loginType: 'login-ci',
|
|
1135
|
+
webClientPreload: undefined,
|
|
1136
|
+
name: 'client.alert.displayed',
|
|
1137
|
+
userType: 'host',
|
|
1138
|
+
isConvergedArchitectureEnabled: undefined,
|
|
1139
|
+
webexSubServiceType: undefined,
|
|
1140
|
+
},
|
|
1141
|
+
options
|
|
1142
|
+
);
|
|
1143
|
+
assert.calledWith(submitToCallDiagnosticsSpy, {
|
|
1144
|
+
event: {
|
|
1145
|
+
meetingJoinedTime: fakeMeeting4.isoLocalClientMeetingJoinTime,
|
|
1146
|
+
canProceed: true,
|
|
1147
|
+
eventData: {
|
|
1148
|
+
webClientDomain: 'whatever',
|
|
1149
|
+
},
|
|
1150
|
+
identifiers: {
|
|
1151
|
+
correlationId: 'correlationId',
|
|
1152
|
+
deviceId: 'deviceUrl',
|
|
1153
|
+
locusId: 'url',
|
|
1154
|
+
locusStartTime: 'lastActive',
|
|
1155
|
+
locusUrl: 'locus/url',
|
|
1156
|
+
mediaAgentAlias: 'alias',
|
|
1157
|
+
mediaAgentGroupId: '1',
|
|
1158
|
+
orgId: 'orgId',
|
|
1159
|
+
userId: 'userId',
|
|
1160
|
+
},
|
|
1161
|
+
loginType: 'login-ci',
|
|
1162
|
+
webClientPreload: undefined,
|
|
1163
|
+
name: 'client.alert.displayed',
|
|
1164
|
+
userType: 'host',
|
|
1165
|
+
isConvergedArchitectureEnabled: undefined,
|
|
1166
|
+
webexSubServiceType: undefined,
|
|
1167
|
+
},
|
|
1168
|
+
eventId: 'my-fake-id',
|
|
1169
|
+
origin: {
|
|
1170
|
+
origin: 'fake-origin',
|
|
1171
|
+
},
|
|
1172
|
+
originTime: {
|
|
1173
|
+
sent: 'not_defined_yet',
|
|
1174
|
+
triggered: now.toISOString(),
|
|
1175
|
+
},
|
|
1176
|
+
senderCountryCode: 'UK',
|
|
1177
|
+
version: 1,
|
|
1178
|
+
});
|
|
1179
|
+
assert.calledWith(validatorSpy, {
|
|
1180
|
+
type: 'ce',
|
|
1181
|
+
event: {
|
|
1182
|
+
event: {
|
|
1183
|
+
meetingJoinedTime: fakeMeeting4.isoLocalClientMeetingJoinTime,
|
|
1184
|
+
canProceed: true,
|
|
1185
|
+
eventData: {
|
|
1186
|
+
webClientDomain: 'whatever',
|
|
1187
|
+
},
|
|
1188
|
+
identifiers: {
|
|
1189
|
+
correlationId: 'correlationId',
|
|
1190
|
+
deviceId: 'deviceUrl',
|
|
1191
|
+
locusId: 'url',
|
|
1192
|
+
locusStartTime: 'lastActive',
|
|
1193
|
+
locusUrl: 'locus/url',
|
|
1194
|
+
mediaAgentAlias: 'alias',
|
|
1195
|
+
mediaAgentGroupId: '1',
|
|
1196
|
+
orgId: 'orgId',
|
|
1197
|
+
userId: 'userId',
|
|
1198
|
+
},
|
|
1199
|
+
loginType: 'login-ci',
|
|
1200
|
+
webClientPreload: undefined,
|
|
1201
|
+
name: 'client.alert.displayed',
|
|
1202
|
+
userType: 'host',
|
|
1203
|
+
isConvergedArchitectureEnabled: undefined,
|
|
1204
|
+
webexSubServiceType: undefined,
|
|
1205
|
+
},
|
|
1206
|
+
eventId: 'my-fake-id',
|
|
1207
|
+
origin: {
|
|
1208
|
+
origin: 'fake-origin',
|
|
1209
|
+
},
|
|
1210
|
+
originTime: {
|
|
1211
|
+
sent: 'not_defined_yet',
|
|
1212
|
+
triggered: now.toISOString(),
|
|
1213
|
+
},
|
|
1214
|
+
senderCountryCode: 'UK',
|
|
1215
|
+
version: 1,
|
|
1216
|
+
},
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
const webexLoggerLogCalls = webex.logger.log.getCalls();
|
|
1220
|
+
assert.deepEqual(webexLoggerLogCalls[1].args, [
|
|
1221
|
+
'call-diagnostic-events -> ',
|
|
1222
|
+
'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
|
|
1223
|
+
`name: client.alert.displayed`,
|
|
1224
|
+
]);
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1083
1227
|
it('should submit client event successfully with meetingId which has emailInput and userNameInput', () => {
|
|
1084
1228
|
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
1085
1229
|
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
1086
1230
|
const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
|
|
1087
1231
|
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
1088
|
-
const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
|
|
1089
1232
|
sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
|
|
1090
1233
|
const validatorSpy = sinon.spy(cd, 'validator');
|
|
1091
1234
|
const options = {
|
|
@@ -1232,7 +1375,14 @@ describe('internal-plugin-metrics', () => {
|
|
|
1232
1375
|
const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
|
|
1233
1376
|
const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
|
|
1234
1377
|
const validatorSpy = sinon.spy(cd, 'validator');
|
|
1235
|
-
|
|
1378
|
+
|
|
1379
|
+
Object.defineProperty(global, 'navigator', {
|
|
1380
|
+
value: {
|
|
1381
|
+
userAgent,
|
|
1382
|
+
},
|
|
1383
|
+
configurable: true,
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1236
1386
|
sinon.stub(bowser, 'getParser').returns(userAgent);
|
|
1237
1387
|
|
|
1238
1388
|
const options = {
|
|
@@ -1805,7 +1955,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1805
1955
|
assert.deepEqual(webexLoggerLogCalls[2].args, [
|
|
1806
1956
|
'call-diagnostic-events -> ',
|
|
1807
1957
|
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
1808
|
-
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
|
|
1958
|
+
`generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
|
|
1809
1959
|
]);
|
|
1810
1960
|
});
|
|
1811
1961
|
|
|
@@ -1885,7 +2035,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1885
2035
|
assert.deepEqual(webexLoggerLogCalls[2].args, [
|
|
1886
2036
|
'call-diagnostic-events -> ',
|
|
1887
2037
|
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
1888
|
-
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
|
|
2038
|
+
`generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
|
|
1889
2039
|
]);
|
|
1890
2040
|
});
|
|
1891
2041
|
|
|
@@ -1958,7 +2108,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1958
2108
|
assert.deepEqual(webexLoggerLogCalls[2].args, [
|
|
1959
2109
|
'call-diagnostic-events -> ',
|
|
1960
2110
|
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
1961
|
-
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
|
|
2111
|
+
`generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
|
|
1962
2112
|
]);
|
|
1963
2113
|
});
|
|
1964
2114
|
|
|
@@ -2032,7 +2182,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2032
2182
|
assert.deepEqual(webexLoggerLogCalls[2].args, [
|
|
2033
2183
|
'call-diagnostic-events -> ',
|
|
2034
2184
|
'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
|
|
2035
|
-
`generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
|
|
2185
|
+
`generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
|
|
2036
2186
|
]);
|
|
2037
2187
|
});
|
|
2038
2188
|
|
|
@@ -2412,8 +2562,37 @@ describe('internal-plugin-metrics', () => {
|
|
|
2412
2562
|
rawErrorMessage: 'bad times',
|
|
2413
2563
|
};
|
|
2414
2564
|
|
|
2565
|
+
it('should be cached if called twice with the same payload', () => {
|
|
2566
|
+
const error = new Error('bad times');
|
|
2567
|
+
const expectedPayload = {
|
|
2568
|
+
category: 'other',
|
|
2569
|
+
errorCode: 9999,
|
|
2570
|
+
errorData: {errorName: 'Error'},
|
|
2571
|
+
serviceErrorCode: 9999,
|
|
2572
|
+
fatal: true,
|
|
2573
|
+
shownToUser: false,
|
|
2574
|
+
name: 'other',
|
|
2575
|
+
rawErrorMessage: 'bad times',
|
|
2576
|
+
errorDescription: 'UnknownError',
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2580
|
+
assert.isFalse(cached);
|
|
2581
|
+
assert.deepEqual(res, expectedPayload);
|
|
2582
|
+
|
|
2583
|
+
const [res2, cached2] = cd.generateClientEventErrorPayload(error);
|
|
2584
|
+
assert.isTrue(cached2);
|
|
2585
|
+
assert.deepEqual(res2, expectedPayload);
|
|
2586
|
+
|
|
2587
|
+
// after clearing the cache, it should be false again
|
|
2588
|
+
cd.clearErrorCache();
|
|
2589
|
+
const [res3, cached3] = cd.generateClientEventErrorPayload(error);
|
|
2590
|
+
assert.isFalse(cached3);
|
|
2591
|
+
assert.deepEqual(res3, expectedPayload);
|
|
2592
|
+
});
|
|
2593
|
+
|
|
2415
2594
|
const checkNameError = (payload: any, isExpectedToBeCalled: boolean) => {
|
|
2416
|
-
const res = cd.generateClientEventErrorPayload(payload);
|
|
2595
|
+
const [res, cached] = cd.generateClientEventErrorPayload(payload);
|
|
2417
2596
|
const expectedResult = {
|
|
2418
2597
|
category: 'expected',
|
|
2419
2598
|
errorDescription: 'CameraPermissionDenied',
|
|
@@ -2442,7 +2621,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2442
2621
|
});
|
|
2443
2622
|
|
|
2444
2623
|
const checkCodeError = (payload: any, expetedRes: any) => {
|
|
2445
|
-
const res = cd.generateClientEventErrorPayload(payload);
|
|
2624
|
+
const [res, cached] = cd.generateClientEventErrorPayload(payload);
|
|
2446
2625
|
assert.deepEqual(res, expetedRes);
|
|
2447
2626
|
};
|
|
2448
2627
|
it('should generate event error payload correctly', () => {
|
|
@@ -2468,7 +2647,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2468
2647
|
});
|
|
2469
2648
|
|
|
2470
2649
|
const checkLocusError = (payload: any, isExpectedToBeCalled: boolean) => {
|
|
2471
|
-
const res = cd.generateClientEventErrorPayload(payload);
|
|
2650
|
+
const [res, cached] = cd.generateClientEventErrorPayload(payload);
|
|
2472
2651
|
const expectedResult = {
|
|
2473
2652
|
category: 'signaling',
|
|
2474
2653
|
errorDescription: 'NewLocusError',
|
|
@@ -2496,7 +2675,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2496
2675
|
});
|
|
2497
2676
|
|
|
2498
2677
|
const checkMeetingInfoError = (payload: any, isExpectedToBeCalled: boolean) => {
|
|
2499
|
-
const res = cd.generateClientEventErrorPayload(payload);
|
|
2678
|
+
const [res, cached] = cd.generateClientEventErrorPayload(payload);
|
|
2500
2679
|
const expectedResult = {
|
|
2501
2680
|
category: 'signaling',
|
|
2502
2681
|
errorDescription: 'MeetingInfoLookupError',
|
|
@@ -2537,7 +2716,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2537
2716
|
});
|
|
2538
2717
|
|
|
2539
2718
|
it('should return NetworkError code for a NetworkOrCORSERror', () => {
|
|
2540
|
-
const res = cd.generateClientEventErrorPayload(
|
|
2719
|
+
const [res, cached] = cd.generateClientEventErrorPayload(
|
|
2541
2720
|
new WebexHttpError.NetworkOrCORSError({
|
|
2542
2721
|
url: 'https://example.com',
|
|
2543
2722
|
statusCode: 0,
|
|
@@ -2581,7 +2760,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2581
2760
|
message: 'No codecs present in m-line with MID 0 after filtering.',
|
|
2582
2761
|
},
|
|
2583
2762
|
};
|
|
2584
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
2763
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2585
2764
|
assert.deepEqual(res, {
|
|
2586
2765
|
category: 'expected',
|
|
2587
2766
|
errorCode: 2051,
|
|
@@ -2607,7 +2786,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2607
2786
|
message: 'empty local SDP',
|
|
2608
2787
|
},
|
|
2609
2788
|
};
|
|
2610
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
2789
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2611
2790
|
assert.deepEqual(res, {
|
|
2612
2791
|
category: 'media',
|
|
2613
2792
|
errorCode: 2050,
|
|
@@ -2632,7 +2811,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2632
2811
|
category: 'expected',
|
|
2633
2812
|
};
|
|
2634
2813
|
|
|
2635
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
2814
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2636
2815
|
assert.deepEqual(res, {
|
|
2637
2816
|
category: 'expected',
|
|
2638
2817
|
errorDescription: 'UnknownError',
|
|
@@ -2661,7 +2840,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2661
2840
|
category: 'expected',
|
|
2662
2841
|
};
|
|
2663
2842
|
|
|
2664
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
2843
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2665
2844
|
assert.deepEqual(res, {
|
|
2666
2845
|
category: 'expected',
|
|
2667
2846
|
errorDescription: 'NetworkError',
|
|
@@ -2676,7 +2855,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2676
2855
|
});
|
|
2677
2856
|
|
|
2678
2857
|
it('should return AuthenticationFailed code for an Unauthorized error', () => {
|
|
2679
|
-
const res = cd.generateClientEventErrorPayload(
|
|
2858
|
+
const [res, cached] = cd.generateClientEventErrorPayload(
|
|
2680
2859
|
new WebexHttpError.Unauthorized({
|
|
2681
2860
|
url: 'https://example.com',
|
|
2682
2861
|
statusCode: 0,
|
|
@@ -2709,7 +2888,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2709
2888
|
category: 'expected',
|
|
2710
2889
|
};
|
|
2711
2890
|
|
|
2712
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
2891
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2713
2892
|
assert.deepEqual(res, {
|
|
2714
2893
|
category: 'expected',
|
|
2715
2894
|
errorDescription: 'AuthenticationFailed',
|
|
@@ -2724,7 +2903,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2724
2903
|
});
|
|
2725
2904
|
|
|
2726
2905
|
it('should return unknown error otherwise', () => {
|
|
2727
|
-
const res = cd.generateClientEventErrorPayload({something: 'new', message: 'bad times'});
|
|
2906
|
+
const [res, cached] = cd.generateClientEventErrorPayload({something: 'new', message: 'bad times'});
|
|
2728
2907
|
assert.deepEqual(res, {
|
|
2729
2908
|
category: 'other',
|
|
2730
2909
|
errorDescription: 'UnknownError',
|
|
@@ -2738,7 +2917,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2738
2917
|
});
|
|
2739
2918
|
|
|
2740
2919
|
it('should generate event error payload correctly for locus error 2423012', () => {
|
|
2741
|
-
const res = cd.generateClientEventErrorPayload({
|
|
2920
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2742
2921
|
body: {errorCode: 2423012},
|
|
2743
2922
|
message: 'bad times',
|
|
2744
2923
|
});
|
|
@@ -2754,7 +2933,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2754
2933
|
});
|
|
2755
2934
|
});
|
|
2756
2935
|
it('should generate event error payload correctly for locus error 2409062', () => {
|
|
2757
|
-
const res = cd.generateClientEventErrorPayload({
|
|
2936
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2758
2937
|
body: {errorCode: 2409062},
|
|
2759
2938
|
message: 'bad times',
|
|
2760
2939
|
});
|
|
@@ -2771,7 +2950,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2771
2950
|
});
|
|
2772
2951
|
|
|
2773
2952
|
it('should generate event error payload correctly for locus error 2423021', () => {
|
|
2774
|
-
const res = cd.generateClientEventErrorPayload({
|
|
2953
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2775
2954
|
body: {errorCode: 2423021},
|
|
2776
2955
|
message: 'bad times',
|
|
2777
2956
|
});
|
|
@@ -2788,7 +2967,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2788
2967
|
});
|
|
2789
2968
|
|
|
2790
2969
|
it('should generate event error payload correctly for wdm error 4404002', () => {
|
|
2791
|
-
const res = cd.generateClientEventErrorPayload({
|
|
2970
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2792
2971
|
body: {errorCode: 4404002},
|
|
2793
2972
|
message: 'Operation denied due to region restriction',
|
|
2794
2973
|
});
|
|
@@ -2805,7 +2984,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2805
2984
|
});
|
|
2806
2985
|
|
|
2807
2986
|
it('should generate event error payload correctly for wdm error 4404003', () => {
|
|
2808
|
-
const res = cd.generateClientEventErrorPayload({
|
|
2987
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2809
2988
|
body: {errorCode: 4404003},
|
|
2810
2989
|
message: 'Operation denied due to region restriction',
|
|
2811
2990
|
});
|
|
@@ -2823,7 +3002,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2823
3002
|
|
|
2824
3003
|
describe('httpStatusCode', () => {
|
|
2825
3004
|
it('should include httpStatusCode for browser media errors', () => {
|
|
2826
|
-
const res = cd.generateClientEventErrorPayload({
|
|
3005
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2827
3006
|
name: 'PermissionDeniedError',
|
|
2828
3007
|
message: 'bad times',
|
|
2829
3008
|
statusCode: 401,
|
|
@@ -2845,7 +3024,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2845
3024
|
});
|
|
2846
3025
|
|
|
2847
3026
|
it('should include httpStatusCode for SdpOfferCreationErrors', () => {
|
|
2848
|
-
const res = cd.generateClientEventErrorPayload({
|
|
3027
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2849
3028
|
name: 'SdpOfferCreationError',
|
|
2850
3029
|
message: 'bad times',
|
|
2851
3030
|
statusCode: 404,
|
|
@@ -2867,7 +3046,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2867
3046
|
});
|
|
2868
3047
|
|
|
2869
3048
|
it('should include httpStatusCode for service error codes', () => {
|
|
2870
|
-
const res = cd.generateClientEventErrorPayload({
|
|
3049
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2871
3050
|
body: {errorCode: 58400},
|
|
2872
3051
|
message: 'bad times',
|
|
2873
3052
|
statusCode: 400,
|
|
@@ -2886,7 +3065,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2886
3065
|
});
|
|
2887
3066
|
|
|
2888
3067
|
it('should include httpStatusCode for locus service error codes', () => {
|
|
2889
|
-
const res = cd.generateClientEventErrorPayload({
|
|
3068
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2890
3069
|
body: {errorCode: 2403001},
|
|
2891
3070
|
message: 'bad times',
|
|
2892
3071
|
statusCode: 400,
|
|
@@ -2905,7 +3084,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2905
3084
|
});
|
|
2906
3085
|
|
|
2907
3086
|
it('should include httpStatusCode for meetingInfo service error codes', () => {
|
|
2908
|
-
const res = cd.generateClientEventErrorPayload({
|
|
3087
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2909
3088
|
body: {data: {meetingInfo: {}}},
|
|
2910
3089
|
message: 'bad times',
|
|
2911
3090
|
statusCode: 400,
|
|
@@ -2928,7 +3107,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2928
3107
|
statusCode: 400,
|
|
2929
3108
|
options: {service: '', headers: {}},
|
|
2930
3109
|
});
|
|
2931
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
3110
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2932
3111
|
assert.deepEqual(res, {
|
|
2933
3112
|
category: 'network',
|
|
2934
3113
|
errorCode: 1026,
|
|
@@ -2947,7 +3126,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2947
3126
|
statusCode: 401,
|
|
2948
3127
|
options: {service: '', headers: {}},
|
|
2949
3128
|
});
|
|
2950
|
-
const res = cd.generateClientEventErrorPayload(error);
|
|
3129
|
+
const [res, cached] = cd.generateClientEventErrorPayload(error);
|
|
2951
3130
|
assert.deepEqual(res, {
|
|
2952
3131
|
category: 'network',
|
|
2953
3132
|
errorCode: 1010,
|
|
@@ -2962,7 +3141,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2962
3141
|
});
|
|
2963
3142
|
|
|
2964
3143
|
it('should include httpStatusCode for unknown errors', () => {
|
|
2965
|
-
const res = cd.generateClientEventErrorPayload({
|
|
3144
|
+
const [res, cached] = cd.generateClientEventErrorPayload({
|
|
2966
3145
|
message: 'bad times',
|
|
2967
3146
|
statusCode: 404,
|
|
2968
3147
|
});
|
|
@@ -3011,22 +3190,32 @@ describe('internal-plugin-metrics', () => {
|
|
|
3011
3190
|
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'ScheduledMeeting');
|
|
3012
3191
|
});
|
|
3013
3192
|
|
|
3014
|
-
it('returns subServicetype as Webinar when meeting is Webinar', () => {
|
|
3193
|
+
it('returns subServicetype as Webinar when meeting is non-converged Webinar', () => {
|
|
3015
3194
|
fakeMeeting.meetingInfo = {
|
|
3016
3195
|
webexScheduled: true,
|
|
3017
3196
|
pmr: false,
|
|
3197
|
+
enableEvent: true,
|
|
3198
|
+
enableConvergedArchitecture: false,
|
|
3199
|
+
};
|
|
3200
|
+
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'Webinar');
|
|
3201
|
+
});
|
|
3202
|
+
|
|
3203
|
+
it('returns subServicetype as Webinar when meeting is converged Webinar', () => {
|
|
3204
|
+
fakeMeeting.meetingInfo = {
|
|
3018
3205
|
enableEvent: true,
|
|
3019
3206
|
isConvergedWebinar: true,
|
|
3207
|
+
isConvergedWebinarWebcast: false,
|
|
3208
|
+
enableConvergedArchitecture: true,
|
|
3020
3209
|
};
|
|
3021
3210
|
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'Webinar');
|
|
3022
3211
|
});
|
|
3023
3212
|
|
|
3024
|
-
it('returns subServicetype as Webcast when meeting is Webinar and enable webcast', () => {
|
|
3213
|
+
it('returns subServicetype as Webcast when meeting is converged Webinar and enable webcast', () => {
|
|
3025
3214
|
fakeMeeting.meetingInfo = {
|
|
3026
|
-
webexScheduled: true,
|
|
3027
|
-
pmr: false,
|
|
3028
3215
|
enableEvent: true,
|
|
3216
|
+
isConvergedWebinar: false,
|
|
3029
3217
|
isConvergedWebinarWebcast: true,
|
|
3218
|
+
enableConvergedArchitecture: true,
|
|
3030
3219
|
};
|
|
3031
3220
|
assert.deepEqual(cd.getSubServiceType(fakeMeeting), 'Webcast');
|
|
3032
3221
|
});
|
|
@@ -3309,6 +3498,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
3309
3498
|
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
3310
3499
|
|
|
3311
3500
|
const options = {
|
|
3501
|
+
meetingId: 'meetingId',
|
|
3312
3502
|
correlationId: 'correlationId',
|
|
3313
3503
|
};
|
|
3314
3504
|
|
|
@@ -3341,6 +3531,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
3341
3531
|
name: 'client.alert.displayed',
|
|
3342
3532
|
payload: undefined,
|
|
3343
3533
|
options: {
|
|
3534
|
+
meetingId: 'meetingId',
|
|
3344
3535
|
correlationId: 'correlationId',
|
|
3345
3536
|
triggeredTime: now.toISOString(),
|
|
3346
3537
|
},
|
|
@@ -3349,6 +3540,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
3349
3540
|
name: 'client.alert.removed',
|
|
3350
3541
|
payload: undefined,
|
|
3351
3542
|
options: {
|
|
3543
|
+
meetingId: 'meetingId',
|
|
3352
3544
|
correlationId: 'correlationId',
|
|
3353
3545
|
triggeredTime: now.toISOString(),
|
|
3354
3546
|
},
|
|
@@ -3357,6 +3549,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
3357
3549
|
name: 'client.call.aborted',
|
|
3358
3550
|
payload: undefined,
|
|
3359
3551
|
options: {
|
|
3552
|
+
meetingId: 'meetingId',
|
|
3360
3553
|
correlationId: 'correlationId',
|
|
3361
3554
|
triggeredTime: now.toISOString(),
|
|
3362
3555
|
},
|
|
@@ -3368,6 +3561,79 @@ describe('internal-plugin-metrics', () => {
|
|
|
3368
3561
|
// should not call submitClientEvent again if delayedClientEvents was cleared
|
|
3369
3562
|
assert.notCalled(submitClientEventSpy);
|
|
3370
3563
|
});
|
|
3564
|
+
|
|
3565
|
+
it('calls submitClientEvent for every delayed event with overrides and clears delayedClientEvents array', () => {
|
|
3566
|
+
const submitClientEventSpy = sinon.spy(cd, 'submitClientEvent');
|
|
3567
|
+
const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
|
|
3568
|
+
|
|
3569
|
+
const options = {
|
|
3570
|
+
meetingId: 'meetingId',
|
|
3571
|
+
correlationId: 'correlationId',
|
|
3572
|
+
};
|
|
3573
|
+
|
|
3574
|
+
const overrides = {
|
|
3575
|
+
correlationId: 'newCorrelationId',
|
|
3576
|
+
}
|
|
3577
|
+
|
|
3578
|
+
cd.submitClientEvent({
|
|
3579
|
+
name: 'client.alert.displayed',
|
|
3580
|
+
options,
|
|
3581
|
+
delaySubmitEvent: true,
|
|
3582
|
+
});
|
|
3583
|
+
|
|
3584
|
+
cd.submitClientEvent({
|
|
3585
|
+
name: 'client.alert.removed',
|
|
3586
|
+
options,
|
|
3587
|
+
delaySubmitEvent: true,
|
|
3588
|
+
});
|
|
3589
|
+
|
|
3590
|
+
cd.submitClientEvent({
|
|
3591
|
+
name: 'client.call.aborted',
|
|
3592
|
+
options,
|
|
3593
|
+
delaySubmitEvent: true,
|
|
3594
|
+
});
|
|
3595
|
+
|
|
3596
|
+
assert.notCalled(submitToCallDiagnosticsSpy);
|
|
3597
|
+
assert.calledThrice(submitClientEventSpy);
|
|
3598
|
+
submitClientEventSpy.resetHistory();
|
|
3599
|
+
|
|
3600
|
+
cd.submitDelayedClientEvents(overrides);
|
|
3601
|
+
|
|
3602
|
+
assert.calledThrice(submitClientEventSpy);
|
|
3603
|
+
assert.calledWith(submitClientEventSpy.firstCall, {
|
|
3604
|
+
name: 'client.alert.displayed',
|
|
3605
|
+
payload: undefined,
|
|
3606
|
+
options: {
|
|
3607
|
+
meetingId: 'meetingId',
|
|
3608
|
+
correlationId: 'newCorrelationId',
|
|
3609
|
+
triggeredTime: now.toISOString(),
|
|
3610
|
+
},
|
|
3611
|
+
});
|
|
3612
|
+
assert.calledWith(submitClientEventSpy.secondCall, {
|
|
3613
|
+
name: 'client.alert.removed',
|
|
3614
|
+
payload: undefined,
|
|
3615
|
+
options: {
|
|
3616
|
+
meetingId: 'meetingId',
|
|
3617
|
+
correlationId: 'newCorrelationId',
|
|
3618
|
+
triggeredTime: now.toISOString(),
|
|
3619
|
+
},
|
|
3620
|
+
});
|
|
3621
|
+
assert.calledWith(submitClientEventSpy.thirdCall, {
|
|
3622
|
+
name: 'client.call.aborted',
|
|
3623
|
+
payload: undefined,
|
|
3624
|
+
options: {
|
|
3625
|
+
meetingId: 'meetingId',
|
|
3626
|
+
correlationId: 'newCorrelationId',
|
|
3627
|
+
triggeredTime: now.toISOString(),
|
|
3628
|
+
},
|
|
3629
|
+
});
|
|
3630
|
+
submitClientEventSpy.resetHistory();
|
|
3631
|
+
|
|
3632
|
+
cd.submitDelayedClientEvents();
|
|
3633
|
+
|
|
3634
|
+
// should not call submitClientEvent again if delayedClientEvents was cleared
|
|
3635
|
+
assert.notCalled(submitClientEventSpy);
|
|
3636
|
+
});
|
|
3371
3637
|
});
|
|
3372
3638
|
});
|
|
3373
3639
|
});
|
|
@@ -264,19 +264,43 @@ describe('internal-plugin-metrics', () => {
|
|
|
264
264
|
describe('#setDelaySubmitClientEvents', () => {
|
|
265
265
|
it('sets delaySubmitClientEvents correctly and calls submitDelayedClientEvents when set to false', () => {
|
|
266
266
|
sinon.assert.match(webex.internal.newMetrics.delaySubmitClientEvents, false);
|
|
267
|
+
sinon.assert.match(webex.internal.newMetrics.delayedClientEventsOverrides, {});
|
|
267
268
|
|
|
268
|
-
webex.internal.newMetrics.setDelaySubmitClientEvents(true);
|
|
269
|
+
webex.internal.newMetrics.setDelaySubmitClientEvents({shouldDelay: true});
|
|
269
270
|
|
|
270
271
|
assert.notCalled(webex.internal.newMetrics.callDiagnosticMetrics.submitDelayedClientEvents);
|
|
271
272
|
|
|
272
273
|
sinon.assert.match(webex.internal.newMetrics.delaySubmitClientEvents, true);
|
|
274
|
+
sinon.assert.match(webex.internal.newMetrics.delayedClientEventsOverrides, {});
|
|
273
275
|
|
|
274
|
-
webex.internal.newMetrics.setDelaySubmitClientEvents(false);
|
|
276
|
+
webex.internal.newMetrics.setDelaySubmitClientEvents({shouldDelay: false, overrides: {foo: 'bar'}});
|
|
275
277
|
|
|
276
278
|
assert.calledOnce(webex.internal.newMetrics.callDiagnosticMetrics.submitDelayedClientEvents);
|
|
277
|
-
assert.calledWith(webex.internal.newMetrics.callDiagnosticMetrics.submitDelayedClientEvents);
|
|
279
|
+
assert.calledWith(webex.internal.newMetrics.callDiagnosticMetrics.submitDelayedClientEvents, {foo: 'bar'});
|
|
278
280
|
|
|
279
281
|
sinon.assert.match(webex.internal.newMetrics.delaySubmitClientEvents, false);
|
|
282
|
+
sinon.assert.match(webex.internal.newMetrics.delayedClientEventsOverrides, {foo: 'bar'});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('should not fail when called before webex is ready', () => {
|
|
286
|
+
|
|
287
|
+
// Create mock
|
|
288
|
+
webex = mockWebex()
|
|
289
|
+
|
|
290
|
+
webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp = sinon.stub();
|
|
291
|
+
webex.internal.newMetrics.callDiagnosticLatencies.clearTimestamps = sinon.stub();
|
|
292
|
+
webex.setTimingsAndFetch = sinon.stub();
|
|
293
|
+
|
|
294
|
+
sinon.assert.match(webex.internal.newMetrics.delaySubmitClientEvents, false);
|
|
295
|
+
|
|
296
|
+
// Call the method before webex is ready, will not throw error
|
|
297
|
+
webex.internal.newMetrics.setDelaySubmitClientEvents({shouldDelay: false});
|
|
298
|
+
webex.internal.newMetrics.setDelaySubmitClientEvents({shouldDelay: true});
|
|
299
|
+
|
|
300
|
+
webex.internal.newMetrics.setDelaySubmitClientEvents({shouldDelay: false});
|
|
301
|
+
// Webex is ready
|
|
302
|
+
webex.emit('ready');
|
|
303
|
+
|
|
280
304
|
});
|
|
281
305
|
});
|
|
282
306
|
});
|