@webex/internal-plugin-metrics 3.8.0 → 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,11 @@ _Object$defineProperty(exports, "__esModule", {
13
13
  });
14
14
  exports.default = void 0;
15
15
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
16
+ var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
16
17
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
17
18
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
18
19
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
20
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
19
21
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
20
22
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
21
23
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
@@ -70,6 +72,8 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
70
72
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasLoggedBrowserSerial", void 0);
71
73
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "device", void 0);
72
74
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "delayedClientEvents", []);
75
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventErrorCache", new _weakMap.default());
76
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMercuryConnected", false);
73
77
  // the default validator before piping an event to the batcher
74
78
  // this function can be overridden by the user
75
79
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "validator", function (options) {
@@ -137,6 +141,18 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
137
141
  return undefined;
138
142
  }
139
143
 
144
+ /**
145
+ * Sets mercury connected status for event data object in CA events
146
+ * @public
147
+ * @param status - boolean value indicating mercury connection status
148
+ * @return {void}
149
+ */
150
+ }, {
151
+ key: "setMercuryConnectedStatus",
152
+ value: function setMercuryConnectedStatus(status) {
153
+ this.isMercuryConnected = status;
154
+ }
155
+
140
156
  /**
141
157
  * Returns meeting's subServiceType
142
158
  * @param meeting
@@ -156,13 +172,15 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
156
172
  if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent) && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr)) {
157
173
  return _config2.WEBEX_SUB_SERVICE_TYPES.SCHEDULED_MEETING;
158
174
  }
159
- // if Scheduled, Webinar, not pmr - then Webinar
160
- if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr) && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.isConvergedWebinar) {
161
- return _config2.WEBEX_SUB_SERVICE_TYPES.WEBINAR;
175
+
176
+ // if ConvergedArchitecture enable and isConvergedWebinarWebcast -- then webcast
177
+ if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableConvergedArchitecture && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent) {
178
+ return meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.isConvergedWebinarWebcast ? _config2.WEBEX_SUB_SERVICE_TYPES.WEBCAST : _config2.WEBEX_SUB_SERVICE_TYPES.WEBINAR;
162
179
  }
163
- // if Scheduled, Webinar enable webcast - then webcast
164
- if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr) && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.isConvergedWebinarWebcast) {
165
- return _config2.WEBEX_SUB_SERVICE_TYPES.WEBCAST;
180
+
181
+ // if Scheduled, enable event, not pmr - then Webinar
182
+ if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr)) {
183
+ return _config2.WEBEX_SUB_SERVICE_TYPES.WEBINAR;
166
184
  }
167
185
  }
168
186
  return undefined;
@@ -508,6 +526,15 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
508
526
  return undefined;
509
527
  }
510
528
 
529
+ /**
530
+ * Clear the error cache
531
+ */
532
+ }, {
533
+ key: "clearErrorCache",
534
+ value: function clearErrorCache() {
535
+ this.eventErrorCache = new _weakMap.default();
536
+ }
537
+
511
538
  /**
512
539
  * Generate error payload for Client Event
513
540
  * @param rawError
@@ -516,11 +543,16 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
516
543
  key: "generateClientEventErrorPayload",
517
544
  value: function generateClientEventErrorPayload(rawError) {
518
545
  var _rawError$error, _rawError$error$body, _rawError$body, _rawError$body2, _rawError$body3, _rawError$body3$reaso;
546
+ var cachedError = this.eventErrorCache.get(rawError);
547
+ if (cachedError) {
548
+ return [cachedError, true];
549
+ }
519
550
  var rawErrorMessage = rawError.message;
520
551
  var httpStatusCode = rawError.statusCode;
552
+ var payload;
521
553
  if (rawError.name) {
522
554
  if ((0, _callDiagnosticMetrics.isBrowserMediaErrorName)(rawError.name)) {
523
- return this.getErrorPayloadForClientErrorCode({
555
+ payload = this.getErrorPayloadForClientErrorCode({
524
556
  serviceErrorCode: undefined,
525
557
  clientErrorCode: _config2.BROWSER_MEDIA_ERROR_NAME_TO_CLIENT_ERROR_CODES_MAP[rawError.name],
526
558
  serviceErrorName: rawError.name,
@@ -529,11 +561,11 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
529
561
  });
530
562
  }
531
563
  }
532
- if ((0, _callDiagnosticMetrics.isSdpOfferCreationError)(rawError)) {
564
+ if ((0, _callDiagnosticMetrics.isSdpOfferCreationError)(rawError) && !payload) {
533
565
  var _rawError$cause;
534
566
  // error code is 30005, but that's not specific enough. we also need to check error.cause.type
535
567
  var causeType = (_rawError$cause = rawError.cause) === null || _rawError$cause === void 0 ? void 0 : _rawError$cause.type;
536
- return this.getErrorPayloadForClientErrorCode({
568
+ payload = this.getErrorPayloadForClientErrorCode({
537
569
  serviceErrorCode: undefined,
538
570
  clientErrorCode: _config2.SDP_OFFER_CREATION_ERROR_MAP[causeType] || _config2.SDP_OFFER_CREATION_ERROR_MAP.GENERAL,
539
571
  serviceErrorName: rawError.name,
@@ -544,8 +576,8 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
544
576
  var serviceErrorCode = (rawError === null || rawError === void 0 ? void 0 : (_rawError$error = rawError.error) === null || _rawError$error === void 0 ? void 0 : (_rawError$error$body = _rawError$error.body) === null || _rawError$error$body === void 0 ? void 0 : _rawError$error$body.errorCode) || (rawError === null || rawError === void 0 ? void 0 : (_rawError$body = rawError.body) === null || _rawError$body === void 0 ? void 0 : _rawError$body.errorCode) || (rawError === null || rawError === void 0 ? void 0 : (_rawError$body2 = rawError.body) === null || _rawError$body2 === void 0 ? void 0 : _rawError$body2.code) || (rawError === null || rawError === void 0 ? void 0 : (_rawError$body3 = rawError.body) === null || _rawError$body3 === void 0 ? void 0 : (_rawError$body3$reaso = _rawError$body3.reason) === null || _rawError$body3$reaso === void 0 ? void 0 : _rawError$body3$reaso.reasonCode);
545
577
  if (serviceErrorCode) {
546
578
  var clientErrorCode = _config2.SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP[serviceErrorCode];
547
- if (clientErrorCode) {
548
- return this.getErrorPayloadForClientErrorCode({
579
+ if (clientErrorCode && !payload) {
580
+ payload = this.getErrorPayloadForClientErrorCode({
549
581
  clientErrorCode: clientErrorCode,
550
582
  serviceErrorCode: serviceErrorCode,
551
583
  rawErrorMessage: rawErrorMessage,
@@ -554,8 +586,8 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
554
586
  }
555
587
 
556
588
  // by default, if it is locus error, return new locus err
557
- if ((0, _callDiagnosticMetrics.isLocusServiceErrorCode)(serviceErrorCode)) {
558
- return this.getErrorPayloadForClientErrorCode({
589
+ if ((0, _callDiagnosticMetrics.isLocusServiceErrorCode)(serviceErrorCode) && !payload) {
590
+ payload = this.getErrorPayloadForClientErrorCode({
559
591
  clientErrorCode: _config2.NEW_LOCUS_ERROR_CLIENT_CODE,
560
592
  serviceErrorCode: serviceErrorCode,
561
593
  rawErrorMessage: rawErrorMessage,
@@ -563,16 +595,16 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
563
595
  });
564
596
  }
565
597
  }
566
- if ((0, _callDiagnosticMetrics.isMeetingInfoServiceError)(rawError)) {
567
- return this.getErrorPayloadForClientErrorCode({
598
+ if ((0, _callDiagnosticMetrics.isMeetingInfoServiceError)(rawError) && !payload) {
599
+ payload = this.getErrorPayloadForClientErrorCode({
568
600
  clientErrorCode: _config2.MEETING_INFO_LOOKUP_ERROR_CLIENT_CODE,
569
601
  serviceErrorCode: serviceErrorCode,
570
602
  rawErrorMessage: rawErrorMessage,
571
603
  httpStatusCode: httpStatusCode
572
604
  });
573
605
  }
574
- if ((0, _callDiagnosticMetrics.isNetworkError)(rawError)) {
575
- return this.getErrorPayloadForClientErrorCode({
606
+ if ((0, _callDiagnosticMetrics.isNetworkError)(rawError) && !payload) {
607
+ payload = this.getErrorPayloadForClientErrorCode({
576
608
  clientErrorCode: _config2.NETWORK_ERROR,
577
609
  serviceErrorCode: serviceErrorCode,
578
610
  payloadOverrides: rawError.payloadOverrides,
@@ -580,8 +612,8 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
580
612
  httpStatusCode: httpStatusCode
581
613
  });
582
614
  }
583
- if ((0, _callDiagnosticMetrics.isUnauthorizedError)(rawError)) {
584
- return this.getErrorPayloadForClientErrorCode({
615
+ if ((0, _callDiagnosticMetrics.isUnauthorizedError)(rawError) && !payload) {
616
+ payload = this.getErrorPayloadForClientErrorCode({
585
617
  clientErrorCode: _config2.AUTHENTICATION_FAILED_CODE,
586
618
  serviceErrorCode: serviceErrorCode,
587
619
  payloadOverrides: rawError.payloadOverrides,
@@ -589,16 +621,21 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
589
621
  httpStatusCode: httpStatusCode
590
622
  });
591
623
  }
624
+ if (!payload) {
625
+ // otherwise return unkown error but passing serviceErrorCode and serviceErrorName so that we know the issue
626
+ payload = this.getErrorPayloadForClientErrorCode({
627
+ clientErrorCode: _config2.UNKNOWN_ERROR,
628
+ serviceErrorCode: serviceErrorCode || _config2.UNKNOWN_ERROR,
629
+ serviceErrorName: rawError === null || rawError === void 0 ? void 0 : rawError.name,
630
+ payloadOverrides: rawError.payloadOverrides,
631
+ rawErrorMessage: rawErrorMessage,
632
+ httpStatusCode: httpStatusCode
633
+ });
634
+ }
592
635
 
593
- // otherwise return unkown error but passing serviceErrorCode and serviceErrorName so that we know the issue
594
- return this.getErrorPayloadForClientErrorCode({
595
- clientErrorCode: _config2.UNKNOWN_ERROR,
596
- serviceErrorCode: serviceErrorCode || _config2.UNKNOWN_ERROR,
597
- serviceErrorName: rawError === null || rawError === void 0 ? void 0 : rawError.name,
598
- payloadOverrides: rawError.payloadOverrides,
599
- rawErrorMessage: rawErrorMessage,
600
- httpStatusCode: httpStatusCode
601
- });
636
+ // cache the payload for future use
637
+ this.eventErrorCache.set(rawError, payload);
638
+ return [payload, false];
602
639
  }
603
640
 
604
641
  /**
@@ -645,27 +682,37 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
645
682
  });
646
683
 
647
684
  // create client event object
648
- var clientEventObject = {
685
+ var clientEventObject = _objectSpread(_objectSpread(_objectSpread({
649
686
  name: name,
650
687
  canProceed: true,
651
688
  identifiers: identifiers,
652
689
  errors: errors,
653
690
  eventData: {
654
- webClientDomain: window.location.hostname
691
+ webClientDomain: window.location.hostname,
692
+ isMercuryConnected: this.isMercuryConnected
655
693
  },
656
694
  userType: meeting.getCurUserType(),
657
695
  loginType: 'loginType' in meeting.callStateForMetrics ? meeting.callStateForMetrics.loginType : this.getCurLoginType(),
658
696
  isConvergedArchitectureEnabled: this.getIsConvergedArchitectureEnabled({
659
697
  meetingId: meetingId
660
- }),
698
+ })
699
+ }, meeting.userNameInput && {
700
+ userNameInput: meeting.userNameInput
701
+ }), meeting.emailInput && {
702
+ emailInput: meeting.emailInput
703
+ }), {}, {
661
704
  webexSubServiceType: this.getSubServiceType(meeting),
662
705
  // @ts-ignore
663
706
  webClientPreload: (_this$webex$meetings2 = this.webex.meetings) === null || _this$webex$meetings2 === void 0 ? void 0 : (_this$webex$meetings3 = _this$webex$meetings2.config) === null || _this$webex$meetings3 === void 0 ? void 0 : (_this$webex$meetings4 = _this$webex$meetings3.metrics) === null || _this$webex$meetings4 === void 0 ? void 0 : _this$webex$meetings4.webClientPreload
664
- };
707
+ });
665
708
  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;
666
709
  if (joinFlowVersion) {
667
710
  clientEventObject.joinFlowVersion = joinFlowVersion;
668
711
  }
712
+ var meetingJoinedTime = meeting.isoLocalClientMeetingJoinTime;
713
+ if (meetingJoinedTime) {
714
+ clientEventObject.meetingJoinedTime = meetingJoinedTime;
715
+ }
669
716
  if (options.meetingJoinPhase) {
670
717
  clientEventObject.meetingJoinPhase = options.meetingJoinPhase;
671
718
  }
@@ -708,7 +755,8 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
708
755
  canProceed: true,
709
756
  identifiers: identifiers,
710
757
  eventData: {
711
- webClientDomain: window.location.hostname
758
+ webClientDomain: window.location.hostname,
759
+ isMercuryConnected: this.isMercuryConnected
712
760
  },
713
761
  loginType: this.getCurLoginType(),
714
762
  // @ts-ignore
@@ -720,6 +768,12 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
720
768
  if (options.meetingJoinPhase) {
721
769
  clientEventObject.meetingJoinPhase = options.meetingJoinPhase;
722
770
  }
771
+ if (options.userNameInput) {
772
+ clientEventObject.userNameInput = options.userNameInput;
773
+ }
774
+ if (options.emailInput) {
775
+ clientEventObject.emailInput = options.emailInput;
776
+ }
723
777
  return clientEventObject;
724
778
  }
725
779
 
@@ -746,11 +800,14 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
746
800
  // check if we need to generate errors
747
801
  var errors = [];
748
802
  if (rawError) {
749
- var generatedError = this.generateClientEventErrorPayload(rawError);
803
+ var _this$generateClientE = this.generateClientEventErrorPayload(rawError),
804
+ _this$generateClientE2 = (0, _slicedToArray2.default)(_this$generateClientE, 2),
805
+ generatedError = _this$generateClientE2[0],
806
+ cached = _this$generateClientE2[1];
750
807
  if (generatedError) {
751
808
  errors.push(generatedError);
752
809
  }
753
- this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:', "generatedError: ".concat((0, _stringify.default)(generatedError)));
810
+ this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:', "generatedError (cached: ".concat(cached, "): ").concat((0, _stringify.default)(generatedError)));
754
811
  }
755
812
 
756
813
  // events that will most likely happen in join phase
@@ -828,14 +885,22 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
828
885
  */
829
886
  }, {
830
887
  key: "submitDelayedClientEvents",
831
- value: function submitDelayedClientEvents() {
888
+ value: function submitDelayedClientEvents(overrides) {
832
889
  var _this2 = this;
833
890
  this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @submitDelayedClientEvents. Submitting delayed client events.');
834
891
  if (this.delayedClientEvents.length === 0) {
835
892
  return _promise.default.resolve();
836
893
  }
837
894
  var promises = this.delayedClientEvents.map(function (delayedSubmitClientEventParams) {
838
- return _this2.submitClientEvent(delayedSubmitClientEventParams);
895
+ var name = delayedSubmitClientEventParams.name,
896
+ payload = delayedSubmitClientEventParams.payload,
897
+ options = delayedSubmitClientEventParams.options;
898
+ var optionsWithOverrides = _objectSpread(_objectSpread({}, options), overrides);
899
+ return _this2.submitClientEvent({
900
+ name: name,
901
+ payload: payload,
902
+ options: optionsWithOverrides
903
+ });
839
904
  });
840
905
  this.delayedClientEvents = [];
841
906
  return _promise.default.all(promises);