@webex/internal-plugin-metrics 3.3.1-next.6 → 3.3.1-next.7

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.
@@ -0,0 +1,199 @@
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 _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
13
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
15
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
16
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
17
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
18
+ var _lodash = require("lodash");
19
+ var _common = require("@webex/common");
20
+ var _webexCore = require("@webex/webex-core");
21
+ var _metrics = require("../metrics");
22
+ var _config = require("./config");
23
+ var _clientMetricsBatcher = _interopRequireDefault(require("../client-metrics-batcher"));
24
+ 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); }; }
25
+ 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; } }
26
+ var _BrowserDetection = (0, _common.BrowserDetection)(),
27
+ getOSVersion = _BrowserDetection.getOSVersion,
28
+ getBrowserName = _BrowserDetection.getBrowserName,
29
+ getBrowserVersion = _BrowserDetection.getBrowserVersion;
30
+
31
+ /**
32
+ * @description Util class to handle Behavioral Metrics
33
+ * @export
34
+ * @class BehavioralMetrics
35
+ */
36
+ var BehavioralMetrics = exports.default = /*#__PURE__*/function (_StatelessWebexPlugin) {
37
+ (0, _inherits2.default)(BehavioralMetrics, _StatelessWebexPlugin);
38
+ var _super = _createSuper(BehavioralMetrics);
39
+ /**
40
+ * Constructor
41
+ * @param {any[]} args
42
+ */
43
+ function BehavioralMetrics() {
44
+ var _this;
45
+ (0, _classCallCheck2.default)(this, BehavioralMetrics);
46
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
47
+ args[_key] = arguments[_key];
48
+ }
49
+ _this = _super.call.apply(_super, [this].concat(args));
50
+ // @ts-ignore
51
+ // @ts-ignore
52
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clientMetricsBatcher", void 0);
53
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "logger", void 0);
54
+ // to avoid adding @ts-ignore everywhere
55
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "device", void 0);
56
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "version", void 0);
57
+ _this.logger = _this.webex.logger;
58
+ // @ts-ignore
59
+ _this.device = _this.webex.internal.device;
60
+ // @ts-ignore
61
+ _this.version = _this.webex.version;
62
+ // @ts-ignore
63
+ _this.clientMetricsBatcher = new _clientMetricsBatcher.default({}, {
64
+ parent: _this.webex
65
+ });
66
+ return _this;
67
+ }
68
+
69
+ /**
70
+ * Returns the deviceId from our registration with WDM.
71
+ * @returns {string} deviceId or empty string
72
+ */
73
+ (0, _createClass2.default)(BehavioralMetrics, [{
74
+ key: "getDeviceId",
75
+ value: function getDeviceId() {
76
+ var url = this.device.url;
77
+ if (url && url.length !== 0) {
78
+ var n = url.lastIndexOf('/');
79
+ if (n !== -1) {
80
+ return url.substring(n + 1);
81
+ }
82
+ }
83
+ return '';
84
+ }
85
+
86
+ /**
87
+ * Returns the context object to be submitted with all behavioral metrics.
88
+ * @returns {BehavioralEventContext}
89
+ */
90
+ }, {
91
+ key: "getContext",
92
+ value: function getContext() {
93
+ var context = {
94
+ app: {
95
+ version: this.version
96
+ },
97
+ device: {
98
+ id: this.getDeviceId()
99
+ },
100
+ locale: window.navigator.language,
101
+ os: {
102
+ name: (0, _metrics.getOSNameInternal)(),
103
+ version: getOSVersion()
104
+ }
105
+ };
106
+ return context;
107
+ }
108
+
109
+ /**
110
+ * Returns the default tags to be included with all behavioral metrics.
111
+ * @returns {BehavioralEventPayload}
112
+ */
113
+ }, {
114
+ key: "getDefaultTags",
115
+ value: function getDefaultTags() {
116
+ var tags = {
117
+ browser: getBrowserName(),
118
+ browserHeight: window.innerHeight,
119
+ browserVersion: getBrowserVersion(),
120
+ browserWidth: window.innerWidth,
121
+ domain: window.location.hostname,
122
+ inIframe: window.self !== window.top,
123
+ locale: window.navigator.language,
124
+ os: (0, _metrics.getOSNameInternal)()
125
+ };
126
+ return tags;
127
+ }
128
+
129
+ /**
130
+ * Creates the object to send to our metrics endpoint for a behavioral event
131
+ * @param {MetricEventProduct} product
132
+ * @param {MetricEventAgent} agent
133
+ * @param {string} target
134
+ * @param {MetricEventVerb} verb
135
+ * @returns {BehavioralEventPayload}
136
+ */
137
+ }, {
138
+ key: "createEventObject",
139
+ value: function createEventObject(_ref) {
140
+ var product = _ref.product,
141
+ agent = _ref.agent,
142
+ target = _ref.target,
143
+ verb = _ref.verb,
144
+ payload = _ref.payload;
145
+ var metricName = "".concat(product, ".").concat(agent, ".").concat(target, ".").concat(verb);
146
+ var allTags = payload;
147
+ allTags = (0, _lodash.merge)(allTags, this.getDefaultTags());
148
+ var event = {
149
+ context: this.getContext(),
150
+ metricName: metricName,
151
+ tags: allTags,
152
+ timestamp: (0, _now.default)(),
153
+ type: ['behavioral']
154
+ };
155
+ return event;
156
+ }
157
+
158
+ /**
159
+ * Returns true once we're ready to submit behavioral metrics, after startup.
160
+ * @returns {boolean} true when deviceId is defined and non-empty
161
+ */
162
+ }, {
163
+ key: "isReadyToSubmitBehavioralEvents",
164
+ value: function isReadyToSubmitBehavioralEvents() {
165
+ var deviceId = this.getDeviceId();
166
+ return deviceId && deviceId.length !== 0;
167
+ }
168
+
169
+ /**
170
+ * Submit a behavioral metric to our metrics endpoint.
171
+ * @param {MetricEventProduct} product the product from which the metric is being submitted, e.g. 'webex' web client, 'wxcc_desktop'
172
+ * @param {MetricEventAgent} agent the source of the action for this metric
173
+ * @param {string} target the 'thing' that this metric includes information about
174
+ * @param {MetricEventVerb} verb the action that this metric includes information about
175
+ * @param {BehavioralEventPayload} payload information specific to this event. This should be flat, i.e. it should not include nested objects.
176
+ * @returns {Promise<any>}
177
+ */
178
+ }, {
179
+ key: "submitBehavioralEvent",
180
+ value: function submitBehavioralEvent(_ref2) {
181
+ var product = _ref2.product,
182
+ agent = _ref2.agent,
183
+ target = _ref2.target,
184
+ verb = _ref2.verb,
185
+ payload = _ref2.payload;
186
+ this.logger.log(_config.BEHAVIORAL_LOG_IDENTIFIER, "BehavioralMetrics: @submitBehavioralEvent. Submit Behavioral event: ".concat(product, ".").concat(agent, ".").concat(target, ".").concat(verb));
187
+ var behavioralEvent = this.createEventObject({
188
+ product: product,
189
+ agent: agent,
190
+ target: target,
191
+ verb: verb,
192
+ payload: payload
193
+ });
194
+ return this.clientMetricsBatcher.request(behavioralEvent);
195
+ }
196
+ }]);
197
+ return BehavioralMetrics;
198
+ }(_webexCore.StatelessWebexPlugin);
199
+ //# sourceMappingURL=behavioral-metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lodash","require","_common","_webexCore","_metrics","_config","_clientMetricsBatcher","_interopRequireDefault","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","_BrowserDetection","BrowserDetection","getOSVersion","getBrowserName","getBrowserVersion","BehavioralMetrics","exports","_StatelessWebexPlugin","_inherits2","_super","_this","_classCallCheck2","_len","length","args","Array","_key","concat","_defineProperty2","_assertThisInitialized2","logger","webex","device","internal","version","clientMetricsBatcher","ClientMetricsBatcher","parent","_createClass2","key","value","getDeviceId","url","n","lastIndexOf","substring","getContext","context","app","id","locale","window","navigator","language","os","name","getOSNameInternal","getDefaultTags","tags","browser","browserHeight","innerHeight","browserVersion","browserWidth","innerWidth","domain","location","hostname","inIframe","self","top","createEventObject","_ref","product","agent","target","verb","payload","metricName","allTags","merge","event","timestamp","_now","type","isReadyToSubmitBehavioralEvents","deviceId","submitBehavioralEvent","_ref2","log","BEHAVIORAL_LOG_IDENTIFIER","behavioralEvent","request","StatelessWebexPlugin"],"sources":["behavioral-metrics.ts"],"sourcesContent":["import {merge} from 'lodash';\nimport {BrowserDetection} from '@webex/common';\nimport {StatelessWebexPlugin} from '@webex/webex-core';\nimport {getOSNameInternal} from '../metrics';\nimport {BEHAVIORAL_LOG_IDENTIFIER} from './config';\nimport {\n MetricEventProduct,\n MetricEventAgent,\n MetricEventVerb,\n BehavioralEventContext,\n BehavioralEvent,\n BehavioralEventPayload,\n} from '../metrics.types';\nimport ClientMetricsBatcher from '../client-metrics-batcher';\n\nconst {getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();\n\n/**\n * @description Util class to handle Behavioral Metrics\n * @export\n * @class BehavioralMetrics\n */\nexport default class BehavioralMetrics extends StatelessWebexPlugin {\n // @ts-ignore\n private clientMetricsBatcher: ClientMetricsBatcher;\n private logger: any; // to avoid adding @ts-ignore everywhere\n private device: any;\n private version: string;\n\n /**\n * Constructor\n * @param {any[]} args\n */\n constructor(...args) {\n super(...args);\n // @ts-ignore\n this.logger = this.webex.logger;\n // @ts-ignore\n this.device = this.webex.internal.device;\n // @ts-ignore\n this.version = this.webex.version;\n // @ts-ignore\n this.clientMetricsBatcher = new ClientMetricsBatcher({}, {parent: this.webex});\n }\n\n /**\n * Returns the deviceId from our registration with WDM.\n * @returns {string} deviceId or empty string\n */\n private getDeviceId(): string {\n const {url} = this.device;\n if (url && url.length !== 0) {\n const n = url.lastIndexOf('/');\n if (n !== -1) {\n return url.substring(n + 1);\n }\n }\n\n return '';\n }\n\n /**\n * Returns the context object to be submitted with all behavioral metrics.\n * @returns {BehavioralEventContext}\n */\n private getContext(): BehavioralEventContext {\n const context: BehavioralEventContext = {\n app: {\n version: this.version,\n },\n device: {\n id: this.getDeviceId(),\n },\n locale: window.navigator.language,\n os: {\n name: getOSNameInternal(),\n version: getOSVersion(),\n },\n };\n\n return context;\n }\n\n /**\n * Returns the default tags to be included with all behavioral metrics.\n * @returns {BehavioralEventPayload}\n */\n private getDefaultTags(): BehavioralEventPayload {\n const tags = {\n browser: getBrowserName(),\n browserHeight: window.innerHeight,\n browserVersion: getBrowserVersion(),\n browserWidth: window.innerWidth,\n domain: window.location.hostname,\n inIframe: window.self !== window.top,\n locale: window.navigator.language,\n os: getOSNameInternal(),\n };\n\n return tags;\n }\n\n /**\n * Creates the object to send to our metrics endpoint for a behavioral event\n * @param {MetricEventProduct} product\n * @param {MetricEventAgent} agent\n * @param {string} target\n * @param {MetricEventVerb} verb\n * @returns {BehavioralEventPayload}\n */\n private createEventObject({\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 }): BehavioralEvent {\n const metricName = `${product}.${agent}.${target}.${verb}`;\n let allTags: BehavioralEventPayload = payload;\n allTags = merge(allTags, this.getDefaultTags());\n\n const event: BehavioralEvent = {\n context: this.getContext(),\n metricName,\n tags: allTags,\n timestamp: Date.now(),\n type: ['behavioral'],\n };\n\n return event;\n }\n\n /**\n * Returns true once we're ready to submit behavioral metrics, after startup.\n * @returns {boolean} true when deviceId is defined and non-empty\n */\n public isReadyToSubmitBehavioralEvents(): boolean {\n const deviceId = this.getDeviceId();\n\n return deviceId && deviceId.length !== 0;\n }\n\n /**\n * Submit a behavioral metric to our metrics endpoint.\n * @param {MetricEventProduct} product the product from which the metric is being submitted, e.g. 'webex' web client, 'wxcc_desktop'\n * @param {MetricEventAgent} agent the source of the action for this metric\n * @param {string} target the 'thing' that this metric includes information about\n * @param {MetricEventVerb} verb the action that this metric includes information about\n * @param {BehavioralEventPayload} payload information specific to this event. This should be flat, i.e. it should not include nested objects.\n * @returns {Promise<any>}\n */\n public 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 this.logger.log(\n BEHAVIORAL_LOG_IDENTIFIER,\n `BehavioralMetrics: @submitBehavioralEvent. Submit Behavioral event: ${product}.${agent}.${target}.${verb}`\n );\n const behavioralEvent = this.createEventObject({product, agent, target, verb, payload});\n\n return this.clientMetricsBatcher.request(behavioralEvent);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AASA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAA6D,SAAAO,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,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AAA/C,MAAA,CAAIgD,MAAM,OAAAhD,MAAA,CAAIiD,IAAI,CAC3G,CAAC;MACD,IAAMe,eAAe,GAAG,IAAI,CAACpB,iBAAiB,CAAC;QAACE,OAAO,EAAPA,OAAO;QAAEC,KAAK,EAALA,KAAK;QAAEC,MAAM,EAANA,MAAM;QAAEC,IAAI,EAAJA,IAAI;QAAEC,OAAO,EAAPA;MAAO,CAAC,CAAC;MAEvF,OAAO,IAAI,CAAC1C,oBAAoB,CAACyD,OAAO,CAACD,eAAe,CAAC;IAC3D;EAAC;EAAA,OAAA5E,iBAAA;AAAA,EA3J4C8E,+BAAoB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.BEHAVIORAL_LOG_IDENTIFIER = void 0;
8
+ /* eslint-disable import/prefer-default-export */
9
+
10
+ var BEHAVIORAL_LOG_IDENTIFIER = exports.BEHAVIORAL_LOG_IDENTIFIER = 'behavioral-events -> ';
11
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BEHAVIORAL_LOG_IDENTIFIER","exports"],"sources":["config.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nexport const BEHAVIORAL_LOG_IDENTIFIER = 'behavioral-events -> ';\n"],"mappings":";;;;;;;AAAA;;AAEO,IAAMA,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,uBAAuB"}
package/dist/index.js CHANGED
@@ -8,6 +8,12 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
8
8
  _Object$defineProperty(exports, "__esModule", {
9
9
  value: true
10
10
  });
