@webex/internal-plugin-metrics 2.60.1-next.9 → 2.60.2

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