@webex/internal-plugin-metrics 3.4.0-next.1 → 3.4.0-next.3

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 (40) hide show
  1. package/dist/behavioral-metrics.js +63 -0
  2. package/dist/behavioral-metrics.js.map +1 -0
  3. package/dist/business-metrics.js +62 -0
  4. package/dist/business-metrics.js.map +1 -0
  5. package/dist/{behavioral/behavioral-metrics.js → generic-metrics.js} +77 -92
  6. package/dist/generic-metrics.js.map +1 -0
  7. package/dist/index.js +15 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/metrics.js +1 -1
  10. package/dist/metrics.types.js.map +1 -1
  11. package/dist/new-metrics.js +92 -24
  12. package/dist/new-metrics.js.map +1 -1
  13. package/dist/operational-metrics.js +56 -0
  14. package/dist/operational-metrics.js.map +1 -0
  15. package/dist/types/behavioral-metrics.d.ts +25 -0
  16. package/dist/types/business-metrics.d.ts +19 -0
  17. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +2 -2
  18. package/dist/types/generic-metrics.d.ts +63 -0
  19. package/dist/types/index.d.ts +4 -2
  20. package/dist/types/metrics.types.d.ts +25 -14
  21. package/dist/types/new-metrics.d.ts +29 -9
  22. package/dist/types/operational-metrics.d.ts +19 -0
  23. package/package.json +11 -11
  24. package/src/behavioral-metrics.ts +40 -0
  25. package/src/business-metrics.ts +30 -0
  26. package/src/generic-metrics.ts +146 -0
  27. package/src/index.ts +5 -1
  28. package/src/metrics.types.ts +29 -16
  29. package/src/new-metrics.ts +68 -17
  30. package/src/operational-metrics.ts +24 -0
  31. package/test/unit/spec/behavioral/behavioral-metrics.ts +51 -10
  32. package/test/unit/spec/business/business-metrics.ts +120 -0
  33. package/test/unit/spec/operational/operational-metrics.ts +115 -0
  34. package/dist/behavioral/behavioral-metrics.js.map +0 -1
  35. package/dist/behavioral/config.js +0 -11
  36. package/dist/behavioral/config.js.map +0 -1
  37. package/dist/types/behavioral/behavioral-metrics.d.ts +0 -63
  38. package/dist/types/behavioral/config.d.ts +0 -1
  39. package/src/behavioral/behavioral-metrics.ts +0 -179
  40. package/src/behavioral/config.ts +0 -3
@@ -19,7 +19,9 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/he
19
19
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
20
20
  var _webexCore = require("@webex/webex-core");
21
21
  var _callDiagnosticMetrics = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics"));
22
- var _behavioralMetrics = _interopRequireDefault(require("./behavioral/behavioral-metrics"));
22
+ var _behavioralMetrics = _interopRequireDefault(require("./behavioral-metrics"));
23
+ var _operationalMetrics = _interopRequireDefault(require("./operational-metrics"));
24
+ var _businessMetrics = _interopRequireDefault(require("./business-metrics"));
23
25
  var _callDiagnosticMetricsLatencies = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics-latencies"));
24
26
  var _callDiagnosticMetrics2 = require("./call-diagnostic/call-diagnostic-metrics.util");
25
27
  var _utils = require("./utils");
@@ -58,6 +60,9 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
58
60
  // Helper classes to handle the different types of metrics
59
61
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticMetrics", void 0);
60
62
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "behavioralMetrics", void 0);
63
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "operationalMetrics", void 0);
64
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "businessMetrics", void 0);
65
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isReady", false);
61
66
  _this.callDiagnosticLatencies = new _callDiagnosticMetricsLatencies.default({}, {
62
67
  parent: _this.webex
63
68
  });
@@ -78,10 +83,7 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
78
83
  _this2.callDiagnosticMetrics = new _callDiagnosticMetrics.default({}, {
79
84
  parent: _this2.webex
80
85
  });
81
- // @ts-ignore
82
- _this2.behavioralMetrics = new _behavioralMetrics.default({}, {
83
- parent: _this2.webex
84
- });
86
+ _this2.isReady = true;
85
87
  });
86
88
  }
87
89
 
