@webex/internal-plugin-metrics 3.8.1-next.12 → 3.8.1-next.13
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.
- package/dist/call-diagnostic/call-diagnostic-metrics.js +157 -27
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +32 -1
- package/package.json +2 -2
- package/src/call-diagnostic/call-diagnostic-metrics.ts +144 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +404 -1
|
@@ -14,8 +14,11 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
14
14
|
exports.default = void 0;
|
|
15
15
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
16
16
|
var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
|
|
17
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
|
|
18
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/set"));
|
|
17
19
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
18
20
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
21
|
+
var _from = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/from"));
|
|
19
22
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
20
23
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
21
24
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
@@ -75,6 +78,8 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
75
78
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "delayedClientFeatureEvents", []);
|
|
76
79
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventErrorCache", new _weakMap.default());
|
|
77
80
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isMercuryConnected", false);
|
|
81
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventLimitTracker", new _map.default());
|
|
82
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventLimitWarningsLogged", new _set.default());
|
|
78
83
|
// the default validator before piping an event to the batcher
|
|
79
84
|
// this function can be overridden by the user
|
|
80
85
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "validator", function (options) {
|
|
@@ -613,6 +618,128 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
613
618
|
this.eventErrorCache = new _weakMap.default();
|
|
614
619
|
}
|
|
615
620
|
|
|
621
|
+
/**
|
|
622
|
+
* Checks if an event should be limited based on criteria defined in the event dictionary.
|
|
623
|
+
* Returns true if the event should be sent, false if it has reached its limit.
|
|
624
|
+
* @param event - The diagnostic event object
|
|
625
|
+
* @returns boolean indicating whether the event should be sent
|
|
626
|
+
*/
|
|
627
|
+
}, {
|
|
628
|
+
key: "shouldSendEvent",
|
|
629
|
+
value: function shouldSendEvent(_ref7) {
|
|
630
|
+
var _event$identifiers;
|
|
631
|
+
var event = _ref7.event;
|
|
632
|
+
var eventName = event === null || event === void 0 ? void 0 : event.name;
|
|
633
|
+
var correlationId = event === null || event === void 0 ? void 0 : (_event$identifiers = event.identifiers) === null || _event$identifiers === void 0 ? void 0 : _event$identifiers.correlationId;
|
|
634
|
+
if (!correlationId || correlationId === 'unknown') {
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
var limitKeyPrefix = "".concat(eventName, ":").concat(correlationId);
|
|
638
|
+
switch (eventName) {
|
|
639
|
+
case 'client.media.render.start':
|
|
640
|
+
case 'client.media.render.stop':
|
|
641
|
+
case 'client.media.rx.start':
|
|
642
|
+
case 'client.media.rx.stop':
|
|
643
|
+
case 'client.media.tx.start':
|
|
644
|
+
case 'client.media.tx.stop':
|
|
645
|
+
{
|
|
646
|
+
// Send only once per mediaType-correlationId pair (or mediaType-correlationId-shareInstanceId for share/share_audio)
|
|
647
|
+
var mediaType = event === null || event === void 0 ? void 0 : event.mediaType;
|
|
648
|
+
if (mediaType) {
|
|
649
|
+
if (mediaType === 'share' || mediaType === 'share_audio') {
|
|
650
|
+
var shareInstanceId = event === null || event === void 0 ? void 0 : event.shareInstanceId;
|
|
651
|
+
if (shareInstanceId) {
|
|
652
|
+
var limitKey = "".concat(limitKeyPrefix, ":").concat(mediaType, ":").concat(shareInstanceId);
|
|
653
|
+
return this.checkAndIncrementEventCount(limitKey, 1, "".concat(eventName, " for ").concat(mediaType, " instance ").concat(shareInstanceId));
|
|
654
|
+
}
|
|
655
|
+
} else {
|
|
656
|
+
var _limitKey = "".concat(limitKeyPrefix, ":").concat(mediaType);
|
|
657
|
+
return this.checkAndIncrementEventCount(_limitKey, 1, "".concat(eventName, " for mediaType ").concat(mediaType));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
case 'client.roap-message.received':
|
|
663
|
+
case 'client.roap-message.sent':
|
|
664
|
+
{
|
|
665
|
+
var _event$roap, _event$roap2;
|
|
666
|
+
// Send only once per correlationId and roap.messageType/roap.type
|
|
667
|
+
var roapMessageType = (event === null || event === void 0 ? void 0 : (_event$roap = event.roap) === null || _event$roap === void 0 ? void 0 : _event$roap.messageType) || (event === null || event === void 0 ? void 0 : (_event$roap2 = event.roap) === null || _event$roap2 === void 0 ? void 0 : _event$roap2.type);
|
|
668
|
+
if (roapMessageType) {
|
|
669
|
+
var _limitKey2 = "".concat(limitKeyPrefix, ":").concat(roapMessageType);
|
|
670
|
+
return this.checkAndIncrementEventCount(_limitKey2, 1, "".concat(eventName, " for ROAP type ").concat(roapMessageType));
|
|
671
|
+
}
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
default:
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Checks the current count for a limit key and increments if under limit.
|
|
682
|
+
* @param limitKey - The unique key for this limit combination
|
|
683
|
+
* @param maxCount - Maximum allowed count
|
|
684
|
+
* @param eventDescription - Description for logging
|
|
685
|
+
* @returns true if under limit and incremented, false if at/over limit
|
|
686
|
+
*/
|
|
687
|
+
}, {
|
|
688
|
+
key: "checkAndIncrementEventCount",
|
|
689
|
+
value: function checkAndIncrementEventCount(limitKey, maxCount, eventDescription) {
|
|
690
|
+
var currentCount = this.eventLimitTracker.get(limitKey) || 0;
|
|
691
|
+
if (currentCount >= maxCount) {
|
|
692
|
+
// Log warning only once per limit key
|
|
693
|
+
if (!this.eventLimitWarningsLogged.has(limitKey)) {
|
|
694
|
+
this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, "CallDiagnosticMetrics: Event limit reached for ".concat(eventDescription, ". ") + "Max count ".concat(maxCount, " exceeded. Event will not be sent."), "limitKey: ".concat(limitKey));
|
|
695
|
+
this.eventLimitWarningsLogged.add(limitKey);
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// Increment count and allow event
|
|
701
|
+
this.eventLimitTracker.set(limitKey, currentCount + 1);
|
|
702
|
+
return true;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Clears event limit tracking
|
|
707
|
+
*/
|
|
708
|
+
}, {
|
|
709
|
+
key: "clearEventLimits",
|
|
710
|
+
value: function clearEventLimits() {
|
|
711
|
+
this.eventLimitTracker.clear();
|
|
712
|
+
this.eventLimitWarningsLogged.clear();
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Clears event limit tracking for a specific correlationId only.
|
|
717
|
+
* Keeps limits for other meetings intact.
|
|
718
|
+
*/
|
|
719
|
+
}, {
|
|
720
|
+
key: "clearEventLimitsForCorrelationId",
|
|
721
|
+
value: function clearEventLimitsForCorrelationId(correlationId) {
|
|
722
|
+
if (!correlationId) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
// Keys are formatted as "eventName:correlationId:..." across all limiters.
|
|
726
|
+
var hasCorrIdAtSecondToken = function hasCorrIdAtSecondToken(key) {
|
|
727
|
+
return key.split(':')[1] === correlationId;
|
|
728
|
+
};
|
|
729
|
+
for (var _i = 0, _Array$from = (0, _from.default)(this.eventLimitTracker.keys()); _i < _Array$from.length; _i++) {
|
|
730
|
+
var key = _Array$from[_i];
|
|
731
|
+
if (hasCorrIdAtSecondToken(key)) {
|
|
732
|
+
this.eventLimitTracker.delete(key);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
for (var _i2 = 0, _Array$from3 = (0, _from.default)(this.eventLimitWarningsLogged.values()); _i2 < _Array$from3.length; _i2++) {
|
|
736
|
+
var _key2 = _Array$from3[_i2];
|
|
737
|
+
if (hasCorrIdAtSecondToken(_key2)) {
|
|
738
|
+
this.eventLimitWarningsLogged.delete(_key2);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
616
743
|
/**
|
|
617
744
|
* Generate error payload for Client Event
|
|
618
745
|
* @param rawError
|
|
@@ -725,12 +852,12 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
725
852
|
*/
|
|
726
853
|
}, {
|
|
727
854
|
key: "createCommonEventObjectInMeeting",
|
|
728
|
-
value: function createCommonEventObjectInMeeting(
|
|
855
|
+
value: function createCommonEventObjectInMeeting(_ref8) {
|
|
729
856
|
var _this$webex$meetings2, _this$webex$meetings3, _this$webex$meetings4, _options$joinFlowVers, _meeting$callStateFor;
|
|
730
|
-
var name =
|
|
731
|
-
options =
|
|
732
|
-
|
|
733
|
-
eventType =
|
|
857
|
+
var name = _ref8.name,
|
|
858
|
+
options = _ref8.options,
|
|
859
|
+
_ref8$eventType = _ref8.eventType,
|
|
860
|
+
eventType = _ref8$eventType === void 0 ? 'client' : _ref8$eventType;
|
|
734
861
|
var meetingId = options.meetingId,
|
|
735
862
|
mediaConnections = options.mediaConnections,
|
|
736
863
|
globalMeetingId = options.globalMeetingId,
|
|
@@ -808,10 +935,10 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
808
935
|
*/
|
|
809
936
|
}, {
|
|
810
937
|
key: "createClientEventObjectInMeeting",
|
|
811
|
-
value: function createClientEventObjectInMeeting(
|
|
812
|
-
var name =
|
|
813
|
-
options =
|
|
814
|
-
errors =
|
|
938
|
+
value: function createClientEventObjectInMeeting(_ref9) {
|
|
939
|
+
var name = _ref9.name,
|
|
940
|
+
options = _ref9.options,
|
|
941
|
+
errors = _ref9.errors;
|
|
815
942
|
var commonObject = this.createCommonEventObjectInMeeting({
|
|
816
943
|
name: name,
|
|
817
944
|
options: options,
|
|
@@ -834,9 +961,9 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
834
961
|
*/
|
|
835
962
|
}, {
|
|
836
963
|
key: "createFeatureEventObjectInMeeting",
|
|
837
|
-
value: function createFeatureEventObjectInMeeting(
|
|
838
|
-
var name =
|
|
839
|
-
options =
|
|
964
|
+
value: function createFeatureEventObjectInMeeting(_ref10) {
|
|
965
|
+
var name = _ref10.name,
|
|
966
|
+
options = _ref10.options;
|
|
840
967
|
var commonObject = this.createCommonEventObjectInMeeting({
|
|
841
968
|
name: name,
|
|
842
969
|
options: options,
|
|
@@ -857,11 +984,11 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
857
984
|
*/
|
|
858
985
|
}, {
|
|
859
986
|
key: "createClientEventObjectPreMeeting",
|
|
860
|
-
value: function createClientEventObjectPreMeeting(
|
|
987
|
+
value: function createClientEventObjectPreMeeting(_ref11) {
|
|
861
988
|
var _this$webex$meetings5, _this$webex$meetings6, _this$webex$meetings7;
|
|
862
|
-
var name =
|
|
863
|
-
options =
|
|
864
|
-
errors =
|
|
989
|
+
var name = _ref11.name,
|
|
990
|
+
options = _ref11.options,
|
|
991
|
+
errors = _ref11.errors;
|
|
865
992
|
var correlationId = options.correlationId,
|
|
866
993
|
globalMeetingId = options.globalMeetingId,
|
|
867
994
|
webexConferenceIdStr = options.webexConferenceIdStr,
|
|
@@ -917,10 +1044,10 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
917
1044
|
*/
|
|
918
1045
|
}, {
|
|
919
1046
|
key: "prepareClientEvent",
|
|
920
|
-
value: function prepareClientEvent(
|
|
921
|
-
var name =
|
|
922
|
-
payload =
|
|
923
|
-
options =
|
|
1047
|
+
value: function prepareClientEvent(_ref12) {
|
|
1048
|
+
var name = _ref12.name,
|
|
1049
|
+
payload = _ref12.payload,
|
|
1050
|
+
options = _ref12.options;
|
|
924
1051
|
var meetingId = options.meetingId,
|
|
925
1052
|
correlationId = options.correlationId,
|
|
926
1053
|
rawError = options.rawError;
|
|
@@ -976,11 +1103,11 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
976
1103
|
*/
|
|
977
1104
|
}, {
|
|
978
1105
|
key: "submitClientEvent",
|
|
979
|
-
value: function submitClientEvent(
|
|
980
|
-
var name =
|
|
981
|
-
payload =
|
|
982
|
-
options =
|
|
983
|
-
delaySubmitEvent =
|
|
1106
|
+
value: function submitClientEvent(_ref13) {
|
|
1107
|
+
var name = _ref13.name,
|
|
1108
|
+
payload = _ref13.payload,
|
|
1109
|
+
options = _ref13.options,
|
|
1110
|
+
delaySubmitEvent = _ref13.delaySubmitEvent;
|
|
984
1111
|
if (delaySubmitEvent) {
|
|
985
1112
|
// Preserve the time when the event was triggered if delaying the submission to Call Diagnostics
|
|
986
1113
|
var delayedOptions = _objectSpread(_objectSpread({}, options), {}, {
|
|
@@ -999,6 +1126,9 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
999
1126
|
payload: payload,
|
|
1000
1127
|
options: options
|
|
1001
1128
|
});
|
|
1129
|
+
if (!this.shouldSendEvent(diagnosticEvent)) {
|
|
1130
|
+
return _promise.default.resolve();
|
|
1131
|
+
}
|
|
1002
1132
|
if (options !== null && options !== void 0 && options.preLoginId) {
|
|
1003
1133
|
return this.submitToCallDiagnosticsPreLogin(diagnosticEvent, options === null || options === void 0 ? void 0 : options.preLoginId);
|
|
1004
1134
|
}
|
|
@@ -1089,12 +1219,12 @@ var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessW
|
|
|
1089
1219
|
* @throws
|
|
1090
1220
|
*/
|
|
1091
1221
|
function () {
|
|
1092
|
-
var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(
|
|
1222
|
+
var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref14) {
|
|
1093
1223
|
var name, payload, options, clientEvent, diagnosticEvent, request;
|
|
1094
1224
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
1095
1225
|
while (1) switch (_context.prev = _context.next) {
|
|
1096
1226
|
case 0:
|
|
1097
|
-
name =
|
|
1227
|
+
name = _ref14.name, payload = _ref14.payload, options = _ref14.options;
|
|
1098
1228
|
this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @buildClientEventFetchRequestOptions. Building request options object for fetch()...', "name: ".concat(name));
|
|
1099
1229
|
clientEvent = this.prepareClientEvent({
|
|
1100
1230
|
name: name,
|