@webex/internal-plugin-metrics 3.3.1 → 3.4.0
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/behavioral/behavioral-metrics.js +199 -0
- package/dist/behavioral/behavioral-metrics.js.map +1 -0
- package/dist/behavioral/config.js +11 -0
- package/dist/behavioral/config.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +3 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +14 -11
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
- package/dist/call-diagnostic/config.js +19 -13
- package/dist/call-diagnostic/config.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +31 -6
- package/dist/new-metrics.js.map +1 -1
- package/dist/types/behavioral/behavioral-metrics.d.ts +63 -0
- package/dist/types/behavioral/config.d.ts +1 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +3 -2
- package/dist/types/call-diagnostic/config.d.ts +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/metrics.types.d.ts +28 -7
- package/dist/types/new-metrics.d.ts +14 -6
- package/package.json +11 -11
- package/src/behavioral/behavioral-metrics.ts +179 -0
- package/src/behavioral/config.ts +3 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +3 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +16 -17
- package/src/call-diagnostic/config.ts +9 -2
- package/src/index.ts +2 -0
- package/src/metrics.types.ts +59 -8
- package/src/new-metrics.ts +34 -8
- package/test/unit/spec/behavioral/behavioral-metrics.ts +164 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +48 -52
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +9 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +41 -22
- package/test/unit/spec/prelogin-metrics-batcher.ts +1 -1
package/dist/new-metrics.js
CHANGED
|
@@ -19,6 +19,7 @@ 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
23
|
var _callDiagnosticMetricsLatencies = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics-latencies"));
|
|
23
24
|
var _callDiagnosticMetrics2 = require("./call-diagnostic/call-diagnostic-metrics.util");
|
|
24
25
|
var _utils = require("./utils");
|
|
@@ -56,6 +57,7 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
|
|
|
56
57
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticLatencies", void 0);
|
|
57
58
|
// Helper classes to handle the different types of metrics
|
|
58
59
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticMetrics", void 0);
|
|
60
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "behavioralMetrics", void 0);
|
|
59
61
|
_this.callDiagnosticLatencies = new _callDiagnosticMetricsLatencies.default({}, {
|
|
60
62
|
parent: _this.webex
|
|
61
63
|
});
|
|
@@ -76,6 +78,10 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
|
|
|
76
78
|
_this2.callDiagnosticMetrics = new _callDiagnosticMetrics.default({}, {
|
|
77
79
|
parent: _this2.webex
|
|
78
80
|
});
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
_this2.behavioralMetrics = new _behavioralMetrics.default({}, {
|
|
83
|
+
parent: _this2.webex
|
|
84
|
+
});
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -98,6 +104,15 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
|
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @returns true once we have the deviceId we need to submit behavioral events to Amplitude
|
|
109
|
+
*/
|
|
110
|
+
}, {
|
|
111
|
+
key: "isReadyToSubmitBehavioralEvents",
|
|
112
|
+
value: function isReadyToSubmitBehavioralEvents() {
|
|
113
|
+
return this.behavioralMetrics.isReadyToSubmitBehavioralEvents();
|
|
114
|
+
}
|
|
115
|
+
|
|
101
116
|
/**
|
|
102
117
|
* Behavioral event
|
|
103
118
|
* @param args
|
|
@@ -105,13 +120,23 @@ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
|
|
|
105
120
|
}, {
|
|
106
121
|
key: "submitBehavioralEvent",
|
|
107
122
|
value: function submitBehavioralEvent(_ref2) {
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
var product = _ref2.product,
|
|
124
|
+
agent = _ref2.agent,
|
|
125
|
+
target = _ref2.target,
|
|
126
|
+
verb = _ref2.verb,
|
|
127
|
+
payload = _ref2.payload;
|
|
128
|
+
if (!this.behavioralMetrics) {
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
this.webex.logger.log("NewMetrics: @submitBehavioralEvent. Attempted to submit before webex.ready: ".concat(product, ".").concat(agent, ".").concat(target, ".").concat(verb));
|
|
131
|
+
return _promise.default.resolve();
|
|
132
|
+
}
|
|
133
|
+
return this.behavioralMetrics.submitBehavioralEvent({
|
|
134
|
+
product: product,
|
|
135
|
+
agent: agent,
|
|
136
|
+
target: target,
|
|
137
|
+
verb: verb,
|
|
138
|
+
payload: payload
|
|
113
139
|
});
|
|
114
|
-
throw new Error('Not implemented.');
|
|
115
140
|
}
|
|
116
141
|
|
|
117
142
|
/**
|
package/dist/new-metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_webexCore","require","_callDiagnosticMetrics","_interopRequireDefault","_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","submitInternalEvent","_ref","name","payload","options","clearTimestamps","saveTimestamp","submitBehavioralEvent","_ref2","Error","submitOperationalEvent","_ref3","submitMQE","_ref4","submitFeatureEvent","_ref5","submitClientEvent","_ref6","logger","log","_promise","resolve","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 {\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,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAWA,IAAAG,+BAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AAC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0F,mCAAA;IAAA;IAED;AACF;AACA;AACA;AACA;AACA;AACA;IANE;EAAA;IAAA3D,GAAA;IAAAC,KAAA,EAQA,SAAA6D,yBAAgCpD,OAAY,EAAgB;MAC1D;MACA,OAAO,IAAI,CAACb,KAAK,CAACkE,kBAAkB,CAAC,IAAAC,wCAAgB,EAACtD,OAAO,CAAC,CAAC;IACjE;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAAV,GAAA;IAAAC,KAAA,EAKA,SAAAgE,uBAA8BC,gBAAwB,EAAW;MAC/D,OAAO,IAAI,CAAC9D,qBAAqB,CAAC6D,sBAAsB,CAACC,gBAAgB,CAAC;IAC5E;EAAC;EAAA,OAAAtF,OAAA;AAAA,EAxPmBuF,sBAAW;AAAA/G,MAAA,GAA3BwB,OAAO;AACX;AAAA,IAAAY,gBAAA,CAAA5B,OAAA,EADIgB,OAAO;AAAA,IAAAwF,QAAA,GAAAC,OAAA,CAAAzG,OAAA,GA2PEgB,OAAO"}
|
|
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,KA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A+F,QAAA,GAAAC,OAAA,CAAAhH,OAAA,GAiREgB,OAAO"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { StatelessWebexPlugin } from '@webex/webex-core';
|
|
2
|
+
import { MetricEventProduct, MetricEventAgent, MetricEventVerb, BehavioralEventPayload } from '../metrics.types';
|
|
3
|
+
/**
|
|
4
|
+
* @description Util class to handle Behavioral Metrics
|
|
5
|
+
* @export
|
|
6
|
+
* @class BehavioralMetrics
|
|
7
|
+
*/
|
|
8
|
+
export default class BehavioralMetrics extends StatelessWebexPlugin {
|
|
9
|
+
private clientMetricsBatcher;
|
|
10
|
+
private logger;
|
|
11
|
+
private device;
|
|
12
|
+
private version;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
* @param {any[]} args
|
|
16
|
+
*/
|
|
17
|
+
constructor(...args: any[]);
|
|
18
|
+
/**
|
|
19
|
+
* Returns the deviceId from our registration with WDM.
|
|
20
|
+
* @returns {string} deviceId or empty string
|
|
21
|
+
*/
|
|
22
|
+
private getDeviceId;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the context object to be submitted with all behavioral metrics.
|
|
25
|
+
* @returns {BehavioralEventContext}
|
|
26
|
+
*/
|
|
27
|
+
private getContext;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the default tags to be included with all behavioral metrics.
|
|
30
|
+
* @returns {BehavioralEventPayload}
|
|
31
|
+
*/
|
|
32
|
+
private getDefaultTags;
|
|
33
|
+
/**
|
|
34
|
+
* Creates the object to send to our metrics endpoint for a behavioral event
|
|
35
|
+
* @param {MetricEventProduct} product
|
|
36
|
+
* @param {MetricEventAgent} agent
|
|
37
|
+
* @param {string} target
|
|
38
|
+
* @param {MetricEventVerb} verb
|
|
39
|
+
* @returns {BehavioralEventPayload}
|
|
40
|
+
*/
|
|
41
|
+
private createEventObject;
|
|
42
|
+
/**
|
|
43
|
+
* Returns true once we're ready to submit behavioral metrics, after startup.
|
|
44
|
+
* @returns {boolean} true when deviceId is defined and non-empty
|
|
45
|
+
*/
|
|
46
|
+
isReadyToSubmitBehavioralEvents(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Submit a behavioral metric to our metrics endpoint.
|
|
49
|
+
* @param {MetricEventProduct} product the product from which the metric is being submitted, e.g. 'webex' web client, 'wxcc_desktop'
|
|
50
|
+
* @param {MetricEventAgent} agent the source of the action for this metric
|
|
51
|
+
* @param {string} target the 'thing' that this metric includes information about
|
|
52
|
+
* @param {MetricEventVerb} verb the action that this metric includes information about
|
|
53
|
+
* @param {BehavioralEventPayload} payload information specific to this event. This should be flat, i.e. it should not include nested objects.
|
|
54
|
+
* @returns {Promise<any>}
|
|
55
|
+
*/
|
|
56
|
+
submitBehavioralEvent({ product, agent, target, verb, payload, }: {
|
|
57
|
+
product: MetricEventProduct;
|
|
58
|
+
agent: MetricEventAgent;
|
|
59
|
+
target: string;
|
|
60
|
+
verb: MetricEventVerb;
|
|
61
|
+
payload?: BehavioralEventPayload;
|
|
62
|
+
}): any;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BEHAVIORAL_LOG_IDENTIFIER = "behavioral-events -> ";
|
|
@@ -96,8 +96,9 @@ export declare const extractVersionMetadata: (version: string) => {
|
|
|
96
96
|
* Generates client error codes for specific ice failures
|
|
97
97
|
* that happen when trying to add media in a meeting.
|
|
98
98
|
*/
|
|
99
|
-
export declare const generateClientErrorCodeForIceFailure: ({ signalingState,
|
|
99
|
+
export declare const generateClientErrorCodeForIceFailure: ({ signalingState, iceConnected, turnServerUsed, unreachable, }: {
|
|
100
100
|
signalingState: RTCPeerConnection['signalingState'];
|
|
101
|
-
|
|
101
|
+
iceConnected: boolean;
|
|
102
102
|
turnServerUsed: boolean;
|
|
103
|
+
unreachable: boolean;
|
|
103
104
|
}) => number;
|
|
@@ -10,6 +10,7 @@ export declare const MISSING_ROAP_ANSWER_CLIENT_CODE = 2007;
|
|
|
10
10
|
export declare const DTLS_HANDSHAKE_FAILED_CLIENT_CODE = 2008;
|
|
11
11
|
export declare const ICE_FAILED_WITH_TURN_TLS_CLIENT_CODE = 2010;
|
|
12
12
|
export declare const ICE_FAILED_WITHOUT_TURN_TLS_CLIENT_CODE = 2009;
|
|
13
|
+
export declare const ICE_AND_REACHABILITY_FAILED_CLIENT_CODE = 2011;
|
|
13
14
|
export declare const WBX_APP_API_URL = "wbxappapi";
|
|
14
15
|
export declare const WEBEX_SUB_SERVICE_TYPES: Record<string, ClientSubServiceType>;
|
|
15
16
|
export declare const BROWSER_MEDIA_ERROR_NAME_TO_CLIENT_ERROR_CODES_MAP: {
|
|
@@ -92,6 +93,7 @@ export declare const ERROR_DESCRIPTIONS: {
|
|
|
92
93
|
DTLS_HANDSHAKE_FAILED: string;
|
|
93
94
|
ICE_FAILED_WITHOUT_TURN_TLS: string;
|
|
94
95
|
ICE_FAILED_WITH_TURN_TLS: string;
|
|
96
|
+
ICE_AND_REACHABILITY_FAILED: string;
|
|
95
97
|
SDP_OFFER_CREATION_ERROR: string;
|
|
96
98
|
SDP_OFFER_CREATION_ERROR_MISSING_CODEC: string;
|
|
97
99
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ 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
13
|
export { default, getOSNameInternal } from './metrics';
|
|
13
|
-
export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, };
|
|
14
|
+
export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, BehavioralMetrics, };
|
|
14
15
|
export type { ClientEvent, ClientEventLeaveReason, SubmitBehavioralEvent, SubmitClientEvent, SubmitInternalEvent, SubmitMQE, SubmitOperationalEvent, PreComputedLatencies, };
|
|
@@ -7,6 +7,9 @@ export type EnvironmentType = NonNullable<RawEvent['origin']['environment']>;
|
|
|
7
7
|
export type NewEnvironmentType = NonNullable<RawEvent['origin']['newEnvironment']>;
|
|
8
8
|
export type ClientLaunchMethodType = NonNullable<RawEvent['origin']['clientInfo']>['clientLaunchMethod'];
|
|
9
9
|
export type BrowserLaunchMethodType = NonNullable<RawEvent['origin']['clientInfo']>['browserLaunchMethod'];
|
|
10
|
+
export type MetricEventProduct = 'webex' | 'wxcc_desktop';
|
|
11
|
+
export type MetricEventAgent = 'user' | 'browser' | 'system' | 'sdk' | 'redux' | 'service';
|
|
12
|
+
export type MetricEventVerb = 'create' | 'get' | 'fetch' | 'update' | 'list' | 'delete' | 'select' | 'view' | 'set' | 'toggle' | 'load' | 'reload' | 'click' | 'hover' | 'register' | 'unregister' | 'enable' | 'disable' | 'use' | 'complete' | 'submit' | 'apply' | 'cancel' | 'abort' | 'sync' | 'login' | 'logout' | 'answer' | 'activate' | 'deactivate';
|
|
10
13
|
export type SubmitClientEventOptions = {
|
|
11
14
|
meetingId?: string;
|
|
12
15
|
mediaConnections?: any[];
|
|
@@ -37,11 +40,27 @@ export interface ClientEvent {
|
|
|
37
40
|
payload?: RawClientEvent;
|
|
38
41
|
options?: SubmitClientEventOptions;
|
|
39
42
|
}
|
|
43
|
+
export interface BehavioralEventContext {
|
|
44
|
+
app: {
|
|
45
|
+
version: string;
|
|
46
|
+
};
|
|
47
|
+
device: {
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
locale: string;
|
|
51
|
+
os: {
|
|
52
|
+
name: string;
|
|
53
|
+
version: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
40
56
|
export interface BehavioralEvent {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
context: BehavioralEventContext;
|
|
58
|
+
metricName: string;
|
|
59
|
+
tags: Record<string, string | number | boolean>;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
type: string[];
|
|
44
62
|
}
|
|
63
|
+
export type BehavioralEventPayload = BehavioralEvent['tags'];
|
|
45
64
|
export interface OperationalEvent {
|
|
46
65
|
name: never;
|
|
47
66
|
payload?: never;
|
|
@@ -60,7 +79,7 @@ export interface MediaQualityEvent {
|
|
|
60
79
|
export type RecursivePartial<T> = {
|
|
61
80
|
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
62
81
|
};
|
|
63
|
-
export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['
|
|
82
|
+
export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['metricName'] | OperationalEvent['name'] | FeatureEvent['name'] | MediaQualityEvent['name'];
|
|
64
83
|
export type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;
|
|
65
84
|
export type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];
|
|
66
85
|
export type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];
|
|
@@ -80,9 +99,11 @@ export type SubmitInternalEvent = (args: {
|
|
|
80
99
|
options?: any;
|
|
81
100
|
}) => void;
|
|
82
101
|
export type SubmitBehavioralEvent = (args: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
product: MetricEventProduct;
|
|
103
|
+
agent: MetricEventAgent;
|
|
104
|
+
target: string;
|
|
105
|
+
verb: MetricEventVerb;
|
|
106
|
+
payload?: BehavioralEventPayload;
|
|
86
107
|
}) => void;
|
|
87
108
|
export type SubmitClientEvent = (args: {
|
|
88
109
|
name: ClientEvent['name'];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WebexPlugin } from '@webex/webex-core';
|
|
2
2
|
import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
|
|
3
|
-
import
|
|
3
|
+
import BehavioralMetrics from './behavioral/behavioral-metrics';
|
|
4
|
+
import { RecursivePartial, MetricEventProduct, MetricEventAgent, MetricEventVerb, ClientEvent, FeatureEvent, BehavioralEventPayload, OperationalEvent, MediaQualityEvent, InternalEvent, SubmitClientEventOptions } from './metrics.types';
|
|
4
5
|
import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
|
|
5
6
|
/**
|
|
6
7
|
* Metrics plugin to centralize all types of metrics.
|
|
@@ -10,6 +11,7 @@ declare class Metrics extends WebexPlugin {
|
|
|
10
11
|
static instance: Metrics;
|
|
11
12
|
callDiagnosticLatencies: CallDiagnosticLatencies;
|
|
12
13
|
callDiagnosticMetrics: CallDiagnosticMetrics;
|
|
14
|
+
behavioralMetrics: BehavioralMetrics;
|
|
13
15
|
/**
|
|
14
16
|
* Constructor
|
|
15
17
|
* @param args
|
|
@@ -31,15 +33,21 @@ declare class Metrics extends WebexPlugin {
|
|
|
31
33
|
payload?: RecursivePartial<InternalEvent['payload']>;
|
|
32
34
|
options?: any;
|
|
33
35
|
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* @returns true once we have the deviceId we need to submit behavioral events to Amplitude
|
|
38
|
+
*/
|
|
39
|
+
isReadyToSubmitBehavioralEvents(): boolean;
|
|
34
40
|
/**
|
|
35
41
|
* Behavioral event
|
|
36
42
|
* @param args
|
|
37
43
|
*/
|
|
38
|
-
submitBehavioralEvent({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
submitBehavioralEvent({ product, agent, target, verb, payload, }: {
|
|
45
|
+
product: MetricEventProduct;
|
|
46
|
+
agent: MetricEventAgent;
|
|
47
|
+
target: string;
|
|
48
|
+
verb: MetricEventVerb;
|
|
49
|
+
payload?: BehavioralEventPayload;
|
|
50
|
+
}): any;
|
|
43
51
|
/**
|
|
44
52
|
* Operational event
|
|
45
53
|
* @param args
|
package/package.json
CHANGED
|
@@ -26,22 +26,22 @@
|
|
|
26
26
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
27
27
|
"@webex/jest-config-legacy": "0.0.0",
|
|
28
28
|
"@webex/legacy-tools": "0.0.0",
|
|
29
|
-
"@webex/test-helper-chai": "3.
|
|
30
|
-
"@webex/test-helper-mocha": "3.
|
|
31
|
-
"@webex/test-helper-mock-webex": "3.
|
|
32
|
-
"@webex/test-helper-test-users": "3.
|
|
29
|
+
"@webex/test-helper-chai": "3.4.0",
|
|
30
|
+
"@webex/test-helper-mocha": "3.4.0",
|
|
31
|
+
"@webex/test-helper-mock-webex": "3.4.0",
|
|
32
|
+
"@webex/test-helper-test-users": "3.4.0",
|
|
33
33
|
"eslint": "^8.24.0",
|
|
34
34
|
"prettier": "^2.7.1",
|
|
35
35
|
"sinon": "^9.2.4"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@webex/common": "3.
|
|
39
|
-
"@webex/common-timers": "3.
|
|
38
|
+
"@webex/common": "3.4.0",
|
|
39
|
+
"@webex/common-timers": "3.4.0",
|
|
40
40
|
"@webex/event-dictionary-ts": "^1.0.1406",
|
|
41
|
-
"@webex/internal-plugin-metrics": "3.
|
|
42
|
-
"@webex/test-helper-chai": "3.
|
|
43
|
-
"@webex/test-helper-mock-webex": "3.
|
|
44
|
-
"@webex/webex-core": "3.
|
|
41
|
+
"@webex/internal-plugin-metrics": "3.4.0",
|
|
42
|
+
"@webex/test-helper-chai": "3.4.0",
|
|
43
|
+
"@webex/test-helper-mock-webex": "3.4.0",
|
|
44
|
+
"@webex/webex-core": "3.4.0",
|
|
45
45
|
"ip-anonymize": "^0.1.0",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"uuid": "^3.3.2"
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"test:style": "eslint ./src/**/*.*",
|
|
55
55
|
"test:unit": "webex-legacy-tools test --unit --runner mocha"
|
|
56
56
|
},
|
|
57
|
-
"version": "3.
|
|
57
|
+
"version": "3.4.0"
|
|
58
58
|
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {merge} from 'lodash';
|
|
2
|
+
import {BrowserDetection} from '@webex/common';
|
|
3
|
+
import {StatelessWebexPlugin} from '@webex/webex-core';
|
|
4
|
+
import {getOSNameInternal} from '../metrics';
|
|
5
|
+
import {BEHAVIORAL_LOG_IDENTIFIER} from './config';
|
|
6
|
+
import {
|
|
7
|
+
MetricEventProduct,
|
|
8
|
+
MetricEventAgent,
|
|
9
|
+
MetricEventVerb,
|
|
10
|
+
BehavioralEventContext,
|
|
11
|
+
BehavioralEvent,
|
|
12
|
+
BehavioralEventPayload,
|
|
13
|
+
} from '../metrics.types';
|
|
14
|
+
import ClientMetricsBatcher from '../client-metrics-batcher';
|
|
15
|
+
|
|
16
|
+
const {getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @description Util class to handle Behavioral Metrics
|
|
20
|
+
* @export
|
|
21
|
+
* @class BehavioralMetrics
|
|
22
|
+
*/
|
|
23
|
+
export default class BehavioralMetrics extends StatelessWebexPlugin {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
private clientMetricsBatcher: ClientMetricsBatcher;
|
|
26
|
+
private logger: any; // to avoid adding @ts-ignore everywhere
|
|
27
|
+
private device: any;
|
|
28
|
+
private version: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Constructor
|
|
32
|
+
* @param {any[]} args
|
|
33
|
+
*/
|
|
34
|
+
constructor(...args) {
|
|
35
|
+
super(...args);
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
this.logger = this.webex.logger;
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
this.device = this.webex.internal.device;
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
this.version = this.webex.version;
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
this.clientMetricsBatcher = new ClientMetricsBatcher({}, {parent: this.webex});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Returns the deviceId from our registration with WDM.
|
|
48
|
+
* @returns {string} deviceId or empty string
|
|
49
|
+
*/
|
|
50
|
+
private getDeviceId(): string {
|
|
51
|
+
const {url} = this.device;
|
|
52
|
+
if (url && url.length !== 0) {
|
|
53
|
+
const n = url.lastIndexOf('/');
|
|
54
|
+
if (n !== -1) {
|
|
55
|
+
return url.substring(n + 1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns the context object to be submitted with all behavioral metrics.
|
|
64
|
+
* @returns {BehavioralEventContext}
|
|
65
|
+
*/
|
|
66
|
+
private getContext(): BehavioralEventContext {
|
|
67
|
+
const context: BehavioralEventContext = {
|
|
68
|
+
app: {
|
|
69
|
+
version: this.version,
|
|
70
|
+
},
|
|
71
|
+
device: {
|
|
72
|
+
id: this.getDeviceId(),
|
|
73
|
+
},
|
|
74
|
+
locale: window.navigator.language,
|
|
75
|
+
os: {
|
|
76
|
+
name: getOSNameInternal(),
|
|
77
|
+
version: getOSVersion(),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return context;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Returns the default tags to be included with all behavioral metrics.
|
|
86
|
+
* @returns {BehavioralEventPayload}
|
|
87
|
+
*/
|
|
88
|
+
private getDefaultTags(): BehavioralEventPayload {
|
|
89
|
+
const tags = {
|
|
90
|
+
browser: getBrowserName(),
|
|
91
|
+
browserHeight: window.innerHeight,
|
|
92
|
+
browserVersion: getBrowserVersion(),
|
|
93
|
+
browserWidth: window.innerWidth,
|
|
94
|
+
domain: window.location.hostname,
|
|
95
|
+
inIframe: window.self !== window.top,
|
|
96
|
+
locale: window.navigator.language,
|
|
97
|
+
os: getOSNameInternal(),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return tags;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Creates the object to send to our metrics endpoint for a behavioral event
|
|
105
|
+
* @param {MetricEventProduct} product
|
|
106
|
+
* @param {MetricEventAgent} agent
|
|
107
|
+
* @param {string} target
|
|
108
|
+
* @param {MetricEventVerb} verb
|
|
109
|
+
* @returns {BehavioralEventPayload}
|
|
110
|
+
*/
|
|
111
|
+
private createEventObject({
|
|
112
|
+
product,
|
|
113
|
+
agent,
|
|
114
|
+
target,
|
|
115
|
+
verb,
|
|
116
|
+
payload,
|
|
117
|
+
}: {
|
|
118
|
+
product: MetricEventProduct;
|
|
119
|
+
agent: MetricEventAgent;
|
|
120
|
+
target: string;
|
|
121
|
+
verb: MetricEventVerb;
|
|
122
|
+
payload?: BehavioralEventPayload;
|
|
123
|
+
}): BehavioralEvent {
|
|
124
|
+
const metricName = `${product}.${agent}.${target}.${verb}`;
|
|
125
|
+
let allTags: BehavioralEventPayload = payload;
|
|
126
|
+
allTags = merge(allTags, this.getDefaultTags());
|
|
127
|
+
|
|
128
|
+
const event: BehavioralEvent = {
|
|
129
|
+
context: this.getContext(),
|
|
130
|
+
metricName,
|
|
131
|
+
tags: allTags,
|
|
132
|
+
timestamp: Date.now(),
|
|
133
|
+
type: ['behavioral'],
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return event;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns true once we're ready to submit behavioral metrics, after startup.
|
|
141
|
+
* @returns {boolean} true when deviceId is defined and non-empty
|
|
142
|
+
*/
|
|
143
|
+
public isReadyToSubmitBehavioralEvents(): boolean {
|
|
144
|
+
const deviceId = this.getDeviceId();
|
|
145
|
+
|
|
146
|
+
return deviceId && deviceId.length !== 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Submit a behavioral metric to our metrics endpoint.
|
|
151
|
+
* @param {MetricEventProduct} product the product from which the metric is being submitted, e.g. 'webex' web client, 'wxcc_desktop'
|
|
152
|
+
* @param {MetricEventAgent} agent the source of the action for this metric
|
|
153
|
+
* @param {string} target the 'thing' that this metric includes information about
|
|
154
|
+
* @param {MetricEventVerb} verb the action that this metric includes information about
|
|
155
|
+
* @param {BehavioralEventPayload} payload information specific to this event. This should be flat, i.e. it should not include nested objects.
|
|
156
|
+
* @returns {Promise<any>}
|
|
157
|
+
*/
|
|
158
|
+
public submitBehavioralEvent({
|
|
159
|
+
product,
|
|
160
|
+
agent,
|
|
161
|
+
target,
|
|
162
|
+
verb,
|
|
163
|
+
payload,
|
|
164
|
+
}: {
|
|
165
|
+
product: MetricEventProduct;
|
|
166
|
+
agent: MetricEventAgent;
|
|
167
|
+
target: string;
|
|
168
|
+
verb: MetricEventVerb;
|
|
169
|
+
payload?: BehavioralEventPayload;
|
|
170
|
+
}) {
|
|
171
|
+
this.logger.log(
|
|
172
|
+
BEHAVIORAL_LOG_IDENTIFIER,
|
|
173
|
+
`BehavioralMetrics: @submitBehavioralEvent. Submit Behavioral event: ${product}.${agent}.${target}.${verb}`
|
|
174
|
+
);
|
|
175
|
+
const behavioralEvent = this.createEventObject({product, agent, target, verb, payload});
|
|
176
|
+
|
|
177
|
+
return this.clientMetricsBatcher.request(behavioralEvent);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -455,6 +455,9 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
|
|
|
455
455
|
},
|
|
456
456
|
intervals: payload.intervals,
|
|
457
457
|
callingServiceType: 'LOCUS',
|
|
458
|
+
meetingJoinInfo: {
|
|
459
|
+
clientSignallingProtocol: 'WebRTC',
|
|
460
|
+
},
|
|
458
461
|
sourceMetadata: {
|
|
459
462
|
applicationSoftwareType: CLIENT_NAME,
|
|
460
463
|
// @ts-ignore
|