@webex/internal-plugin-metrics 3.0.0-bnr.4 → 3.0.0-next.1

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