@webex/internal-plugin-metrics 3.0.0-beta.386 → 3.0.0-beta.387

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.
package/dist/metrics.js CHANGED
@@ -165,7 +165,7 @@ var Metrics = _webexCore.WebexPlugin.extend({
165
165
  });
166
166
  });
167
167
  },
168
- version: "3.0.0-beta.386"
168
+ version: "3.0.0-beta.387"
169
169
  });
170
170
  var _default = Metrics;
171
171
  exports.default = _default;
@@ -51,8 +51,13 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
51
51
  args[_key] = arguments[_key];
52
52
  }
53
53
  _this = _super.call.apply(_super, [this].concat(args));
54
+
55
+ // @ts-ignore
54
56
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticLatencies", void 0);
55
57
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticMetrics", void 0);
58
+ _this.callDiagnosticLatencies = new _callDiagnosticMetricsLatencies.default({}, {
59
+ parent: _this.webex
60
+ });
56
61
  _this.onReady();
57
62
  return _this;
58
63
  }
@@ -70,10 +75,6 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
70
75
  _this2.callDiagnosticMetrics = new _callDiagnosticMetrics.default({}, {
71
76
  parent: _this2.webex
72
77
  });
73
- // @ts-ignore
74
- _this2.callDiagnosticLatencies = new _callDiagnosticMetricsLatencies.default({}, {
75
- parent: _this2.webex
76
- });
77
78
  });
78
79
  }
79
80
 
