@webex/internal-plugin-metrics 3.0.0-bnr.5 → 3.0.0-next.10

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