@webex/internal-plugin-metrics 3.8.0-web-workers-keepalive.1 → 3.8.1-next.1

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.
@@ -13,9 +13,12 @@ import {
13
13
  } from '@webex/internal-plugin-metrics';
14
14
  import uuid from 'uuid';
15
15
  import {omit} from 'lodash';
16
- import { glob } from 'glob';
17
- import { expect } from 'chai';
18
- import { ClientEmailInput, ClientUserNameInput } from '@webex/internal-plugin-metrics/src/metrics.types';
16
+ import {glob} from 'glob';
17
+ import {expect} from 'chai';
18
+ import {
19
+ ClientEmailInput,
20
+ ClientUserNameInput,
21
+ } from '@webex/internal-plugin-metrics/src/metrics.types';
19
22
 
20
23
  //@ts-ignore
21
24
  global.window = {location: {hostname: 'whatever'}};
@@ -65,14 +68,14 @@ describe('internal-plugin-metrics', () => {
65
68
  ...fakeMeeting,
66
69
  id: '4',
67
70
  isoLocalClientMeetingJoinTime: 'testTimeString',
68
- }
71
+ };
69
72
  const fakeMeeting5 = {
70
73
  ...fakeMeeting,
71
74
  id: '5',
72
75
  correlationId: 'correlationId5',
73
76
  sessionCorrelationId: 'sessionCorrelationId5',
74
77
  userNameInput: 'test',
75
- emailInput: 'test@test.com'
78
+ emailInput: 'test@test.com',
76
79
  };
77
80
 
78
81
  const fakeMeetings = {
@@ -823,7 +826,147 @@ describe('internal-plugin-metrics', () => {
823
826
  meetingId: fakeMeeting.id,
824
827
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
825
828
  };
829
+ cd.setMercuryConnectedStatus(true);
830
+
831
+ cd.submitClientEvent({
832
+ name: 'client.alert.displayed',
833
+ options,
834
+ });
835
+
836
+ assert.called(getIdentifiersSpy);
837
+ assert.calledWith(getIdentifiersSpy, {
838
+ meeting: fakeMeeting,
839
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
840
+ webexConferenceIdStr: undefined,
841
+ sessionCorrelationId: undefined,
842
+ globalMeetingId: undefined,
843
+ });
844
+ assert.notCalled(generateClientEventErrorPayloadSpy);
845
+ assert.calledWith(
846
+ prepareDiagnosticEventSpy,
847
+ {
848
+ canProceed: true,
849
+ eventData: {
850
+ webClientDomain: 'whatever',
851
+ isMercuryConnected: true,
852
+ },
853
+ identifiers: {
854
+ correlationId: 'correlationId',
855
+ deviceId: 'deviceUrl',
856
+ locusId: 'url',
857
+ locusStartTime: 'lastActive',
858
+ locusUrl: 'locus/url',
859
+ mediaAgentAlias: 'alias',
860
+ mediaAgentGroupId: '1',
861
+ orgId: 'orgId',
862
+ userId: 'userId',
863
+ },
864
+ loginType: 'login-ci',
865
+ name: 'client.alert.displayed',
866
+ userType: 'host',
867
+ isConvergedArchitectureEnabled: undefined,
868
+ webexSubServiceType: undefined,
869
+ webClientPreload: undefined,
870
+ },
871
+ options
872
+ );
873
+ assert.calledWith(submitToCallDiagnosticsSpy, {
874
+ event: {
875
+ canProceed: true,
876
+ eventData: {
877
+ webClientDomain: 'whatever',
878
+ isMercuryConnected: true,
879
+ },
880
+ identifiers: {
881
+ correlationId: 'correlationId',
882
+ deviceId: 'deviceUrl',
883
+ locusId: 'url',
884
+ locusStartTime: 'lastActive',
885
+ locusUrl: 'locus/url',
886
+ mediaAgentAlias: 'alias',
887
+ mediaAgentGroupId: '1',
888
+ orgId: 'orgId',
889
+ userId: 'userId',
890
+ },
891
+ loginType: 'login-ci',
892
+ name: 'client.alert.displayed',
893
+ userType: 'host',
894
+ isConvergedArchitectureEnabled: undefined,
895
+ webexSubServiceType: undefined,
896
+ webClientPreload: undefined,
897
+ },
898
+ eventId: 'my-fake-id',
899
+ origin: {
900
+ origin: 'fake-origin',
901
+ },
902
+ originTime: {
903
+ sent: 'not_defined_yet',
904
+ triggered: now.toISOString(),
905
+ },
906
+ senderCountryCode: 'UK',
907
+ version: 1,
908
+ });
909
+ assert.calledWith(validatorSpy, {
910
+ type: 'ce',
911
+ event: {
912
+ event: {
913
+ canProceed: true,
914
+ eventData: {
915
+ webClientDomain: 'whatever',
916
+ isMercuryConnected: true,
917
+ },
918
+ identifiers: {
919
+ correlationId: 'correlationId',
920
+ deviceId: 'deviceUrl',
921
+ locusId: 'url',
922
+ locusStartTime: 'lastActive',
923
+ locusUrl: 'locus/url',
924
+ mediaAgentAlias: 'alias',
925
+ mediaAgentGroupId: '1',
926
+ orgId: 'orgId',
927
+ userId: 'userId',
928
+ },
929
+ loginType: 'login-ci',
930
+ name: 'client.alert.displayed',
931
+ userType: 'host',
932
+ isConvergedArchitectureEnabled: undefined,
933
+ webexSubServiceType: undefined,
934
+ webClientPreload: undefined,
935
+ },
936
+ eventId: 'my-fake-id',
937
+ origin: {
938
+ origin: 'fake-origin',
939
+ },
940
+ originTime: {
941
+ sent: 'not_defined_yet',
942
+ triggered: now.toISOString(),
943
+ },
944
+ senderCountryCode: 'UK',
945
+ version: 1,
946
+ },
947
+ });
948
+
949
+ const webexLoggerLogCalls = webex.logger.log.getCalls();
950
+ assert.deepEqual(webexLoggerLogCalls[1].args, [
951
+ 'call-diagnostic-events -> ',
952
+ 'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
953
+ `name: client.alert.displayed`,
954
+ ]);
955
+ });
826
956
 
