@webex/internal-plugin-metrics 2.60.0-next.8 → 2.60.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.
Files changed (68) hide show
  1. package/dist/batcher.js +3 -3
  2. package/dist/batcher.js.map +1 -1
  3. package/dist/call-diagnostic-events-batcher.js +60 -0
  4. package/dist/call-diagnostic-events-batcher.js.map +1 -0
  5. package/dist/client-metrics-batcher.js +3 -3
  6. package/dist/client-metrics-batcher.js.map +1 -1
  7. package/dist/config.js +9 -6
  8. package/dist/config.js.map +1 -1
  9. package/dist/index.js +2 -21
  10. package/dist/index.js.map +1 -1
  11. package/dist/metrics.js +22 -24
  12. package/dist/metrics.js.map +1 -1
  13. package/package.json +19 -24
  14. package/src/batcher.js +0 -1
  15. package/src/call-diagnostic-events-batcher.js +62 -0
  16. package/src/client-metrics-batcher.js +0 -1
  17. package/src/config.js +0 -1
  18. package/src/index.js +15 -0
  19. package/src/metrics.js +16 -17
  20. package/test/unit/spec/batcher.js +0 -2
  21. package/test/unit/spec/call-diagnostic-events-batcher.js +195 -0
  22. package/test/unit/spec/client-metrics-batcher.js +0 -2
  23. package/test/unit/spec/metrics.js +94 -65
  24. package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +0 -67
  25. package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +0 -1
  26. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +0 -454
  27. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +0 -1
  28. package/dist/call-diagnostic/call-diagnostic-metrics.js +0 -821
  29. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +0 -1
  30. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +0 -323
  31. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +0 -1
  32. package/dist/call-diagnostic/config.js +0 -593
  33. package/dist/call-diagnostic/config.js.map +0 -1
  34. package/dist/metrics.types.js +0 -7
  35. package/dist/metrics.types.js.map +0 -1
  36. package/dist/new-metrics.js +0 -336
  37. package/dist/new-metrics.js.map +0 -1
  38. package/dist/types/batcher.d.ts +0 -2
  39. package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +0 -2
  40. package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +0 -194
  41. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +0 -418
  42. package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +0 -96
  43. package/dist/types/call-diagnostic/config.d.ts +0 -172
  44. package/dist/types/client-metrics-batcher.d.ts +0 -2
  45. package/dist/types/config.d.ts +0 -36
  46. package/dist/types/index.d.ts +0 -13
  47. package/dist/types/metrics.d.ts +0 -3
  48. package/dist/types/metrics.types.d.ts +0 -104
  49. package/dist/types/new-metrics.d.ts +0 -139
  50. package/dist/types/utils.d.ts +0 -6
  51. package/dist/utils.js +0 -26
  52. package/dist/utils.js.map +0 -1
  53. package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +0 -75
  54. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +0 -419
  55. package/src/call-diagnostic/call-diagnostic-metrics.ts +0 -875
  56. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +0 -362
  57. package/src/call-diagnostic/config.ts +0 -666
  58. package/src/index.ts +0 -43
  59. package/src/metrics.types.ts +0 -160
  60. package/src/new-metrics.ts +0 -317
  61. package/src/utils.ts +0 -17
  62. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +0 -453
  63. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +0 -506
  64. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +0 -2078
  65. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +0 -565
  66. package/test/unit/spec/new-metrics.ts +0 -266
  67. package/test/unit/spec/utils.ts +0 -22
  68. package/tsconfig.json +0 -6
