@webex/internal-plugin-metrics 3.8.1-next.4 → 3.8.1-next.5

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.
@@ -72,6 +72,7 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
72
72
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasLoggedBrowserSerial", void 0);
73
73
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "device", void 0);
74
74
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "delayedClientEvents", []);
75
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "delayedClientFeatureEvents", []);
75
76
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventErrorCache", new _weakMap.default());
76
77
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMercuryConnected", false);
77
78
  // the default validator before piping an event to the batcher
@@ -388,14 +389,91 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
388
389
  }
389
390
 
390
391
  /**
391
- * TODO: NOT IMPLEMENTED
392
+ * Create feature event
393
+ * @param name
394
+ * @param payload
395
+ * @param options
396
+ * @returns
397
+ */
398
+ }, {
399
+ key: "prepareClientFeatureEvent",
400
+ value: function prepareClientFeatureEvent(_ref3) {
401
+ var name = _ref3.name,
402
+ payload = _ref3.payload,
403
+ options = _ref3.options;
404
+ var meetingId = options.meetingId,
405
+ correlationId = options.correlationId;
406
+ var featureEventObject;
407
+
408
+ // events that will most likely happen in join phase
409
+ if (meetingId) {
410
+ featureEventObject = this.createFeatureEventObjectInMeeting({
411
+ name: name,
412
+ options: options
413
+ });
414
+ } else {
415
+ throw new Error('Not implemented');
416
+ }
417
+
418
+ // merge any new properties, or override existing ones
419
+ featureEventObject = (0, _lodash.merge)(featureEventObject, payload);
420
+
421
+ // append client event data to the call diagnostic event
422
+ var featureEvent = this.prepareDiagnosticEvent(featureEventObject, options);
423
+ return featureEvent;
424
+ }
425
+
426
+ /**
392
427
  * Submit Feature Event
428
+ * submit to business_ucf
393
429
  * @returns
394
430
  */
395
431
  }, {
396
432
  key: "submitFeatureEvent",
397
- value: function submitFeatureEvent() {
398
- throw Error('Not implemented');
433
+ value: function submitFeatureEvent(_ref4) {
434
+ var name = _ref4.name,
435
+ payload = _ref4.payload,
436
+ options = _ref4.options,
437
+ delaySubmitEvent = _ref4.delaySubmitEvent;
438
+ if (delaySubmitEvent) {
439
+ // Preserve the time when the event was triggered if delaying the submission to Call Features
440
+ var delayedOptions = _objectSpread(_objectSpread({}, options), {}, {
441
+ triggeredTime: new Date().toISOString()
442
+ });
443
+ this.delayedClientFeatureEvents.push({
444
+ name: name,
445
+ payload: payload,
446
+ options: delayedOptions
447
+ });
448
+ return _promise.default.resolve();
449
+ }
450
+ this.logger.log(_config2.CALL_FEATURE_LOG_IDENTIFIER, 'CallFeatureMetrics: @submitFeatureEvent. Submit Client Feature Event CA event.', "name: ".concat(name));
451
+ var featureEvent = this.prepareClientFeatureEvent({
452
+ name: name,
453
+ payload: payload,
454
+ options: options
455
+ });
456
+ this.validator({
457
+ type: 'ce',
458
+ event: featureEvent
459
+ });
460
+ return this.submitToCallFeatures(featureEvent);
461
+ }
462
+
463
+ /**
464
+ * Submit Feature Event
465
+ * type is business
466
+ * @param event
467
+ */
468
+ }, {
469
+ key: "submitToCallFeatures",
470
+ value: function submitToCallFeatures(event) {
471
+ // build metrics-a event type
472
+ var finalEvent = {
473
+ eventPayload: event,
474
+ type: ['business']
475
+ };
476
+ return this.callDiagnosticEventsBatcher.request(finalEvent);
399
477
  }
400
478
 
401
479
  /**
@@ -407,10 +485,10 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
407
485
  */
408
486
  }, {
409
487
  key: "submitMQE",
410
- value: function submitMQE(_ref3) {
411
- var name = _ref3.name,
412
- payload = _ref3.payload,
413
- options = _ref3.options;
488
+ value: function submitMQE(_ref5) {
489
+ var name = _ref5.name,
490
+ payload = _ref5.payload,
491
+ options = _ref5.options;
414
492
  var meetingId = options.meetingId,
415
493
  mediaConnections = options.mediaConnections,
416
494
  webexConferenceIdStr = options.webexConferenceIdStr,
@@ -489,13 +567,13 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
489
567
  */
490
568
  }, {
491
569
  key: "getErrorPayloadForClientErrorCode",
492
- value: function getErrorPayloadForClientErrorCode(_ref4) {
493
- var clientErrorCode = _ref4.clientErrorCode,
494
- serviceErrorCode = _ref4.serviceErrorCode,
495
- serviceErrorName = _ref4.serviceErrorName,
496
- rawErrorMessage = _ref4.rawErrorMessage,
497
- payloadOverrides = _ref4.payloadOverrides,
498
- httpStatusCode = _ref4.httpStatusCode;
570
+ value: function getErrorPayloadForClientErrorCode(_ref6) {
571
+ var clientErrorCode = _ref6.clientErrorCode,
572
+ serviceErrorCode = _ref6.serviceErrorCode,
573
+ serviceErrorName = _ref6.serviceErrorName,
574
+ rawErrorMessage = _ref6.rawErrorMessage,
575
+ payloadOverrides = _ref6.payloadOverrides,
576
+ httpStatusCode = _ref6.httpStatusCode;
499
577
  var error;
500
578
  if (clientErrorCode) {
501
579
  var partialParsedError = _config2.CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD[clientErrorCode];
@@ -639,19 +717,20 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
639
717
  }
640
718
 
641
719
  /**
642
- * Create client event object for in meeting events
643
- * @param arg - create args
644
- * @param arg.event - event key
645
- * @param arg.options - options
720
+ * Create common object for in meeting events
721
+ * @param name
722
+ * @param options
723
+ * @param eventType - 'client' | 'feature'
646
724
  * @returns object
647
725
  */
648
726
  }, {
649
- key: "createClientEventObjectInMeeting",
650
- value: function createClientEventObjectInMeeting(_ref5) {
727
+ key: "createCommonEventObjectInMeeting",
728
+ value: function createCommonEventObjectInMeeting(_ref7) {
651
729
  var _this$webex$meetings2, _this$webex$meetings3, _this$webex$meetings4, _options$joinFlowVers, _meeting$callStateFor;
652
- var name = _ref5.name,
653
- options = _ref5.options,
654
- errors = _ref5.errors;
730
+ var name = _ref7.name,
731
+ options = _ref7.options,
732
+ _ref7$eventType = _ref7.eventType,
733
+ eventType = _ref7$eventType === void 0 ? 'client' : _ref7$eventType;
655
734
  var meetingId = options.meetingId,
656
735
  mediaConnections = options.mediaConnections,
657
736
  globalMeetingId = options.globalMeetingId,
@@ -661,9 +740,9 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
661
740
  // @ts-ignore
662
741
  var meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
663
742
  if (!meeting) {
664
- console.warn('Attempt to send client event but no meeting was found...', "name: ".concat(name, ", meetingId: ").concat(meetingId));
743
+ console.warn('Attempt to send common event but no meeting was found...', "name: ".concat(name, ", meetingId: ").concat(meetingId));
665
744
  // @ts-ignore
666
- this.webex.internal.metrics.submitClientMetrics(_config2.CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND, {
745
+ this.webex.internal.metrics.submitClientMetrics(eventType === 'feature' ? _config2.CALL_FEATURE_EVENT_FAILED_TO_SEND : _config2.CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND, {
667
746
  fields: {
668
747
  meetingId: meetingId,
669
748
  name: name
@@ -681,15 +760,13 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
681
760
  sessionCorrelationId: sessionCorrelationId
682
761
  });
683
762
 
684
- // create client event object
685
- var clientEventObject = _objectSpread(_objectSpread(_objectSpread({
763
+ // create common event object structur
764
+ var commonEventObject = _objectSpread(_objectSpread(_objectSpread({
686
765
  name: name,
687
766
  canProceed: true,
688
767
  identifiers: identifiers,
689
- errors: errors,
690
768
  eventData: {
691
- webClientDomain: window.location.hostname,
692
- isMercuryConnected: this.isMercuryConnected
769
+ webClientDomain: window.location.hostname
693
770
  },
694
771
  userType: meeting.getCurUserType(),
695
772
  loginType: 'loginType' in meeting.callStateForMetrics ? meeting.callStateForMetrics.loginType : this.getCurLoginType(),
@@ -707,16 +784,68 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
707
784
  });
708
785
  var joinFlowVersion = (_options$joinFlowVers = options.joinFlowVersion) !== null && _options$joinFlowVers !== void 0 ? _options$joinFlowVers : (_meeting$callStateFor = meeting.callStateForMetrics) === null || _meeting$callStateFor === void 0 ? void 0 : _meeting$callStateFor.joinFlowVersion;
709
786
  if (joinFlowVersion) {
710
- clientEventObject.joinFlowVersion = joinFlowVersion;
787
+ // @ts-ignore
788
+ commonEventObject.joinFlowVersion = joinFlowVersion;
711
789
  }
712
790
  var meetingJoinedTime = meeting.isoLocalClientMeetingJoinTime;
713
791
  if (meetingJoinedTime) {
714
- clientEventObject.meetingJoinedTime = meetingJoinedTime;
792
+ // @ts-ignore
793
+ commonEventObject.meetingJoinedTime = meetingJoinedTime;
715
794
  }
716
795
  if (options.meetingJoinPhase) {
717
- clientEventObject.meetingJoinPhase = options.meetingJoinPhase;
796
+ // @ts-ignore
797
+ commonEventObject.meetingJoinPhase = options.meetingJoinPhase;
718
798
  }
719
- return clientEventObject;
799
+ return commonEventObject;
800
+ }
801
+
802
+ /**
803
+ * Create client event object for in meeting events
804
+ * @param arg - create args
805
+ * @param arg.event - event key
806
+ * @param arg.options - options
807
+ * @returns object
808
+ */
809
+ }, {
810
+ key: "createClientEventObjectInMeeting",
811
+ value: function createClientEventObjectInMeeting(_ref8) {
812
+ var name = _ref8.name,
813
+ options = _ref8.options,
814
+ errors = _ref8.errors;
815
+ var commonObject = this.createCommonEventObjectInMeeting({
816
+ name: name,
817
+ options: options,
818
+ eventType: 'client'
819
+ });
820
+ if (!commonObject) return undefined;
821
+ return _objectSpread(_objectSpread({}, commonObject), {}, {
822
+ errors: errors,
823
+ eventData: _objectSpread(_objectSpread({}, commonObject.eventData), {}, {
824
+ isMercuryConnected: this.isMercuryConnected
825
+ })
826
+ });
827
+ }
828
+
829
+ /**
830
+ * Create feature event object for in meeting function event
831
+ * @param name
832
+ * @param options
833
+ * @returns object
834
+ */
835
+ }, {
836
+ key: "createFeatureEventObjectInMeeting",
837
+ value: function createFeatureEventObjectInMeeting(_ref9) {
838
+ var name = _ref9.name,
839
+ options = _ref9.options;
840
+ var commonObject = this.createCommonEventObjectInMeeting({
841
+ name: name,
842
+ options: options,
843
+ eventType: 'feature'
844
+ });
845
+ if (!commonObject) return undefined;
846
+ return _objectSpread(_objectSpread({}, commonObject), {}, {
847
+ key: 'UcfFeatureUsage'
848
+ });
720
849
  }
721
850
 
722
851
  /**
@@ -728,11 +857,11 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
728
857
  */
729
858
  }, {
730
859
  key: "createClientEventObjectPreMeeting",
731
- value: function createClientEventObjectPreMeeting(_ref6) {
860
+ value: function createClientEventObjectPreMeeting(_ref10) {
732
861
  var _this$webex$meetings5, _this$webex$meetings6, _this$webex$meetings7;
733
- var name = _ref6.name,
734
- options = _ref6.options,
735
- errors = _ref6.errors;
862
+ var name = _ref10.name,
863
+ options = _ref10.options,
864
+ errors = _ref10.errors;
736
865
  var correlationId = options.correlationId,
737
866
  globalMeetingId = options.globalMeetingId,
738
867
  webexConferenceIdStr = options.webexConferenceIdStr,
@@ -788,10 +917,10 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
788
917
  */
789
918
  }, {
790
919
  key: "prepareClientEvent",
791
- value: function prepareClientEvent(_ref7) {
792
- var name = _ref7.name,
793
- payload = _ref7.payload,
794
- options = _ref7.options;
920
+ value: function prepareClientEvent(_ref11) {
921
+ var name = _ref11.name,
922
+ payload = _ref11.payload,
923
+ options = _ref11.options;
795
924
  var meetingId = options.meetingId,
796
925
  correlationId = options.correlationId,
797
926
  rawError = options.rawError;
@@ -847,11 +976,11 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
847
976
  */
848
977
  }, {
849
978
  key: "submitClientEvent",
850
- value: function submitClientEvent(_ref8) {
851
- var name = _ref8.name,
852
- payload = _ref8.payload,
853
- options = _ref8.options,
854
- delaySubmitEvent = _ref8.delaySubmitEvent;
979
+ value: function submitClientEvent(_ref12) {
980
+ var name = _ref12.name,
981
+ payload = _ref12.payload,
982
+ options = _ref12.options,
983
+ delaySubmitEvent = _ref12.delaySubmitEvent;
855
984
  if (delaySubmitEvent) {
856
985
  // Preserve the time when the event was triggered if delaying the submission to Call Diagnostics
857
986
  var delayedOptions = _objectSpread(_objectSpread({}, options), {}, {
@@ -906,6 +1035,32 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
906
1035
  return _promise.default.all(promises);
907
1036
  }
908
1037
 
1038
+ /**
1039
+ * Submit Delayed feature Event CA events. Clears submitDelayedClientFeatureEvents array after submission.
1040
+ */
1041
+ }, {
1042
+ key: "submitDelayedClientFeatureEvents",
1043
+ value: function submitDelayedClientFeatureEvents(overrides) {
1044
+ var _this3 = this;
1045
+ this.logger.log(_config2.CALL_FEATURE_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @submitDelayedClientFeatureEvents. Submitting delayed feature events.');
1046
+ if (this.delayedClientFeatureEvents.length === 0) {
1047
+ return _promise.default.resolve();
1048
+ }
1049
+ var promises = this.delayedClientFeatureEvents.map(function (delayedSubmitClientEventParams) {
1050
+ var name = delayedSubmitClientEventParams.name,
1051
+ payload = delayedSubmitClientEventParams.payload,
1052
+ options = delayedSubmitClientEventParams.options;
1053
+ var optionsWithOverrides = _objectSpread(_objectSpread({}, options), overrides);
1054
+ return _this3.submitFeatureEvent({
1055
+ name: name,
1056
+ payload: payload,
1057
+ options: optionsWithOverrides
1058
+ });
1059
+ });
1060
+ this.delayedClientFeatureEvents = [];
1061
+ return _promise.default.all(promises);
1062
+ }
1063
+
909
1064
  /**
910
1065
  * Prepare the event and send the request to metrics-a service.
911
1066
  * @param event
@@ -934,12 +1089,12 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
934
1089
  * @throws
935
1090
  */
936
1091
  function () {
937
- var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref9) {
1092
+ var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref13) {
938
1093
  var name, payload, options, clientEvent, diagnosticEvent, request;
939
1094
  return _regenerator.default.wrap(function _callee$(_context) {
940
1095
  while (1) switch (_context.prev = _context.next) {
941
1096
  case 0:
942
- name = _ref9.name, payload = _ref9.payload, options = _ref9.options;
1097
+ name = _ref13.name, payload = _ref13.payload, options = _ref13.options;
943
1098
  this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @buildClientEventFetchRequestOptions. Building request options object for fetch()...', "name: ".concat(name));
944
1099
  clientEvent = this.prepareClientEvent({
945
1100
  name: name,