11
+ _Object$defineProperty(exports, "BehavioralMetrics", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _behavioralMetrics.default;
15
+ }
16
+ });
11
17
  exports.CALL_DIAGNOSTIC_CONFIG = void 0;
12
18
  _Object$defineProperty(exports, "CallDiagnosticLatencies", {
13
19
  enumerable: true,
@@ -59,6 +65,7 @@ var CallDiagnosticUtils = _interopRequireWildcard(require("./call-diagnostic/cal
59
65
  exports.CallDiagnosticUtils = CallDiagnosticUtils;
60
66
  var _callDiagnosticMetrics2 = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics"));
61
67
  var _callDiagnosticMetricsLatencies = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics-latencies"));
68
+ var _behavioralMetrics = _interopRequireDefault(require("./behavioral/behavioral-metrics"));
62
69
  function _getRequireWildcardCache(e) { if ("function" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
63
70
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
64
71
  /*!
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_webexCore","require","_metrics","_interopRequireWildcard","_config","_interopRequireDefault","_newMetrics","Utils","exports","CALL_DIAGNOSTIC_CONFIG","CallDiagnosticUtils","_callDiagnosticMetrics2","_callDiagnosticMetricsLatencies","_getRequireWildcardCache","e","_WeakMap","r","t","__esModule","_typeof","default","has","get","n","__proto__","a","_Object$defineProperty","_Object$getOwnPropertyDescriptor","u","Object","prototype","hasOwnProperty","call","i","set","registerInternalPlugin","Metrics","config","NewMetrics"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerInternalPlugin} from '@webex/webex-core';\n\nimport Metrics from './metrics';\nimport config from './config';\nimport NewMetrics from './new-metrics';\nimport * as Utils from './utils';\nimport {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitOperationalEvent,\n SubmitMQE,\n PreComputedLatencies,\n} from './metrics.types';\nimport * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';\nimport * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';\nimport CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';\nimport CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';\n\nregisterInternalPlugin('metrics', Metrics, {\n config,\n});\n\nregisterInternalPlugin('newMetrics', NewMetrics, {\n config,\n});\n\nexport {default, getOSNameInternal} from './metrics';\n\nexport {\n config,\n CALL_DIAGNOSTIC_CONFIG,\n NewMetrics,\n Utils,\n CallDiagnosticUtils,\n CallDiagnosticLatencies,\n CallDiagnosticMetrics,\n};\nexport type {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitMQE,\n SubmitOperationalEvent,\n PreComputedLatencies,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,KAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAAiCO,OAAA,CAAAD,KAAA,GAAAA,KAAA;AAWjC,IAAAE,sBAAA,GAAAN,uBAAA,CAAAF,OAAA;AAAmEO,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;A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AAA,GAAAA,CAAA;AAvB1F;AACA;AACA;;AAuBA,IAAAY,iCAAsB,EAAC,SAAS,EAAEC,gBAAO,EAAE;EACzCC,MAAM,EAANA;AACF,CAAC,CAAC;AAEF,IAAAF,iCAAsB,EAAC,YAAY,EAAEG,mBAAU,EAAE;EAC/CD,MAAM,EAANA;AACF,CAAC,CAAC"}
1
+ {"version":3,"names":["_webexCore","require","_metrics","_interopRequireWildcard","_config","_interopRequireDefault","_newMetrics","Utils","exports","CALL_DIAGNOSTIC_CONFIG","CallDiagnosticUtils","_callDiagnosticMetrics2","_callDiagnosticMetricsLatencies","_behavioralMetrics","_getRequireWildcardCache","e","_WeakMap","r","t","__esModule","_typeof","default","has","get","n","__proto__","a","_Object$defineProperty","_Object$getOwnPropertyDescriptor","u","Object","prototype","hasOwnProperty","call","i","set","registerInternalPlugin","Metrics","config","NewMetrics"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerInternalPlugin} from '@webex/webex-core';\n\nimport Metrics from './metrics';\nimport config from './config';\nimport NewMetrics from './new-metrics';\nimport * as Utils from './utils';\nimport {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitOperationalEvent,\n SubmitMQE,\n PreComputedLatencies,\n} from './metrics.types';\nimport * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';\nimport * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';\nimport CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';\nimport CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';\nimport BehavioralMetrics from './behavioral/behavioral-metrics';\n\nregisterInternalPlugin('metrics', Metrics, {\n config,\n});\n\nregisterInternalPlugin('newMetrics', NewMetrics, {\n config,\n});\n\nexport {default, getOSNameInternal} from './metrics';\n\nexport {\n config,\n CALL_DIAGNOSTIC_CONFIG,\n NewMetrics,\n Utils,\n CallDiagnosticUtils,\n CallDiagnosticLatencies,\n CallDiagnosticMetrics,\n BehavioralMetrics,\n};\nexport type {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitMQE,\n SubmitOperationalEvent,\n PreComputedLatencies,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,KAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAAiCO,OAAA,CAAAD,KAAA,GAAAA,KAAA;AAWjC,IAAAE,sBAAA,GAAAN,uBAAA,CAAAF,OAAA;AAAmEO,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AACnE,IAAAC,mBAAA,GAAAP,uBAAA,CAAAF,OAAA;AAAsFO,OAAA,CAAAE,mBAAA,GAAAA,mBAAA;AACtF,IAAAC,uBAAA,GAAAN,sBAAA,CAAAJ,OAAA;AACA,IAAAW,+BAAA,GAAAP,sBAAA,CAAAJ,OAAA;AACA,IAAAY,kBAAA,GAAAR,sBAAA,CAAAJ,OAAA;AAAgE,SAAAa,yBAAAC,CAAA,6BAAAC,QAAA,mBAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OAAA,CAAAL,CAAA,0BAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAI,GAAA,CAAAP,CAAA,UAAAG,CAAA,CAAAK,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,sBAAA,IAAAC,gCAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAC,MAAA,CAAAC,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAlB,CAAA,EAAAc,CAAA,SAAAK,CAAA,GAAAR,CAAA,GAAAE,gCAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAK,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,sBAAA,CAAAH,CAAA,EAAAK,CAAA,EAAAK,CAAA,IAAAV,CAAA,CAAAK,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAL,CAAA,CAAAH,OAAA,GAAAN,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAiB,GAAA,CAAApB,CAAA,EAAAS,CAAA,GAAAA,CAAA;AAxBhE;AACA;AACA;;AAwBA,IAAAY,iCAAsB,EAAC,SAAS,EAAEC,gBAAO,EAAE;EACzCC,MAAM,EAANA;AACF,CAAC,CAAC;AAEF,IAAAF,iCAAsB,EAAC,YAAY,EAAEG,mBAAU,EAAE;EAC/CD,MAAM,EAANA;AACF,CAAC,CAAC"}
package/dist/metrics.js CHANGED
@@ -148,7 +148,7 @@ var Metrics = _webexCore.WebexPlugin.extend({
148
148
  }
149
149
  });
150
150
  },
151
- version: "3.3.1-next.6"
151
+ version: "3.3.1-next.7"
152
152
  });
153
153
  var _default = exports.default = Metrics;
154
154
  //# sourceMappingURL=metrics.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["metrics.types.ts"],"sourcesContent":["import {\n ClientEvent as RawClientEvent,\n Event as RawEvent,\n MediaQualityEvent as RawMediaQualityEvent,\n} from '@webex/event-dictionary-ts';\n\nexport type Event = Omit<RawEvent, 'event'> & {event: RawClientEvent | RawMediaQualityEvent};\n\nexport type ClientEventError = NonNullable<RawClientEvent['errors']>[0];\n\nexport type EnvironmentType = NonNullable<RawEvent['origin']['environment']>;\n\nexport type NewEnvironmentType = NonNullable<RawEvent['origin']['newEnvironment']>;\n\nexport type ClientLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['clientLaunchMethod'];\n\nexport type BrowserLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['browserLaunchMethod'];\n\nexport type SubmitClientEventOptions = {\n meetingId?: string;\n mediaConnections?: any[];\n rawError?: any;\n correlationId?: string;\n preLoginId?: string;\n environment?: EnvironmentType;\n newEnvironmentType?: NewEnvironmentType;\n clientLaunchMethod?: ClientLaunchMethodType;\n browserLaunchMethod?: BrowserLaunchMethodType;\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type SubmitMQEOptions = {\n meetingId: string;\n mediaConnections?: any[];\n networkType?: Event['origin']['networkType'];\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type InternalEvent = {\n name:\n | 'internal.client.meetinginfo.request'\n | 'internal.client.meetinginfo.response'\n | 'internal.register.device.request'\n | 'internal.register.device.response'\n | 'internal.reset.join.latencies'\n | 'internal.client.meeting.click.joinbutton'\n | 'internal.host.meeting.participant.admitted'\n | 'internal.client.meeting.interstitial-window.showed'\n | 'internal.client.interstitial-window.click.joinbutton'\n | 'internal.client.add-media.turn-discovery.start'\n | 'internal.client.add-media.turn-discovery.end';\n\n payload?: never;\n options?: never;\n};\n\nexport interface ClientEvent {\n name: RawClientEvent['name'];\n payload?: RawClientEvent;\n options?: SubmitClientEventOptions;\n}\n\nexport interface BehavioralEvent {\n // TODO: not implemented\n name: 'host.meeting.participant.admitted' | 'sdk.media-flow.started';\n payload?: never;\n options?: never;\n}\n\nexport interface OperationalEvent {\n // TODO: not implemented\n name: never;\n payload?: never;\n options?: never;\n}\n\nexport interface FeatureEvent {\n // TODO: not implemented\n name: never;\n payload?: never;\n options?: never;\n}\n\nexport interface MediaQualityEvent {\n name: RawMediaQualityEvent['name'];\n payload?: RawMediaQualityEvent;\n options: SubmitMQEOptions;\n}\n\nexport type RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? RecursivePartial<U>[]\n : T[P] extends object\n ? RecursivePartial<T[P]>\n : T[P];\n};\n\nexport type MetricEventNames =\n | InternalEvent['name']\n | ClientEvent['name']\n | BehavioralEvent['name']\n | OperationalEvent['name']\n | FeatureEvent['name']\n | MediaQualityEvent['name'];\n\nexport type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;\nexport type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];\nexport type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];\nexport type NetworkType = NonNullable<RawEvent['origin']>['networkType'];\n\nexport type ClientSubServiceType = ClientEvent['payload']['webexSubServiceType'];\nexport type ClientEventPayload = RecursivePartial<ClientEvent['payload']>;\nexport type ClientEventLeaveReason = ClientEvent['payload']['leaveReason'];\nexport type ClientEventPayloadError = ClientEvent['payload']['errors'];\n\nexport type MediaQualityEventAudioSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['audioSetupDelay'];\nexport type MediaQualityEventVideoSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['videoSetupDelay'];\n\nexport type SubmitMQEPayload = RecursivePartial<MediaQualityEvent['payload']> & {\n intervals: NonNullable<MediaQualityEvent['payload']>['intervals'];\n};\n\nexport type SubmitInternalEvent = (args: {\n name: InternalEvent['name'];\n payload?: RecursivePartial<InternalEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitBehavioralEvent = (args: {\n name: BehavioralEvent['name'];\n payload?: RecursivePartial<BehavioralEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitClientEvent = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type SubmitOperationalEvent = (args: {\n name: OperationalEvent['name'];\n payload?: RecursivePartial<OperationalEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitMQE = (args: {\n name: MediaQualityEvent['name'];\n payload: SubmitMQEPayload;\n options: any;\n}) => void;\n\nexport type BuildClientEventFetchRequestOptions = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type PreComputedLatencies =\n | 'internal.client.pageJMT'\n | 'internal.download.time'\n | 'internal.get.cluster.time'\n | 'internal.click.to.interstitial'\n | 'internal.refresh.captcha.time'\n | 'internal.exchange.ci.token.time'\n | 'internal.get.u2c.time'\n | 'internal.call.init.join.req'\n | 'internal.other.app.api.time'\n | 'internal.api.fetch.intelligence.models';\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["metrics.types.ts"],"sourcesContent":["import {\n ClientEvent as RawClientEvent,\n Event as RawEvent,\n MediaQualityEvent as RawMediaQualityEvent,\n} from '@webex/event-dictionary-ts';\n\nexport type Event = Omit<RawEvent, 'event'> & {event: RawClientEvent | RawMediaQualityEvent};\n\nexport type ClientEventError = NonNullable<RawClientEvent['errors']>[0];\n\nexport type EnvironmentType = NonNullable<RawEvent['origin']['environment']>;\n\nexport type NewEnvironmentType = NonNullable<RawEvent['origin']['newEnvironment']>;\n\nexport type ClientLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['clientLaunchMethod'];\n\nexport type BrowserLaunchMethodType = NonNullable<\n RawEvent['origin']['clientInfo']\n>['browserLaunchMethod'];\n\nexport type MetricEventProduct = 'webex' | 'wxcc_desktop';\n\nexport type MetricEventAgent = 'user' | 'browser' | 'system' | 'sdk' | 'redux' | 'service';\n\nexport type MetricEventVerb =\n | 'create'\n | 'get'\n | 'fetch'\n | 'update'\n | 'list'\n | 'delete'\n | 'select'\n | 'view'\n | 'set'\n | 'toggle'\n | 'load'\n | 'reload'\n | 'click'\n | 'hover'\n | 'register'\n | 'unregister'\n | 'enable'\n | 'disable'\n | 'use'\n | 'complete'\n | 'submit'\n | 'apply'\n | 'cancel'\n | 'abort'\n | 'sync'\n | 'login'\n | 'logout';\n\nexport type SubmitClientEventOptions = {\n meetingId?: string;\n mediaConnections?: any[];\n rawError?: any;\n correlationId?: string;\n preLoginId?: string;\n environment?: EnvironmentType;\n newEnvironmentType?: NewEnvironmentType;\n clientLaunchMethod?: ClientLaunchMethodType;\n browserLaunchMethod?: BrowserLaunchMethodType;\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type SubmitMQEOptions = {\n meetingId: string;\n mediaConnections?: any[];\n networkType?: Event['origin']['networkType'];\n webexConferenceIdStr?: string;\n globalMeetingId?: string;\n};\n\nexport type InternalEvent = {\n name:\n | 'internal.client.meetinginfo.request'\n | 'internal.client.meetinginfo.response'\n | 'internal.register.device.request'\n | 'internal.register.device.response'\n | 'internal.reset.join.latencies'\n | 'internal.client.meeting.click.joinbutton'\n | 'internal.host.meeting.participant.admitted'\n | 'internal.client.meeting.interstitial-window.showed'\n | 'internal.client.interstitial-window.click.joinbutton'\n | 'internal.client.add-media.turn-discovery.start'\n | 'internal.client.add-media.turn-discovery.end';\n\n payload?: never;\n options?: never;\n};\n\nexport interface ClientEvent {\n name: RawClientEvent['name'];\n payload?: RawClientEvent;\n options?: SubmitClientEventOptions;\n}\n\nexport interface BehavioralEventContext {\n app: {version: string};\n device: {id: string};\n locale: string;\n os: {\n name: string;\n version: string;\n };\n}\n\nexport interface BehavioralEvent {\n context: BehavioralEventContext;\n metricName: string;\n tags: Record<string, string | number | boolean>;\n timestamp: number;\n type: string[];\n}\n\nexport type BehavioralEventPayload = BehavioralEvent['tags'];\n\nexport interface OperationalEvent {\n // TODO: not implemented\n name: never;\n payload?: never;\n options?: never;\n}\n\nexport interface FeatureEvent {\n // TODO: not implemented\n name: never;\n payload?: never;\n options?: never;\n}\n\nexport interface MediaQualityEvent {\n name: RawMediaQualityEvent['name'];\n payload?: RawMediaQualityEvent;\n options: SubmitMQEOptions;\n}\n\nexport type RecursivePartial<T> = {\n [P in keyof T]?: T[P] extends (infer U)[]\n ? RecursivePartial<U>[]\n : T[P] extends object\n ? RecursivePartial<T[P]>\n : T[P];\n};\n\nexport type MetricEventNames =\n | InternalEvent['name']\n | ClientEvent['name']\n | BehavioralEvent['metricName']\n | OperationalEvent['name']\n | FeatureEvent['name']\n | MediaQualityEvent['name'];\n\nexport type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;\nexport type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];\nexport type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];\nexport type NetworkType = NonNullable<RawEvent['origin']>['networkType'];\n\nexport type ClientSubServiceType = ClientEvent['payload']['webexSubServiceType'];\nexport type ClientEventPayload = RecursivePartial<ClientEvent['payload']>;\nexport type ClientEventLeaveReason = ClientEvent['payload']['leaveReason'];\nexport type ClientEventPayloadError = ClientEvent['payload']['errors'];\n\nexport type MediaQualityEventAudioSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['audioSetupDelay'];\nexport type MediaQualityEventVideoSetupDelayPayload = NonNullable<\n MediaQualityEvent['payload']\n>['videoSetupDelay'];\n\nexport type SubmitMQEPayload = RecursivePartial<MediaQualityEvent['payload']> & {\n intervals: NonNullable<MediaQualityEvent['payload']>['intervals'];\n};\n\nexport type SubmitInternalEvent = (args: {\n name: InternalEvent['name'];\n payload?: RecursivePartial<InternalEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitBehavioralEvent = (args: {\n product: MetricEventProduct;\n agent: MetricEventAgent;\n target: string;\n verb: MetricEventVerb;\n payload?: BehavioralEventPayload;\n}) => void;\n\nexport type SubmitClientEvent = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type SubmitOperationalEvent = (args: {\n name: OperationalEvent['name'];\n payload?: RecursivePartial<OperationalEvent['payload']>;\n options?: any;\n}) => void;\n\nexport type SubmitMQE = (args: {\n name: MediaQualityEvent['name'];\n payload: SubmitMQEPayload;\n options: any;\n}) => void;\n\nexport type BuildClientEventFetchRequestOptions = (args: {\n name: ClientEvent['name'];\n payload?: RecursivePartial<ClientEvent['payload']>;\n options?: SubmitClientEventOptions;\n}) => Promise<any>;\n\nexport type PreComputedLatencies =\n | 'internal.client.pageJMT'\n | 'internal.download.time'\n | 'internal.get.cluster.time'\n | 'internal.click.to.interstitial'\n | 'internal.refresh.captcha.time'\n | 'internal.exchange.ci.token.time'\n | 'internal.get.u2c.time'\n | 'internal.call.init.join.req'\n | 'internal.other.app.api.time'\n | 'internal.api.fetch.intelligence.models';\n"],"mappings":""}
@@ -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 name = _ref2.name,
109
- payload = _ref2.payload,
110
- options = _ref2.options;
111
- this.callDiagnosticLatencies.saveTimestamp({
112
- key: name
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
  /**
@@ -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;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAoD,IAAAM,MAAA;AApB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E;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,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MA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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 -> ";
@@ -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';
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
- name: 'host.meeting.participant.admitted' | 'sdk.media-flow.started';
42
- payload?: never;
43
- options?: never;
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['name'] | OperationalEvent['name'] | FeatureEvent['name'] | MediaQualityEvent['name'];
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
- name: BehavioralEvent['name'];
84
- payload?: RecursivePartial<BehavioralEvent['payload']>;
85
- options?: any;
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 { RecursivePartial, ClientEvent, FeatureEvent, BehavioralEvent, OperationalEvent, MediaQualityEvent, InternalEvent, SubmitClientEventOptions } from './metrics.types';
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({ name, payload, options, }: {
39
- name: BehavioralEvent['name'];
40
- payload?: RecursivePartial<BehavioralEvent['payload']>;
41
- options?: any;
42
- }): void;
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.3.1-next.6",
30
- "@webex/test-helper-mocha": "3.3.1-next.6",
31
- "@webex/test-helper-mock-webex": "3.3.1-next.6",
32
- "@webex/test-helper-test-users": "3.3.1-next.6",
29
+ "@webex/test-helper-chai": "3.3.1-next.7",
30
+ "@webex/test-helper-mocha": "3.3.1-next.7",
31
+ "@webex/test-helper-mock-webex": "3.3.1-next.7",
32
+ "@webex/test-helper-test-users": "3.3.1-next.7",
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.3.1-next.6",
39
- "@webex/common-timers": "3.3.1-next.6",
38
+ "@webex/common": "3.3.1-next.7",
39
+ "@webex/common-timers": "3.3.1-next.7",
40
40
  "@webex/event-dictionary-ts": "^1.0.1406",
41
- "@webex/internal-plugin-metrics": "3.3.1-next.6",
42
- "@webex/test-helper-chai": "3.3.1-next.6",
43
- "@webex/test-helper-mock-webex": "3.3.1-next.6",
44
- "@webex/webex-core": "3.3.1-next.6",
41
+ "@webex/internal-plugin-metrics": "3.3.1-next.7",
42
+ "@webex/test-helper-chai": "3.3.1-next.7",
43
+ "@webex/test-helper-mock-webex": "3.3.1-next.7",
44
+ "@webex/webex-core": "3.3.1-next.7",
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.3.1-next.6"
57
+ "version": "3.3.1-next.7"
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
+ }
@@ -0,0 +1,3 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+
3
+ export const BEHAVIORAL_LOG_IDENTIFIER = 'behavioral-events -> ';
package/src/index.ts CHANGED
@@ -22,6 +22,7 @@ import * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';
22
22
  import * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';
23
23
  import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
24
24
  import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
25
+ import BehavioralMetrics from './behavioral/behavioral-metrics';
25
26
 
26
27
  registerInternalPlugin('metrics', Metrics, {
27
28
  config,
@@ -41,6 +42,7 @@ export {
41
42
  CallDiagnosticUtils,
42
43
  CallDiagnosticLatencies,
43
44
  CallDiagnosticMetrics,
45
+ BehavioralMetrics,
44
46
  };
45
47
  export type {
46
48
  ClientEvent,
@@ -20,6 +20,39 @@ export type BrowserLaunchMethodType = NonNullable<
20
20
  RawEvent['origin']['clientInfo']
21
21
  >['browserLaunchMethod'];
22
22
 
23
+ export type MetricEventProduct = 'webex' | 'wxcc_desktop';
24
+
25
+ export type MetricEventAgent = 'user' | 'browser' | 'system' | 'sdk' | 'redux' | 'service';
26
+
27
+ export type MetricEventVerb =
28
+ | 'create'
29
+ | 'get'
30
+ | 'fetch'
31
+ | 'update'
32
+ | 'list'
33
+ | 'delete'
34
+ | 'select'
35
+ | 'view'
36
+ | 'set'
37
+ | 'toggle'
38
+ | 'load'
39
+ | 'reload'
40
+ | 'click'
41
+ | 'hover'
42
+ | 'register'
43
+ | 'unregister'
44
+ | 'enable'
45
+ | 'disable'
46
+ | 'use'
47
+ | 'complete'
48
+ | 'submit'
49
+ | 'apply'
50
+ | 'cancel'
51
+ | 'abort'
52
+ | 'sync'
53
+ | 'login'
54
+ | 'logout';
55
+
23
56
  export type SubmitClientEventOptions = {
24
57
  meetingId?: string;
25
58
  mediaConnections?: any[];
@@ -66,13 +99,26 @@ export interface ClientEvent {
66
99
  options?: SubmitClientEventOptions;
67
100
  }
68
101
 
102
+ export interface BehavioralEventContext {
103
+ app: {version: string};
104
+ device: {id: string};
105
+ locale: string;
106
+ os: {
107
+ name: string;
108
+ version: string;
109
+ };
110
+ }
111
+
69
112
  export interface BehavioralEvent {
70
- // TODO: not implemented
71
- name: 'host.meeting.participant.admitted' | 'sdk.media-flow.started';
72
- payload?: never;
73
- options?: never;
113
+ context: BehavioralEventContext;
114
+ metricName: string;
115
+ tags: Record<string, string | number | boolean>;
116
+ timestamp: number;
117
+ type: string[];
74
118
  }
75
119
 
120
+ export type BehavioralEventPayload = BehavioralEvent['tags'];
121
+
76
122
  export interface OperationalEvent {
77
123
  // TODO: not implemented
78
124
  name: never;
@@ -104,7 +150,7 @@ export type RecursivePartial<T> = {
104
150
  export type MetricEventNames =
105
151
  | InternalEvent['name']
106
152
  | ClientEvent['name']
107
- | BehavioralEvent['name']
153
+ | BehavioralEvent['metricName']
108
154
  | OperationalEvent['name']
109
155
  | FeatureEvent['name']
110
156
  | MediaQualityEvent['name'];
@@ -137,9 +183,11 @@ export type SubmitInternalEvent = (args: {
137
183
  }) => void;
138
184
 
139
185
  export type SubmitBehavioralEvent = (args: {
140
- name: BehavioralEvent['name'];
141
- payload?: RecursivePartial<BehavioralEvent['payload']>;
142
- options?: any;
186
+ product: MetricEventProduct;
187
+ agent: MetricEventAgent;
188
+ target: string;
189
+ verb: MetricEventVerb;
190
+ payload?: BehavioralEventPayload;
143
191
  }) => void;
144
192
 
145
193
  export type SubmitClientEvent = (args: {
@@ -6,11 +6,15 @@
6
6
  import {WebexPlugin} from '@webex/webex-core';
7
7
 
8
8
  import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
9
+ import BehavioralMetrics from './behavioral/behavioral-metrics';
9
10
  import {
10
11
  RecursivePartial,
12
+ MetricEventProduct,
13
+ MetricEventAgent,
14
+ MetricEventVerb,
11
15
  ClientEvent,
12
16
  FeatureEvent,
13
- BehavioralEvent,
17
+ BehavioralEventPayload,
14
18
  OperationalEvent,
15
19
  MediaQualityEvent,
16
20
  InternalEvent,
@@ -32,6 +36,7 @@ class Metrics extends WebexPlugin {
32
36
  callDiagnosticLatencies: CallDiagnosticLatencies;
33
37
  // Helper classes to handle the different types of metrics
34
38
  callDiagnosticMetrics: CallDiagnosticMetrics;
39
+ behavioralMetrics: BehavioralMetrics;
35
40
 
36
41
  /**
37
42
  * Constructor
@@ -56,6 +61,8 @@ class Metrics extends WebexPlugin {
56
61
  this.webex.once('ready', () => {
57
62
  // @ts-ignore
58
63
  this.callDiagnosticMetrics = new CallDiagnosticMetrics({}, {parent: this.webex});
64
+ // @ts-ignore
65
+ this.behavioralMetrics = new BehavioralMetrics({}, {parent: this.webex});
59
66
  });
60
67
  }
61
68
 
@@ -79,21 +86,40 @@ class Metrics extends WebexPlugin {
79
86
  }
80
87
  }
81
88
 
89
+ /**
90
+ * @returns true once we have the deviceId we need to submit behavioral events to Amplitude
91
+ */
92
+ isReadyToSubmitBehavioralEvents() {
93
+ return this.behavioralMetrics.isReadyToSubmitBehavioralEvents();
94
+ }
95
+
82
96
  /**
83
97
  * Behavioral event
84
98
  * @param args
85
99
  */
86
100
  submitBehavioralEvent({
87
- name,
101
+ product,
102
+ agent,
103
+ target,
104
+ verb,
88
105
  payload,
89
- options,
90
106
  }: {
91
- name: BehavioralEvent['name'];
92
- payload?: RecursivePartial<BehavioralEvent['payload']>;
93
- options?: any;
107
+ product: MetricEventProduct;
108
+ agent: MetricEventAgent;
109
+ target: string;
110
+ verb: MetricEventVerb;
111
+ payload?: BehavioralEventPayload;
94
112
  }) {
95
- this.callDiagnosticLatencies.saveTimestamp({key: name});
96
- throw new Error('Not implemented.');
113
+ if (!this.behavioralMetrics) {
114
+ // @ts-ignore
115
+ this.webex.logger.log(
116
+ `NewMetrics: @submitBehavioralEvent. Attempted to submit before webex.ready: ${product}.${agent}.${target}.${verb}`
117
+ );
118
+
119
+ return Promise.resolve();
120
+ }
121
+
122
+ return this.behavioralMetrics.submitBehavioralEvent({product, agent, target, verb, payload});
97
123
  }
98
124
 
99
125
  /**
@@ -0,0 +1,164 @@
1
+ import sinon from 'sinon';
2
+ import {assert} from '@webex/test-helper-chai';
3
+ import {BrowserDetection} from '@webex/common';
4
+ import {BehavioralMetrics, config, getOSNameInternal} from '@webex/internal-plugin-metrics';
5
+ import uuid from 'uuid';
6
+ import {merge} from 'lodash';
7
+
8
+ //@ts-ignore
9
+ global.window = {location: {hostname: 'whatever'}, navigator: {language: 'language'}};
10
+ process.env.NODE_ENV = 'test';
11
+
12
+ const {getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();
13
+
14
+ describe('internal-plugin-metrics', () => {
15
+ describe('BehavioralMetrics', () => {
16
+ let webex;
17
+ let now;
18
+ let behavioralMetrics: BehavioralMetrics;
19
+
20
+ const tags = {key: 'val'};
21
+
22
+ beforeEach(() => {
23
+ now = new Date();
24
+
25
+ webex = {
26
+ canAuthorize: true,
27
+ version: 'webex-version',
28
+ internal: {
29
+ services: {
30
+ get: () => 'locus-url',
31
+ },
32
+ metrics: {
33
+ submitClientMetrics: sinon.stub(),
34
+ config: {...config.metrics},
35
+ },
36
+ newMetrics: {},
37
+ device: {
38
+ userId: 'userId',
39
+ url: 'https://wdm-intb.ciscospark.com/wdm/api/v1/devices/deviceId',
40
+ orgId: 'orgId',
41
+ },
42
+ },
43
+ meetings: {
44
+ config: {
45
+ metrics: {
46
+ clientType: 'TEAMS_CLIENT',
47
+ subClientType: 'WEB_APP',
48
+ clientName: 'Cantina',
49
+ },
50
+ },
51
+ geoHintInfo: {
52
+ clientAddress: '1.3.4.5',
53
+ countryCode: 'UK',
54
+ },
55
+ },
56
+ credentials: {
57
+ isUnverifiedGuest: false,
58
+ },
59
+ prepareFetchOptions: sinon.stub().callsFake((opts: any) => ({...opts, foo: 'bar'})),
60
+ request: sinon.stub().resolves({body: {}}),
61
+ logger: {
62
+ log: sinon.stub(),
63
+ error: sinon.stub(),
64
+ },
65
+ };
66
+
67
+ sinon.createSandbox();
68
+ sinon.useFakeTimers(now.getTime());
69
+ behavioralMetrics = new BehavioralMetrics({}, {parent: webex});
70
+ sinon.stub(uuid, 'v4').returns('my-fake-id');
71
+ });
72
+
73
+ afterEach(() => {
74
+ sinon.restore();
75
+ });
76
+
77
+ describe('#getContext', () => {
78
+ it('should build context correctly', () => {
79
+ const res = behavioralMetrics.getContext();
80
+
81
+ assert.deepEqual(res, {
82
+ app: {
83
+ version: 'webex-version',
84
+ },
85
+ device: {
86
+ id: 'deviceId',
87
+ },
88
+ locale: 'language',
89
+ os: {
90
+ name: getOSNameInternal(),
91
+ version: getOSVersion(),
92
+ },
93
+ });
94
+ });
95
+ });
96
+
97
+ describe('#getDefaultTags', () => {
98
+ it('should build tags correctly', () => {
99
+ const res = behavioralMetrics.getDefaultTags();
100
+
101
+ assert.deepEqual(res, {
102
+ browser: getBrowserName(),
103
+ browserHeight: window.innerHeight,
104
+ browserVersion: getBrowserVersion(),
105
+ browserWidth: window.innerWidth,
106
+ domain: window.location.hostname,
107
+ inIframe: false,
108
+ locale: window.navigator.language,
109
+ os: getOSNameInternal(),
110
+ });
111
+ });
112
+ });
113
+
114
+ describe('#isReadyToSubmitBehavioralEvents', () => {
115
+ it('should return true when we have a deviceId, false when deviceId is empty or undefined', async () => {
116
+ assert.equal(true, behavioralMetrics.isReadyToSubmitBehavioralEvents());
117
+
118
+ webex.internal.device.url = "";
119
+ assert.equal(false, behavioralMetrics.isReadyToSubmitBehavioralEvents());
120
+
121
+ delete webex.internal.device.url;
122
+ assert.equal(false, behavioralMetrics.isReadyToSubmitBehavioralEvents());
123
+ });
124
+ });
125
+
126
+ describe('#createEventObject', () => {
127
+ it('should build event object correctly', async () => {
128
+ const res = behavioralMetrics.createEventObject({
129
+ product: 'webex',
130
+ agent: 'user',
131
+ target: 'target',
132
+ verb: 'create',
133
+ payload: tags,
134
+ });
135
+
136
+ assert.deepEqual(res, {
137
+ context: {
138
+ app: {
139
+ version: 'webex-version',
140
+ },
141
+ device: {
142
+ id: 'deviceId',
143
+ },
144
+ locale: 'language',
145
+ os: {
146
+ name: getOSNameInternal(),
147
+ version: getOSVersion(),
148
+ },
149
+ },
150
+ metricName: 'webex.user.target.create',
151
+ tags: merge(tags, {
152
+ browser: getBrowserName(),
153
+ browserVersion: getBrowserVersion(),
154
+ domain: window.location.hostname,
155
+ locale: window.navigator.language,
156
+ os: getOSNameInternal(),
157
+ }),
158
+ timestamp: res.timestamp,
159
+ type: ['behavioral'],
160
+ });
161
+ });
162
+ });
163
+ });
164
+ });