@@ -1,821 +0,0 @@
1
- "use strict";
2
-
3
- var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
4
- var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
5
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
7
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
8
- var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
9
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
10
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
11
- _Object$defineProperty(exports, "__esModule", {
12
- value: true
13
- });
14
- exports.default = void 0;
15
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
16
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
17
- var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
18
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
19
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
20
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
21
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
22
- var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
23
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
24
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
25
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
26
- var _internalPluginMetrics = require("@webex/internal-plugin-metrics");
27
- var _common = require("@webex/common");
28
- var _uuid = _interopRequireDefault(require("uuid"));
29
- var _lodash = require("lodash");
30
- var _webexCore = require("@webex/webex-core");
31
- var _callDiagnosticMetrics = require("./call-diagnostic-metrics.util");
32
- var _config = require("../config");
33
- var _callDiagnosticMetricsBatcher = _interopRequireDefault(require("./call-diagnostic-metrics-batcher"));
34
- var _config2 = require("./config");
35
- function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
36
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
37
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
38
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable class-methods-use-this */ /* eslint-disable valid-jsdoc */
39
- var _BrowserDetection = (0, _common.BrowserDetection)(),
40
- getOSVersion = _BrowserDetection.getOSVersion,
41
- getBrowserName = _BrowserDetection.getBrowserName,
42
- getBrowserVersion = _BrowserDetection.getBrowserVersion;
43
- /**
44
- * @description Util class to handle Call Analyzer Metrics
45
- * @export
46
- * @class CallDiagnosticMetrics
47
- */
48
- var CallDiagnosticMetrics = exports.default = /*#__PURE__*/function (_StatelessWebexPlugin) {
49
- (0, _inherits2.default)(CallDiagnosticMetrics, _StatelessWebexPlugin);
50
- var _super = _createSuper(CallDiagnosticMetrics);
51
- /**
52
- * Constructor
53
- * @param args
54
- */
55
- function CallDiagnosticMetrics() {
56
- var _this;
57
- (0, _classCallCheck2.default)(this, CallDiagnosticMetrics);
58
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
59
- args[_key] = arguments[_key];
60
- }
61
- _this = _super.call.apply(_super, [this].concat(args));
62
- // @ts-ignore
63
- // @ts-ignore
64
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticEventsBatcher", void 0);
65
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "logger", void 0);
66
- // to avoid adding @ts-ignore everywhere
67
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasLoggedBrowserSerial", void 0);
68
- // the default validator before piping an event to the batcher
69
- // this function can be overridden by the user
70
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "validator", function (options) {
71
- return _promise.default.resolve({
72
- event: options === null || options === void 0 ? void 0 : options.event,
73
- valid: true
74
- });
75
- });
76
- /**
77
- * Pre login events are not batched. We make the request directly.
78
- * @param event
79
- * @param preLoginId
80
- * @returns
81
- */
82
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "submitToCallDiagnosticsPreLogin", function (event, preLoginId) {
83
- // build metrics-a event type
84
- // @ts-ignore
85
- var diagnosticEvent = (0, _callDiagnosticMetrics.prepareDiagnosticMetricItem)(_this.webex, {
86
- eventPayload: event,
87
- type: ['diagnostic-event']
88
- });
89
-
90
- // append sent timestamp
91
- diagnosticEvent.eventPayload.originTime.sent = new Date().toISOString();
92
-
93
- // @ts-ignore
94
- return _this.webex.internal.newMetrics.postPreLoginMetric(diagnosticEvent, preLoginId);
95
- });
96
- _this.logger = _this.webex.logger;
97
- // @ts-ignore
98
- _this.callDiagnosticEventsBatcher = new _callDiagnosticMetricsBatcher.default({}, {
99
- parent: _this.webex
100
- });
101
- return _this;
102
- }
103
-
104
- /**
105
- * Returns the login type of the current user
106
- * @returns one of 'login-ci','unverified-guest', null
107
- */
108
- (0, _createClass2.default)(CallDiagnosticMetrics, [{
109
- key: "getCurLoginType",
110
- value: function getCurLoginType() {
111
- // @ts-ignore
112
- if (this.webex.canAuthorize) {
113
- // @ts-ignore
114
- return this.webex.credentials.isUnverifiedGuest ? 'unverified-guest' : 'login-ci';
115
- }
116
- return null;
117
- }
118
-
119
- /**
120
- * Returns if the meeting has converged architecture enabled
121
- * @param options.meetingId
122
- */
123
- }, {
124
- key: "getIsConvergedArchitectureEnabled",
125
- value: function getIsConvergedArchitectureEnabled(_ref) {
126
- var meetingId = _ref.meetingId;
127
- if (meetingId) {
128
- var _meeting$meetingInfo;
129
- // @ts-ignore
130
- var meeting = this.webex.meetings.meetingCollection.get(meetingId);
131
- return meeting === null || meeting === void 0 ? void 0 : (_meeting$meetingInfo = meeting.meetingInfo) === null || _meeting$meetingInfo === void 0 ? void 0 : _meeting$meetingInfo.enableConvergedArchitecture;
132
- }
133
- return undefined;
134
- }
135
-
136
- /**
137
- * Returns meeting's subServiceType
138
- * @param meeting
139
- * @returns
140
- */
141
- }, {
142
- key: "getSubServiceType",
143
- value: function getSubServiceType(meeting) {
144
- if (meeting) {
145
- // @ts-ignore
146
- var meetingInfo = meeting === null || meeting === void 0 ? void 0 : meeting.meetingInfo;
147
- // if not Scheduled, not Webinar, pmr - then pmr
148
- if (!(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled) && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent) && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr) {
149
- return _config2.WEBEX_SUB_SERVICE_TYPES.PMR;
150
- }
151
- // if Scheduled, not Webinar, not pmr - then ScheduledMeeting
152
- if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent) && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr)) {
153
- return _config2.WEBEX_SUB_SERVICE_TYPES.SCHEDULED_MEETING;
154
- }
155
- // if Scheduled, Webinar, not pmr - then Webinar
156
- if (meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.webexScheduled && meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.enableEvent && !(meetingInfo !== null && meetingInfo !== void 0 && meetingInfo.pmr)) {
157
- return _config2.WEBEX_SUB_SERVICE_TYPES.WEBINAR;
158
- }
159
- }
160
- return undefined;
161
- }
162
-
163
- /**
164
- * Get origin object for Call Diagnostic Event payload.
165
- * @param options
166
- * @param meetingId
167
- * @returns
168
- */
169
- }, {
170
- key: "getOrigin",
171
- value: function getOrigin(options, meetingId) {
172
- var _this$webex$meetings$, _this$webex$meetings$2, _this$webex$meetings$3, _this$webex$meetings$4, _this$webex$meetings$5, _this$webex$meetings$6;
173
- var defaultClientType = // @ts-ignore
174
- (_this$webex$meetings$ = this.webex.meetings.config) === null || _this$webex$meetings$ === void 0 ? void 0 : (_this$webex$meetings$2 = _this$webex$meetings$.metrics) === null || _this$webex$meetings$2 === void 0 ? void 0 : _this$webex$meetings$2.clientType;
175
- var defaultSubClientType = // @ts-ignore
176
- (_this$webex$meetings$3 = this.webex.meetings.config) === null || _this$webex$meetings$3 === void 0 ? void 0 : (_this$webex$meetings$4 = _this$webex$meetings$3.metrics) === null || _this$webex$meetings$4 === void 0 ? void 0 : _this$webex$meetings$4.subClientType;
177
- // @ts-ignore
178
- var providedClientVersion = (_this$webex$meetings$5 = this.webex.meetings.config) === null || _this$webex$meetings$5 === void 0 ? void 0 : (_this$webex$meetings$6 = _this$webex$meetings$5.metrics) === null || _this$webex$meetings$6 === void 0 ? void 0 : _this$webex$meetings$6.clientVersion;
179
- // @ts-ignore
180
- var defaultSDKClientVersion = "".concat(_config.CLIENT_NAME, "/").concat(this.webex.version);
181
- var versionMetadata = {};
182
-
183
- // sdk version split doesn't really make sense for now...
184
- if (providedClientVersion) {
185
- versionMetadata = (0, _callDiagnosticMetrics.extractVersionMetadata)(providedClientVersion);
186
- }
187
- if (!this.hasLoggedBrowserSerial) {
188
- this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, "CallDiagnosticMetrics: @createClientEventObjectInMeeting => collected browser data", (0, _stringify.default)((0, _common.getBrowserSerial)()));
189
- this.hasLoggedBrowserSerial = true;
190
- }
191
- if (defaultClientType && defaultSubClientType || options.clientType && options.subClientType) {
192
- var _this$webex$meetings, _this$webex$meetings$7, _this$webex$meetings$8, _this$webex$meetings$9;
193
- var origin = {
194
- name: 'endpoint',
195
- networkType: (options === null || options === void 0 ? void 0 : options.networkType) || 'unknown',
196
- userAgent: (0, _callDiagnosticMetrics.userAgentToString)({
197
- // @ts-ignore
198
- clientName: (_this$webex$meetings = this.webex.meetings) === null || _this$webex$meetings === void 0 ? void 0 : (_this$webex$meetings$7 = _this$webex$meetings.config) === null || _this$webex$meetings$7 === void 0 ? void 0 : (_this$webex$meetings$8 = _this$webex$meetings$7.metrics) === null || _this$webex$meetings$8 === void 0 ? void 0 : _this$webex$meetings$8.clientName,
199
- // @ts-ignore
200
- webexVersion: this.webex.version
201
- }),
202
- clientInfo: _objectSpread(_objectSpread({
203
- clientType: (options === null || options === void 0 ? void 0 : options.clientType) || defaultClientType,
204
- clientVersion: providedClientVersion || defaultSDKClientVersion
205
- }, versionMetadata), {}, {
206
- localNetworkPrefix:
207
- // @ts-ignore
208
- (0, _callDiagnosticMetrics.anonymizeIPAddress)((_this$webex$meetings$9 = this.webex.meetings.geoHintInfo) === null || _this$webex$meetings$9 === void 0 ? void 0 : _this$webex$meetings$9.clientAddress) || undefined,
209
- osVersion: getOSVersion() || 'unknown',
210
- subClientType: (options === null || options === void 0 ? void 0 : options.subClientType) || defaultSubClientType,
211
- os: (0, _internalPluginMetrics.getOSNameInternal)(),
212
- browser: getBrowserName(),
213
- browserVersion: getBrowserVersion()
214
- })
215
- };
216
- if (meetingId) {
217
- // @ts-ignore
218
- var meeting = this.webex.meetings.meetingCollection.get(meetingId);
219
- if (meeting !== null && meeting !== void 0 && meeting.environment) {
220
- origin.environment = meeting.environment;
221
- }
222
- }
223
- if (options !== null && options !== void 0 && options.environment) {
224
- origin.environment = options.environment;
225
- }
226
- if (options !== null && options !== void 0 && options.newEnvironment) {
227
- origin.newEnvironment = options.newEnvironment;
228
- }
229
- if (options !== null && options !== void 0 && options.clientLaunchMethod) {
230
- origin.clientInfo.clientLaunchMethod = options.clientLaunchMethod;
231
- }
232
- return origin;
233
- }
234
- throw new Error("ClientType and SubClientType can't be undefined");
235
- }
236
-
237
- /**
238
- * Gather identifier details for call diagnostic payload.
239
- * @throws Error if initialization fails.
240
- * @param options
241
- */
242
- }, {
243
- key: "getIdentifiers",
244
- value: function getIdentifiers(options) {
245
- var _meeting$locusInfo, _meeting$meetingInfo2, _meeting$meetingInfo3, _meeting$meetingInfo6, _meeting$meetingInfo8;
246
- var meeting = options.meeting,
247
- mediaConnections = options.mediaConnections,
248
- correlationId = options.correlationId,
249
- webexConferenceIdStr = options.webexConferenceIdStr,
250
- globalMeetingId = options.globalMeetingId,
251
- preLoginId = options.preLoginId;
252
- var identifiers = {
253
- correlationId: 'unknown'
254
- };
255
- if (meeting) {
256
- identifiers.correlationId = meeting.correlationId;
257
- }
258
- if (correlationId) {
259
- identifiers.correlationId = correlationId;
260
- }
261
- // @ts-ignore
262
- if (this.webex.internal) {
263
- // @ts-ignore
264
- var device = this.webex.internal.device;
265
- identifiers.userId = device.userId || preLoginId;
266
- identifiers.deviceId = device.url;
267
- identifiers.orgId = device.orgId;
268
- // @ts-ignore
269
- identifiers.locusUrl = this.webex.internal.services.get('locus');
270
- }
271
- if (meeting !== null && meeting !== void 0 && (_meeting$locusInfo = meeting.locusInfo) !== null && _meeting$locusInfo !== void 0 && _meeting$locusInfo.fullState) {
272
- identifiers.locusUrl = meeting.locusUrl;
273
- identifiers.locusId = meeting.locusUrl && meeting.locusUrl.split('/').pop();
274
- identifiers.locusStartTime = meeting.locusInfo.fullState && meeting.locusInfo.fullState.lastActive;
275
- }
276
- if (meeting !== null && meeting !== void 0 && (_meeting$meetingInfo2 = meeting.meetingInfo) !== null && _meeting$meetingInfo2 !== void 0 && _meeting$meetingInfo2.confIdStr || meeting !== null && meeting !== void 0 && (_meeting$meetingInfo3 = meeting.meetingInfo) !== null && _meeting$meetingInfo3 !== void 0 && _meeting$meetingInfo3.confID) {
277
- var _meeting$meetingInfo4, _meeting$meetingInfo5;
278
- identifiers.webexConferenceIdStr = "".concat(((_meeting$meetingInfo4 = meeting.meetingInfo) === null || _meeting$meetingInfo4 === void 0 ? void 0 : _meeting$meetingInfo4.confIdStr) || ((_meeting$meetingInfo5 = meeting.meetingInfo) === null || _meeting$meetingInfo5 === void 0 ? void 0 : _meeting$meetingInfo5.confID));
279
- }
280
- if (meeting !== null && meeting !== void 0 && (_meeting$meetingInfo6 = meeting.meetingInfo) !== null && _meeting$meetingInfo6 !== void 0 && _meeting$meetingInfo6.meetingId) {
281
- var _meeting$meetingInfo7;
282
- identifiers.globalMeetingId = (_meeting$meetingInfo7 = meeting.meetingInfo) === null || _meeting$meetingInfo7 === void 0 ? void 0 : _meeting$meetingInfo7.meetingId;
283
- }
284
- if (meeting !== null && meeting !== void 0 && (_meeting$meetingInfo8 = meeting.meetingInfo) !== null && _meeting$meetingInfo8 !== void 0 && _meeting$meetingInfo8.siteName) {
285
- var _meeting$meetingInfo9;
286
- identifiers.webexSiteName = (_meeting$meetingInfo9 = meeting.meetingInfo) === null || _meeting$meetingInfo9 === void 0 ? void 0 : _meeting$meetingInfo9.siteName;
287
- }
288
- if (mediaConnections) {
289
- var _mediaConnections$, _mediaConnections$2;
290
- identifiers.mediaAgentAlias = mediaConnections === null || mediaConnections === void 0 ? void 0 : (_mediaConnections$ = mediaConnections[0]) === null || _mediaConnections$ === void 0 ? void 0 : _mediaConnections$.mediaAgentAlias;
291
- identifiers.mediaAgentGroupId = mediaConnections === null || mediaConnections === void 0 ? void 0 : (_mediaConnections$2 = mediaConnections[0]) === null || _mediaConnections$2 === void 0 ? void 0 : _mediaConnections$2.mediaAgentGroupId;
292
- }
293
- if (!(identifiers !== null && identifiers !== void 0 && identifiers.webexConferenceIdStr) && webexConferenceIdStr) {
294
- identifiers.webexConferenceIdStr = "".concat(webexConferenceIdStr);
295
- }
296
- if (!(identifiers !== null && identifiers !== void 0 && identifiers.globalMeetingId) && globalMeetingId) {
297
- identifiers.globalMeetingId = globalMeetingId;
298
- }
299
- if (identifiers.correlationId === undefined) {
300
- throw new Error('Identifiers initialization failed.');
301
- }
302
- return identifiers;
303
- }
304
-
305
- /**
306
- * Create diagnostic event, which can hold client event, feature event or MQE event data.
307
- * This just initiates the shared properties that are required for all the 3 event categories.
308
- * @param eventData
309
- * @param options
310
- * @returns
311
- */
312
- }, {
313
- key: "prepareDiagnosticEvent",
314
- value: function prepareDiagnosticEvent(eventData, options) {
315
- var _this$webex$meetings$10;
316
- var meetingId = options.meetingId;
317
- var origin = this.getOrigin(options, meetingId);
318
- var event = {
319
- eventId: _uuid.default.v4(),
320
- version: 1,
321
- origin: origin,
322
- originTime: {
323
- triggered: new Date().toISOString(),
324
- // is overridden in prepareRequest batcher
325
- sent: 'not_defined_yet'
326
- },
327
- // @ts-ignore
328
- senderCountryCode: (_this$webex$meetings$10 = this.webex.meetings.geoHintInfo) === null || _this$webex$meetings$10 === void 0 ? void 0 : _this$webex$meetings$10.countryCode,
329
- event: eventData
330
- };
331
-
332
- // sanitize (remove empty properties, CA requires it)
333
- // but we don't want to sanitize MQE as most of the times
334
- // values will be 0, [] etc, and they are required.
335
- if (eventData.name !== 'client.mediaquality.event') {
336
- (0, _callDiagnosticMetrics.clearEmptyKeysRecursively)(event);
337
- }
338
- return event;
339
- }
340
-
341
- /**
342
- * TODO: NOT IMPLEMENTED
343
- * Submit Feature Event
344
- * @returns
345
- */
346
- }, {
347
- key: "submitFeatureEvent",
348
- value: function submitFeatureEvent() {
349
- throw Error('Not implemented');
350
- }
351
-
352
- /**
353
- * Submit Media Quality Event
354
- * @param args - submit params
355
- * @param arg.name - event key
356
- * @param arg.payload - additional payload to be merge with the default payload
357
- * @param arg.options - options
358
- */
359
- }, {
360
- key: "submitMQE",
361
- value: function submitMQE(_ref2) {
362
- var name = _ref2.name,
363
- payload = _ref2.payload,
364
- options = _ref2.options;
365
- var meetingId = options.meetingId,
366
- mediaConnections = options.mediaConnections,
367
- webexConferenceIdStr = options.webexConferenceIdStr,
368
- globalMeetingId = options.globalMeetingId;
369
-
370
- // events that will most likely happen in join phase
371
- if (meetingId) {
372
- // @ts-ignore
373
- var meeting = this.webex.meetings.meetingCollection.get(meetingId);
374
- if (!meeting) {
375
- console.warn('Attempt to send MQE but no meeting was found...', "event: ".concat(name, ", meetingId: ").concat(meetingId));
376
- // @ts-ignore
377
- this.webex.internal.metrics.submitClientMetrics(_config2.CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND, {
378
- fields: {
379
- meetingId: meetingId,
380
- name: name
381
- }
382
- });
383
- return;
384
- }
385
-
386
- // merge identifiers
387
- var identifiers = this.getIdentifiers({
388
- meeting: meeting,
389
- mediaConnections: meeting.mediaConnections || mediaConnections,
390
- webexConferenceIdStr: webexConferenceIdStr,
391
- globalMeetingId: globalMeetingId
392
- });
393
-
394
- // create media quality event object
395
- var clientEventObject = {
396
- name: name,
397
- canProceed: true,
398
- identifiers: identifiers,
399
- eventData: {
400
- webClientDomain: window.location.hostname
401
- },
402
- intervals: payload.intervals,
403
- sourceMetadata: {
404
- applicationSoftwareType: _config.CLIENT_NAME,
405
- // @ts-ignore
406
- applicationSoftwareVersion: this.webex.version,
407
- mediaEngineSoftwareType: getBrowserName() || 'browser',
408
- mediaEngineSoftwareVersion: getOSVersion() || 'unknown',
409
- startTime: new Date().toISOString()
410
- }
411
- };
412
-
413
- // merge any new properties, or override existing ones
414
- clientEventObject = (0, _lodash.merge)(clientEventObject, payload);
415
-
416
- // append media quality event data to the call diagnostic event
417
- var diagnosticEvent = this.prepareDiagnosticEvent(clientEventObject, options);
418
- this.validator({
419
- type: 'mqe',
420
- event: diagnosticEvent
421
- });
422
- this.submitToCallDiagnostics(diagnosticEvent);
423
- } else {
424
- throw new Error('Media quality events cant be sent outside the context of a meeting. Meeting id is required.');
425
- }
426
- }
427
-
428
- /**
429
- * Return Client Event payload by client error code
430
- * @param arg - get error arg
431
- * @param arg.clientErrorCode
432
- * @param arg.serviceErrorCode
433
- * @param arg.payloadOverrides
434
- * @returns
435
- */
436
- }, {
437
- key: "getErrorPayloadForClientErrorCode",
438
- value: function getErrorPayloadForClientErrorCode(_ref3) {
439
- var clientErrorCode = _ref3.clientErrorCode,
440
- serviceErrorCode = _ref3.serviceErrorCode,
441
- serviceErrorName = _ref3.serviceErrorName,
442
- rawErrorMessage = _ref3.rawErrorMessage,
443
- payloadOverrides = _ref3.payloadOverrides;
444
- var error;
445
- if (clientErrorCode) {
446
- var partialParsedError = _config2.CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD[clientErrorCode];
447
- if (partialParsedError) {
448
- error = (0, _lodash.merge)({
449
- fatal: true,
450
- shownToUser: false,
451
- name: 'other',
452
- category: 'other'
453
- },
454
- // default values
455
- {
456
- errorCode: clientErrorCode
457
- }, serviceErrorName ? {
458
- errorData: {
459
- errorName: serviceErrorName
460
- }
461
- } : {}, {
462
- serviceErrorCode: serviceErrorCode
463
- }, {
464
- rawErrorMessage: rawErrorMessage
465
- }, partialParsedError, payloadOverrides || {});
466
- return error;
467
- }
468
- }
469
- return undefined;
470
- }
471
-
472
- /**
473
- * Generate error payload for Client Event
474
- * @param rawError
475
- */
476
- }, {
477
- key: "generateClientEventErrorPayload",
478
- value: function generateClientEventErrorPayload(rawError) {
479
- var _rawError$error, _rawError$error$body, _rawError$body, _rawError$body2, _rawError$body3, _rawError$body3$reaso;
480
- var rawErrorMessage = rawError.message;
481
- if (rawError.name) {
482
- if ((0, _callDiagnosticMetrics.isBrowserMediaErrorName)(rawError.name)) {
483
- return this.getErrorPayloadForClientErrorCode({
484
- serviceErrorCode: undefined,
485
- clientErrorCode: _config2.BROWSER_MEDIA_ERROR_NAME_TO_CLIENT_ERROR_CODES_MAP[rawError.name],
486
- serviceErrorName: rawError.name,
487
- rawErrorMessage: rawErrorMessage
488
- });
489
- }
490
- }
491
- 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);
492
- if (serviceErrorCode) {
493
- var clientErrorCode = _config2.SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP[serviceErrorCode];
494
- if (clientErrorCode) {
495
- return this.getErrorPayloadForClientErrorCode({
496
- clientErrorCode: clientErrorCode,
497
- serviceErrorCode: serviceErrorCode,
498
- rawErrorMessage: rawErrorMessage
499
- });
500
- }
501
-
502
- // by default, if it is locus error, return new locus err
503
- if ((0, _callDiagnosticMetrics.isLocusServiceErrorCode)(serviceErrorCode)) {
504
- return this.getErrorPayloadForClientErrorCode({
505
- clientErrorCode: _config2.NEW_LOCUS_ERROR_CLIENT_CODE,
506
- serviceErrorCode: serviceErrorCode,
507
- rawErrorMessage: rawErrorMessage
508
- });
509
- }
510
- }
511
- if ((0, _callDiagnosticMetrics.isMeetingInfoServiceError)(rawError)) {
512
- return this.getErrorPayloadForClientErrorCode({
513
- clientErrorCode: _config2.MEETING_INFO_LOOKUP_ERROR_CLIENT_CODE,
514
- serviceErrorCode: serviceErrorCode,
515
- rawErrorMessage: rawErrorMessage
516
- });
517
- }
518
- if ((0, _callDiagnosticMetrics.isNetworkError)(rawError)) {
519
- return this.getErrorPayloadForClientErrorCode({
520
- clientErrorCode: _config2.NETWORK_ERROR,
521
- serviceErrorCode: serviceErrorCode,
522
- payloadOverrides: rawError.payloadOverrides,
523
- rawErrorMessage: rawErrorMessage
524
- });
525
- }
526
- if ((0, _callDiagnosticMetrics.isUnauthorizedError)(rawError)) {
527
- return this.getErrorPayloadForClientErrorCode({
528
- clientErrorCode: _config2.AUTHENTICATION_FAILED_CODE,
529
- serviceErrorCode: serviceErrorCode,
530
- payloadOverrides: rawError.payloadOverrides,
531
- rawErrorMessage: rawErrorMessage
532
- });
533
- }
534
-
535
- // otherwise return unkown error
536
- return this.getErrorPayloadForClientErrorCode({
537
- clientErrorCode: _config2.UNKNOWN_ERROR,
538
- serviceErrorCode: _config2.UNKNOWN_ERROR,
539
- rawErrorMessage: rawErrorMessage
540
- });
541
- }
542
-
543
- /**
544
- * Create client event object for in meeting events
545
- * @param arg - create args
546
- * @param arg.event - event key
547
- * @param arg.options - options
548
- * @returns object
549
- */
550
- }, {
551
- key: "createClientEventObjectInMeeting",
552
- value: function createClientEventObjectInMeeting(_ref4) {
553
- var name = _ref4.name,
554
- options = _ref4.options,
555
- errors = _ref4.errors;
556
- var meetingId = options.meetingId,
557
- mediaConnections = options.mediaConnections,
558
- globalMeetingId = options.globalMeetingId,
559
- webexConferenceIdStr = options.webexConferenceIdStr;
560
-
561
- // @ts-ignore
562
- var meeting = this.webex.meetings.meetingCollection.get(meetingId);
563
- if (!meeting) {
564
- console.warn('Attempt to send client event but no meeting was found...', "name: ".concat(name, ", meetingId: ").concat(meetingId));
565
- // @ts-ignore
566
- this.webex.internal.metrics.submitClientMetrics(_config2.CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND, {
567
- fields: {
568
- meetingId: meetingId,
569
- name: name
570
- }
571
- });
572
- return undefined;
573
- }
574
-
575
- // grab identifiers
576
- var identifiers = this.getIdentifiers({
577
- meeting: meeting,
578
- mediaConnections: (meeting === null || meeting === void 0 ? void 0 : meeting.mediaConnections) || mediaConnections,
579
- webexConferenceIdStr: webexConferenceIdStr,
580
- globalMeetingId: globalMeetingId
581
- });
582
-
583
- // create client event object
584
- var clientEventObject = {
585
- name: name,
586
- canProceed: true,
587
- identifiers: identifiers,
588
- errors: errors,
589
- eventData: {
590
- webClientDomain: window.location.hostname
591
- },
592
- userType: meeting.getCurUserType(),
593
- loginType: 'loginType' in meeting.callStateForMetrics ? meeting.callStateForMetrics.loginType : this.getCurLoginType(),
594
- isConvergedArchitectureEnabled: this.getIsConvergedArchitectureEnabled({
595
- meetingId: meetingId
596
- }),
597
- webexSubServiceType: this.getSubServiceType(meeting)
598
- };
599
- return clientEventObject;
600
- }
601
-
602
- /**
603
- * Create client event object for pre meeting events
604
- * @param arg - create args
605
- * @param arg.event - event key
606
- * @param arg.options - payload
607
- * @returns object
608
- */
609
- }, {
610
- key: "createClientEventObjectPreMeeting",
611
- value: function createClientEventObjectPreMeeting(_ref5) {
612
- var name = _ref5.name,
613
- options = _ref5.options,
614
- errors = _ref5.errors;
615
- var correlationId = options.correlationId,
616
- globalMeetingId = options.globalMeetingId,
617
- webexConferenceIdStr = options.webexConferenceIdStr,
618
- preLoginId = options.preLoginId;
619
-
620
- // grab identifiers
621
- var identifiers = this.getIdentifiers({
622
- correlationId: correlationId,
623
- preLoginId: preLoginId,
624
- globalMeetingId: globalMeetingId,
625
- webexConferenceIdStr: webexConferenceIdStr
626
- });
627
-
628
- // create client event object
629
- var clientEventObject = {
630
- name: name,
631
- errors: errors,
632
- canProceed: true,
633
- identifiers: identifiers,
634
- eventData: {
635
- webClientDomain: window.location.hostname
636
- },
637
- loginType: this.getCurLoginType()
638
- };
639
- return clientEventObject;
640
- }
641
-
642
- /**
643
- * Prepare Client Event CA event.
644
- * @param arg - submit params
645
- * @param arg.event - event key
646
- * @param arg.payload - additional payload to be merged with default payload
647
- * @param arg.options - payload
648
- * @returns {any} options to be with fetch
649
- * @throws
650
- */
651
- }, {
652
- key: "prepareClientEvent",
653
- value: function prepareClientEvent(_ref6) {
654
- var name = _ref6.name,
655
- payload = _ref6.payload,
656
- options = _ref6.options;
657
- var meetingId = options.meetingId,
658
- correlationId = options.correlationId,
659
- rawError = options.rawError;
660
- var clientEventObject;
661
-
662
- // check if we need to generate errors
663
- var errors = [];
664
- if (rawError) {
665
- var generatedError = this.generateClientEventErrorPayload(rawError);
666
- if (generatedError) {
667
- errors.push(generatedError);
668
- }
669
- this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @prepareClientEvent. Generated errors:', "generatedError: ".concat((0, _stringify.default)(generatedError)));
670
- }
671
-
672
- // events that will most likely happen in join phase
673
- if (meetingId) {
674
- clientEventObject = this.createClientEventObjectInMeeting({
675
- name: name,
676
- options: options,
677
- errors: errors
678
- });
679
- } else if (correlationId) {
680
- // any pre join events or events that are outside the meeting.
681
- clientEventObject = this.createClientEventObjectPreMeeting({
682
- name: name,
683
- options: options,
684
- errors: errors
685
- });
686
- } else {
687
- throw new Error('Not implemented');
688
- }
689
-
690
- // merge any new properties, or override existing ones
691
- clientEventObject = (0, _lodash.merge)(clientEventObject, payload);
692
-
693
- // append client event data to the call diagnostic event
694
- var diagnosticEvent = this.prepareDiagnosticEvent(clientEventObject, options);
695
- return diagnosticEvent;
696
- }
697
-
698
- /**
699
- * Submit Client Event CA event.
700
- * @param arg - submit params
701
- * @param arg.event - event key
702
- * @param arg.payload - additional payload to be merged with default payload
703
- * @param arg.options - payload
704
- * @throws
705
- */
706
- }, {
707
- key: "submitClientEvent",
708
- value: function submitClientEvent(_ref7) {
709
- var name = _ref7.name,
710
- payload = _ref7.payload,
711
- options = _ref7.options;
712
- this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @submitClientEvent. Submit Client Event CA event.', "name: ".concat(name));
713
- var diagnosticEvent = this.prepareClientEvent({
714
- name: name,
715
- payload: payload,
716
- options: options
717
- });
718
- if (options !== null && options !== void 0 && options.preLoginId) {
719
- return this.submitToCallDiagnosticsPreLogin(diagnosticEvent, options === null || options === void 0 ? void 0 : options.preLoginId);
720
- }
721
- this.validator({
722
- type: 'ce',
723
- event: diagnosticEvent
724
- });
725
- return this.submitToCallDiagnostics(diagnosticEvent);
726
- }
727
-
728
- /**
729
- * Prepare the event and send the request to metrics-a service.
730
- * @param event
731
- * @returns promise
732
- */
733
- }, {
734
- key: "submitToCallDiagnostics",
735
- value: function submitToCallDiagnostics(event) {
736
- // build metrics-a event type
737
- var finalEvent = {
738
- eventPayload: event,
739
- type: ['diagnostic-event']
740
- };
741
- return this.callDiagnosticEventsBatcher.request(finalEvent);
742
- }
743
- }, {
744
- key: "buildClientEventFetchRequestOptions",
745
- value: (
746
- /**
747
- * Builds a request options object to later be passed to fetch().
748
- * @param arg - submit params
749
- * @param arg.event - event key
750
- * @param arg.payload - additional payload to be merged with default payload
751
- * @param arg.options - client event options
752
- * @returns {Promise<any>}
753
- * @throws
754
- */
755
- function () {
756
- var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref8) {
757
- var name, payload, options, clientEvent, diagnosticEvent, request;
758
- return _regenerator.default.wrap(function _callee$(_context) {
759
- while (1) switch (_context.prev = _context.next) {
760
- case 0:
761
- name = _ref8.name, payload = _ref8.payload, options = _ref8.options;
762
- this.logger.log(_config2.CALL_DIAGNOSTIC_LOG_IDENTIFIER, 'CallDiagnosticMetrics: @buildClientEventFetchRequestOptions. Building request options object for fetch()...', "name: ".concat(name));
763
- clientEvent = this.prepareClientEvent({
764
- name: name,
765
- payload: payload,
766
- options: options
767
- }); // build metrics-a event type
768
- // @ts-ignore
769
- diagnosticEvent = (0, _callDiagnosticMetrics.prepareDiagnosticMetricItem)(this.webex, {
770
- eventPayload: clientEvent,
771
- type: ['diagnostic-event']
772
- });
773
- request = {
774
- method: 'POST',
775
- service: 'metrics',
776
- resource: 'clientmetrics',
777
- body: {
778
- metrics: [diagnosticEvent]
779
- },
780
- headers: {},
781
- // @ts-ignore
782
- waitForServiceTimeout: this.webex.internal.metrics.config.waitForServiceTimeout
783
- };
784
- if (options.preLoginId) {
785
- request.headers = {
786
- authorization: false,
787
- 'x-prelogin-userid': options.preLoginId
788
- };
789
- request.resource = 'clientmetrics-prelogin';
790
- }
791
-
792
- // @ts-ignore
793
- return _context.abrupt("return", this.webex.prepareFetchOptions(request));
794
- case 7:
795
- case "end":
796
- return _context.stop();
797
- }
798
- }, _callee, this);
799
- }));
800
- function buildClientEventFetchRequestOptions(_x) {
801
- return _buildClientEventFetchRequestOptions.apply(this, arguments);
802
- }
803
- return buildClientEventFetchRequestOptions;
804
- }()
805
- /**
806
- * Returns true if the specified serviceErrorCode maps to an expected error.
807
- * @param {number} serviceErrorCode the service error code
808
- * @returns {boolean}
809
- */
810
- )
811
- }, {
812
- key: "isServiceErrorExpected",
813
- value: function isServiceErrorExpected(serviceErrorCode) {
814
- var clientErrorCode = _config2.SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP[serviceErrorCode];
815
- var clientErrorPayload = _config2.CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD[clientErrorCode];
816
- return (clientErrorPayload === null || clientErrorPayload === void 0 ? void 0 : clientErrorPayload.category) === 'expected';
817
- }
818
- }]);
819
- return CallDiagnosticMetrics;
820
- }(_webexCore.StatelessWebexPlugin);
821
- //# sourceMappingURL=call-diagnostic-metrics.js.map