@@ -110,7 +112,28 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
110
112
  }, {
111
113
  key: "isReadyToSubmitBehavioralEvents",
112
114
  value: function isReadyToSubmitBehavioralEvents() {
113
- return this.behavioralMetrics.isReadyToSubmitBehavioralEvents();
115
+ var _this$behavioralMetri, _this$behavioralMetri2;
116
+ return (_this$behavioralMetri = (_this$behavioralMetri2 = this.behavioralMetrics) === null || _this$behavioralMetri2 === void 0 ? void 0 : _this$behavioralMetri2.isReadyToSubmitEvents()) !== null && _this$behavioralMetri !== void 0 ? _this$behavioralMetri : false;
117
+ }
118
+
119
+ /**
120
+ * @returns true once we have the deviceId we need to submit operational events
121
+ */
122
+ }, {
123
+ key: "isReadyToSubmitOperationalEvents",
124
+ value: function isReadyToSubmitOperationalEvents() {
125
+ var _this$operationalMetr, _this$operationalMetr2;
126
+ return (_this$operationalMetr = (_this$operationalMetr2 = this.operationalMetrics) === null || _this$operationalMetr2 === void 0 ? void 0 : _this$operationalMetr2.isReadyToSubmitEvents()) !== null && _this$operationalMetr !== void 0 ? _this$operationalMetr : false;
127
+ }
128
+
129
+ /**
130
+ * @returns true once we have the deviceId we need to submit buisness events
131
+ */
132
+ }, {
133
+ key: "isReadyToSubmitBusinessEvents",
134
+ value: function isReadyToSubmitBusinessEvents() {
135
+ var _this$businessMetrics, _this$businessMetrics2;
136
+ return (_this$businessMetrics = (_this$businessMetrics2 = this.businessMetrics) === null || _this$businessMetrics2 === void 0 ? void 0 : _this$businessMetrics2.isReadyToSubmitEvents()) !== null && _this$businessMetrics !== void 0 ? _this$businessMetrics : false;
114
137
  }
115
138
 
116
139
  /**
@@ -125,11 +148,17 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
125
148
  target = _ref2.target,
126
149
  verb = _ref2.verb,
127
150
  payload = _ref2.payload;
128
- if (!this.behavioralMetrics) {
151
+ if (!this.isReady) {
129
152
  // @ts-ignore
130
153
  this.webex.logger.log("NewMetrics: @submitBehavioralEvent. Attempted to submit before webex.ready: ".concat(product, ".").concat(agent, ".").concat(target, ".").concat(verb));
131
154
  return _promise.default.resolve();
132
155
  }
156
+ if (!this.behavioralMetrics) {
157
+ // @ts-ignore
158
+ this.behavioralMetrics = new _behavioralMetrics.default({}, {
159
+ parent: this.webex
160
+ });
161
+ }
133
162
  return this.behavioralMetrics.submitBehavioralEvent({
134
163
  product: product,
135
164
  agent: agent,
@@ -147,9 +176,48 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
147
176
  key: "submitOperationalEvent",
148
177
  value: function submitOperationalEvent(_ref3) {
149
178
  var name = _ref3.name,
150
- payload = _ref3.payload,
151
- options = _ref3.options;
152
- throw new Error('Not implemented.');
179
+ payload = _ref3.payload;
180
+ if (!this.isReady) {
181
+ // @ts-ignore
182
+ this.webex.logger.log("NewMetrics: @submitOperationalEvent. Attempted to submit before webex.ready: ".concat(name));
183
+ return _promise.default.resolve();
184
+ }
185
+ if (!this.operationalMetrics) {
186
+ // @ts-ignore
187
+ this.operationalMetrics = new _operationalMetrics.default({}, {
188
+ parent: this.webex
189
+ });
190
+ }
191
+ return this.operationalMetrics.submitOperationalEvent({
192
+ name: name,
193
+ payload: payload
194
+ });
195
+ }
196
+
197
+ /**
198
+ * Buisness event
199
+ * @param args
200
+ */
201
+ }, {
202
+ key: "submitBusinessEvent",
203
+ value: function submitBusinessEvent(_ref4) {
204
+ var name = _ref4.name,
205
+ payload = _ref4.payload;
206
+ if (!this.isReady) {
207
+ // @ts-ignore
208
+ this.webex.logger.log("NewMetrics: @submitBusinessEvent. Attempted to submit before webex.ready: ".concat(name));
209
+ return _promise.default.resolve();
210
+ }
211
+ if (!this.businessMetrics) {
212
+ // @ts-ignore
213
+ this.businessMetrics = new _businessMetrics.default({}, {
214
+ parent: this.webex
215
+ });
216
+ }
217
+ return this.businessMetrics.submitBusinessEvent({
218
+ name: name,
219
+ payload: payload
220
+ });
153
221
  }
154
222
 
155
223
  /**
@@ -158,10 +226,10 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
158
226
  */
159
227
  }, {
160
228
  key: "submitMQE",
161
- value: function submitMQE(_ref4) {
162
- var name = _ref4.name,
163
- payload = _ref4.payload,
164
- options = _ref4.options;
229
+ value: function submitMQE(_ref5) {
230
+ var name = _ref5.name,
231
+ payload = _ref5.payload,
232
+ options = _ref5.options;
165
233
  this.callDiagnosticLatencies.saveTimestamp({
166
234
  key: name
167
235
  });
@@ -178,10 +246,10 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
178
246
  */
179
247
  }, {
180
248
  key: "submitFeatureEvent",
181
- value: function submitFeatureEvent(_ref5) {
182
- var name = _ref5.name,
183
- payload = _ref5.payload,
184
- options = _ref5.options;
249
+ value: function submitFeatureEvent(_ref6) {
250
+ var name = _ref6.name,
251
+ payload = _ref6.payload,
252
+ options = _ref6.options;
185
253
  throw new Error('Not implemented.');
186
254
  }
187
255
 
@@ -192,10 +260,10 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
192
260
  */
193
261
  }, {
194
262
  key: "submitClientEvent",
195
- value: function submitClientEvent(_ref6) {
196
- var name = _ref6.name,
197
- payload = _ref6.payload,
198
- options = _ref6.options;
263
+ value: function submitClientEvent(_ref7) {
264
+ var name = _ref7.name,
265
+ payload = _ref7.payload,
266
+ options = _ref7.options;
199
267
  if (!this.callDiagnosticLatencies || !this.callDiagnosticMetrics) {
200
268
  // @ts-ignore
201
269
  this.webex.logger.log("NewMetrics: @submitClientEvent. Attempted to submit before webex.ready. Event name: ".concat(name));
@@ -271,12 +339,12 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
271
339
  }, {
272
340
  key: "buildClientEventFetchRequestOptions",
273
341
  value: (function () {
274
- var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref7) {
342
+ var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref8) {
275
343
  var name, payload, options;
276
344
  return _regenerator.default.wrap(function _callee$(_context) {
277
345
  while (1) switch (_context.prev = _context.next) {
278
346
  case 0:
279
- name = _ref7.name, payload = _ref7.payload, options = _ref7.options;
347
+ name = _ref8.name, payload = _ref8.payload, options = _ref8.options;
280
348
  return _context.abrupt("return", this.callDiagnosticMetrics.buildClientEventFetchRequestOptions({
281
349
  name: name,
282
350
  payload: payload,
@@ -1 +1 @@
1
- {"version":3,"names":["_webexCore","require","_callDiagnosticMetrics","_interopRequireDefault","_behavioralMetrics","_callDiagnosticMetricsLatencies","_callDiagnosticMetrics2","_utils","_class","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","Metrics","_WebexPlugin","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","concat","_defineProperty2","_assertThisInitialized2","callDiagnosticLatencies","CallDiagnosticLatencies","parent","webex","onReady","_createClass2","key","value","_this2","once","callDiagnosticMetrics","CallDiagnosticMetrics","behavioralMetrics","BehavioralMetrics","submitInternalEvent","_ref","name","payload","options","clearTimestamps","saveTimestamp","isReadyToSubmitBehavioralEvents","submitBehavioralEvent","_ref2","product","agent","target","verb","logger","log","_promise","resolve","submitOperationalEvent","_ref3","Error","submitMQE","_ref4","submitFeatureEvent","_ref5","submitClientEvent","_ref6","meetingId","clientMetricsAliasUser","preLoginId","_this3","request","method","api","resource","headers","body","qs","alias","then","res","catch","err","error","generateCommonErrorMetadata","reject","_buildClientEventFetchRequestOptions","_asyncToGenerator2","_regenerator","mark","_callee","_ref7","wrap","_callee$","_context","prev","next","abrupt","buildClientEventFetchRequestOptions","stop","_x","setMetricTimingsAndFetch","setTimingsAndFetch","setMetricTimings","isServiceErrorExpected","serviceErrorCode","WebexPlugin","_default","exports"],"sources":["new-metrics.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable class-methods-use-this */\n/* eslint-disable valid-jsdoc */\n\n// @ts-ignore\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';\nimport BehavioralMetrics from './behavioral/behavioral-metrics';\nimport {\n RecursivePartial,\n MetricEventProduct,\n MetricEventAgent,\n MetricEventVerb,\n ClientEvent,\n FeatureEvent,\n BehavioralEventPayload,\n OperationalEvent,\n MediaQualityEvent,\n InternalEvent,\n SubmitClientEventOptions,\n} from './metrics.types';\nimport CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';\nimport {setMetricTimings} from './call-diagnostic/call-diagnostic-metrics.util';\nimport {generateCommonErrorMetadata} from './utils';\n\n/**\n * Metrics plugin to centralize all types of metrics.\n * @class\n */\nclass Metrics extends WebexPlugin {\n // eslint-disable-next-line no-use-before-define\n static instance: Metrics;\n\n // Call Diagnostic latencies\n callDiagnosticLatencies: CallDiagnosticLatencies;\n // Helper classes to handle the different types of metrics\n callDiagnosticMetrics: CallDiagnosticMetrics;\n behavioralMetrics: BehavioralMetrics;\n\n /**\n * Constructor\n * @param args\n * @constructor\n * @private\n * @returns\n */\n constructor(...args) {\n super(...args);\n\n // @ts-ignore\n this.callDiagnosticLatencies = new CallDiagnosticLatencies({}, {parent: this.webex});\n this.onReady();\n }\n\n /**\n * On Ready\n */\n private onReady() {\n // @ts-ignore\n this.webex.once('ready', () => {\n // @ts-ignore\n this.callDiagnosticMetrics = new CallDiagnosticMetrics({}, {parent: this.webex});\n // @ts-ignore\n this.behavioralMetrics = new BehavioralMetrics({}, {parent: this.webex});\n });\n }\n\n /**\n * Used for internal purposes only\n * @param args\n */\n submitInternalEvent({\n name,\n payload,\n options,\n }: {\n name: InternalEvent['name'];\n payload?: RecursivePartial<InternalEvent['payload']>;\n options?: any;\n }) {\n if (name === 'internal.reset.join.latencies') {\n this.callDiagnosticLatencies.clearTimestamps();\n } else {\n this.callDiagnosticLatencies.saveTimestamp({key: name});\n }\n }\n\n /**\n * @returns true once we have the deviceId we need to submit behavioral events to Amplitude\n */\n isReadyToSubmitBehavioralEvents() {\n return this.behavioralMetrics.isReadyToSubmitBehavioralEvents();\n }\n\n /**\n * Behavioral event\n * @param args\n */\n submitBehavioralEvent({\n product,\n agent,\n target,\n verb,\n payload,\n }: {\n product: MetricEventProduct;\n agent: MetricEventAgent;\n target: string;\n verb: MetricEventVerb;\n payload?: BehavioralEventPayload;\n }) {\n if (!this.behavioralMetrics) {\n // @ts-ignore\n this.webex.logger.log(\n `NewMetrics: @submitBehavioralEvent. Attempted to submit before webex.ready: ${product}.${agent}.${target}.${verb}`\n );\n\n return Promise.resolve();\n }\n\n return this.behavioralMetrics.submitBehavioralEvent({product, agent, target, verb, payload});\n }\n\n /**\n * Operational event\n * @param args\n */\n submitOperationalEvent({\n name,\n payload,\n options,\n }: {\n name: OperationalEvent['name'];\n payload?: RecursivePartial<OperationalEvent['payload']>;\n options?: any;\n }) {\n throw new Error('Not implemented.');\n }\n\n /**\n * Call Analyzer: Media Quality Event\n * @param args\n */\n submitMQE({\n name,\n payload,\n options,\n }: {\n name: MediaQualityEvent['name'];\n payload: RecursivePartial<MediaQualityEvent['payload']> & {\n intervals: MediaQualityEvent['payload']['intervals'];\n };\n options: any;\n }) {\n this.callDiagnosticLatencies.saveTimestamp({key: name});\n this.callDiagnosticMetrics.submitMQE({name, payload, options});\n }\n\n /**\n * Call Analyzer: Feature Usage Event\n * @param args\n */\n submitFeatureEvent({\n name,\n payload,\n options,\n }: {\n name: FeatureEvent['name'];\n payload?: RecursivePartial<FeatureEvent['payload']>;\n options: any;\n }) {\n throw new Error('Not implemented.');\n }\n\n /**\n * Call Analyzer: Client Event\n * @public\n * @param args\n */\n public submitClientEvent({\n name,\n payload,\n options,\n }: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n }): Promise<any> {\n if (!this.callDiagnosticLatencies || !this.callDiagnosticMetrics) {\n // @ts-ignore\n this.webex.logger.log(\n `NewMetrics: @submitClientEvent. Attempted to submit before webex.ready. Event name: ${name}`\n );\n\n return Promise.resolve();\n }\n this.callDiagnosticLatencies.saveTimestamp({\n key: name,\n options: {meetingId: options?.meetingId},\n });\n\n return this.callDiagnosticMetrics.submitClientEvent({name, payload, options});\n }\n\n /**\n * Issue request to alias a user's pre-login ID with their CI UUID\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n public clientMetricsAliasUser(preLoginId: string) {\n // @ts-ignore\n return this.webex\n .request({\n method: 'POST',\n api: 'metrics',\n resource: 'clientmetrics',\n headers: {\n 'x-prelogin-userid': preLoginId,\n },\n body: {},\n qs: {\n alias: true,\n },\n })\n .then((res) => {\n // @ts-ignore\n this.webex.logger.log(`NewMetrics: @clientMetricsAliasUser. Request successful.`);\n\n return res;\n })\n .catch((err) => {\n // @ts-ignore\n this.logger.error(\n `NewMetrics: @clientMetricsAliasUser. Request failed:`,\n `err: ${generateCommonErrorMetadata(err)}`\n );\n\n return Promise.reject(err);\n });\n }\n\n /**\n * Returns a promise that will resolve to fetch options for submitting a metric.\n *\n * This is to support quickly submitting metrics when the browser/tab is closing.\n * Calling submitClientEvent will not work because there some async steps that will\n * not complete before the browser is closed. Instead, we pre-gather all the\n * information/options needed for the request(s), and then simply and quickly\n * fire the fetch(es) when beforeUnload is triggered.\n *\n * We must use fetch instead of request because fetch has a keepalive option that\n * allows the request it to outlive the page.\n *\n * Note: the timings values will be wrong, but setMetricTimingsAndFetch() will\n * properly adjust them before submitting.\n *\n * @public\n * @param {Object} arg\n * @param {String} arg.name - event name\n * @param {Object} arg.payload - event payload\n * @param {Object} arg.options - other options\n * @returns {Promise} promise that resolves to options to be used with fetch\n */\n public async buildClientEventFetchRequestOptions({\n name,\n payload,\n options,\n }: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n }): Promise<any> {\n return this.callDiagnosticMetrics.buildClientEventFetchRequestOptions({\n name,\n payload,\n options,\n });\n }\n\n /**\n * Submits a metric from pre-built request options via the fetch API. Updates\n * the \"$timings\" and \"originTime\" values to Date.now() since the existing times\n * were set when the options were built (not submitted).\n\n * @param {any} options - the pre-built request options for submitting a metric\n * @returns {Promise} promise that resolves to the response object\n */\n public setMetricTimingsAndFetch(options: any): Promise<any> {\n // @ts-ignore\n return this.webex.setTimingsAndFetch(setMetricTimings(options));\n }\n\n /**\n * Returns true if the specified serviceErrorCode maps to an expected error.\n * @param {number} serviceErrorCode the service error code\n * @returns {boolean}\n */\n public isServiceErrorExpected(serviceErrorCode: number): boolean {\n return this.callDiagnosticMetrics.isServiceErrorExpected(serviceErrorCode);\n }\n}\n\nexport default Metrics;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAcA,IAAAI,+BAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAAoD,IAAAO,MAAA;AAxBpD;AACA;AACA;AAEA;AAAA,SAAAC,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,EAAAO,SAAA,EAAAH,SAAA,YAAAD,MAAA,GAAA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AAI,GAAAiD,KAAA,CAAJjD,IAAI,EACJC,OAAO,GAAAgD,KAAA,CAAPhD,OAAO,EACPC,OAAO,GAAA+C,KAAA,CAAP/C,OAAO;cAAA,OAAAkD,QAAA,CAAAG,MAAA,WAMA,IAAI,CAAC7D,qBAAqB,CAAC8D,mCAAmC,CAAC;gBACpExD,IAAI,EAAJA,IAAI;gBACJC,OAAO,EAAPA,OAAO;gBACPC,OAAO,EAAPA;cACF,CAAC,CAAC;YAAA;YAAA;cAAA,OAAAkD,QAAA,CAAAK,IAAA;UAAA;QAAA,GAAAT,OAAA;MAAA,CACH;MAAA,SAAAQ,oCAAAE,EAAA;QAAA,OAAAd,oCAAA,CAAApF,KAAA,OAAAD,SAAA;MAAA;MAAA,OAAAiG,mCAAA;IAAA;IAED;AACF;AACA;AACA;AACA;AACA;AACA;IANE;EAAA;IAAAlE,GAAA;IAAAC,KAAA,EAQA,SAAAoE,yBAAgCzD,OAAY,EAAgB;MAC1D;MACA,OAAO,IAAI,CAACf,KAAK,CAACyE,kBAAkB,CAAC,IAAAC,wCAAgB,EAAC3D,OAAO,CAAC,CAAC;IACjE;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAAZ,GAAA;IAAAC,KAAA,EAKA,SAAAuE,uBAA8BC,gBAAwB,EAAW;MAC/D,OAAO,IAAI,CAACrE,qBAAqB,CAACoE,sBAAsB,CAACC,gBAAgB,CAAC;IAC5E;EAAC;EAAA,OAAA7F,OAAA;AAAA,EA9QmB8F,sBAAW;AAAAtH,MAAA,GAA3BwB,OAAO;AACX;AAAA,IAAAY,gBAAA,CAAA5B,OAAA,EADIgB,OAAO;AAAA,IAAA+F,QAAA,GAAAC,OAAA,CAAAhH,OAAA,GAiREgB,OAAO"}
1
+ {"version":3,"names":["_webexCore","require","_callDiagnosticMetrics","_interopRequireDefault","_behavioralMetrics","_operationalMetrics","_businessMetrics","_callDiagnosticMetricsLatencies","_callDiagnosticMetrics2","_utils","_class","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","Metrics","_WebexPlugin","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","concat","_defineProperty2","_assertThisInitialized2","callDiagnosticLatencies","CallDiagnosticLatencies","parent","webex","onReady","_createClass2","key","value","_this2","once","callDiagnosticMetrics","CallDiagnosticMetrics","isReady","submitInternalEvent","_ref","name","payload","options","clearTimestamps","saveTimestamp","isReadyToSubmitBehavioralEvents","_this$behavioralMetri","_this$behavioralMetri2","behavioralMetrics","isReadyToSubmitEvents","isReadyToSubmitOperationalEvents","_this$operationalMetr","_this$operationalMetr2","operationalMetrics","isReadyToSubmitBusinessEvents","_this$businessMetrics","_this$businessMetrics2","businessMetrics","submitBehavioralEvent","_ref2","product","agent","target","verb","logger","log","_promise","resolve","BehavioralMetrics","submitOperationalEvent","_ref3","OperationalMetrics","submitBusinessEvent","_ref4","BusinessMetrics","submitMQE","_ref5","submitFeatureEvent","_ref6","Error","submitClientEvent","_ref7","meetingId","clientMetricsAliasUser","preLoginId","_this3","request","method","api","resource","headers","body","qs","alias","then","res","catch","err","error","generateCommonErrorMetadata","reject","_buildClientEventFetchRequestOptions","_asyncToGenerator2","_regenerator","mark","_callee","_ref8","wrap","_callee$","_context","prev","next","abrupt","buildClientEventFetchRequestOptions","stop","_x","setMetricTimingsAndFetch","setTimingsAndFetch","setMetricTimings","isServiceErrorExpected","serviceErrorCode","WebexPlugin","_default","exports"],"sources":["new-metrics.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable class-methods-use-this */\n/* eslint-disable valid-jsdoc */\n\n// @ts-ignore\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';\nimport BehavioralMetrics from './behavioral-metrics';\nimport OperationalMetrics from './operational-metrics';\nimport BusinessMetrics from './business-metrics';\nimport {\n RecursivePartial,\n MetricEventProduct,\n MetricEventAgent,\n MetricEventVerb,\n ClientEvent,\n FeatureEvent,\n EventPayload,\n OperationalEvent,\n MediaQualityEvent,\n InternalEvent,\n SubmitClientEventOptions,\n} from './metrics.types';\nimport CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';\nimport {setMetricTimings} from './call-diagnostic/call-diagnostic-metrics.util';\nimport {generateCommonErrorMetadata} from './utils';\n\n/**\n * Metrics plugin to centralize all types of metrics.\n * @class\n */\nclass Metrics extends WebexPlugin {\n // eslint-disable-next-line no-use-before-define\n static instance: Metrics;\n\n // Call Diagnostic latencies\n callDiagnosticLatencies: CallDiagnosticLatencies;\n // Helper classes to handle the different types of metrics\n callDiagnosticMetrics: CallDiagnosticMetrics;\n behavioralMetrics: BehavioralMetrics;\n operationalMetrics: OperationalMetrics;\n businessMetrics: BusinessMetrics;\n isReady = false;\n\n /**\n * Constructor\n * @param args\n * @constructor\n * @private\n * @returns\n */\n constructor(...args) {\n super(...args);\n\n // @ts-ignore\n this.callDiagnosticLatencies = new CallDiagnosticLatencies({}, {parent: this.webex});\n this.onReady();\n }\n\n /**\n * On Ready\n */\n private onReady() {\n // @ts-ignore\n this.webex.once('ready', () => {\n // @ts-ignore\n this.callDiagnosticMetrics = new CallDiagnosticMetrics({}, {parent: this.webex});\n this.isReady = true;\n });\n }\n\n /**\n * Used for internal purposes only\n * @param args\n */\n submitInternalEvent({\n name,\n payload,\n options,\n }: {\n name: InternalEvent['name'];\n payload?: RecursivePartial<InternalEvent['payload']>;\n options?: any;\n }) {\n if (name === 'internal.reset.join.latencies') {\n this.callDiagnosticLatencies.clearTimestamps();\n } else {\n this.callDiagnosticLatencies.saveTimestamp({key: name});\n }\n }\n\n /**\n * @returns true once we have the deviceId we need to submit behavioral events to Amplitude\n */\n isReadyToSubmitBehavioralEvents() {\n return this.behavioralMetrics?.isReadyToSubmitEvents() ?? false;\n }\n\n /**\n * @returns true once we have the deviceId we need to submit operational events\n */\n isReadyToSubmitOperationalEvents() {\n return this.operationalMetrics?.isReadyToSubmitEvents() ?? false;\n }\n\n /**\n * @returns true once we have the deviceId we need to submit buisness events\n */\n isReadyToSubmitBusinessEvents() {\n return this.businessMetrics?.isReadyToSubmitEvents() ?? false;\n }\n\n /**\n * Behavioral event\n * @param args\n */\n submitBehavioralEvent({\n product,\n agent,\n target,\n verb,\n payload,\n }: {\n product: MetricEventProduct;\n agent: MetricEventAgent;\n target: string;\n verb: MetricEventVerb;\n payload?: EventPayload;\n }) {\n if (!this.isReady) {\n // @ts-ignore\n this.webex.logger.log(\n `NewMetrics: @submitBehavioralEvent. Attempted to submit before webex.ready: ${product}.${agent}.${target}.${verb}`\n );\n\n return Promise.resolve();\n }\n\n if (!this.behavioralMetrics) {\n // @ts-ignore\n this.behavioralMetrics = new BehavioralMetrics({}, {parent: this.webex});\n }\n\n return this.behavioralMetrics.submitBehavioralEvent({product, agent, target, verb, payload});\n }\n\n /**\n * Operational event\n * @param args\n */\n submitOperationalEvent({name, payload}: {name: string; payload?: EventPayload}) {\n if (!this.isReady) {\n // @ts-ignore\n this.webex.logger.log(\n `NewMetrics: @submitOperationalEvent. Attempted to submit before webex.ready: ${name}`\n );\n\n return Promise.resolve();\n }\n\n if (!this.operationalMetrics) {\n // @ts-ignore\n this.operationalMetrics = new OperationalMetrics({}, {parent: this.webex});\n }\n\n return this.operationalMetrics.submitOperationalEvent({name, payload});\n }\n\n /**\n * Buisness event\n * @param args\n */\n submitBusinessEvent({name, payload}: {name: string; payload: EventPayload}) {\n if (!this.isReady) {\n // @ts-ignore\n this.webex.logger.log(\n `NewMetrics: @submitBusinessEvent. Attempted to submit before webex.ready: ${name}`\n );\n\n return Promise.resolve();\n }\n\n if (!this.businessMetrics) {\n // @ts-ignore\n this.businessMetrics = new BusinessMetrics({}, {parent: this.webex});\n }\n\n return this.businessMetrics.submitBusinessEvent({name, payload});\n }\n\n /**\n * Call Analyzer: Media Quality Event\n * @param args\n */\n submitMQE({\n name,\n payload,\n options,\n }: {\n name: MediaQualityEvent['name'];\n payload: RecursivePartial<MediaQualityEvent['payload']> & {\n intervals: MediaQualityEvent['payload']['intervals'];\n };\n options: any;\n }) {\n this.callDiagnosticLatencies.saveTimestamp({key: name});\n this.callDiagnosticMetrics.submitMQE({name, payload, options});\n }\n\n /**\n * Call Analyzer: Feature Usage Event\n * @param args\n */\n submitFeatureEvent({\n name,\n payload,\n options,\n }: {\n name: FeatureEvent['name'];\n payload?: RecursivePartial<FeatureEvent['payload']>;\n options: any;\n }) {\n throw new Error('Not implemented.');\n }\n\n /**\n * Call Analyzer: Client Event\n * @public\n * @param args\n */\n public submitClientEvent({\n name,\n payload,\n options,\n }: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n }): Promise<any> {\n if (!this.callDiagnosticLatencies || !this.callDiagnosticMetrics) {\n // @ts-ignore\n this.webex.logger.log(\n `NewMetrics: @submitClientEvent. Attempted to submit before webex.ready. Event name: ${name}`\n );\n\n return Promise.resolve();\n }\n this.callDiagnosticLatencies.saveTimestamp({\n key: name,\n options: {meetingId: options?.meetingId},\n });\n\n return this.callDiagnosticMetrics.submitClientEvent({name, payload, options});\n }\n\n /**\n * Issue request to alias a user's pre-login ID with their CI UUID\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n public clientMetricsAliasUser(preLoginId: string) {\n // @ts-ignore\n return this.webex\n .request({\n method: 'POST',\n api: 'metrics',\n resource: 'clientmetrics',\n headers: {\n 'x-prelogin-userid': preLoginId,\n },\n body: {},\n qs: {\n alias: true,\n },\n })\n .then((res) => {\n // @ts-ignore\n this.webex.logger.log(`NewMetrics: @clientMetricsAliasUser. Request successful.`);\n\n return res;\n })\n .catch((err) => {\n // @ts-ignore\n this.logger.error(\n `NewMetrics: @clientMetricsAliasUser. Request failed:`,\n `err: ${generateCommonErrorMetadata(err)}`\n );\n\n return Promise.reject(err);\n });\n }\n\n /**\n * Returns a promise that will resolve to fetch options for submitting a metric.\n *\n * This is to support quickly submitting metrics when the browser/tab is closing.\n * Calling submitClientEvent will not work because there some async steps that will\n * not complete before the browser is closed. Instead, we pre-gather all the\n * information/options needed for the request(s), and then simply and quickly\n * fire the fetch(es) when beforeUnload is triggered.\n *\n * We must use fetch instead of request because fetch has a keepalive option that\n * allows the request it to outlive the page.\n *\n * Note: the timings values will be wrong, but setMetricTimingsAndFetch() will\n * properly adjust them before submitting.\n *\n * @public\n * @param {Object} arg\n * @param {String} arg.name - event name\n * @param {Object} arg.payload - event payload\n * @param {Object} arg.options - other options\n * @returns {Promise} promise that resolves to options to be used with fetch\n */\n public async buildClientEventFetchRequestOptions({\n name,\n payload,\n options,\n }: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n }): Promise<any> {\n return this.callDiagnosticMetrics.buildClientEventFetchRequestOptions({\n name,\n payload,\n options,\n });\n }\n\n /**\n * Submits a metric from pre-built request options via the fetch API. Updates\n * the \"$timings\" and \"originTime\" values to Date.now() since the existing times\n * were set when the options were built (not submitted).\n\n * @param {any} options - the pre-built request options for submitting a metric\n * @returns {Promise} promise that resolves to the response object\n */\n public setMetricTimingsAndFetch(options: any): Promise<any> {\n // @ts-ignore\n return this.webex.setTimingsAndFetch(setMetricTimings(options));\n }\n\n /**\n * Returns true if the specified serviceErrorCode maps to an expected error.\n * @param {number} serviceErrorCode the service error code\n * @returns {boolean}\n */\n public isServiceErrorExpected(serviceErrorCode: number): boolean {\n return this.callDiagnosticMetrics.isServiceErrorExpected(serviceErrorCode);\n }\n}\n\nexport default Metrics;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,mBAAA,GAA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AA+G,QAAA,GAAAC,OAAA,CAAAhI,OAAA,GAkUEgB,OAAO"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
4
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
5
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
+ _Object$defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.default = void 0;
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
15
+ var _genericMetrics = _interopRequireDefault(require("./generic-metrics"));
16
+ 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); }; }
17
+ 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; } }
18
+ /**
19
+ * @description Util class to handle Operational Metrics
20
+ * @export
21
+ * @class OperationalMetrics
22
+ */
23
+ var OperationalMetrics = exports.default = /*#__PURE__*/function (_GenericMetrics) {
24
+ (0, _inherits2.default)(OperationalMetrics, _GenericMetrics);
25
+ var _super = _createSuper(OperationalMetrics);
26
+ function OperationalMetrics() {
27
+ (0, _classCallCheck2.default)(this, OperationalMetrics);
28
+ return _super.apply(this, arguments);
29
+ }
30
+ (0, _createClass2.default)(OperationalMetrics, [{
31
+ key: "submitOperationalEvent",
32
+ value:
33
+ /**
34
+ * Submit an operational metric to our metrics endpoint.
35
+ * @param {string} name of the metric
36
+ * @param {EventPayload} user payload of the metric
37
+ * @returns {Promise<any>}
38
+ */
39
+ function submitOperationalEvent(_ref) {
40
+ var name = _ref.name,
41
+ payload = _ref.payload;
42
+ var event = this.createTaggedEventObject({
43
+ type: ['operational'],
44
+ name: name,
45
+ payload: payload
46
+ });
47
+ this.submitEvent({
48
+ kind: 'operational-events -> ',
49
+ name: name,
50
+ event: event
51
+ });
52
+ }
53
+ }]);
54
+ return OperationalMetrics;
55
+ }(_genericMetrics.default);
56
+ //# sourceMappingURL=operational-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_genericMetrics","_interopRequireDefault","require","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","OperationalMetrics","exports","_GenericMetrics","_inherits2","_super","_classCallCheck2","_createClass2","key","value","submitOperationalEvent","_ref","name","payload","event","createTaggedEventObject","type","submitEvent","kind","GenericMetrics"],"sources":["operational-metrics.ts"],"sourcesContent":["import GenericMetrics from './generic-metrics';\nimport {EventPayload} from './metrics.types';\n\n/**\n * @description Util class to handle Operational Metrics\n * @export\n * @class OperationalMetrics\n */\nexport default class OperationalMetrics extends GenericMetrics {\n /**\n * Submit an operational metric to our metrics endpoint.\n * @param {string} name of the metric\n * @param {EventPayload} user payload of the metric\n * @returns {Promise<any>}\n */\n public submitOperationalEvent({name, payload}: {name: string; payload: EventPayload}) {\n const event = this.createTaggedEventObject({\n type: ['operational'],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AAPE,OAAO;MAC1C,IAAMC,KAAK,GAAG,IAAI,CAACC,uBAAuB,CAAC;QACzCC,IAAI,EAAE,CAAC,aAAa,CAAC;QACrBJ,IAAI,EAAJA,IAAI;QACJC,OAAO,EAAPA;MACF,CAAC,CAAC;MACF,IAAI,CAACI,WAAW,CAAC;QAACC,IAAI,EAAE,wBAAwB;QAAEN,IAAI,EAAJA,IAAI;QAAEE,KAAK,EAALA;MAAK,CAAC,CAAC;IACjE;EAAC;EAAA,OAAAb,kBAAA;AAAA,EAd6CkB,uBAAc"}
@@ -0,0 +1,25 @@
1
+ import { MetricEventProduct, MetricEventAgent, MetricEventVerb, EventPayload } from './metrics.types';
2
+ import GenericMetrics from './generic-metrics';
3
+ /**
4
+ * @description Util class to handle Behavioral Metrics
5
+ * @export
6
+ * @class BehavioralMetrics
7
+ */
8
+ export default class BehavioralMetrics extends GenericMetrics {
9
+ /**
10
+ * Submit a behavioral metric to our metrics endpoint.
11
+ * @param {MetricEventProduct} product the product from which the metric is being submitted, e.g. 'webex' web client, 'wxcc_desktop'
12
+ * @param {MetricEventAgent} agent the source of the action for this metric
13
+ * @param {string} target the 'thing' that this metric includes information about
14
+ * @param {MetricEventVerb} verb the action that this metric includes information about
15
+ * @param {EventPayload} payload information specific to this event. This should be flat, i.e. it should not include nested objects.
16
+ * @returns {Promise<any>}
17
+ */
18
+ submitBehavioralEvent({ product, agent, target, verb, payload, }: {
19
+ product: MetricEventProduct;
20
+ agent: MetricEventAgent;
21
+ target: string;
22
+ verb: MetricEventVerb;
23
+ payload?: EventPayload;
24
+ }): void;
25
+ }
@@ -0,0 +1,19 @@
1
+ import GenericMetrics from './generic-metrics';
2
+ import { EventPayload } from './metrics.types';
3
+ /**
4
+ * @description Util class to handle Buisness Metrics
5
+ * @export
6
+ * @class BusinessMetrics
7
+ */
8
+ export default class BusinessMetrics extends GenericMetrics {
9
+ /**
10
+ * Submit a buisness metric to our metrics endpoint.
11
+ * @param {string} name of the metric
12
+ * @param {EventPayload} user payload of the metric
13
+ * @returns {Promise<any>}
14
+ */
15
+ submitBusinessEvent({ name, payload }: {
16
+ name: string;
17
+ payload: EventPayload;
18
+ }): void;
19
+ }
@@ -77,7 +77,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
77
77
  environment?: string;
78
78
  newEnvironment?: string;
79
79
  clientInfo?: {
80
- os?: "other" | "chrome" | "windows" | "mac" | "ios" | "android" | "linux" | "android-x64" | "android-arm64" | "uwp-arm64";
80
+ os?: "windows" | "mac" | "ios" | "android" | "chrome" | "linux" | "other" | "android-x64" | "android-arm64" | "uwp-arm64";
81
81
  osVersion?: string;
82
82
  localIP?: string;
83
83
  gatewayIP?: string;
@@ -336,7 +336,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
336
336
  */
337
337
  generateClientEventErrorPayload(rawError: any): {
338
338
  fatal: boolean;
339
- category: "signaling" | "media" | "network" | "other" | "expected";
339
+ category: "other" | "signaling" | "media" | "network" | "expected";
340
340
  errorDescription?: string;
341
341
  errorCode?: number;
342
342
  errorCodeStr?: string;
@@ -0,0 +1,63 @@
1
+ import { StatelessWebexPlugin } from '@webex/webex-core';
2
+ import { DeviceContext, TaggedEvent, EventPayload, MetricType } from './metrics.types';
3
+ /**
4
+ * @description top-level abstract class to handle Metrics and common routines.
5
+ * @export
6
+ * @class GenericMetrics
7
+ */
8
+ export default abstract class GenericMetrics extends StatelessWebexPlugin {
9
+ private clientMetricsBatcher;
10
+ private logger;
11
+ private device;
12
+ private version;
13
+ private deviceId;
14
+ /**
15
+ * Constructor
16
+ * @param {any[]} args
17
+ */
18
+ constructor(...args: any[]);
19
+ /**
20
+ * Submit a buisness metric to our metrics endpoint.
21
+ * @param {string} kind of metric for logging
22
+ * @param {string} name of the metric
23
+ * @param {object} event
24
+ * @returns {Promise<any>}
25
+ */
26
+ protected submitEvent({ kind, name, event }: {
27
+ kind: string;
28
+ name: string;
29
+ event: object;
30
+ }): any;
31
+ /**
32
+ * Returns the deviceId from our registration with WDM.
33
+ * @returns {string} deviceId or empty string
34
+ */
35
+ protected getDeviceId(): string;
36
+ /**
37
+ * Returns the context object to be submitted with all metrics.
38
+ * @returns {DeviceContext}
39
+ */
40
+ protected getContext(): DeviceContext;
41
+ /**
42
+ * Returns the browser details to be included with all metrics.
43
+ * @returns {object}
44
+ */
45
+ protected getBrowserDetails(): object;
46
+ /**
47
+ * Returns true once we have the deviceId we need to submit behavioral/operational/buisness events
48
+ * @returns {boolean}
49
+ */
50
+ isReadyToSubmitEvents(): boolean;
51
+ /**
52
+ * Creates the object to send to our metrics endpoint for a tagged event (i.e. behavoral or operational)
53
+ * @param {[MetricType]} list of event type (i.e. ['behavioral'], ['operational', 'behavioral'])
54
+ * @param {string} metric name
55
+ * @param {EventPayload} user payload
56
+ * @returns {EventPayload}
57
+ */
58
+ protected createTaggedEventObject({ type, name, payload, }: {
59
+ type: [MetricType];
60
+ name: string;
61
+ payload: EventPayload;
62
+ }): TaggedEvent;
63
+ }
@@ -9,7 +9,9 @@ import * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';
9
9
  import * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';
10
10
  import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
11
11
  import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
12
- import BehavioralMetrics from './behavioral/behavioral-metrics';
12
+ import BehavioralMetrics from './behavioral-metrics';
13
+ import OperationalMetrics from './operational-metrics';
14
+ import BusinessMetrics from './business-metrics';
13
15
  export { default, getOSNameInternal } from './metrics';
14
- export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, BehavioralMetrics, };
16
+ export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, BehavioralMetrics, OperationalMetrics, BusinessMetrics, };
15
17
  export type { ClientEvent, ClientEventLeaveReason, SubmitBehavioralEvent, SubmitClientEvent, SubmitInternalEvent, SubmitMQE, SubmitOperationalEvent, PreComputedLatencies, };
@@ -40,7 +40,7 @@ export interface ClientEvent {
40
40
  payload?: RawClientEvent;
41
41
  options?: SubmitClientEventOptions;
42
42
  }
43
- export interface BehavioralEventContext {
43
+ export interface DeviceContext {
44
44
  app: {
45
45
  version: string;
46
46
  };
@@ -53,19 +53,30 @@ export interface BehavioralEventContext {
53
53
  version: string;
54
54
  };
55
55
  }
56
- export interface BehavioralEvent {
57
- context: BehavioralEventContext;
56
+ export type MetricType = 'behavioral' | 'operational' | 'business';
57
+ type InternalEventPayload = string | number | boolean;
58
+ export type EventPayload = Record<string, InternalEventPayload>;
59
+ export type BehavioralEventPayload = EventPayload;
60
+ export interface BusinessEventPayload {
58
61
  metricName: string;
59
- tags: Record<string, string | number | boolean>;
60
62
  timestamp: number;
63
+ context: DeviceContext;
64
+ browserDetails: EventPayload;
65
+ value: EventPayload;
66
+ }
67
+ export interface BusinessEvent {
61
68
  type: string[];
69
+ eventPayload: BusinessEventPayload;
62
70
  }
63
- export type BehavioralEventPayload = BehavioralEvent['tags'];
64
- export interface OperationalEvent {
65
- name: never;
66
- payload?: never;
67
- options?: never;
71
+ export interface TaggedEvent {
72
+ context: DeviceContext;
73
+ metricName: string;
74
+ tags: EventPayload;
75
+ timestamp: number;
76
+ type: [MetricType];
68
77
  }
78
+ export type BehavioralEvent = TaggedEvent;
79
+ export type OperationalEvent = TaggedEvent;
69
80
  export interface FeatureEvent {
70
81
  name: never;
71
82
  payload?: never;
@@ -79,7 +90,7 @@ export interface MediaQualityEvent {
79
90
  export type RecursivePartial<T> = {
80
91
  [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
81
92
  };
82
- export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['metricName'] | OperationalEvent['name'] | FeatureEvent['name'] | MediaQualityEvent['name'];
93
+ export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['metricName'] | OperationalEvent['metricName'] | BusinessEvent['eventPayload']['metricName'] | FeatureEvent['name'] | MediaQualityEvent['name'];
83
94
  export type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;
84
95
  export type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];
85
96
  export type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];
@@ -103,7 +114,7 @@ export type SubmitBehavioralEvent = (args: {
103
114
  agent: MetricEventAgent;
104
115
  target: string;
105
116
  verb: MetricEventVerb;
106
- payload?: BehavioralEventPayload;
117
+ payload?: EventPayload;
107
118
  }) => void;
108
119
  export type SubmitClientEvent = (args: {
109
120
  name: ClientEvent['name'];
@@ -111,9 +122,8 @@ export type SubmitClientEvent = (args: {
111
122
  options?: SubmitClientEventOptions;
112
123
  }) => Promise<any>;
113
124
  export type SubmitOperationalEvent = (args: {
114
- name: OperationalEvent['name'];
115
- payload?: RecursivePartial<OperationalEvent['payload']>;
116
- options?: any;
125
+ name: OperationalEvent['metricName'];
126
+ payload: EventPayload;
117
127
  }) => void;
118
128
  export type SubmitMQE = (args: {
119
129
  name: MediaQualityEvent['name'];
@@ -126,3 +136,4 @@ export type BuildClientEventFetchRequestOptions = (args: {
126
136
  options?: SubmitClientEventOptions;
127
137
  }) => Promise<any>;
128
138
  export type PreComputedLatencies = 'internal.client.pageJMT' | 'internal.download.time' | 'internal.get.cluster.time' | 'internal.click.to.interstitial' | 'internal.refresh.captcha.time' | 'internal.exchange.ci.token.time' | 'internal.get.u2c.time' | 'internal.call.init.join.req' | 'internal.other.app.api.time' | 'internal.api.fetch.intelligence.models';
139
+ export {};
@@ -1,7 +1,9 @@
1
1
  import { WebexPlugin } from '@webex/webex-core';
2
2
  import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
3
- import BehavioralMetrics from './behavioral/behavioral-metrics';
4
- import { RecursivePartial, MetricEventProduct, MetricEventAgent, MetricEventVerb, ClientEvent, FeatureEvent, BehavioralEventPayload, OperationalEvent, MediaQualityEvent, InternalEvent, SubmitClientEventOptions } from './metrics.types';
3
+ import BehavioralMetrics from './behavioral-metrics';
4
+ import OperationalMetrics from './operational-metrics';
5
+ import BusinessMetrics from './business-metrics';
6
+ import { RecursivePartial, MetricEventProduct, MetricEventAgent, MetricEventVerb, ClientEvent, FeatureEvent, EventPayload, MediaQualityEvent, InternalEvent, SubmitClientEventOptions } from './metrics.types';
5
7
  import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
6
8
  /**
7
9
  * Metrics plugin to centralize all types of metrics.
@@ -12,6 +14,9 @@ declare class Metrics extends WebexPlugin {
12
14
  callDiagnosticLatencies: CallDiagnosticLatencies;
13
15
  callDiagnosticMetrics: CallDiagnosticMetrics;
14
16
  behavioralMetrics: BehavioralMetrics;
17
+ operationalMetrics: OperationalMetrics;
18
+ businessMetrics: BusinessMetrics;
19
+ isReady: boolean;
15
20
  /**
16
21
  * Constructor
17
22
  * @param args
@@ -37,6 +42,14 @@ declare class Metrics extends WebexPlugin {
37
42
  * @returns true once we have the deviceId we need to submit behavioral events to Amplitude
38
43
  */
39
44
  isReadyToSubmitBehavioralEvents(): boolean;
45
+ /**
46
+ * @returns true once we have the deviceId we need to submit operational events
47
+ */
48
+ isReadyToSubmitOperationalEvents(): boolean;
49
+ /**
50
+ * @returns true once we have the deviceId we need to submit buisness events
51
+ */
52
+ isReadyToSubmitBusinessEvents(): boolean;
40
53
  /**
41
54
  * Behavioral event
42
55
  * @param args
@@ -46,17 +59,24 @@ declare class Metrics extends WebexPlugin {
46
59
  agent: MetricEventAgent;
47
60
  target: string;
48
61
  verb: MetricEventVerb;
49
- payload?: BehavioralEventPayload;
50
- }): any;
62
+ payload?: EventPayload;
63
+ }): void | Promise<void>;
51
64
  /**
52
65
  * Operational event
53
66
  * @param args
54
67
  */
55
- submitOperationalEvent({ name, payload, options, }: {
56
- name: OperationalEvent['name'];
57
- payload?: RecursivePartial<OperationalEvent['payload']>;
58
- options?: any;
59
- }): void;
68
+ submitOperationalEvent({ name, payload }: {
69
+ name: string;
70
+ payload?: EventPayload;
71
+ }): void | Promise<void>;
72
+ /**
73
+ * Buisness event
74
+ * @param args
75
+ */
76
+ submitBusinessEvent({ name, payload }: {
77
+ name: string;
78
+ payload: EventPayload;
79
+ }): void | Promise<void>;
60
80
  /**
61
81
  * Call Analyzer: Media Quality Event
62
82
  * @param args