957
+ it('should submit client event correctly when mercury is not connected', () => {
958
+ const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
959
+ const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
960
+ const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
961
+ const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
962
+ const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
963
+ sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
964
+ const validatorSpy = sinon.spy(cd, 'validator');
965
+ const options = {
966
+ meetingId: fakeMeeting.id,
967
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
968
+ };
969
+ cd.setMercuryConnectedStatus(false);
827
970
  cd.submitClientEvent({
828
971
  name: 'client.alert.displayed',
829
972
  options,
@@ -844,6 +987,7 @@ describe('internal-plugin-metrics', () => {
844
987
  canProceed: true,
845
988
  eventData: {
846
989
  webClientDomain: 'whatever',
990
+ isMercuryConnected: false,
847
991
  },
848
992
  identifiers: {
849
993
  correlationId: 'correlationId',
@@ -870,6 +1014,7 @@ describe('internal-plugin-metrics', () => {
870
1014
  canProceed: true,
871
1015
  eventData: {
872
1016
  webClientDomain: 'whatever',
1017
+ isMercuryConnected: false,
873
1018
  },
874
1019
  identifiers: {
875
1020
  correlationId: 'correlationId',
@@ -907,6 +1052,7 @@ describe('internal-plugin-metrics', () => {
907
1052
  canProceed: true,
908
1053
  eventData: {
909
1054
  webClientDomain: 'whatever',
1055
+ isMercuryConnected: false,
910
1056
  },
911
1057
  identifiers: {
912
1058
  correlationId: 'correlationId',
@@ -959,7 +1105,7 @@ describe('internal-plugin-metrics', () => {
959
1105
  meetingId: fakeMeeting3.id,
960
1106
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
961
1107
  };
962
-
1108
+ cd.setMercuryConnectedStatus(true);
963
1109
  cd.submitClientEvent({
964
1110
  name: 'client.alert.displayed',
965
1111
  options,
@@ -980,6 +1126,7 @@ describe('internal-plugin-metrics', () => {
980
1126
  canProceed: true,
981
1127
  eventData: {
982
1128
  webClientDomain: 'whatever',
1129
+ isMercuryConnected: true,
983
1130
  },
984
1131
  identifiers: {
985
1132
  correlationId: 'correlationId3',
@@ -1007,6 +1154,7 @@ describe('internal-plugin-metrics', () => {
1007
1154
  canProceed: true,
1008
1155
  eventData: {
1009
1156
  webClientDomain: 'whatever',
1157
+ isMercuryConnected: true,
1010
1158
  },
1011
1159
  identifiers: {
1012
1160
  correlationId: 'correlationId3',
@@ -1045,6 +1193,7 @@ describe('internal-plugin-metrics', () => {
1045
1193
  canProceed: true,
1046
1194
  eventData: {
1047
1195
  webClientDomain: 'whatever',
1196
+ isMercuryConnected: true,
1048
1197
  },
1049
1198
  identifiers: {
1050
1199
  correlationId: 'correlationId3',
@@ -1097,7 +1246,7 @@ describe('internal-plugin-metrics', () => {
1097
1246
  meetingId: fakeMeeting4.id,
1098
1247
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
1099
1248
  };
1100
-
1249
+ cd.setMercuryConnectedStatus(true);
1101
1250
  cd.submitClientEvent({
1102
1251
  name: 'client.alert.displayed',
1103
1252
  options,
@@ -1119,6 +1268,7 @@ describe('internal-plugin-metrics', () => {
1119
1268
  canProceed: true,
1120
1269
  eventData: {
1121
1270
  webClientDomain: 'whatever',
1271
+ isMercuryConnected: true,
1122
1272
  },
1123
1273
  identifiers: {
1124
1274
  correlationId: 'correlationId',
@@ -1146,6 +1296,7 @@ describe('internal-plugin-metrics', () => {
1146
1296
  canProceed: true,
1147
1297
  eventData: {
1148
1298
  webClientDomain: 'whatever',
1299
+ isMercuryConnected: true,
1149
1300
  },
1150
1301
  identifiers: {
1151
1302
  correlationId: 'correlationId',
@@ -1184,6 +1335,7 @@ describe('internal-plugin-metrics', () => {
1184
1335
  canProceed: true,
1185
1336
  eventData: {
1186
1337
  webClientDomain: 'whatever',
1338
+ isMercuryConnected: true,
1187
1339
  },
1188
1340
  identifiers: {
1189
1341
  correlationId: 'correlationId',
@@ -1235,7 +1387,7 @@ describe('internal-plugin-metrics', () => {
1235
1387
  meetingId: fakeMeeting5.id,
1236
1388
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
1237
1389
  };
1238
-
1390
+ cd.setMercuryConnectedStatus(true);
1239
1391
  cd.submitClientEvent({
1240
1392
  name: 'client.alert.displayed',
1241
1393
  options,
@@ -1256,6 +1408,7 @@ describe('internal-plugin-metrics', () => {
1256
1408
  canProceed: true,
1257
1409
  eventData: {
1258
1410
  webClientDomain: 'whatever',
1411
+ isMercuryConnected: true,
1259
1412
  },
1260
1413
  identifiers: {
1261
1414
  correlationId: 'correlationId5',
@@ -1285,6 +1438,7 @@ describe('internal-plugin-metrics', () => {
1285
1438
  canProceed: true,
1286
1439
  eventData: {
1287
1440
  webClientDomain: 'whatever',
1441
+ isMercuryConnected: true,
1288
1442
  },
1289
1443
  identifiers: {
1290
1444
  correlationId: 'correlationId5',
@@ -1325,6 +1479,7 @@ describe('internal-plugin-metrics', () => {
1325
1479
  canProceed: true,
1326
1480
  eventData: {
1327
1481
  webClientDomain: 'whatever',
1482
+ isMercuryConnected: true,
1328
1483
  },
1329
1484
  identifiers: {
1330
1485
  correlationId: 'correlationId5',
@@ -1375,7 +1530,14 @@ describe('internal-plugin-metrics', () => {
1375
1530
  const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
1376
1531
  const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
1377
1532
  const validatorSpy = sinon.spy(cd, 'validator');
1378
- sinon.stub(window.navigator, 'userAgent').get(() => userAgent);
1533
+
1534
+ Object.defineProperty(global, 'navigator', {
1535
+ value: {
1536
+ userAgent,
1537
+ },
1538
+ configurable: true,
1539
+ });
1540
+
1379
1541
  sinon.stub(bowser, 'getParser').returns(userAgent);
1380
1542
 
1381
1543
  const options = {
@@ -1429,7 +1591,7 @@ describe('internal-plugin-metrics', () => {
1429
1591
  globalMeetingId: 'globalMeetingId1',
1430
1592
  sessionCorrelationId: 'sessionCorrelationId1',
1431
1593
  };
1432
-
1594
+ cd.setMercuryConnectedStatus(true);
1433
1595
  cd.submitClientEvent({
1434
1596
  name: 'client.alert.displayed',
1435
1597
  options,
@@ -1450,6 +1612,7 @@ describe('internal-plugin-metrics', () => {
1450
1612
  canProceed: true,
1451
1613
  eventData: {
1452
1614
  webClientDomain: 'whatever',
1615
+ isMercuryConnected: true,
1453
1616
  },
1454
1617
  identifiers: {
1455
1618
  correlationId: 'correlationId',
@@ -1463,7 +1626,7 @@ describe('internal-plugin-metrics', () => {
1463
1626
  },
1464
1627
  loginType: 'login-ci',
1465
1628
  name: 'client.alert.displayed',
1466
- webClientPreload: undefined
1629
+ webClientPreload: undefined,
1467
1630
  },
1468
1631
  options
1469
1632
  );
@@ -1472,6 +1635,7 @@ describe('internal-plugin-metrics', () => {
1472
1635
  canProceed: true,
1473
1636
  eventData: {
1474
1637
  webClientDomain: 'whatever',
1638
+ isMercuryConnected: true,
1475
1639
  },
1476
1640
  identifiers: {
1477
1641
  correlationId: 'correlationId',
@@ -1485,7 +1649,7 @@ describe('internal-plugin-metrics', () => {
1485
1649
  },
1486
1650
  loginType: 'login-ci',
1487
1651
  name: 'client.alert.displayed',
1488
- webClientPreload: undefined
1652
+ webClientPreload: undefined,
1489
1653
  },
1490
1654
  eventId: 'my-fake-id',
1491
1655
  origin: {
@@ -1517,7 +1681,7 @@ describe('internal-plugin-metrics', () => {
1517
1681
  const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
1518
1682
  const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
1519
1683
  sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
1520
-
1684
+ cd.setMercuryConnectedStatus(true);
1521
1685
  const options = {
1522
1686
  correlationId: 'correlationId',
1523
1687
  webexConferenceIdStr: 'webexConferenceIdStr1',
@@ -1546,6 +1710,7 @@ describe('internal-plugin-metrics', () => {
1546
1710
  canProceed: true,
1547
1711
  eventData: {
1548
1712
  webClientDomain: 'whatever',
1713
+ isMercuryConnected: true,
1549
1714
  },
1550
1715
  identifiers: {
1551
1716
  correlationId: 'correlationId',
@@ -1585,7 +1750,7 @@ describe('internal-plugin-metrics', () => {
1585
1750
  webexConferenceIdStr: 'webexConferenceIdStr1',
1586
1751
  globalMeetingId: 'globalMeetingId1',
1587
1752
  },
1588
- eventData: {webClientDomain: 'whatever'},
1753
+ eventData: {webClientDomain: 'whatever', isMercuryConnected: true},
1589
1754
  loginType: 'login-ci',
1590
1755
  webClientPreload: undefined,
1591
1756
  },
@@ -1603,7 +1768,7 @@ describe('internal-plugin-metrics', () => {
1603
1768
  const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
1604
1769
  const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
1605
1770
  sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
1606
-
1771
+ cd.setMercuryConnectedStatus(true);
1607
1772
  const options = {
1608
1773
  correlationId: 'correlationId',
1609
1774
  webexConferenceIdStr: 'webexConferenceIdStr1',
@@ -1634,6 +1799,7 @@ describe('internal-plugin-metrics', () => {
1634
1799
  canProceed: true,
1635
1800
  eventData: {
1636
1801
  webClientDomain: 'whatever',
1802
+ isMercuryConnected: true,
1637
1803
  },
1638
1804
  identifiers: {
1639
1805
  correlationId: 'correlationId',
@@ -1675,7 +1841,7 @@ describe('internal-plugin-metrics', () => {
1675
1841
  webexConferenceIdStr: 'webexConferenceIdStr1',
1676
1842
  globalMeetingId: 'globalMeetingId1',
1677
1843
  },
1678
- eventData: {webClientDomain: 'whatever'},
1844
+ eventData: {webClientDomain: 'whatever', isMercuryConnected: true},
1679
1845
  loginType: 'login-ci',
1680
1846
  userNameInput: 'current',
1681
1847
  emailInput: 'current',
@@ -1693,7 +1859,7 @@ describe('internal-plugin-metrics', () => {
1693
1859
  meetingId: fakeMeeting2.id,
1694
1860
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
1695
1861
  };
1696
-
1862
+ cd.setMercuryConnectedStatus(true);
1697
1863
  cd.submitClientEvent({
1698
1864
  name: 'client.alert.displayed',
1699
1865
  options,
@@ -1704,6 +1870,7 @@ describe('internal-plugin-metrics', () => {
1704
1870
  canProceed: true,
1705
1871
  eventData: {
1706
1872
  webClientDomain: 'whatever',
1873
+ isMercuryConnected: true,
1707
1874
  },
1708
1875
  identifiers: {
1709
1876
  correlationId: 'correlationId2',
@@ -1745,7 +1912,7 @@ describe('internal-plugin-metrics', () => {
1745
1912
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
1746
1913
  sessionCorrelationId: 'sessionCorrelationId1',
1747
1914
  };
1748
-
1915
+ cd.setMercuryConnectedStatus(true);
1749
1916
  cd.submitClientEvent({
1750
1917
  name: 'client.alert.displayed',
1751
1918
  options,
@@ -1756,6 +1923,7 @@ describe('internal-plugin-metrics', () => {
1756
1923
  canProceed: true,
1757
1924
  eventData: {
1758
1925
  webClientDomain: 'whatever',
1926
+ isMercuryConnected: true,
1759
1927
  },
1760
1928
  identifiers: {
1761
1929
  correlationId: 'correlationId2',
@@ -1804,7 +1972,7 @@ describe('internal-plugin-metrics', () => {
1804
1972
  globalMeetingId: 'globalMeetingId1',
1805
1973
  sessionCorrelationId: 'sessionCorrelationId1',
1806
1974
  };
1807
-
1975
+ cd.setMercuryConnectedStatus(true);
1808
1976
  cd.submitClientEvent({
1809
1977
  name: 'client.alert.displayed',
1810
1978
  options,
@@ -1817,6 +1985,7 @@ describe('internal-plugin-metrics', () => {
1817
1985
  canProceed: true,
1818
1986
  eventData: {
1819
1987
  webClientDomain: 'whatever',
1988
+ isMercuryConnected: true,
1820
1989
  },
1821
1990
  identifiers: {
1822
1991
  correlationId: 'correlationId',
@@ -1839,6 +2008,7 @@ describe('internal-plugin-metrics', () => {
1839
2008
  canProceed: true,
1840
2009
  eventData: {
1841
2010
  webClientDomain: 'whatever',
2011
+ isMercuryConnected: true,
1842
2012
  },
1843
2013
  identifiers: {
1844
2014
  correlationId: 'correlationId',
@@ -1882,7 +2052,7 @@ describe('internal-plugin-metrics', () => {
1882
2052
  },
1883
2053
  },
1884
2054
  };
1885
-
2055
+ cd.setMercuryConnectedStatus(true);
1886
2056
  cd.submitClientEvent({
1887
2057
  name: 'client.alert.displayed',
1888
2058
  options,
@@ -1893,6 +2063,7 @@ describe('internal-plugin-metrics', () => {
1893
2063
  canProceed: true,
1894
2064
  eventData: {
1895
2065
  webClientDomain: 'whatever',
2066
+ isMercuryConnected: true,
1896
2067
  },
1897
2068
  identifiers: {
1898
2069
  correlationId: 'correlationId',
@@ -1948,7 +2119,7 @@ describe('internal-plugin-metrics', () => {
1948
2119
  assert.deepEqual(webexLoggerLogCalls[2].args, [
1949
2120
  'call-diagnostic-events -> ',
1950
2121
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
1951
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
2122
+ `generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
1952
2123
  ]);
1953
2124
  });
1954
2125
 
@@ -1961,7 +2132,7 @@ describe('internal-plugin-metrics', () => {
1961
2132
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
1962
2133
  rawError: new Error('bad times'),
1963
2134
  };
1964
-
2135
+ cd.setMercuryConnectedStatus(true);
1965
2136
  cd.submitClientEvent({
1966
2137
  name: 'client.alert.displayed',
1967
2138
  options,
@@ -1972,6 +2143,7 @@ describe('internal-plugin-metrics', () => {
1972
2143
  canProceed: true,
1973
2144
  eventData: {
1974
2145
  webClientDomain: 'whatever',
2146
+ isMercuryConnected: true,
1975
2147
  },
1976
2148
  identifiers: {
1977
2149
  correlationId: 'correlationId',
@@ -2028,7 +2200,7 @@ describe('internal-plugin-metrics', () => {
2028
2200
  assert.deepEqual(webexLoggerLogCalls[2].args, [
2029
2201
  'call-diagnostic-events -> ',
2030
2202
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
2031
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
2203
+ `generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
2032
2204
  ]);
2033
2205
  });
2034
2206
 
@@ -2040,7 +2212,7 @@ describe('internal-plugin-metrics', () => {
2040
2212
  correlationId: 'correlationId',
2041
2213
  rawError: new Error('bad times'),
2042
2214
  };
2043
-
2215
+ cd.setMercuryConnectedStatus(true);
2044
2216
  cd.submitClientEvent({
2045
2217
  name: 'client.alert.displayed',
2046
2218
  options,
@@ -2051,6 +2223,7 @@ describe('internal-plugin-metrics', () => {
2051
2223
  canProceed: true,
2052
2224
  eventData: {
2053
2225
  webClientDomain: 'whatever',
2226
+ isMercuryConnected: true,
2054
2227
  },
2055
2228
  identifiers: {
2056
2229
  correlationId: 'correlationId',
@@ -2101,7 +2274,7 @@ describe('internal-plugin-metrics', () => {
2101
2274
  assert.deepEqual(webexLoggerLogCalls[2].args, [
2102
2275
  'call-diagnostic-events -> ',
2103
2276
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
2104
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
2277
+ `generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
2105
2278
  ]);
2106
2279
  });
2107
2280
 
@@ -2117,7 +2290,7 @@ describe('internal-plugin-metrics', () => {
2117
2290
  },
2118
2291
  },
2119
2292
  };
2120
-
2293
+ cd.setMercuryConnectedStatus(true);
2121
2294
  cd.submitClientEvent({
2122
2295
  name: 'client.alert.displayed',
2123
2296
  options,
@@ -2128,6 +2301,7 @@ describe('internal-plugin-metrics', () => {
2128
2301
  canProceed: true,
2129
2302
  eventData: {
2130
2303
  webClientDomain: 'whatever',
2304
+ isMercuryConnected: true,
2131
2305
  },
2132
2306
  identifiers: {
2133
2307
  correlationId: 'correlationId',
@@ -2175,7 +2349,7 @@ describe('internal-plugin-metrics', () => {
2175
2349
  assert.deepEqual(webexLoggerLogCalls[2].args, [
2176
2350
  'call-diagnostic-events -> ',
2177
2351
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
2178
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
2352
+ `generatedError (cached: false): {"fatal":true,"shownToUser":false,"name":"other","category":"expected","errorCode":4029,"serviceErrorCode":2409005,"errorDescription":"StartRecordingFailed"}`,
2179
2353
  ]);
2180
2354
  });
2181
2355
 
@@ -2187,7 +2361,7 @@ describe('internal-plugin-metrics', () => {
2187
2361
  meetingId: fakeMeeting.id,
2188
2362
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
2189
2363
  };
2190
-
2364
+ cd.setMercuryConnectedStatus(true);
2191
2365
  cd.submitClientEvent({
2192
2366
  name: 'client.alert.displayed',
2193
2367
  payload: {
@@ -2208,6 +2382,7 @@ describe('internal-plugin-metrics', () => {
2208
2382
  canProceed: true,
2209
2383
  eventData: {
2210
2384
  webClientDomain: 'whatever',
2385
+ isMercuryConnected: true,
2211
2386
  },
2212
2387
  identifiers: {
2213
2388
  correlationId: 'correlationId',
@@ -2555,8 +2730,37 @@ describe('internal-plugin-metrics', () => {
2555
2730
  rawErrorMessage: 'bad times',
2556
2731
  };
2557
2732
 
2733
+ it('should be cached if called twice with the same payload', () => {
2734
+ const error = new Error('bad times');
2735
+ const expectedPayload = {
2736
+ category: 'other',
2737
+ errorCode: 9999,
2738
+ errorData: {errorName: 'Error'},
2739
+ serviceErrorCode: 9999,
2740
+ fatal: true,
2741
+ shownToUser: false,
2742
+ name: 'other',
2743
+ rawErrorMessage: 'bad times',
2744
+ errorDescription: 'UnknownError',
2745
+ };
2746
+
2747
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
2748
+ assert.isFalse(cached);
2749
+ assert.deepEqual(res, expectedPayload);
2750
+
2751
+ const [res2, cached2] = cd.generateClientEventErrorPayload(error);
2752
+ assert.isTrue(cached2);
2753
+ assert.deepEqual(res2, expectedPayload);
2754
+
2755
+ // after clearing the cache, it should be false again
2756
+ cd.clearErrorCache();
2757
+ const [res3, cached3] = cd.generateClientEventErrorPayload(error);
2758
+ assert.isFalse(cached3);
2759
+ assert.deepEqual(res3, expectedPayload);
2760
+ });
2761
+
2558
2762
  const checkNameError = (payload: any, isExpectedToBeCalled: boolean) => {
2559
- const res = cd.generateClientEventErrorPayload(payload);
2763
+ const [res, cached] = cd.generateClientEventErrorPayload(payload);
2560
2764
  const expectedResult = {
2561
2765
  category: 'expected',
2562
2766
  errorDescription: 'CameraPermissionDenied',
@@ -2585,7 +2789,7 @@ describe('internal-plugin-metrics', () => {
2585
2789
  });
2586
2790
 
2587
2791
  const checkCodeError = (payload: any, expetedRes: any) => {
2588
- const res = cd.generateClientEventErrorPayload(payload);
2792
+ const [res, cached] = cd.generateClientEventErrorPayload(payload);
2589
2793
  assert.deepEqual(res, expetedRes);
2590
2794
  };
2591
2795
  it('should generate event error payload correctly', () => {
@@ -2611,7 +2815,7 @@ describe('internal-plugin-metrics', () => {
2611
2815
  });
2612
2816
 
2613
2817
  const checkLocusError = (payload: any, isExpectedToBeCalled: boolean) => {
2614
- const res = cd.generateClientEventErrorPayload(payload);
2818
+ const [res, cached] = cd.generateClientEventErrorPayload(payload);
2615
2819
  const expectedResult = {
2616
2820
  category: 'signaling',
2617
2821
  errorDescription: 'NewLocusError',
@@ -2639,7 +2843,7 @@ describe('internal-plugin-metrics', () => {
2639
2843
  });
2640
2844
 
2641
2845
  const checkMeetingInfoError = (payload: any, isExpectedToBeCalled: boolean) => {
2642
- const res = cd.generateClientEventErrorPayload(payload);
2846
+ const [res, cached] = cd.generateClientEventErrorPayload(payload);
2643
2847
  const expectedResult = {
2644
2848
  category: 'signaling',
2645
2849
  errorDescription: 'MeetingInfoLookupError',
@@ -2680,7 +2884,7 @@ describe('internal-plugin-metrics', () => {
2680
2884
  });
2681
2885
 
2682
2886
  it('should return NetworkError code for a NetworkOrCORSERror', () => {
2683
- const res = cd.generateClientEventErrorPayload(
2887
+ const [res, cached] = cd.generateClientEventErrorPayload(
2684
2888
  new WebexHttpError.NetworkOrCORSError({
2685
2889
  url: 'https://example.com',
2686
2890
  statusCode: 0,
@@ -2724,7 +2928,7 @@ describe('internal-plugin-metrics', () => {
2724
2928
  message: 'No codecs present in m-line with MID 0 after filtering.',
2725
2929
  },
2726
2930
  };
2727
- const res = cd.generateClientEventErrorPayload(error);
2931
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
2728
2932
  assert.deepEqual(res, {
2729
2933
  category: 'expected',
2730
2934
  errorCode: 2051,
@@ -2750,7 +2954,7 @@ describe('internal-plugin-metrics', () => {
2750
2954
  message: 'empty local SDP',
2751
2955
  },
2752
2956
  };
2753
- const res = cd.generateClientEventErrorPayload(error);
2957
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
2754
2958
  assert.deepEqual(res, {
2755
2959
  category: 'media',
2756
2960
  errorCode: 2050,
@@ -2775,7 +2979,7 @@ describe('internal-plugin-metrics', () => {
2775
2979
  category: 'expected',
2776
2980
  };
2777
2981
 
2778
- const res = cd.generateClientEventErrorPayload(error);
2982
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
2779
2983
  assert.deepEqual(res, {
2780
2984
  category: 'expected',
2781
2985
  errorDescription: 'UnknownError',
@@ -2804,7 +3008,7 @@ describe('internal-plugin-metrics', () => {
2804
3008
  category: 'expected',
2805
3009
  };
2806
3010
 
2807
- const res = cd.generateClientEventErrorPayload(error);
3011
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
2808
3012
  assert.deepEqual(res, {
2809
3013
  category: 'expected',
2810
3014
  errorDescription: 'NetworkError',
@@ -2819,7 +3023,7 @@ describe('internal-plugin-metrics', () => {
2819
3023
  });
2820
3024
 
2821
3025
  it('should return AuthenticationFailed code for an Unauthorized error', () => {
2822
- const res = cd.generateClientEventErrorPayload(
3026
+ const [res, cached] = cd.generateClientEventErrorPayload(
2823
3027
  new WebexHttpError.Unauthorized({
2824
3028
  url: 'https://example.com',
2825
3029
  statusCode: 0,
@@ -2852,7 +3056,7 @@ describe('internal-plugin-metrics', () => {
2852
3056
  category: 'expected',
2853
3057
  };
2854
3058
 
2855
- const res = cd.generateClientEventErrorPayload(error);
3059
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
2856
3060
  assert.deepEqual(res, {
2857
3061
  category: 'expected',
2858
3062
  errorDescription: 'AuthenticationFailed',
@@ -2867,7 +3071,10 @@ describe('internal-plugin-metrics', () => {
2867
3071
  });
2868
3072
 
2869
3073
  it('should return unknown error otherwise', () => {
2870
- const res = cd.generateClientEventErrorPayload({something: 'new', message: 'bad times'});
3074
+ const [res, cached] = cd.generateClientEventErrorPayload({
3075
+ something: 'new',
3076
+ message: 'bad times',
3077
+ });
2871
3078
  assert.deepEqual(res, {
2872
3079
  category: 'other',
2873
3080
  errorDescription: 'UnknownError',
@@ -2881,7 +3088,7 @@ describe('internal-plugin-metrics', () => {
2881
3088
  });
2882
3089
 
2883
3090
  it('should generate event error payload correctly for locus error 2423012', () => {
2884
- const res = cd.generateClientEventErrorPayload({
3091
+ const [res, cached] = cd.generateClientEventErrorPayload({
2885
3092
  body: {errorCode: 2423012},
2886
3093
  message: 'bad times',
2887
3094
  });
@@ -2897,7 +3104,7 @@ describe('internal-plugin-metrics', () => {
2897
3104
  });
2898
3105
  });
2899
3106
  it('should generate event error payload correctly for locus error 2409062', () => {
2900
- const res = cd.generateClientEventErrorPayload({
3107
+ const [res, cached] = cd.generateClientEventErrorPayload({
2901
3108
  body: {errorCode: 2409062},
2902
3109
  message: 'bad times',
2903
3110
  });
@@ -2914,7 +3121,7 @@ describe('internal-plugin-metrics', () => {
2914
3121
  });
2915
3122
 
2916
3123
  it('should generate event error payload correctly for locus error 2423021', () => {
2917
- const res = cd.generateClientEventErrorPayload({
3124
+ const [res, cached] = cd.generateClientEventErrorPayload({
2918
3125
  body: {errorCode: 2423021},
2919
3126
  message: 'bad times',
2920
3127
  });
@@ -2931,7 +3138,7 @@ describe('internal-plugin-metrics', () => {
2931
3138
  });
2932
3139
 
2933
3140
  it('should generate event error payload correctly for wdm error 4404002', () => {
2934
- const res = cd.generateClientEventErrorPayload({
3141
+ const [res, cached] = cd.generateClientEventErrorPayload({
2935
3142
  body: {errorCode: 4404002},
2936
3143
  message: 'Operation denied due to region restriction',
2937
3144
  });
@@ -2948,7 +3155,7 @@ describe('internal-plugin-metrics', () => {
2948
3155
  });
2949
3156
 
2950
3157
  it('should generate event error payload correctly for wdm error 4404003', () => {
2951
- const res = cd.generateClientEventErrorPayload({
3158
+ const [res, cached] = cd.generateClientEventErrorPayload({
2952
3159
  body: {errorCode: 4404003},
2953
3160
  message: 'Operation denied due to region restriction',
2954
3161
  });
@@ -2966,7 +3173,7 @@ describe('internal-plugin-metrics', () => {
2966
3173
 
2967
3174
  describe('httpStatusCode', () => {
2968
3175
  it('should include httpStatusCode for browser media errors', () => {
2969
- const res = cd.generateClientEventErrorPayload({
3176
+ const [res, cached] = cd.generateClientEventErrorPayload({
2970
3177
  name: 'PermissionDeniedError',
2971
3178
  message: 'bad times',
2972
3179
  statusCode: 401,
@@ -2988,7 +3195,7 @@ describe('internal-plugin-metrics', () => {
2988
3195
  });
2989
3196
 
2990
3197
  it('should include httpStatusCode for SdpOfferCreationErrors', () => {
2991
- const res = cd.generateClientEventErrorPayload({
3198
+ const [res, cached] = cd.generateClientEventErrorPayload({
2992
3199
  name: 'SdpOfferCreationError',
2993
3200
  message: 'bad times',
2994
3201
  statusCode: 404,
@@ -3010,7 +3217,7 @@ describe('internal-plugin-metrics', () => {
3010
3217
  });
3011
3218
 
3012
3219
  it('should include httpStatusCode for service error codes', () => {
3013
- const res = cd.generateClientEventErrorPayload({
3220
+ const [res, cached] = cd.generateClientEventErrorPayload({
3014
3221
  body: {errorCode: 58400},
3015
3222
  message: 'bad times',
3016
3223
  statusCode: 400,
@@ -3029,7 +3236,7 @@ describe('internal-plugin-metrics', () => {
3029
3236
  });
3030
3237
 
3031
3238
  it('should include httpStatusCode for locus service error codes', () => {
3032
- const res = cd.generateClientEventErrorPayload({
3239
+ const [res, cached] = cd.generateClientEventErrorPayload({
3033
3240
  body: {errorCode: 2403001},
3034
3241
  message: 'bad times',
3035
3242
  statusCode: 400,
@@ -3048,7 +3255,7 @@ describe('internal-plugin-metrics', () => {
3048
3255
  });
3049
3256
 
3050
3257
  it('should include httpStatusCode for meetingInfo service error codes', () => {
3051
- const res = cd.generateClientEventErrorPayload({
3258
+ const [res, cached] = cd.generateClientEventErrorPayload({
3052
3259
  body: {data: {meetingInfo: {}}},
3053
3260
  message: 'bad times',
3054
3261
  statusCode: 400,
@@ -3071,7 +3278,7 @@ describe('internal-plugin-metrics', () => {
3071
3278
  statusCode: 400,
3072
3279
  options: {service: '', headers: {}},
3073
3280
  });
3074
- const res = cd.generateClientEventErrorPayload(error);
3281
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
3075
3282
  assert.deepEqual(res, {
3076
3283
  category: 'network',
3077
3284
  errorCode: 1026,
@@ -3090,7 +3297,7 @@ describe('internal-plugin-metrics', () => {
3090
3297
  statusCode: 401,
3091
3298
  options: {service: '', headers: {}},
3092
3299
  });
3093
- const res = cd.generateClientEventErrorPayload(error);
3300
+ const [res, cached] = cd.generateClientEventErrorPayload(error);
3094
3301
  assert.deepEqual(res, {
3095
3302
  category: 'network',
3096
3303
  errorCode: 1010,
@@ -3105,7 +3312,7 @@ describe('internal-plugin-metrics', () => {
3105
3312
  });
3106
3313
 
3107
3314
  it('should include httpStatusCode for unknown errors', () => {
3108
- const res = cd.generateClientEventErrorPayload({
3315
+ const [res, cached] = cd.generateClientEventErrorPayload({
3109
3316
  message: 'bad times',
3110
3317
  statusCode: 404,
3111
3318
  });
@@ -3215,7 +3422,7 @@ describe('internal-plugin-metrics', () => {
3215
3422
  meetingId: fakeMeeting.id,
3216
3423
  preLoginId,
3217
3424
  };
3218
-
3425
+ cd.setMercuryConnectedStatus(true);
3219
3426
  const triggered = new Date();
3220
3427
  const fetchOptions = await cd.buildClientEventFetchRequestOptions({
3221
3428
  name: 'client.exit.app',
@@ -3231,6 +3438,7 @@ describe('internal-plugin-metrics', () => {
3231
3438
  canProceed: false,
3232
3439
  eventData: {
3233
3440
  webClientDomain: 'whatever',
3441
+ isMercuryConnected: true,
3234
3442
  },
3235
3443
  identifiers: {
3236
3444
  correlationId: 'correlationId',
@@ -3462,6 +3670,7 @@ describe('internal-plugin-metrics', () => {
3462
3670
  const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
3463
3671
 
3464
3672
  const options = {
3673
+ meetingId: 'meetingId',
3465
3674
  correlationId: 'correlationId',
3466
3675
  };
3467
3676
 
@@ -3494,6 +3703,7 @@ describe('internal-plugin-metrics', () => {
3494
3703
  name: 'client.alert.displayed',
3495
3704
  payload: undefined,
3496
3705
  options: {
3706
+ meetingId: 'meetingId',
3497
3707
  correlationId: 'correlationId',
3498
3708
  triggeredTime: now.toISOString(),
3499
3709
  },
@@ -3502,6 +3712,7 @@ describe('internal-plugin-metrics', () => {
3502
3712
  name: 'client.alert.removed',
3503
3713
  payload: undefined,
3504
3714
  options: {
3715
+ meetingId: 'meetingId',
3505
3716
  correlationId: 'correlationId',
3506
3717
  triggeredTime: now.toISOString(),
3507
3718
  },
@@ -3510,6 +3721,7 @@ describe('internal-plugin-metrics', () => {
3510
3721
  name: 'client.call.aborted',
3511
3722
  payload: undefined,
3512
3723
  options: {
3724
+ meetingId: 'meetingId',
3513
3725
  correlationId: 'correlationId',
3514
3726
  triggeredTime: now.toISOString(),
3515
3727
  },
@@ -3521,6 +3733,79 @@ describe('internal-plugin-metrics', () => {
3521
3733
  // should not call submitClientEvent again if delayedClientEvents was cleared
3522
3734
  assert.notCalled(submitClientEventSpy);
3523
3735
  });
3736
+
3737
+ it('calls submitClientEvent for every delayed event with overrides and clears delayedClientEvents array', () => {
3738
+ const submitClientEventSpy = sinon.spy(cd, 'submitClientEvent');
3739
+ const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
3740
+
3741
+ const options = {
3742
+ meetingId: 'meetingId',
3743
+ correlationId: 'correlationId',
3744
+ };
3745
+
3746
+ const overrides = {
3747
+ correlationId: 'newCorrelationId',
3748
+ };
3749
+
3750
+ cd.submitClientEvent({
3751
+ name: 'client.alert.displayed',
3752
+ options,
3753
+ delaySubmitEvent: true,
3754
+ });
3755
+
3756
+ cd.submitClientEvent({
3757
+ name: 'client.alert.removed',
3758
+ options,
3759
+ delaySubmitEvent: true,
3760
+ });
3761
+
3762
+ cd.submitClientEvent({
3763
+ name: 'client.call.aborted',
3764
+ options,
3765
+ delaySubmitEvent: true,
3766
+ });
3767
+
3768
+ assert.notCalled(submitToCallDiagnosticsSpy);
3769
+ assert.calledThrice(submitClientEventSpy);
3770
+ submitClientEventSpy.resetHistory();
3771
+
3772
+ cd.submitDelayedClientEvents(overrides);
3773
+
3774
+ assert.calledThrice(submitClientEventSpy);
3775
+ assert.calledWith(submitClientEventSpy.firstCall, {
3776
+ name: 'client.alert.displayed',
3777
+ payload: undefined,
3778
+ options: {
3779
+ meetingId: 'meetingId',
3780
+ correlationId: 'newCorrelationId',
3781
+ triggeredTime: now.toISOString(),
3782
+ },
3783
+ });
3784
+ assert.calledWith(submitClientEventSpy.secondCall, {
3785
+ name: 'client.alert.removed',
3786
+ payload: undefined,
3787
+ options: {
3788
+ meetingId: 'meetingId',
3789
+ correlationId: 'newCorrelationId',
3790
+ triggeredTime: now.toISOString(),
3791
+ },
3792
+ });
3793
+ assert.calledWith(submitClientEventSpy.thirdCall, {
3794
+ name: 'client.call.aborted',
3795
+ payload: undefined,
3796
+ options: {
3797
+ meetingId: 'meetingId',
3798
+ correlationId: 'newCorrelationId',
3799
+ triggeredTime: now.toISOString(),
3800
+ },
3801
+ });
3802
+ submitClientEventSpy.resetHistory();
3803
+
3804
+ cd.submitDelayedClientEvents();
3805
+
3806
+ // should not call submitClientEvent again if delayedClientEvents was cleared
3807
+ assert.notCalled(submitClientEventSpy);
3808
+ });
3524
3809
  });
3525
3810
  });
3526
3811
  });