@@ -1 +1 @@
1
- {"version":3,"names":["Metrics","args","onReady","webex","once","callDiagnosticMetrics","CallDiagnosticMetrics","parent","callDiagnosticLatencies","CallDiagnosticLatencies","name","payload","options","clearTimestamps","saveTimestamp","key","Error","submitMQE","logger","log","resolve","meetingId","submitClientEvent","preLoginId","request","method","api","resource","headers","body","qs","alias","then","res","catch","err","error","generateCommonErrorMetadata","reject","buildClientEventFetchRequestOptions","setTimingsAndFetch","setMetricTimings","serviceErrorCode","isServiceErrorExpected","WebexPlugin"],"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 {\n RecursivePartial,\n ClientEvent,\n FeatureEvent,\n BehavioralEvent,\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\n /**\n * Constructor\n * @param args\n * @constructor\n * @private\n * @returns\n */\n constructor(...args) {\n super(...args);\n\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.callDiagnosticLatencies = new CallDiagnosticLatencies({}, {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 * Behavioral event\n * @param args\n */\n submitBehavioralEvent({\n name,\n payload,\n options,\n }: {\n name: BehavioralEvent['name'];\n payload?: RecursivePartial<BehavioralEvent['payload']>;\n options?: any;\n }) {\n this.callDiagnosticLatencies.saveTimestamp({key: name});\n throw new Error('Not implemented.');\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;AAEA;AAWA;AACA;AACA;AAAoD;AAAA;AAEpD;AACA;AACA;AACA;AAHA,IAIMA,OAAO;EAAA;EAAA;EACX;;EAGA;;EAEA;;EAGA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,mBAAqB;IAAA;IAAA;IAAA,kCAANC,IAAI;MAAJA,IAAI;IAAA;IACjB,gDAASA,IAAI;IAAE;IAAA;IAEf,MAAKC,OAAO,EAAE;IAAC;EACjB;;EAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,mBAAkB;MAAA;MAChB;MACA,IAAI,CAACC,KAAK,CAACC,IAAI,CAAC,OAAO,EAAE,YAAM;QAC7B;QACA,MAAI,CAACC,qBAAqB,GAAG,IAAIC,8BAAqB,CAAC,CAAC,CAAC,EAAE;UAACC,MAAM,EAAE,MAAI,CAACJ;QAAK,CAAC,CAAC;QAChF;QACA,MAAI,CAACK,uBAAuB,GAAG,IAAIC,uCAAuB,CAAC,CAAC,CAAC,EAAE;UAACF,MAAM,EAAE,MAAI,CAACJ;QAAK,CAAC,CAAC;MACtF,CAAC,CAAC;IACJ;;IAEA;AACF;AACA;AACA;EAHE;IAAA;IAAA,OAIA,mCAQG;MAAA,IAPDO,IAAI,QAAJA,IAAI;QACJC,OAAO,QAAPA,OAAO;QACPC,OAAO,QAAPA,OAAO;MAMP,IAAIF,IAAI,KAAK,+BAA+B,EAAE;QAC5C,IAAI,CAACF,uBAAuB,CAACK,eAAe,EAAE;MAChD,CAAC,MAAM;QACL,IAAI,CAACL,uBAAuB,CAACM,aAAa,CAAC;UAACC,GAAG,EAAEL;QAAI,CAAC,CAAC;MACzD;IACF;;IAEA;AACF;AACA;AACA;EAHE;IAAA;IAAA,OAIA,sCAQG;MAAA,IAPDA,IAAI,SA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,SAAPA,OAAO,EACPC,OAAO,SAAPA,OAAO;cAAA,iCAMA,IAAI,CAACP,qBAAqB,CAACkC,mCAAmC,CAAC;gBACpE7B,IAAI,EAAJA,IAAI;gBACJC,OAAO,EAAPA,OAAO;gBACPC,OAAO,EAAPA;cACF,CAAC,CAAC;YAAA;YAAA;cAAA;UAAA;QAAA;MAAA,CACH;MAAA;QAAA;MAAA;MAAA;IAAA;IAED;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAQA,kCAAgCA,OAAY,EAAgB;MAC1D;MACA,OAAO,IAAI,CAACT,KAAK,CAACqC,kBAAkB,CAAC,IAAAC,wCAAgB,EAAC7B,OAAO,CAAC,CAAC;IACjE;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,gCAA8B8B,gBAAwB,EAAW;MAC/D,OAAO,IAAI,CAACrC,qBAAqB,CAACsC,sBAAsB,CAACD,gBAAgB,CAAC;IAC5E;EAAC;EAAA;AAAA,EAxPmBE,sBAAW;AAAA,8BAA3B5C,OAAO;AAAA,eA2PEA,OAAO;AAAA"}
1
+ {"version":3,"names":["Metrics","args","callDiagnosticLatencies","CallDiagnosticLatencies","parent","webex","onReady","once","callDiagnosticMetrics","CallDiagnosticMetrics","name","payload","options","clearTimestamps","saveTimestamp","key","Error","submitMQE","logger","log","resolve","meetingId","submitClientEvent","preLoginId","request","method","api","resource","headers","body","qs","alias","then","res","catch","err","error","generateCommonErrorMetadata","reject","buildClientEventFetchRequestOptions","setTimingsAndFetch","setMetricTimings","serviceErrorCode","isServiceErrorExpected","WebexPlugin"],"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 {\n RecursivePartial,\n ClientEvent,\n FeatureEvent,\n BehavioralEvent,\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\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 });\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 * Behavioral event\n * @param args\n */\n submitBehavioralEvent({\n name,\n payload,\n options,\n }: {\n name: BehavioralEvent['name'];\n payload?: RecursivePartial<BehavioralEvent['payload']>;\n options?: any;\n }) {\n this.callDiagnosticLatencies.saveTimestamp({key: name});\n throw new Error('Not implemented.');\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;AAEA;AAWA;AACA;AACA;AAAoD;AAAA;AAEpD;AACA;AACA;AACA;AAHA,IAIMA,OAAO;EAAA;EAAA;EACX;;EAGA;;EAEA;;EAGA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A;AACA;AACA;EANE;IAAA;IAAA,OAQA,kCAAgCA,OAAY,EAAgB;MAC1D;MACA,OAAO,IAAI,CAACP,KAAK,CAACmC,kBAAkB,CAAC,IAAAC,wCAAgB,EAAC7B,OAAO,CAAC,CAAC;IACjE;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,gCAA8B8B,gBAAwB,EAAW;MAC/D,OAAO,IAAI,CAAClC,qBAAqB,CAACmC,sBAAsB,CAACD,gBAAgB,CAAC;IAC5E;EAAC;EAAA;AAAA,EAxPmBE,sBAAW;AAAA,8BAA3B5C,OAAO;AAAA,eA2PEA,OAAO;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-metrics",
3
- "version": "3.0.0-beta.386",
3
+ "version": "3.0.0-beta.387",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -28,14 +28,14 @@
28
28
  "build": "yarn run -T tsc --declaration true --declarationDir ./dist/types"
29
29
  },
