@webex/internal-plugin-metrics 3.5.0-next.1 → 3.5.0-next.11

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.
Files changed (47) hide show
  1. package/dist/business-metrics.js +119 -9
  2. package/dist/business-metrics.js.map +1 -1
  3. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +1 -1
  4. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
  5. package/dist/call-diagnostic/call-diagnostic-metrics.js +15 -9
  6. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
  7. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +7 -2
  8. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
  9. package/dist/call-diagnostic/config.js +13 -3
  10. package/dist/call-diagnostic/config.js.map +1 -1
  11. package/dist/index.js +7 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/metrics.js +1 -1
  14. package/dist/metrics.types.js.map +1 -1
  15. package/dist/new-metrics.js +5 -2
  16. package/dist/new-metrics.js.map +1 -1
  17. package/dist/rtcMetrics/constants.js +11 -0
  18. package/dist/rtcMetrics/constants.js.map +1 -0
  19. package/dist/rtcMetrics/index.js +202 -0
  20. package/dist/rtcMetrics/index.js.map +1 -0
  21. package/dist/types/business-metrics.d.ts +36 -4
  22. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +6 -1
  23. package/dist/types/call-diagnostic/config.d.ts +3 -0
  24. package/dist/types/index.d.ts +2 -1
  25. package/dist/types/metrics.types.d.ts +1 -0
  26. package/dist/types/new-metrics.d.ts +5 -3
  27. package/dist/types/rtcMetrics/constants.d.ts +4 -0
  28. package/dist/types/rtcMetrics/index.d.ts +71 -0
  29. package/package.json +11 -11
  30. package/src/business-metrics.ts +97 -5
  31. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
  32. package/src/call-diagnostic/call-diagnostic-metrics.ts +13 -9
  33. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +11 -5
  34. package/src/call-diagnostic/config.ts +12 -0
  35. package/src/index.ts +2 -0
  36. package/src/metrics.types.ts +2 -0
  37. package/src/new-metrics.ts +12 -2
  38. package/src/rtcMetrics/constants.ts +3 -0
  39. package/src/rtcMetrics/index.ts +186 -0
  40. package/test/unit/spec/business/business-metrics.ts +69 -2
  41. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +2 -1
  42. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +4 -6
  43. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +275 -34
  44. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +7 -3
  45. package/test/unit/spec/new-metrics.ts +18 -3
  46. package/test/unit/spec/prelogin-metrics-batcher.ts +3 -1
  47. package/test/unit/spec/rtcMetrics/index.ts +155 -0
@@ -1,7 +1,9 @@
1
1
  import sinon from 'sinon';
2
+ import bowser from 'bowser';
2
3
  import {assert} from '@webex/test-helper-chai';
3
4
  import {WebexHttpError} from '@webex/webex-core';
4
5
  import {BrowserDetection} from '@webex/common';
