@webex/internal-plugin-metrics 3.0.0-beta.42 → 3.0.0-beta.420

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