30
30
  "dependencies": {
31
- "@webex/common": "3.0.0-beta.386",
32
- "@webex/common-timers": "3.0.0-beta.386",
31
+ "@webex/common": "3.0.0-beta.387",
32
+ "@webex/common-timers": "3.0.0-beta.387",
33
33
  "@webex/event-dictionary-ts": "^1.0.1329",
34
- "@webex/internal-plugin-device": "3.0.0-beta.386",
35
- "@webex/internal-plugin-metrics": "3.0.0-beta.386",
36
- "@webex/test-helper-chai": "3.0.0-beta.386",
37
- "@webex/test-helper-mock-webex": "3.0.0-beta.386",
38
- "@webex/webex-core": "3.0.0-beta.386",
34
+ "@webex/internal-plugin-device": "3.0.0-beta.387",
35
+ "@webex/internal-plugin-metrics": "3.0.0-beta.387",
36
+ "@webex/test-helper-chai": "3.0.0-beta.387",
37
+ "@webex/test-helper-mock-webex": "3.0.0-beta.387",
38
+ "@webex/webex-core": "3.0.0-beta.387",
39
39
  "ip-anonymize": "^0.1.0",
40
40
  "lodash": "^4.17.21",
41
41
  "uuid": "^3.3.2"
@@ -43,6 +43,8 @@ class Metrics extends WebexPlugin {
43
43
  constructor(...args) {
44
44
  super(...args);
45
45
 
46
+ // @ts-ignore
47
+ this.callDiagnosticLatencies = new CallDiagnosticLatencies({}, {parent: this.webex});
46
48
  this.onReady();
47
49
  }
48
50
 
@@ -54,8 +56,6 @@ class Metrics extends WebexPlugin {
54
56
  this.webex.once('ready', () => {
55
57
  // @ts-ignore
56
58
  this.callDiagnosticMetrics = new CallDiagnosticMetrics({}, {parent: this.webex});
57
- // @ts-ignore
58
- this.callDiagnosticLatencies = new CallDiagnosticLatencies({}, {parent: this.webex});
59
59
  });
60
60
  }
61
61
 
@@ -1,29 +1,31 @@
1
1
  import {assert} from '@webex/test-helper-chai';
2
- import {NewMetrics} from '@webex/internal-plugin-metrics';
2
+ import {NewMetrics, CallDiagnosticLatencies} from '@webex/internal-plugin-metrics';
3
3
  import MockWebex from '@webex/test-helper-mock-webex';
4
4
  import sinon from 'sinon';
5
5
  import {Utils} from '@webex/internal-plugin-metrics';
6
6
 
7
7
  describe('internal-plugin-metrics', () => {
8
8
 
9
+ const mockWebex = () => new MockWebex({
10
+ children: {
11
+ newMetrics: NewMetrics,
12
+ },
13
+ meetings: {
14
+ meetingCollection: {
15
+ get: sinon.stub(),
16
+ },
17
+ },
18
+ request: sinon.stub().resolves({}),
19
+ logger: {
20
+ log: sinon.stub(),
21
+ error: sinon.stub(),
22
+ }
23
+ });
24
+
9
25
  describe('check submitClientEvent when webex is not ready', () => {
10
26
  let webex;
11
27
  //@ts-ignore
12
- webex = new MockWebex({
13
- children: {
14
- newMetrics: NewMetrics,
15
- },
16
- meetings: {
17
- meetingCollection: {
18
- get: sinon.stub(),
19
- },
20
- },
21
- request: sinon.stub().resolves({}),
22
- logger: {
23
- log: sinon.stub(),
24
- error: sinon.stub(),
25
- }
26
- });
28
+ webex = mockWebex();
27
29
 
28
30
  it('checks the log', () => {
29
31
  webex.internal.newMetrics.submitClientEvent({
@@ -39,26 +41,21 @@ describe('internal-plugin-metrics', () => {
39
41
  });
40
42
  });
41
43
 
44
+ describe('new-metrics contstructor', () => {
45
+ it('checks callDiagnosticLatencies is defined before ready emit', () => {
46
+
47
+ const webex = mockWebex();
48
+
49
+ assert.instanceOf(webex.internal.newMetrics.callDiagnosticLatencies, CallDiagnosticLatencies);
50
+ });
51
+ });
52
+
42
53
  describe('new-metrics', () => {
43
54
  let webex;
44
55
 
45
56
  beforeEach(() => {
46
57
  //@ts-ignore
47
- webex = new MockWebex({
48
- children: {
49
- newMetrics: NewMetrics,
50
- },
51
- meetings: {
52
- meetingCollection: {
53
- get: sinon.stub(),
54
- },
55
- },
56
- request: sinon.stub().resolves({}),
57
- logger: {
58
- log: sinon.stub(),
59
- error: sinon.stub(),
60
- }
61
- });
58
+ webex = mockWebex();
62
59
 
63
60
  webex.emit('ready');
64
61