6
+ import window from 'global/window';
5
7
  import {
6
8
  CallDiagnosticLatencies,
7
9
  CallDiagnosticMetrics,
@@ -30,7 +32,6 @@ describe('internal-plugin-metrics', () => {
30
32
  const fakeMeeting = {
31
33
  id: '1',
32
34
  correlationId: 'correlationId',
33
- sessionCorrelationId: undefined,
34
35
  callStateForMetrics: {},
35
36
  environment: 'meeting_evn',
36
37
  locusUrl: 'locus/url',
@@ -41,9 +42,6 @@ describe('internal-plugin-metrics', () => {
41
42
  },
42
43
  meetingInfo: {},
43
44
  getCurUserType: () => 'host',
44
- statsAnalyzer: {
45
- getLocalIpAddress: () => '192.168.1.90',
46
- },
47
45
  };
48
46
 
49
47
  const fakeMeeting2 = {
@@ -53,9 +51,17 @@ describe('internal-plugin-metrics', () => {
53
51
  callStateForMetrics: {loginType: 'fakeLoginType'},
54
52
  };
55
53
 
54
+ const fakeMeeting3 = {
55
+ ...fakeMeeting,
56
+ id: '3',
57
+ correlationId: 'correlationId3',
58
+ sessionCorrelationId: 'sessionCorrelationId3',
59
+ }
60
+
56
61
  const fakeMeetings = {
57
62
  1: fakeMeeting,
58
63
  2: fakeMeeting2,
64
+ 3: fakeMeeting3,
59
65
  };
60
66
 
61
67
  let webex;
@@ -87,8 +93,19 @@ describe('internal-plugin-metrics', () => {
87
93
  clientName: 'Cantina',
88
94
  },
89
95
  },
96
+ getBasicMeetingInformation: (id) => fakeMeetings[id],
90
97
  meetingCollection: {
91
- get: (id) => fakeMeetings[id],
98
+ get: (meetingId) => {
99
+ return {
100
+ statsAnalyzer: {
101
+ getLocalIpAddress: () => {
102
+ if (meetingId) {
103
+ return '192.168.1.90';
104
+ }
105
+ },
106
+ }
107
+ }
108
+ },
92
109
  },
93
110
  geoHintInfo: {
94
111
  clientAddress: '1.3.4.5',
@@ -355,7 +372,6 @@ describe('internal-plugin-metrics', () => {
355
372
 
356
373
  assert.deepEqual(res, {
357
374
  correlationId: 'correlationId',
358
- sessionCorrelationId: undefined,
359
375
  deviceId: 'deviceUrl',
360
376
  locusId: 'url',
361
377
  locusStartTime: 'lastActive',
@@ -368,7 +384,37 @@ describe('internal-plugin-metrics', () => {
368
384
  });
369
385
  });
370
386
 
371
- it('should build identifiers correctly', () => {
387
+ [undefined, null, '', false, 0].forEach((sessionCorrelationId) => {
388
+ it(`should build identifiers correctly and not add session correlation id if it is falsy: ${sessionCorrelationId}`, () => {
389
+ cd.device = {
390
+ ...cd.device,
391
+ config: {installationId: 'installationId'},
392
+ };
393
+
394
+ const res = cd.getIdentifiers({
395
+ mediaConnections: [
396
+ {mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
397
+ ],
398
+ meeting: {...fakeMeeting, sessionCorrelationId},
399
+ sessionCorrelationId: sessionCorrelationId as any,
400
+ });
401
+
402
+ assert.deepEqual(res, {
403
+ correlationId: 'correlationId',
404
+ deviceId: 'deviceUrl',
405
+ locusId: 'url',
406
+ locusStartTime: 'lastActive',
407
+ locusUrl: 'locus/url',
408
+ machineId: 'installationId',
409
+ mediaAgentAlias: 'mediaAgentAlias',
410
+ mediaAgentGroupId: 'mediaAgentGroupId',
411
+ orgId: 'orgId',
412
+ userId: 'userId',
413
+ });
414
+ });
415
+ });
416
+
417
+ it('should build identifiers correctly with sessionCorrelationID as a param', () => {
372
418
  cd.device = {
373
419
  ...cd.device,
374
420
  config: {installationId: 'installationId'},
@@ -397,6 +443,35 @@ describe('internal-plugin-metrics', () => {
397
443
  });
398
444
  });
399
445
 
446
+ it('should build identifiers correctly with sessionCorrelationID as a param and a meeting with session correlation id, and the param should take precedence', () => {
447
+ cd.device = {
448
+ ...cd.device,
449
+ config: {installationId: 'installationId'},
450
+ };
451
+
452
+ const res = cd.getIdentifiers({
453
+ mediaConnections: [
454
+ {mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
455
+ ],
456
+ meeting: {...fakeMeeting, sessionCorrelationId: 'sessionCorrelationId1'},
457
+ sessionCorrelationId: 'sessionCorrelationId',
458
+ });
459
+
460
+ assert.deepEqual(res, {
461
+ correlationId: 'correlationId',
462
+ sessionCorrelationId: 'sessionCorrelationId',
463
+ deviceId: 'deviceUrl',
464
+ locusId: 'url',
465
+ locusStartTime: 'lastActive',
466
+ locusUrl: 'locus/url',
467
+ machineId: 'installationId',
468
+ mediaAgentAlias: 'mediaAgentAlias',
469
+ mediaAgentGroupId: 'mediaAgentGroupId',
470
+ orgId: 'orgId',
471
+ userId: 'userId',
472
+ });
473
+ });
474
+
400
475
  it('should build identifiers correctly with a meeting that has meetingInfo with a webexConferenceIdStr and globalMeetingId, and that should take precedence over the options passed to it', () => {
401
476
  const res = cd.getIdentifiers({
402
477
  mediaConnections: [
@@ -450,7 +525,6 @@ describe('internal-plugin-metrics', () => {
450
525
 
451
526
  assert.deepEqual(res, {
452
527
  correlationId: 'correlationId',
453
- sessionCorrelationId: undefined,
454
528
  webexConferenceIdStr: 'webexConferenceIdStr1',
455
529
  globalMeetingId: 'globalMeetingId1',
456
530
  deviceId: 'deviceUrl',
@@ -484,7 +558,6 @@ describe('internal-plugin-metrics', () => {
484
558
 
485
559
  assert.deepEqual(res, {
486
560
  correlationId: 'correlationId',
487
- sessionCorrelationId: undefined,
488
561
  webexConferenceIdStr: 'webexConferenceIdStr1',
489
562
  globalMeetingId: 'globalMeetingId1',
490
563
  deviceId: 'deviceUrl',
@@ -543,7 +616,6 @@ describe('internal-plugin-metrics', () => {
543
616
 
544
617
  assert.deepEqual(res, {
545
618
  correlationId: 'correlationId',
546
- sessionCorrelationId: 'unknown',
547
619
  webexConferenceIdStr: 'webexConferenceIdStr1',
548
620
  deviceId: 'deviceUrl',
549
621
  locusUrl: 'locus-url',
@@ -560,7 +632,6 @@ describe('internal-plugin-metrics', () => {
560
632
 
561
633
  assert.deepEqual(res, {
562
634
  correlationId: 'correlationId',
563
- sessionCorrelationId: 'unknown',
564
635
  globalMeetingId: 'globalMeetingId1',
565
636
  deviceId: 'deviceUrl',
566
637
  locusUrl: 'locus-url',
@@ -576,7 +647,6 @@ describe('internal-plugin-metrics', () => {
576
647
 
577
648
  assert.deepEqual(res, {
578
649
  correlationId: 'correlationId',
579
- sessionCorrelationId: 'unknown',
580
650
  deviceId: 'deviceUrl',
581
651
  locusUrl: 'locus-url',
582
652
  orgId: 'orgId',
@@ -621,7 +691,6 @@ describe('internal-plugin-metrics', () => {
621
691
 
622
692
  assert.deepEqual(res, {
623
693
  correlationId: 'correlationId',
624
- sessionCorrelationId: 'unknown',
625
694
  locusUrl: 'locus-url',
626
695
  deviceId: 'deviceUrl',
627
696
  orgId: 'orgId',
@@ -695,12 +764,13 @@ describe('internal-plugin-metrics', () => {
695
764
  options,
696
765
  });
697
766
 
767
+ assert.called(getIdentifiersSpy);
698
768
  assert.calledWith(getIdentifiersSpy, {
699
769
  meeting: fakeMeeting,
700
770
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
701
771
  webexConferenceIdStr: undefined,
702
- sessionCorrelationId: undefined,
703
772
  globalMeetingId: undefined,
773
+ sessionCorrelationId: undefined,
704
774
  });
705
775
  assert.notCalled(generateClientEventErrorPayloadSpy);
706
776
  assert.calledWith(
@@ -712,7 +782,6 @@ describe('internal-plugin-metrics', () => {
712
782
  },
713
783
  identifiers: {
714
784
  correlationId: 'correlationId',
715
- sessionCorrelationId: undefined,
716
785
  deviceId: 'deviceUrl',
717
786
  locusId: 'url',
718
787
  locusStartTime: 'lastActive',
@@ -738,7 +807,6 @@ describe('internal-plugin-metrics', () => {
738
807
  },
739
808
  identifiers: {
740
809
  correlationId: 'correlationId',
741
- sessionCorrelationId: undefined,
742
810
  deviceId: 'deviceUrl',
743
811
  locusId: 'url',
744
812
  locusStartTime: 'lastActive',
@@ -775,7 +843,142 @@ describe('internal-plugin-metrics', () => {
775
843
  },
776
844
  identifiers: {
777
845
  correlationId: 'correlationId',
778
- sessionCorrelationId: undefined,
846
+ deviceId: 'deviceUrl',
847
+ locusId: 'url',
848
+ locusStartTime: 'lastActive',
849
+ locusUrl: 'locus/url',
850
+ mediaAgentAlias: 'alias',
851
+ mediaAgentGroupId: '1',
852
+ orgId: 'orgId',
853
+ userId: 'userId',
854
+ },
855
+ loginType: 'login-ci',
856
+ name: 'client.alert.displayed',
857
+ userType: 'host',
858
+ isConvergedArchitectureEnabled: undefined,
859
+ webexSubServiceType: undefined,
860
+ },
861
+ eventId: 'my-fake-id',
862
+ origin: {
863
+ origin: 'fake-origin',
864
+ },
865
+ originTime: {
866
+ sent: 'not_defined_yet',
867
+ triggered: now.toISOString(),
868
+ },
869
+ senderCountryCode: 'UK',
870
+ version: 1,
871
+ },
872
+ });
873
+
874
+ const webexLoggerLogCalls = webex.logger.log.getCalls();
875
+ assert.deepEqual(webexLoggerLogCalls[1].args, [
876
+ 'call-diagnostic-events -> ',
877
+ 'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
878
+ `name: client.alert.displayed`,
879
+ ]);
880
+ });
881
+
882
+ it('should submit client event successfully with meetingId which has a sessionCorrelationId', () => {
883
+ const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
884
+ const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
885
+ const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
886
+ const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
887
+ const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
888
+ sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
889
+ const validatorSpy = sinon.spy(cd, 'validator');
890
+ const options = {
891
+ meetingId: fakeMeeting3.id,
892
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
893
+ };
894
+
895
+ cd.submitClientEvent({
896
+ name: 'client.alert.displayed',
897
+ options,
898
+ });
899
+
900
+ assert.called(getIdentifiersSpy);
901
+ assert.calledWith(getIdentifiersSpy, {
902
+ meeting: {...fakeMeeting3, sessionCorrelationId: 'sessionCorrelationId3'},
903
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
904
+ webexConferenceIdStr: undefined,
905
+ globalMeetingId: undefined,
906
+ sessionCorrelationId: undefined,
907
+ });
908
+ assert.notCalled(generateClientEventErrorPayloadSpy);
909
+ assert.calledWith(
910
+ prepareDiagnosticEventSpy,
911
+ {
912
+ canProceed: true,
913
+ eventData: {
914
+ webClientDomain: 'whatever',
915
+ },
916
+ identifiers: {
917
+ correlationId: 'correlationId3',
918
+ sessionCorrelationId: 'sessionCorrelationId3',
919
+ deviceId: 'deviceUrl',
920
+ locusId: 'url',
921
+ locusStartTime: 'lastActive',
922
+ locusUrl: 'locus/url',
923
+ mediaAgentAlias: 'alias',
924
+ mediaAgentGroupId: '1',
925
+ orgId: 'orgId',
926
+ userId: 'userId',
927
+ },
928
+ loginType: 'login-ci',
929
+ name: 'client.alert.displayed',
930
+ userType: 'host',
931
+ isConvergedArchitectureEnabled: undefined,
932
+ webexSubServiceType: undefined,
933
+ },
934
+ options
935
+ );
936
+ assert.calledWith(submitToCallDiagnosticsSpy, {
937
+ event: {
938
+ canProceed: true,
939
+ eventData: {
940
+ webClientDomain: 'whatever',
941
+ },
942
+ identifiers: {
943
+ correlationId: 'correlationId3',
944
+ sessionCorrelationId: 'sessionCorrelationId3',
945
+ deviceId: 'deviceUrl',
946
+ locusId: 'url',
947
+ locusStartTime: 'lastActive',
948
+ locusUrl: 'locus/url',
949
+ mediaAgentAlias: 'alias',
950
+ mediaAgentGroupId: '1',
951
+ orgId: 'orgId',
952
+ userId: 'userId',
953
+ },
954
+ loginType: 'login-ci',
955
+ name: 'client.alert.displayed',
956
+ userType: 'host',
957
+ isConvergedArchitectureEnabled: undefined,
958
+ webexSubServiceType: undefined,
959
+ },
960
+ eventId: 'my-fake-id',
961
+ origin: {
962
+ origin: 'fake-origin',
963
+ },
964
+ originTime: {
965
+ sent: 'not_defined_yet',
966
+ triggered: now.toISOString(),
967
+ },
968
+ senderCountryCode: 'UK',
969
+ version: 1,
970
+ });
971
+ assert.calledWith(validatorSpy, {
972
+ type: 'ce',
973
+ event: {
974
+ event: {
975
+ canProceed: true,
976
+ eventData: {
977
+ webClientDomain: 'whatever',
978
+ },
979
+ identifiers: {
980
+ correlationId: 'correlationId3',
981
+ sessionCorrelationId: 'sessionCorrelationId3',
779
982
  deviceId: 'deviceUrl',
780
983
  locusId: 'url',
781
984
  locusStartTime: 'lastActive',
@@ -819,6 +1022,9 @@ describe('internal-plugin-metrics', () => {
819
1022
  const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
820
1023
  const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
821
1024
  const validatorSpy = sinon.spy(cd, 'validator');
1025
+ sinon.stub(window.navigator, 'userAgent').get(() => userAgent);
1026
+ sinon.stub(bowser, 'getParser').returns(userAgent);
1027
+
822
1028
  const options = {
823
1029
  meetingId: fakeMeeting.id,
824
1030
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
@@ -847,7 +1053,7 @@ describe('internal-plugin-metrics', () => {
847
1053
  assert.deepEqual(webexLoggerLogCalls[2].args, [
848
1054
  'call-diagnostic-events -> ',
849
1055
  'CallDiagnosticMetrics: @createClientEventObjectInMeeting => collected browser data',
850
- '{"error":"unable to access window.navigator.userAgent"}',
1056
+ `${JSON.stringify(userAgent)}`,
851
1057
  ]);
852
1058
 
853
1059
  assert.deepEqual(webexLoggerLogCalls[3].args, [
@@ -1052,7 +1258,6 @@ describe('internal-plugin-metrics', () => {
1052
1258
  },
1053
1259
  identifiers: {
1054
1260
  correlationId: 'correlationId2',
1055
- sessionCorrelationId: undefined,
1056
1261
  deviceId: 'deviceUrl',
1057
1262
  locusId: 'url',
1058
1263
  locusStartTime: 'lastActive',
@@ -1161,7 +1366,6 @@ describe('internal-plugin-metrics', () => {
1161
1366
  },
1162
1367
  identifiers: {
1163
1368
  correlationId: 'correlationId',
1164
- sessionCorrelationId: undefined,
1165
1369
  webexConferenceIdStr: 'webexConferenceIdStr1',
1166
1370
  globalMeetingId: 'globalMeetingId1',
1167
1371
  deviceId: 'deviceUrl',
@@ -1240,7 +1444,6 @@ describe('internal-plugin-metrics', () => {
1240
1444
  },
1241
1445
  identifiers: {
1242
1446
  correlationId: 'correlationId',
1243
- sessionCorrelationId: undefined,
1244
1447
  deviceId: 'deviceUrl',
1245
1448
  locusId: 'url',
1246
1449
  locusStartTime: 'lastActive',
@@ -1257,6 +1460,9 @@ describe('internal-plugin-metrics', () => {
1257
1460
  name: 'other',
1258
1461
  category: 'other',
1259
1462
  errorCode: 9999,
1463
+ errorData: {
1464
+ errorName: 'Error'
1465
+ },
1260
1466
  serviceErrorCode: 9999,
1261
1467
  errorDescription: 'UnknownError',
1262
1468
  rawErrorMessage: 'bad times',
@@ -1290,7 +1496,7 @@ describe('internal-plugin-metrics', () => {
1290
1496
  assert.deepEqual(webexLoggerLogCalls[2].args, [
1291
1497
  'call-diagnostic-events -> ',
1292
1498
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
1293
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1499
+ `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1294
1500
  ]);
1295
1501
  });
1296
1502
 
@@ -1316,7 +1522,6 @@ describe('internal-plugin-metrics', () => {
1316
1522
  },
1317
1523
  identifiers: {
1318
1524
  correlationId: 'correlationId',
1319
- sessionCorrelationId: 'unknown',
1320
1525
  deviceId: 'deviceUrl',
1321
1526
  locusUrl: 'locus-url',
1322
1527
  orgId: 'orgId',
@@ -1329,6 +1534,9 @@ describe('internal-plugin-metrics', () => {
1329
1534
  name: 'other',
1330
1535
  category: 'other',
1331
1536
  errorCode: 9999,
1537
+ errorData: {
1538
+ errorName: 'Error'
1539
+ },
1332
1540
  serviceErrorCode: 9999,
1333
1541
  errorDescription: 'UnknownError',
1334
1542
  rawErrorMessage: 'bad times',
@@ -1360,7 +1568,7 @@ describe('internal-plugin-metrics', () => {
1360
1568
  assert.deepEqual(webexLoggerLogCalls[2].args, [
1361
1569
  'call-diagnostic-events -> ',
1362
1570
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
1363
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1571
+ `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1364
1572
  ]);
1365
1573
  });
1366
1574
 
@@ -1390,7 +1598,6 @@ describe('internal-plugin-metrics', () => {
1390
1598
  },
1391
1599
  identifiers: {
1392
1600
  correlationId: 'correlationId',
1393
- sessionCorrelationId: 'unknown',
1394
1601
  deviceId: 'deviceUrl',
1395
1602
  locusUrl: 'locus-url',
1396
1603
  orgId: 'orgId',
@@ -1470,7 +1677,6 @@ describe('internal-plugin-metrics', () => {
1470
1677
  },
1471
1678
  identifiers: {
1472
1679
  correlationId: 'correlationId',
1473
- sessionCorrelationId: undefined,
1474
1680
  deviceId: 'deviceUrl',
1475
1681
  locusId: 'url',
1476
1682
  locusStartTime: 'lastActive',
@@ -1516,7 +1722,8 @@ describe('internal-plugin-metrics', () => {
1516
1722
  });
1517
1723
 
1518
1724
  it('should send behavioral event if meetingId provided but meeting is undefined', () => {
1519
- webex.meetings.meetingCollection.get = sinon.stub().returns(undefined);
1725
+ webex.meetings.getBasicMeetingInformation = sinon.stub().returns(undefined);
1726
+
1520
1727
  cd.submitClientEvent({name: 'client.alert.displayed', options: {meetingId: 'meetingId'}});
1521
1728
  assert.calledWith(
1522
1729
  webex.internal.metrics.submitClientMetrics,
@@ -1603,7 +1810,6 @@ describe('internal-plugin-metrics', () => {
1603
1810
  canProceed: true,
1604
1811
  identifiers: {
1605
1812
  correlationId: 'correlationId',
1606
- sessionCorrelationId: undefined,
1607
1813
  webexConferenceIdStr: 'webexConferenceIdStr1',
1608
1814
  globalMeetingId: 'globalMeetingId1',
1609
1815
  userId: 'userId',
@@ -1643,7 +1849,6 @@ describe('internal-plugin-metrics', () => {
1643
1849
  canProceed: true,
1644
1850
  identifiers: {
1645
1851
  correlationId: 'correlationId',
1646
- sessionCorrelationId: undefined,
1647
1852
  webexConferenceIdStr: 'webexConferenceIdStr1',
1648
1853
  globalMeetingId: 'globalMeetingId1',
1649
1854
  userId: 'userId',
@@ -1689,7 +1894,6 @@ describe('internal-plugin-metrics', () => {
1689
1894
  locusUrl: 'locus/url',
1690
1895
  locusId: 'url',
1691
1896
  locusStartTime: 'lastActive',
1692
- sessionCorrelationId: undefined,
1693
1897
  },
1694
1898
  eventData: {webClientDomain: 'whatever'},
1695
1899
  intervals: [{}],
@@ -1723,7 +1927,7 @@ describe('internal-plugin-metrics', () => {
1723
1927
  });
1724
1928
 
1725
1929
  it('should send behavioral event if meeting is undefined', () => {
1726
- webex.meetings.meetingCollection.get = sinon.stub().returns(undefined);
1930
+ webex.meetings.getBasicMeetingInformation = sinon.stub().returns(undefined);
1727
1931
  cd.submitMQE({
1728
1932
  name: 'client.mediaquality.event',
1729
1933
  payload: {
@@ -2045,6 +2249,9 @@ describe('internal-plugin-metrics', () => {
2045
2249
  shownToUser: true,
2046
2250
  serviceErrorCode: 9999,
2047
2251
  errorCode: 9999,
2252
+ errorData: {
2253
+ errorName: 'Error'
2254
+ },
2048
2255
  rawErrorMessage: 'bad times',
2049
2256
  });
2050
2257
  });
@@ -2188,6 +2395,40 @@ describe('internal-plugin-metrics', () => {
2188
2395
  });
2189
2396
  });
2190
2397
 
2398
+ it('should generate event error payload correctly for wdm error 4404002', () => {
2399
+ const res = cd.generateClientEventErrorPayload({
2400
+ body: {errorCode: 4404002},
2401
+ message: 'Operation denied due to region restriction',
2402
+ });
2403
+ assert.deepEqual(res, {
2404
+ category: 'expected',
2405
+ errorDescription: 'WdmRestrictedRegion',
2406
+ fatal: true,
2407
+ name: 'other',
2408
+ shownToUser: false,
2409
+ serviceErrorCode: 4404002,
2410
+ errorCode: 13000,
2411
+ rawErrorMessage: 'Operation denied due to region restriction',
2412
+ });
2413
+ });
2414
+
2415
+ it('should generate event error payload correctly for wdm error 4404003', () => {
2416
+ const res = cd.generateClientEventErrorPayload({
2417
+ body: {errorCode: 4404003},
2418
+ message: 'Operation denied due to region restriction',
2419
+ });
2420
+ assert.deepEqual(res, {
2421
+ category: 'expected',
2422
+ errorDescription: 'WdmRestrictedRegion',
2423
+ fatal: true,
2424
+ name: 'other',
2425
+ shownToUser: false,
2426
+ serviceErrorCode: 4404003,
2427
+ errorCode: 13000,
2428
+ rawErrorMessage: 'Operation denied due to region restriction',
2429
+ });
2430
+ });
2431
+
2191
2432
  describe('httpStatusCode', () => {
2192
2433
  it('should include httpStatusCode for browser media errors', () => {
2193
2434
  const res = cd.generateClientEventErrorPayload({
@@ -2443,7 +2684,6 @@ describe('internal-plugin-metrics', () => {
2443
2684
  locusUrl: 'locus/url',
2444
2685
  orgId: 'orgId',
2445
2686
  userId: 'userId',
2446
- sessionCorrelationId: undefined,
2447
2687
  },
2448
2688
  loginType: 'login-ci',
2449
2689
  name: 'client.exit.app',
@@ -2467,6 +2707,7 @@ describe('internal-plugin-metrics', () => {
2467
2707
  environment: 'meeting_evn',
2468
2708
  name: 'endpoint',
2469
2709
  networkType: 'unknown',
2710
+ upgradeChannel: 'test',
2470
2711
  userAgent,
2471
2712
  },
2472
2713
  originTime: {
@@ -2550,11 +2791,11 @@ describe('internal-plugin-metrics', () => {
2550
2791
  // The method is called in beforeEach itself. We are just testing it here
2551
2792
  it('sets the received deviceInfo to call-diagnostics', () => {
2552
2793
  const webexLoggerLogCalls = webex.logger.log.getCalls();
2553
- const device = { userId: 'userId', url: 'deviceUrl', orgId: 'orgId' };
2794
+ const device = {userId: 'userId', url: 'deviceUrl', orgId: 'orgId'};
2554
2795
 
2555
2796
  assert.deepEqual(webexLoggerLogCalls[0].args, [
2556
2797
  'CallDiagnosticMetrics: @setDeviceInfo called',
2557
- device
2798
+ device,
2558
2799
  ]);
2559
2800
 
2560
2801
  assert.deepEqual(cd.device, device);
@@ -274,7 +274,7 @@ describe('internal-plugin-metrics', () => {
274
274
  describe('prepareDiagnosticMetricItem', () => {
275
275
  let webex: any;
276
276
 
277
- const check = (eventName: string, expectedEvent: any) => {
277
+ const check = (eventName: string, expectedEvent: any, expectedUpgradeChannel: string) => {
278
278
  const eventPayload = {event: {name: eventName}};
279
279
  const item = prepareDiagnosticMetricItem(webex, {
280
280
  eventPayload,
@@ -286,6 +286,7 @@ describe('internal-plugin-metrics', () => {
286
286
  origin: {
287
287
  buildType: 'prod',
288
288
  networkType: 'unknown',
289
+ upgradeChannel: expectedUpgradeChannel
289
290
  },
290
291
  event: {name: eventName, ...expectedEvent},
291
292
  },
@@ -417,11 +418,11 @@ describe('internal-plugin-metrics', () => {
417
418
  ],
418
419
  ].forEach(([eventName, expectedEvent]) => {
419
420
  it(`returns expected result for ${eventName}`, () => {
420
- check(eventName as string, expectedEvent);
421
+ check(eventName as string, expectedEvent, 'gold');
421
422
  });
422
423
  });
423
424
 
424
- it('getBuildType returns correct value', () => {
425
+ it('sets buildType and upgradeChannel correctly', () => {
425
426
  const item: any = {
426
427
  eventPayload: {
427
428
  event: {
@@ -438,11 +439,14 @@ describe('internal-plugin-metrics', () => {
438
439
  // just submit any event
439
440
  prepareDiagnosticMetricItem(webex, item);
440
441
  assert.deepEqual(item.eventPayload.origin.buildType, 'test');
442
+ assert.deepEqual(item.eventPayload.origin.upgradeChannel, 'test');
441
443
 
442
444
  delete item.eventPayload.origin.buildType;
445
+ delete item.eventPayload.origin.upgradeChannel;
443
446
  item.eventPayload.event.eventData.markAsTestEvent = false;
444
447
  prepareDiagnosticMetricItem(webex, item);
445
448
  assert.deepEqual(item.eventPayload.origin.buildType, 'prod');
449
+ assert.deepEqual(item.eventPayload.origin.upgradeChannel, 'gold');
446
450
  });
447
451
  });
448
452
 
@@ -11,9 +11,6 @@ describe('internal-plugin-metrics', () => {
11
11
  newMetrics: NewMetrics,
12
12
  },
13
13
  meetings: {
14
- meetingCollection: {
15
- get: sinon.stub(),
16
- },
17
14
  },
18
15
  request: sinon.stub().resolves({}),
19
16
  logger: {
@@ -86,6 +83,24 @@ describe('internal-plugin-metrics', () => {
86
83
  webex.internal.newMetrics.isReadyToSubmitBusinessEvents();
87
84
  assert.isDefined(webex.internal.newMetrics.businessMetrics);
88
85
  })
86
+
87
+ it('passes the table through to the business metrics', () => {
88
+ assert.isUndefined(webex.internal.newMetrics.businessMetrics)
89
+ webex.internal.newMetrics.isReadyToSubmitBusinessEvents();
90
+ assert.isDefined(webex.internal.newMetrics.businessMetrics);
91
+ webex.internal.newMetrics.businessMetrics.submitBusinessEvent = sinon.stub();
92
+ webex.internal.newMetrics.submitBusinessEvent({
93
+ name: 'foobar',
94
+ payload: {},
95
+ table: 'test',
96
+ });
97
+
98
+ assert.calledWith(webex.internal.newMetrics.businessMetrics.submitBusinessEvent, {
99
+ name: 'foobar',
100
+ payload: {},
101
+ table: 'test',
102
+ });
103
+ });
89
104
 
90
105
  it('submits Client Event successfully', () => {
91
106
  webex.internal.newMetrics.submitClientEvent({