@webex/internal-plugin-metrics 3.12.0-next.30 → 3.12.0-next.32
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-batcher.js +0 -23
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +25 -7
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/prelogin-metrics-batcher.js +0 -23
- package/dist/prelogin-metrics-batcher.js.map +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +30 -1
- package/package.json +3 -3
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +0 -26
- package/src/call-diagnostic/call-diagnostic-metrics.ts +23 -3
- package/src/prelogin-metrics-batcher.ts +0 -26
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +0 -136
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +75 -2
- package/test/unit/spec/prelogin-metrics-batcher.ts +1 -120
|
@@ -868,6 +868,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
868
868
|
identifiers: {correlationId: 'test-id'},
|
|
869
869
|
name: 'client.alert.displayed',
|
|
870
870
|
isAutomatedUser: false,
|
|
871
|
+
userActivation: undefined,
|
|
871
872
|
},
|
|
872
873
|
options
|
|
873
874
|
);
|
|
@@ -889,6 +890,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
889
890
|
identifiers: {correlationId: 'test-id'},
|
|
890
891
|
name: 'client.alert.displayed',
|
|
891
892
|
isAutomatedUser: false,
|
|
893
|
+
userActivation: undefined,
|
|
892
894
|
},
|
|
893
895
|
options
|
|
894
896
|
);
|
|
@@ -928,6 +930,42 @@ describe('internal-plugin-metrics', () => {
|
|
|
928
930
|
});
|
|
929
931
|
});
|
|
930
932
|
|
|
933
|
+
describe('#getUserActivation', () => {
|
|
934
|
+
let originalDescriptor;
|
|
935
|
+
|
|
936
|
+
beforeEach(() => {
|
|
937
|
+
originalDescriptor = Object.getOwnPropertyDescriptor(global, 'navigator');
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
afterEach(() => {
|
|
941
|
+
if (originalDescriptor) {
|
|
942
|
+
Object.defineProperty(global, 'navigator', originalDescriptor);
|
|
943
|
+
} else {
|
|
944
|
+
delete (global as any).navigator;
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
it('should return the userActivation state when navigator.userActivation is available', () => {
|
|
949
|
+
Object.defineProperty(global, 'navigator', {
|
|
950
|
+
value: {userActivation: {hasBeenActive: true, isActive: false}},
|
|
951
|
+
configurable: true,
|
|
952
|
+
writable: true,
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
assert.deepEqual(cd.getUserActivation(), {hasBeenActive: true, isActive: false});
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
it('should return undefined when navigator.userActivation is not available', () => {
|
|
959
|
+
Object.defineProperty(global, 'navigator', {
|
|
960
|
+
value: {},
|
|
961
|
+
configurable: true,
|
|
962
|
+
writable: true,
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
assert.isUndefined(cd.getUserActivation());
|
|
966
|
+
});
|
|
967
|
+
});
|
|
968
|
+
|
|
931
969
|
describe('#submitClientEvent', () => {
|
|
932
970
|
it('should submit client event successfully with meetingId', () => {
|
|
933
971
|
const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
|
|
@@ -986,6 +1024,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
986
1024
|
webClientPreload: undefined,
|
|
987
1025
|
isVipMeeting: false,
|
|
988
1026
|
isAutomatedUser: false,
|
|
1027
|
+
userActivation: undefined,
|
|
989
1028
|
},
|
|
990
1029
|
options
|
|
991
1030
|
);
|
|
@@ -1017,6 +1056,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1017
1056
|
webClientPreload: undefined,
|
|
1018
1057
|
isVipMeeting: false,
|
|
1019
1058
|
isAutomatedUser: false,
|
|
1059
|
+
userActivation: undefined,
|
|
1020
1060
|
},
|
|
1021
1061
|
eventId: 'my-fake-id',
|
|
1022
1062
|
origin: {
|
|
@@ -1059,6 +1099,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1059
1099
|
webClientPreload: undefined,
|
|
1060
1100
|
isVipMeeting: false,
|
|
1061
1101
|
isAutomatedUser: false,
|
|
1102
|
+
userActivation: undefined,
|
|
1062
1103
|
},
|
|
1063
1104
|
eventId: 'my-fake-id',
|
|
1064
1105
|
origin: {
|
|
@@ -1137,6 +1178,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1137
1178
|
webClientPreload: undefined,
|
|
1138
1179
|
isVipMeeting: false,
|
|
1139
1180
|
isAutomatedUser: false,
|
|
1181
|
+
userActivation: undefined,
|
|
1140
1182
|
},
|
|
1141
1183
|
options
|
|
1142
1184
|
);
|
|
@@ -1168,6 +1210,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1168
1210
|
webClientPreload: undefined,
|
|
1169
1211
|
isVipMeeting: false,
|
|
1170
1212
|
isAutomatedUser: false,
|
|
1213
|
+
userActivation: undefined,
|
|
1171
1214
|
},
|
|
1172
1215
|
eventId: 'my-fake-id',
|
|
1173
1216
|
origin: {
|
|
@@ -1210,6 +1253,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1210
1253
|
webClientPreload: undefined,
|
|
1211
1254
|
isVipMeeting: false,
|
|
1212
1255
|
isAutomatedUser: false,
|
|
1256
|
+
userActivation: undefined,
|
|
1213
1257
|
},
|
|
1214
1258
|
eventId: 'my-fake-id',
|
|
1215
1259
|
origin: {
|
|
@@ -1289,6 +1333,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1289
1333
|
webClientPreload: undefined,
|
|
1290
1334
|
isVipMeeting: false,
|
|
1291
1335
|
isAutomatedUser: false,
|
|
1336
|
+
userActivation: undefined,
|
|
1292
1337
|
},
|
|
1293
1338
|
options
|
|
1294
1339
|
);
|
|
@@ -1321,6 +1366,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1321
1366
|
webClientPreload: undefined,
|
|
1322
1367
|
isVipMeeting: false,
|
|
1323
1368
|
isAutomatedUser: false,
|
|
1369
|
+
userActivation: undefined,
|
|
1324
1370
|
},
|
|
1325
1371
|
eventId: 'my-fake-id',
|
|
1326
1372
|
origin: {
|
|
@@ -1364,6 +1410,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1364
1410
|
webClientPreload: undefined,
|
|
1365
1411
|
isVipMeeting: false,
|
|
1366
1412
|
isAutomatedUser: false,
|
|
1413
|
+
userActivation: undefined,
|
|
1367
1414
|
},
|
|
1368
1415
|
eventId: 'my-fake-id',
|
|
1369
1416
|
origin: {
|
|
@@ -1442,6 +1489,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1442
1489
|
webexSubServiceType: undefined,
|
|
1443
1490
|
isVipMeeting: false,
|
|
1444
1491
|
isAutomatedUser: false,
|
|
1492
|
+
userActivation: undefined,
|
|
1445
1493
|
},
|
|
1446
1494
|
options
|
|
1447
1495
|
);
|
|
@@ -1474,6 +1522,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1474
1522
|
webexSubServiceType: undefined,
|
|
1475
1523
|
isVipMeeting: false,
|
|
1476
1524
|
isAutomatedUser: false,
|
|
1525
|
+
userActivation: undefined,
|
|
1477
1526
|
},
|
|
1478
1527
|
eventId: 'my-fake-id',
|
|
1479
1528
|
origin: {
|
|
@@ -1517,6 +1566,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1517
1566
|
webexSubServiceType: undefined,
|
|
1518
1567
|
isVipMeeting: false,
|
|
1519
1568
|
isAutomatedUser: false,
|
|
1569
|
+
userActivation: undefined,
|
|
1520
1570
|
},
|
|
1521
1571
|
eventId: 'my-fake-id',
|
|
1522
1572
|
origin: {
|
|
@@ -1597,6 +1647,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1597
1647
|
webClientPreload: undefined,
|
|
1598
1648
|
isVipMeeting: false,
|
|
1599
1649
|
isAutomatedUser: false,
|
|
1650
|
+
userActivation: undefined,
|
|
1600
1651
|
},
|
|
1601
1652
|
options
|
|
1602
1653
|
);
|
|
@@ -1631,6 +1682,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1631
1682
|
webClientPreload: undefined,
|
|
1632
1683
|
isVipMeeting: false,
|
|
1633
1684
|
isAutomatedUser: false,
|
|
1685
|
+
userActivation: undefined,
|
|
1634
1686
|
},
|
|
1635
1687
|
eventId: 'my-fake-id',
|
|
1636
1688
|
origin: {
|
|
@@ -1676,6 +1728,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1676
1728
|
webClientPreload: undefined,
|
|
1677
1729
|
isVipMeeting: false,
|
|
1678
1730
|
isAutomatedUser: false,
|
|
1731
|
+
userActivation: undefined,
|
|
1679
1732
|
},
|
|
1680
1733
|
eventId: 'my-fake-id',
|
|
1681
1734
|
origin: {
|
|
@@ -1804,6 +1857,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1804
1857
|
name: 'client.alert.displayed',
|
|
1805
1858
|
webClientPreload: undefined,
|
|
1806
1859
|
isAutomatedUser: false,
|
|
1860
|
+
userActivation: undefined,
|
|
1807
1861
|
},
|
|
1808
1862
|
options
|
|
1809
1863
|
);
|
|
@@ -1829,6 +1883,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1829
1883
|
name: 'client.alert.displayed',
|
|
1830
1884
|
webClientPreload: undefined,
|
|
1831
1885
|
isAutomatedUser: false,
|
|
1886
|
+
userActivation: undefined,
|
|
1832
1887
|
},
|
|
1833
1888
|
eventId: 'my-fake-id',
|
|
1834
1889
|
origin: {
|
|
@@ -1906,6 +1961,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1906
1961
|
name: 'client.alert.displayed',
|
|
1907
1962
|
webClientPreload: undefined,
|
|
1908
1963
|
isAutomatedUser: false,
|
|
1964
|
+
userActivation: undefined,
|
|
1909
1965
|
},
|
|
1910
1966
|
options
|
|
1911
1967
|
);
|
|
@@ -1936,6 +1992,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
1936
1992
|
telemetryOptOut: undefined,
|
|
1937
1993
|
webClientPreload: undefined,
|
|
1938
1994
|
isAutomatedUser: false,
|
|
1995
|
+
userActivation: undefined,
|
|
1939
1996
|
},
|
|
1940
1997
|
},
|
|
1941
1998
|
options.preLoginId
|
|
@@ -2001,6 +2058,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2001
2058
|
name: 'client.alert.displayed',
|
|
2002
2059
|
webClientPreload: undefined,
|
|
2003
2060
|
isAutomatedUser: false,
|
|
2061
|
+
userActivation: undefined,
|
|
2004
2062
|
},
|
|
2005
2063
|
options
|
|
2006
2064
|
);
|
|
@@ -2033,6 +2091,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2033
2091
|
emailInput: 'current',
|
|
2034
2092
|
webClientPreload: undefined,
|
|
2035
2093
|
isAutomatedUser: false,
|
|
2094
|
+
userActivation: undefined,
|
|
2036
2095
|
},
|
|
2037
2096
|
},
|
|
2038
2097
|
options.preLoginId
|
|
@@ -2081,6 +2140,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2081
2140
|
webClientPreload: undefined,
|
|
2082
2141
|
isVipMeeting: false,
|
|
2083
2142
|
isAutomatedUser: false,
|
|
2143
|
+
userActivation: undefined,
|
|
2084
2144
|
},
|
|
2085
2145
|
eventId: 'my-fake-id',
|
|
2086
2146
|
origin: {
|
|
@@ -2139,6 +2199,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2139
2199
|
webClientPreload: undefined,
|
|
2140
2200
|
isVipMeeting: false,
|
|
2141
2201
|
isAutomatedUser: false,
|
|
2202
|
+
userActivation: undefined,
|
|
2142
2203
|
},
|
|
2143
2204
|
eventId: 'my-fake-id',
|
|
2144
2205
|
origin: {
|
|
@@ -2197,6 +2258,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2197
2258
|
name: 'client.alert.displayed',
|
|
2198
2259
|
webClientPreload: true,
|
|
2199
2260
|
isAutomatedUser: false,
|
|
2261
|
+
userActivation: undefined,
|
|
2200
2262
|
},
|
|
2201
2263
|
options
|
|
2202
2264
|
);
|
|
@@ -2222,6 +2284,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2222
2284
|
name: 'client.alert.displayed',
|
|
2223
2285
|
webClientPreload: true,
|
|
2224
2286
|
isAutomatedUser: false,
|
|
2287
|
+
userActivation: undefined,
|
|
2225
2288
|
},
|
|
2226
2289
|
eventId: 'my-fake-id',
|
|
2227
2290
|
origin: {
|
|
@@ -2293,6 +2356,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2293
2356
|
webClientPreload: undefined,
|
|
2294
2357
|
isVipMeeting: false,
|
|
2295
2358
|
isAutomatedUser: false,
|
|
2359
|
+
userActivation: undefined,
|
|
2296
2360
|
},
|
|
2297
2361
|
options
|
|
2298
2362
|
);
|
|
@@ -2325,6 +2389,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2325
2389
|
webClientPreload: undefined,
|
|
2326
2390
|
isVipMeeting: false,
|
|
2327
2391
|
isAutomatedUser: false,
|
|
2392
|
+
userActivation: undefined,
|
|
2328
2393
|
},
|
|
2329
2394
|
eventId: 'my-fake-id',
|
|
2330
2395
|
origin: {
|
|
@@ -2396,6 +2461,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2396
2461
|
webClientPreload: undefined,
|
|
2397
2462
|
isVipMeeting: true,
|
|
2398
2463
|
isAutomatedUser: false,
|
|
2464
|
+
userActivation: undefined,
|
|
2399
2465
|
},
|
|
2400
2466
|
options
|
|
2401
2467
|
);
|
|
@@ -2428,6 +2494,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2428
2494
|
webClientPreload: undefined,
|
|
2429
2495
|
isVipMeeting: true,
|
|
2430
2496
|
isAutomatedUser: false,
|
|
2497
|
+
userActivation: undefined,
|
|
2431
2498
|
},
|
|
2432
2499
|
eventId: 'my-fake-id',
|
|
2433
2500
|
origin: {
|
|
@@ -2505,6 +2572,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2505
2572
|
webClientPreload: undefined,
|
|
2506
2573
|
isVipMeeting: false,
|
|
2507
2574
|
isAutomatedUser: false,
|
|
2575
|
+
userActivation: undefined,
|
|
2508
2576
|
},
|
|
2509
2577
|
eventId: 'my-fake-id',
|
|
2510
2578
|
origin: {
|
|
@@ -2590,6 +2658,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2590
2658
|
webClientPreload: undefined,
|
|
2591
2659
|
isVipMeeting: false,
|
|
2592
2660
|
isAutomatedUser: false,
|
|
2661
|
+
userActivation: undefined,
|
|
2593
2662
|
},
|
|
2594
2663
|
eventId: 'my-fake-id',
|
|
2595
2664
|
origin: {
|
|
@@ -2665,6 +2734,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2665
2734
|
name: 'client.alert.displayed',
|
|
2666
2735
|
webClientPreload: undefined,
|
|
2667
2736
|
isAutomatedUser: false,
|
|
2737
|
+
userActivation: undefined,
|
|
2668
2738
|
},
|
|
2669
2739
|
eventId: 'my-fake-id',
|
|
2670
2740
|
origin: {
|
|
@@ -2742,6 +2812,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2742
2812
|
name: 'client.alert.displayed',
|
|
2743
2813
|
webClientPreload: undefined,
|
|
2744
2814
|
isAutomatedUser: false,
|
|
2815
|
+
userActivation: undefined,
|
|
2745
2816
|
},
|
|
2746
2817
|
eventId: 'my-fake-id',
|
|
2747
2818
|
origin: {
|
|
@@ -2830,6 +2901,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
2830
2901
|
webClientPreload: undefined,
|
|
2831
2902
|
isVipMeeting: false,
|
|
2832
2903
|
isAutomatedUser: false,
|
|
2904
|
+
userActivation: undefined,
|
|
2833
2905
|
},
|
|
2834
2906
|
eventId: 'my-fake-id',
|
|
2835
2907
|
origin: {
|
|
@@ -3122,7 +3194,6 @@ describe('internal-plugin-metrics', () => {
|
|
|
3122
3194
|
assert.calledWith(requestStub, {
|
|
3123
3195
|
eventPayload: {event: 'test'},
|
|
3124
3196
|
type: ['diagnostic-event'],
|
|
3125
|
-
markTelemetryOptOutOnResponse: true,
|
|
3126
3197
|
});
|
|
3127
3198
|
});
|
|
3128
3199
|
});
|
|
@@ -4252,6 +4323,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
4252
4323
|
webClientPreload: undefined,
|
|
4253
4324
|
isVipMeeting: false,
|
|
4254
4325
|
isAutomatedUser: false,
|
|
4326
|
+
userActivation: undefined,
|
|
4255
4327
|
},
|
|
4256
4328
|
eventId: 'my-fake-id',
|
|
4257
4329
|
origin: {
|
|
@@ -4422,7 +4494,6 @@ describe('internal-plugin-metrics', () => {
|
|
|
4422
4494
|
assert.calledWith(requestStub, {
|
|
4423
4495
|
eventPayload: {event: 'test'},
|
|
4424
4496
|
type: ['diagnostic-event'],
|
|
4425
|
-
markTelemetryOptOutOnResponse: true,
|
|
4426
4497
|
});
|
|
4427
4498
|
});
|
|
4428
4499
|
});
|
|
@@ -4661,6 +4732,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
4661
4732
|
webClientPreload: undefined,
|
|
4662
4733
|
isVipMeeting: false,
|
|
4663
4734
|
isAutomatedUser: false,
|
|
4735
|
+
userActivation: undefined,
|
|
4664
4736
|
meetingSummaryInfo: {
|
|
4665
4737
|
featureName: 'syncSystemMuteStatus',
|
|
4666
4738
|
featureActions: [
|
|
@@ -4705,6 +4777,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
4705
4777
|
webClientPreload: undefined,
|
|
4706
4778
|
isVipMeeting: false,
|
|
4707
4779
|
isAutomatedUser: false,
|
|
4780
|
+
userActivation: undefined,
|
|
4708
4781
|
meetingSummaryInfo: {
|
|
4709
4782
|
featureName: 'syncSystemMuteStatus',
|
|
4710
4783
|
featureActions: [
|
|
@@ -94,7 +94,6 @@ describe('internal-plugin-metrics', () => {
|
|
|
94
94
|
},
|
|
95
95
|
});
|
|
96
96
|
assert.deepEqual(webexRequestArgs.body.metrics[0].type, ['diagnostic-event']);
|
|
97
|
-
assert.equal(webexRequestArgs.body.metrics[0].markTelemetryOptOutOnResponse, true);
|
|
98
97
|
assert.lengthOf(
|
|
99
98
|
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.queue,
|
|
100
99
|
0
|
|
@@ -314,7 +313,7 @@ describe('internal-plugin-metrics', () => {
|
|
|
314
313
|
});
|
|
315
314
|
|
|
316
315
|
describe('#submitHttpRequest', () => {
|
|
317
|
-
it('calls webex.request with the correct parameters
|
|
316
|
+
it('calls webex.request with the correct parameters', async () => {
|
|
318
317
|
const payload = [
|
|
319
318
|
{
|
|
320
319
|
eventPayload: {event: 'my.event'},
|
|
@@ -327,18 +326,11 @@ describe('internal-plugin-metrics', () => {
|
|
|
327
326
|
);
|
|
328
327
|
webex.request = sinon.stub().resolves({statusCode: 200});
|
|
329
328
|
|
|
330
|
-
const handleHttpResponseStatusSpy = sinon.spy(
|
|
331
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher,
|
|
332
|
-
'handleHttpResponseStatus'
|
|
333
|
-
);
|
|
334
|
-
|
|
335
329
|
const promise =
|
|
336
330
|
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.submitHttpRequest(
|
|
337
331
|
payload
|
|
338
332
|
);
|
|
339
333
|
|
|
340
|
-
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 0);
|
|
341
|
-
|
|
342
334
|
await flushPromises();
|
|
343
335
|
|
|
344
336
|
clock.tick(config.metrics.batcherWait);
|
|
@@ -361,117 +353,6 @@ describe('internal-plugin-metrics', () => {
|
|
|
361
353
|
service: 'metrics',
|
|
362
354
|
waitForServiceTimeout: 30,
|
|
363
355
|
});
|
|
364
|
-
|
|
365
|
-
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 1);
|
|
366
|
-
|
|
367
|
-
assert.deepEqual(handleHttpResponseStatusSpy.args[0][0], 200);
|
|
368
|
-
assert.deepEqual(handleHttpResponseStatusSpy.args[0][1], payload);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it('it calls handleHttpResponseStatus on failure', async () => {
|
|
372
|
-
const payload = [
|
|
373
|
-
{
|
|
374
|
-
eventPayload: {event: 'my.event'},
|
|
375
|
-
type: ['diagnostic-event'],
|
|
376
|
-
},
|
|
377
|
-
];
|
|
378
|
-
|
|
379
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.savePreLoginId(
|
|
380
|
-
preLoginId
|
|
381
|
-
);
|
|
382
|
-
webex.request = sinon.stub().rejects({statusCode: 503});
|
|
383
|
-
|
|
384
|
-
const handleHttpResponseStatusSpy = sinon.spy(
|
|
385
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher,
|
|
386
|
-
'handleHttpResponseStatus'
|
|
387
|
-
);
|
|
388
|
-
|
|
389
|
-
const promise =
|
|
390
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.submitHttpRequest(
|
|
391
|
-
payload
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 0);
|
|
395
|
-
|
|
396
|
-
await flushPromises();
|
|
397
|
-
|
|
398
|
-
clock.tick(config.metrics.batcherWait);
|
|
399
|
-
|
|
400
|
-
let error;
|
|
401
|
-
|
|
402
|
-
try {
|
|
403
|
-
await promise;
|
|
404
|
-
} catch (err) {
|
|
405
|
-
error = err;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
assert.deepEqual(error.statusCode, 503);
|
|
409
|
-
|
|
410
|
-
assert.deepEqual(handleHttpResponseStatusSpy.getCalls().length, 1);
|
|
411
|
-
|
|
412
|
-
assert.deepEqual(handleHttpResponseStatusSpy.args[0][0], 503);
|
|
413
|
-
assert.deepEqual(handleHttpResponseStatusSpy.args[0][1], payload);
|
|
414
|
-
});
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
describe('#handleHttpResponseStatus', () => {
|
|
418
|
-
let setIsTelemetryOptOutAutomaticStub;
|
|
419
|
-
|
|
420
|
-
beforeEach(() => {
|
|
421
|
-
setIsTelemetryOptOutAutomaticStub = sinon.stub(
|
|
422
|
-
webex.internal.newMetrics.callDiagnosticMetrics,
|
|
423
|
-
'setIsTelemetryOptOutAutomatic'
|
|
424
|
-
);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
[201, 400, 503, undefined].forEach((statusCode) => {
|
|
428
|
-
it(`does not call setIsTelemetryOptOutAutomatic when shouldMark is true and statusCode is ${statusCode}`, () => {
|
|
429
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
430
|
-
statusCode,
|
|
431
|
-
[{markTelemetryOptOutOnResponse: true}]
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
435
|
-
});
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
it('calls setIsTelemetryOptOutAutomatic(true) when statusCode is 200 and markTelemetryOptOutOnResponse is true', () => {
|
|
439
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
440
|
-
200,
|
|
441
|
-
[{markTelemetryOptOutOnResponse: true}]
|
|
442
|
-
);
|
|
443
|
-
|
|
444
|
-
assert.calledOnce(setIsTelemetryOptOutAutomaticStub);
|
|
445
|
-
assert.calledWithExactly(setIsTelemetryOptOutAutomaticStub, true);
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
[200, 201, 400, 503, undefined].forEach((statusCode) => {
|
|
449
|
-
it(`does not call setIsTelemetryOptOutAutomatic when shouldMark is false (statusCode: ${statusCode})`, () => {
|
|
450
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
451
|
-
statusCode,
|
|
452
|
-
[{markTelemetryOptOutOnResponse: false}]
|
|
453
|
-
);
|
|
454
|
-
|
|
455
|
-
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it('does not call setIsTelemetryOptOutAutomatic when payload is empty', () => {
|
|
460
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
461
|
-
200,
|
|
462
|
-
[]
|
|
463
|
-
);
|
|
464
|
-
|
|
465
|
-
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
it('does not call setIsTelemetryOptOutAutomatic when payload is not an array', () => {
|
|
469
|
-
webex.internal.newMetrics.callDiagnosticMetrics.preLoginMetricsBatcher.handleHttpResponseStatus(
|
|
470
|
-
200,
|
|
471
|
-
null
|
|
472
|
-
);
|
|
473
|
-
|
|
474
|
-
assert.notCalled(setIsTelemetryOptOutAutomaticStub);
|
|
475
356
|
});
|
|
476
357
|
});
|
|
477
358
|
});
|