@webex/internal-plugin-metrics 3.0.0-beta.39 → 3.0.0-beta.390

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