@webex/internal-plugin-metrics 3.5.0 → 3.6.0

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 (55) 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 +18 -7
  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/call-diagnostic-events-batcher.js +59 -0
  12. package/dist/call-diagnostic-events-batcher.js.map +1 -0
  13. package/dist/index.js +7 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/metrics.js +1 -1
  16. package/dist/metrics.types.js.map +1 -1
  17. package/dist/new-metrics.js +5 -2
  18. package/dist/new-metrics.js.map +1 -1
  19. package/dist/rtcMetrics/constants.js +11 -0
  20. package/dist/rtcMetrics/constants.js.map +1 -0
  21. package/dist/rtcMetrics/index.js +223 -0
  22. package/dist/rtcMetrics/index.js.map +1 -0
  23. package/dist/types/business-metrics.d.ts +36 -4
  24. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +6 -1
  25. package/dist/types/call-diagnostic/config.d.ts +3 -0
  26. package/dist/types/index.d.ts +2 -1
  27. package/dist/types/metrics.types.d.ts +17 -2
  28. package/dist/types/new-metrics.d.ts +5 -3
  29. package/dist/types/rtcMetrics/constants.d.ts +4 -0
  30. package/dist/types/rtcMetrics/index.d.ts +80 -0
  31. package/package.json +11 -11
  32. package/src/business-metrics.ts +97 -5
  33. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
  34. package/src/call-diagnostic/call-diagnostic-metrics.ts +17 -7
  35. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +11 -5
  36. package/src/call-diagnostic/config.ts +12 -0
  37. package/src/index.ts +2 -0
  38. package/src/metrics.types.ts +95 -23
  39. package/src/new-metrics.ts +12 -2
  40. package/src/rtcMetrics/constants.ts +3 -0
  41. package/src/rtcMetrics/index.ts +205 -0
  42. package/test/unit/spec/business/business-metrics.ts +69 -2
  43. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +2 -1
  44. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +4 -6
  45. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +406 -11
  46. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +7 -3
  47. package/test/unit/spec/new-metrics.ts +18 -3
  48. package/test/unit/spec/prelogin-metrics-batcher.ts +3 -1
  49. package/test/unit/spec/rtcMetrics/index.ts +196 -0
  50. package/dist/behavioral/behavioral-metrics.js +0 -199
  51. package/dist/behavioral/behavioral-metrics.js.map +0 -1
  52. package/dist/behavioral/config.js +0 -11
  53. package/dist/behavioral/config.js.map +0 -1
  54. package/dist/types/behavioral/behavioral-metrics.d.ts +0 -63
  55. package/dist/types/behavioral/config.d.ts +0 -1
@@ -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,
@@ -40,9 +42,6 @@ describe('internal-plugin-metrics', () => {
40
42
  },
41
43
  meetingInfo: {},
42
44
  getCurUserType: () => 'host',
43
- statsAnalyzer: {
44
- getLocalIpAddress: () => '192.168.1.90',
45
- },
46
45
  };
47
46
 
48
47
  const fakeMeeting2 = {
@@ -52,9 +51,17 @@ describe('internal-plugin-metrics', () => {
52
51
  callStateForMetrics: {loginType: 'fakeLoginType'},
53
52
  };
54
53
 
54
+ const fakeMeeting3 = {
55
+ ...fakeMeeting,
56
+ id: '3',
57
+ correlationId: 'correlationId3',
58
+ sessionCorrelationId: 'sessionCorrelationId3',
59
+ }
60
+
55
61
  const fakeMeetings = {
56
62
  1: fakeMeeting,
57
63
  2: fakeMeeting2,
64
+ 3: fakeMeeting3,
58
65
  };
59
66
 
60
67
  let webex;
@@ -86,8 +93,19 @@ describe('internal-plugin-metrics', () => {
86
93
  clientName: 'Cantina',
87
94
  },
88
95
  },
96
+ getBasicMeetingInformation: (id) => fakeMeetings[id],
89
97
  meetingCollection: {
90
- 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
+ },
91
109
  },
92
110
  geoHintInfo: {
93
111
  clientAddress: '1.3.4.5',
@@ -366,6 +384,94 @@ describe('internal-plugin-metrics', () => {
366
384
  });
367
385
  });
368
386
 
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', () => {
418
+ cd.device = {
419
+ ...cd.device,
420
+ config: {installationId: 'installationId'},
421
+ };
422
+
423
+ const res = cd.getIdentifiers({
424
+ mediaConnections: [
425
+ {mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
426
+ ],
427
+ meeting: fakeMeeting,
428
+ sessionCorrelationId: 'sessionCorrelationId',
429
+ });
430
+
431
+ assert.deepEqual(res, {
432
+ correlationId: 'correlationId',
433
+ sessionCorrelationId: 'sessionCorrelationId',
434
+ deviceId: 'deviceUrl',
435
+ locusId: 'url',
436
+ locusStartTime: 'lastActive',
437
+ locusUrl: 'locus/url',
438
+ machineId: 'installationId',
439
+ mediaAgentAlias: 'mediaAgentAlias',
440
+ mediaAgentGroupId: 'mediaAgentGroupId',
441
+ orgId: 'orgId',
442
+ userId: 'userId',
443
+ });
444
+ });
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
+
369
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', () => {
370
476
  const res = cd.getIdentifiers({
371
477
  mediaConnections: [
@@ -466,6 +572,42 @@ describe('internal-plugin-metrics', () => {
466
572
  });
467
573
  });
468
574
 
575
+ it('should build identifiers correctly with a meeting that has sessionCorrelationId', () => {
576
+ const res = cd.getIdentifiers({
577
+ mediaConnections: [
578
+ {mediaAgentAlias: 'mediaAgentAlias', mediaAgentGroupId: 'mediaAgentGroupId'},
579
+ ],
580
+ webexConferenceIdStr: 'webexConferenceIdStr',
581
+ globalMeetingId: 'globalMeetingId',
582
+ meeting: {
583
+ ...fakeMeeting,
584
+ sessionCorrelationId: 'sessionCorrelationId1',
585
+ meetingInfo: {
586
+ ...fakeMeeting.meetingInfo,
587
+ confIdStr: 'webexConferenceIdStr1',
588
+ meetingId: 'globalMeetingId1',
589
+ siteName: 'siteName1',
590
+ },
591
+ },
592
+ });
593
+
594
+ assert.deepEqual(res, {
595
+ correlationId: 'correlationId',
596
+ sessionCorrelationId: 'sessionCorrelationId1',
597
+ webexConferenceIdStr: 'webexConferenceIdStr1',
598
+ globalMeetingId: 'globalMeetingId1',
599
+ deviceId: 'deviceUrl',
600
+ locusId: 'url',
601
+ locusStartTime: 'lastActive',
602
+ locusUrl: 'locus/url',
603
+ mediaAgentAlias: 'mediaAgentAlias',
604
+ mediaAgentGroupId: 'mediaAgentGroupId',
605
+ orgId: 'orgId',
606
+ userId: 'userId',
607
+ webexSiteName: 'siteName1',
608
+ });
609
+ });
610
+
469
611
  it('should build identifiers correctly given webexConferenceIdStr', () => {
470
612
  const res = cd.getIdentifiers({
471
613
  correlationId: 'correlationId',
@@ -512,6 +654,22 @@ describe('internal-plugin-metrics', () => {
512
654
  });
513
655
  });
514
656
 
657
+ it('should build identifiers correctly given sessionCorrelationId', () => {
658
+ const res = cd.getIdentifiers({
659
+ correlationId: 'correlationId',
660
+ sessionCorrelationId: 'sessionCorrelationId',
661
+ });
662
+
663
+ assert.deepEqual(res, {
664
+ correlationId: 'correlationId',
665
+ sessionCorrelationId: 'sessionCorrelationId',
666
+ deviceId: 'deviceUrl',
667
+ locusUrl: 'locus-url',
668
+ orgId: 'orgId',
669
+ userId: 'userId',
670
+ });
671
+ });
672
+
515
673
  it('should throw Error if correlationId is missing', () => {
516
674
  assert.throws(() =>
517
675
  cd.getIdentifiers({
@@ -606,12 +764,14 @@ describe('internal-plugin-metrics', () => {
606
764
  options,
607
765
  });
608
766
 
767
+ assert.called(getIdentifiersSpy);
609
768
  assert.calledWith(getIdentifiersSpy, {
610
769
  meeting: fakeMeeting,
611
770
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
612
771
  webexConferenceIdStr: undefined,
613
772
  sessionCorrelationId: undefined,
614
773
  globalMeetingId: undefined,
774
+ sessionCorrelationId: undefined,
615
775
  });
616
776
  assert.notCalled(generateClientEventErrorPayloadSpy);
617
777
  assert.calledWith(
@@ -720,6 +880,142 @@ describe('internal-plugin-metrics', () => {
720
880
  ]);
721
881
  });
722
882
 
883
+ it('should submit client event successfully with meetingId which has a sessionCorrelationId', () => {
884
+ const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
885
+ const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
886
+ const generateClientEventErrorPayloadSpy = sinon.spy(cd, 'generateClientEventErrorPayload');
887
+ const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
888
+ const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
889
+ sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
890
+ const validatorSpy = sinon.spy(cd, 'validator');
891
+ const options = {
892
+ meetingId: fakeMeeting3.id,
893
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
894
+ };
895
+
896
+ cd.submitClientEvent({
897
+ name: 'client.alert.displayed',
898
+ options,
899
+ });
900
+
901
+ assert.called(getIdentifiersSpy);
902
+ assert.calledWith(getIdentifiersSpy, {
903
+ meeting: {...fakeMeeting3, sessionCorrelationId: 'sessionCorrelationId3'},
904
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
905
+ webexConferenceIdStr: undefined,
906
+ globalMeetingId: undefined,
907
+ sessionCorrelationId: undefined,
908
+ });
909
+ assert.notCalled(generateClientEventErrorPayloadSpy);
910
+ assert.calledWith(
911
+ prepareDiagnosticEventSpy,
912
+ {
913
+ canProceed: true,
914
+ eventData: {
915
+ webClientDomain: 'whatever',
916
+ },
917
+ identifiers: {
918
+ correlationId: 'correlationId3',
919
+ sessionCorrelationId: 'sessionCorrelationId3',
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
+ },
935
+ options
936
+ );
937
+ assert.calledWith(submitToCallDiagnosticsSpy, {
938
+ event: {
939
+ canProceed: true,
940
+ eventData: {
941
+ webClientDomain: 'whatever',
942
+ },
943
+ identifiers: {
944
+ correlationId: 'correlationId3',
945
+ sessionCorrelationId: 'sessionCorrelationId3',
946
+ deviceId: 'deviceUrl',
947
+ locusId: 'url',
948
+ locusStartTime: 'lastActive',
949
+ locusUrl: 'locus/url',
950
+ mediaAgentAlias: 'alias',
951
+ mediaAgentGroupId: '1',
952
+ orgId: 'orgId',
953
+ userId: 'userId',
954
+ },
955
+ loginType: 'login-ci',
956
+ name: 'client.alert.displayed',
957
+ userType: 'host',
958
+ isConvergedArchitectureEnabled: undefined,
959
+ webexSubServiceType: undefined,
960
+ },
961
+ eventId: 'my-fake-id',
962
+ origin: {
963
+ origin: 'fake-origin',
964
+ },
965
+ originTime: {
966
+ sent: 'not_defined_yet',
967
+ triggered: now.toISOString(),
968
+ },
969
+ senderCountryCode: 'UK',
970
+ version: 1,
971
+ });
972
+ assert.calledWith(validatorSpy, {
973
+ type: 'ce',
974
+ event: {
975
+ event: {
976
+ canProceed: true,
977
+ eventData: {
978
+ webClientDomain: 'whatever',
979
+ },
980
+ identifiers: {
981
+ correlationId: 'correlationId3',
982
+ sessionCorrelationId: 'sessionCorrelationId3',
983
+ deviceId: 'deviceUrl',
984
+ locusId: 'url',
985
+ locusStartTime: 'lastActive',
986
+ locusUrl: 'locus/url',
987
+ mediaAgentAlias: 'alias',
988
+ mediaAgentGroupId: '1',
989
+ orgId: 'orgId',
990
+ userId: 'userId',
991
+ },
992
+ loginType: 'login-ci',
993
+ name: 'client.alert.displayed',
994
+ userType: 'host',
995
+ isConvergedArchitectureEnabled: undefined,
996
+ webexSubServiceType: undefined,
997
+ },
998
+ eventId: 'my-fake-id',
999
+ origin: {
1000
+ origin: 'fake-origin',
1001
+ },
1002
+ originTime: {
1003
+ sent: 'not_defined_yet',
1004
+ triggered: now.toISOString(),
1005
+ },
1006
+ senderCountryCode: 'UK',
1007
+ version: 1,
1008
+ },
1009
+ });
1010
+
1011
+ const webexLoggerLogCalls = webex.logger.log.getCalls();
1012
+ assert.deepEqual(webexLoggerLogCalls[1].args, [
1013
+ 'call-diagnostic-events -> ',
1014
+ 'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.',
1015
+ `name: client.alert.displayed`,
1016
+ ]);
1017
+ });
1018
+
723
1019
  it('should log browser data, but only for the first call diagnostic event', () => {
724
1020
  const prepareDiagnosticEventSpy = sinon.spy(cd, 'prepareDiagnosticEvent');
725
1021
  const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
@@ -727,6 +1023,9 @@ describe('internal-plugin-metrics', () => {
727
1023
  const getIdentifiersSpy = sinon.spy(cd, 'getIdentifiers');
728
1024
  const getSubServiceTypeSpy = sinon.spy(cd, 'getSubServiceType');
729
1025
  const validatorSpy = sinon.spy(cd, 'validator');
1026
+ sinon.stub(window.navigator, 'userAgent').get(() => userAgent);
1027
+ sinon.stub(bowser, 'getParser').returns(userAgent);
1028
+
730
1029
  const options = {
731
1030
  meetingId: fakeMeeting.id,
732
1031
  mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
@@ -755,7 +1054,7 @@ describe('internal-plugin-metrics', () => {
755
1054
  assert.deepEqual(webexLoggerLogCalls[2].args, [
756
1055
  'call-diagnostic-events -> ',
757
1056
  'CallDiagnosticMetrics: @createClientEventObjectInMeeting => collected browser data',
758
- '{"error":"unable to access window.navigator.userAgent"}',
1057
+ `${JSON.stringify(userAgent)}`,
759
1058
  ]);
760
1059
 
761
1060
  assert.deepEqual(webexLoggerLogCalls[3].args, [
@@ -988,6 +1287,57 @@ describe('internal-plugin-metrics', () => {
988
1287
  });
989
1288
  });
990
1289
 
1290
+ it('should use meeting loginType if present and meetingId provided, with sessionCorrelationId', () => {
1291
+ const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
1292
+ sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
1293
+ const options = {
1294
+ meetingId: fakeMeeting2.id,
1295
+ mediaConnections: [{mediaAgentAlias: 'alias', mediaAgentGroupId: '1'}],
1296
+ sessionCorrelationId: 'sessionCorrelationId1'
1297
+ };
1298
+
1299
+ cd.submitClientEvent({
1300
+ name: 'client.alert.displayed',
1301
+ options,
1302
+ });
1303
+
1304
+ assert.calledWith(submitToCallDiagnosticsSpy, {
1305
+ event: {
1306
+ canProceed: true,
1307
+ eventData: {
1308
+ webClientDomain: 'whatever',
1309
+ },
1310
+ identifiers: {
1311
+ correlationId: 'correlationId2',
1312
+ sessionCorrelationId: 'sessionCorrelationId1',
1313
+ deviceId: 'deviceUrl',
1314
+ locusId: 'url',
1315
+ locusStartTime: 'lastActive',
1316
+ locusUrl: 'locus/url',
1317
+ mediaAgentAlias: 'alias',
1318
+ mediaAgentGroupId: '1',
1319
+ orgId: 'orgId',
1320
+ userId: 'userId',
1321
+ },
1322
+ loginType: 'fakeLoginType',
1323
+ name: 'client.alert.displayed',
1324
+ userType: 'host',
1325
+ isConvergedArchitectureEnabled: undefined,
1326
+ webexSubServiceType: undefined,
1327
+ },
1328
+ eventId: 'my-fake-id',
1329
+ origin: {
1330
+ origin: 'fake-origin',
1331
+ },
1332
+ originTime: {
1333
+ sent: 'not_defined_yet',
1334
+ triggered: now.toISOString(),
1335
+ },
1336
+ senderCountryCode: 'UK',
1337
+ version: 1,
1338
+ });
1339
+ });
1340
+
991
1341
  it('it should include errors if provided with meetingId', () => {
992
1342
  sinon.stub(cd, 'getOrigin').returns({origin: 'fake-origin'});
993
1343
  const submitToCallDiagnosticsSpy = sinon.spy(cd, 'submitToCallDiagnostics');
@@ -1111,6 +1461,9 @@ describe('internal-plugin-metrics', () => {
1111
1461
  name: 'other',
1112
1462
  category: 'other',
1113
1463
  errorCode: 9999,
1464
+ errorData: {
1465
+ errorName: 'Error'
1466
+ },
1114
1467
  serviceErrorCode: 9999,
1115
1468
  errorDescription: 'UnknownError',
1116
1469
  rawErrorMessage: 'bad times',
@@ -1144,7 +1497,7 @@ describe('internal-plugin-metrics', () => {
1144
1497
  assert.deepEqual(webexLoggerLogCalls[2].args, [
1145
1498
  'call-diagnostic-events -> ',
1146
1499
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
1147
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1500
+ `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1148
1501
  ]);
1149
1502
  });
1150
1503
 
@@ -1182,6 +1535,9 @@ describe('internal-plugin-metrics', () => {
1182
1535
  name: 'other',
1183
1536
  category: 'other',
1184
1537
  errorCode: 9999,
1538
+ errorData: {
1539
+ errorName: 'Error'
1540
+ },
1185
1541
  serviceErrorCode: 9999,
1186
1542
  errorDescription: 'UnknownError',
1187
1543
  rawErrorMessage: 'bad times',
@@ -1213,7 +1569,7 @@ describe('internal-plugin-metrics', () => {
1213
1569
  assert.deepEqual(webexLoggerLogCalls[2].args, [
1214
1570
  'call-diagnostic-events -> ',
1215
1571
  'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:',
1216
- `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1572
+ `generatedError: {"fatal":true,"shownToUser":false,"name":"other","category":"other","errorCode":9999,"errorData":{"errorName":"Error"},"serviceErrorCode":9999,"rawErrorMessage":"bad times","errorDescription":"UnknownError"}`,
1217
1573
  ]);
1218
1574
  });
1219
1575
 
@@ -1367,7 +1723,8 @@ describe('internal-plugin-metrics', () => {
1367
1723
  });
1368
1724
 
1369
1725
  it('should send behavioral event if meetingId provided but meeting is undefined', () => {
1370
- webex.meetings.meetingCollection.get = sinon.stub().returns(undefined);
1726
+ webex.meetings.getBasicMeetingInformation = sinon.stub().returns(undefined);
1727
+
1371
1728
  cd.submitClientEvent({name: 'client.alert.displayed', options: {meetingId: 'meetingId'}});
1372
1729
  assert.calledWith(
1373
1730
  webex.internal.metrics.submitClientMetrics,
@@ -1571,7 +1928,7 @@ describe('internal-plugin-metrics', () => {
1571
1928
  });
1572
1929
 
1573
1930
  it('should send behavioral event if meeting is undefined', () => {
1574
- webex.meetings.meetingCollection.get = sinon.stub().returns(undefined);
1931
+ webex.meetings.getBasicMeetingInformation = sinon.stub().returns(undefined);
1575
1932
  cd.submitMQE({
1576
1933
  name: 'client.mediaquality.event',
1577
1934
  payload: {
@@ -1893,6 +2250,9 @@ describe('internal-plugin-metrics', () => {
1893
2250
  shownToUser: true,
1894
2251
  serviceErrorCode: 9999,
1895
2252
  errorCode: 9999,
2253
+ errorData: {
2254
+ errorName: 'Error'
2255
+ },
1896
2256
  rawErrorMessage: 'bad times',
1897
2257
  });
1898
2258
  });
@@ -2036,6 +2396,40 @@ describe('internal-plugin-metrics', () => {
2036
2396
  });
2037
2397
  });
2038
2398
 
2399
+ it('should generate event error payload correctly for wdm error 4404002', () => {
2400
+ const res = cd.generateClientEventErrorPayload({
2401
+ body: {errorCode: 4404002},
2402
+ message: 'Operation denied due to region restriction',
2403
+ });
2404
+ assert.deepEqual(res, {
2405
+ category: 'expected',
2406
+ errorDescription: 'WdmRestrictedRegion',
2407
+ fatal: true,
2408
+ name: 'other',
2409
+ shownToUser: false,
2410
+ serviceErrorCode: 4404002,
2411
+ errorCode: 13000,
2412
+ rawErrorMessage: 'Operation denied due to region restriction',
2413
+ });
2414
+ });
2415
+
2416
+ it('should generate event error payload correctly for wdm error 4404003', () => {
2417
+ const res = cd.generateClientEventErrorPayload({
2418
+ body: {errorCode: 4404003},
2419
+ message: 'Operation denied due to region restriction',
2420
+ });
2421
+ assert.deepEqual(res, {
2422
+ category: 'expected',
2423
+ errorDescription: 'WdmRestrictedRegion',
2424
+ fatal: true,
2425
+ name: 'other',
2426
+ shownToUser: false,
2427
+ serviceErrorCode: 4404003,
2428
+ errorCode: 13000,
2429
+ rawErrorMessage: 'Operation denied due to region restriction',
2430
+ });
2431
+ });
2432
+
2039
2433
  describe('httpStatusCode', () => {
2040
2434
  it('should include httpStatusCode for browser media errors', () => {
2041
2435
  const res = cd.generateClientEventErrorPayload({
@@ -2314,6 +2708,7 @@ describe('internal-plugin-metrics', () => {
2314
2708
  environment: 'meeting_evn',
2315
2709
  name: 'endpoint',
2316
2710
  networkType: 'unknown',
2711
+ upgradeChannel: 'test',
2317
2712
  userAgent,
2318
2713
  },
2319
2714
  originTime: {
@@ -2397,11 +2792,11 @@ describe('internal-plugin-metrics', () => {
2397
2792
  // The method is called in beforeEach itself. We are just testing it here
2398
2793
  it('sets the received deviceInfo to call-diagnostics', () => {
2399
2794
  const webexLoggerLogCalls = webex.logger.log.getCalls();
2400
- const device = { userId: 'userId', url: 'deviceUrl', orgId: 'orgId' };
2795
+ const device = {userId: 'userId', url: 'deviceUrl', orgId: 'orgId'};
2401
2796
 
2402
2797
  assert.deepEqual(webexLoggerLogCalls[0].args, [
2403
2798
  'CallDiagnosticMetrics: @setDeviceInfo called',
2404
- device
2799
+ device,
2405
2800
  ]);
2406
2801
 
2407
2802
  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({
@@ -82,6 +82,7 @@ describe('internal-plugin-metrics', () => {
82
82
  origin: {
83
83
  buildType: 'test',
84
84
  networkType: 'unknown',
85
+ upgradeChannel: 'test',
85
86
  },
86
87
  originTime: {
87
88
  sent: dateAfterBatcherWait.toISOString(),
@@ -211,7 +212,7 @@ describe('internal-plugin-metrics', () => {
211
212
  // item also gets assigned a delay property but the key is a Symbol and haven't been able to test that..
212
213
  assert.deepEqual(calls.args[0].eventPayload, {
213
214
  event: 'my.event',
214
- origin: {buildType: 'test', networkType: 'unknown'},
215
+ origin: {buildType: 'test', networkType: 'unknown', upgradeChannel: 'test'},
215
216
  });
216
217
 
217
218
  assert.deepEqual(calls.args[0].type, ['diagnostic-event']);
@@ -225,6 +226,7 @@ describe('internal-plugin-metrics', () => {
225
226
  origin: {
226
227
  buildType: 'test',
227
228
  networkType: 'unknown',
229
+ upgradeChannel: 'test',
228
230
  },
229
231
  });
230
232
  assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[1].type, ['diagnostic-event']);