@webex/internal-plugin-metrics 3.0.0-beta.27 → 3.0.0-beta.270
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/call-diagnostic/call-diagnostic-metrics-batcher.js +65 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +446 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +744 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +310 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +575 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/config.js +20 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +30 -30
- package/dist/metrics.js.map +1 -1
- package/dist/metrics.types.js +7 -0
- package/dist/metrics.types.js.map +1 -0
- package/dist/new-metrics.js +333 -0
- package/dist/new-metrics.js.map +1 -0
- package/dist/types/batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +189 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +392 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +87 -0
- package/dist/types/call-diagnostic/config.d.ts +93 -0
- package/dist/types/client-metrics-batcher.d.ts +2 -0
- package/dist/types/config.d.ts +35 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.types.d.ts +99 -0
- package/dist/types/new-metrics.d.ts +139 -0
- package/dist/types/utils.d.ts +6 -0
- package/dist/utils.js +27 -0
- package/dist/utils.js.map +1 -0
- package/package.json +13 -8
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +82 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +403 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +808 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +320 -0
- package/src/call-diagnostic/config.ts +632 -0
- package/src/config.js +19 -0
- package/src/index.ts +43 -0
- package/src/metrics.js +25 -27
- package/src/metrics.types.ts +152 -0
- package/src/new-metrics.ts +317 -0
- package/src/utils.ts +17 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +394 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +465 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +1607 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +541 -0
- package/test/unit/spec/metrics.js +65 -97
- package/test/unit/spec/new-metrics.ts +269 -0
- package/test/unit/spec/utils.ts +22 -0
- package/tsconfig.json +6 -0
- package/dist/call-diagnostic-events-batcher.js +0 -60
- package/dist/call-diagnostic-events-batcher.js.map +0 -1
- package/src/call-diagnostic-events-batcher.js +0 -62
- package/src/index.js +0 -17
- package/test/unit/spec/call-diagnostic-events-batcher.js +0 -195
package/dist/config.js
CHANGED
|
@@ -4,7 +4,7 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = exports.CLIENT_NAME = void 0;
|
|
7
|
+
exports.default = exports.OS_NAME = exports.OSMap = exports.CLIENT_NAME = void 0;
|
|
8
8
|
var _common = require("@webex/common");
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
@@ -28,4 +28,23 @@ var _default = {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
exports.default = _default;
|
|
31
|
+
var OS_NAME = {
|
|
32
|
+
WINDOWS: 'windows',
|
|
33
|
+
MAC: 'mac',
|
|
34
|
+
IOS: 'ios',
|
|
35
|
+
ANDROID: 'android',
|
|
36
|
+
CHROME: 'chrome',
|
|
37
|
+
LINUX: 'linux',
|
|
38
|
+
OTHERS: 'other'
|
|
39
|
+
};
|
|
40
|
+
exports.OS_NAME = OS_NAME;
|
|
41
|
+
var OSMap = {
|
|
42
|
+
'Chrome OS': OS_NAME.CHROME,
|
|
43
|
+
macOS: OS_NAME.MAC,
|
|
44
|
+
Windows: OS_NAME.WINDOWS,
|
|
45
|
+
iOS: OS_NAME.IOS,
|
|
46
|
+
Android: OS_NAME.ANDROID,
|
|
47
|
+
Linux: OS_NAME.LINUX
|
|
48
|
+
};
|
|
49
|
+
exports.OSMap = OSMap;
|
|
31
50
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CLIENT_NAME","device","preDiscoveryServices","metricsServiceUrl","process","env","METRICS_SERVICE_URL","metrics","appType","inBrowser","batcherWait","batcherMaxCalls","batcherMaxWait","batcherRetryPlateau"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\n\nexport const CLIENT_NAME = 'webex-js-sdk';\nexport default {\n device: {\n preDiscoveryServices: {\n metricsServiceUrl:\n process.env.METRICS_SERVICE_URL || 'https://metrics-a.wbx2.com/metrics/api/v1',\n metrics: process.env.METRICS_SERVICE_URL || 'https://metrics-a.wbx2.com/metrics/api/v1',\n },\n },\n metrics: {\n appType: inBrowser ? 'browser' : 'nodejs',\n batcherWait: 500,\n batcherMaxCalls: 50,\n batcherMaxWait: 1500,\n batcherRetryPlateau: 32000,\n },\n};\n"],"mappings":";;;;;;;AAIA;AAJA;AACA;AACA;;AAIO,IAAMA,WAAW,GAAG,cAAc;AAAC;AAAA,eAC3B;EACbC,MAAM,EAAE;IACNC,oBAAoB,EAAE;MACpBC,iBAAiB,EACfC,OAAO,CAACC,GAAG,CAACC,mBAAmB,IAAI,2CAA2C;MAChFC,OAAO,EAAEH,OAAO,CAACC,GAAG,CAACC,mBAAmB,IAAI;IAC9C;EACF,CAAC;EACDC,OAAO,EAAE;IACPC,OAAO,EAAEC,iBAAS,GAAG,SAAS,GAAG,QAAQ;IACzCC,WAAW,EAAE,GAAG;IAChBC,eAAe,EAAE,EAAE;IACnBC,cAAc,EAAE,IAAI;IACpBC,mBAAmB,EAAE;EACvB;AACF,CAAC;AAAA"}
|
|
1
|
+
{"version":3,"names":["CLIENT_NAME","device","preDiscoveryServices","metricsServiceUrl","process","env","METRICS_SERVICE_URL","metrics","appType","inBrowser","batcherWait","batcherMaxCalls","batcherMaxWait","batcherRetryPlateau","OS_NAME","WINDOWS","MAC","IOS","ANDROID","CHROME","LINUX","OTHERS","OSMap","macOS","Windows","iOS","Android","Linux"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {inBrowser} from '@webex/common';\n\nexport const CLIENT_NAME = 'webex-js-sdk';\nexport default {\n device: {\n preDiscoveryServices: {\n metricsServiceUrl:\n process.env.METRICS_SERVICE_URL || 'https://metrics-a.wbx2.com/metrics/api/v1',\n metrics: process.env.METRICS_SERVICE_URL || 'https://metrics-a.wbx2.com/metrics/api/v1',\n },\n },\n metrics: {\n appType: inBrowser ? 'browser' : 'nodejs',\n batcherWait: 500,\n batcherMaxCalls: 50,\n batcherMaxWait: 1500,\n batcherRetryPlateau: 32000,\n },\n};\n\nexport const OS_NAME = {\n WINDOWS: 'windows',\n MAC: 'mac',\n IOS: 'ios',\n ANDROID: 'android',\n CHROME: 'chrome',\n LINUX: 'linux',\n OTHERS: 'other',\n};\n\nexport const OSMap = {\n 'Chrome OS': OS_NAME.CHROME,\n macOS: OS_NAME.MAC,\n Windows: OS_NAME.WINDOWS,\n iOS: OS_NAME.IOS,\n Android: OS_NAME.ANDROID,\n Linux: OS_NAME.LINUX,\n};\n"],"mappings":";;;;;;;AAIA;AAJA;AACA;AACA;;AAIO,IAAMA,WAAW,GAAG,cAAc;AAAC;AAAA,eAC3B;EACbC,MAAM,EAAE;IACNC,oBAAoB,EAAE;MACpBC,iBAAiB,EACfC,OAAO,CAACC,GAAG,CAACC,mBAAmB,IAAI,2CAA2C;MAChFC,OAAO,EAAEH,OAAO,CAACC,GAAG,CAACC,mBAAmB,IAAI;IAC9C;EACF,CAAC;EACDC,OAAO,EAAE;IACPC,OAAO,EAAEC,iBAAS,GAAG,SAAS,GAAG,QAAQ;IACzCC,WAAW,EAAE,GAAG;IAChBC,eAAe,EAAE,EAAE;IACnBC,cAAc,EAAE,IAAI;IACpBC,mBAAmB,EAAE;EACvB;AACF,CAAC;AAAA;AAEM,IAAMC,OAAO,GAAG;EACrBC,OAAO,EAAE,SAAS;EAClBC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACV,CAAC;AAAC;AAEK,IAAMC,KAAK,GAAG;EACnB,WAAW,EAAER,OAAO,CAACK,MAAM;EAC3BI,KAAK,EAAET,OAAO,CAACE,GAAG;EAClBQ,OAAO,EAAEV,OAAO,CAACC,OAAO;EACxBU,GAAG,EAAEX,OAAO,CAACG,GAAG;EAChBS,OAAO,EAAEZ,OAAO,CAACI,OAAO;EACxBS,KAAK,EAAEb,OAAO,CAACM;AACjB,CAAC;AAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
+
var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
3
5
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
4
7
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
8
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
9
|
value: true
|
|
7
10
|
});
|
|
11
|
+
exports.CallDiagnosticUtils = exports.CALL_DIAGNOSTIC_CONFIG = void 0;
|
|
12
|
+
_Object$defineProperty(exports, "NewMetrics", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _newMetrics.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.Utils = void 0;
|
|
8
19
|
_Object$defineProperty(exports, "config", {
|
|
9
20
|
enumerable: true,
|
|
10
21
|
get: function get() {
|
|
@@ -17,10 +28,25 @@ _Object$defineProperty(exports, "default", {
|
|
|
17
28
|
return _metrics.default;
|
|
18
29
|
}
|
|
19
30
|
});
|
|
31
|
+
_Object$defineProperty(exports, "getOSNameInternal", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _metrics.getOSNameInternal;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
20
37
|
require("@webex/internal-plugin-device");
|
|
21
38
|
var _webexCore = require("@webex/webex-core");
|
|
22
|
-
var _metrics =
|
|
39
|
+
var _metrics = _interopRequireWildcard(require("./metrics"));
|
|
23
40
|
var _config = _interopRequireDefault(require("./config"));
|
|
41
|
+
var _newMetrics = _interopRequireDefault(require("./new-metrics"));
|
|
42
|
+
var Utils = _interopRequireWildcard(require("./utils"));
|
|
43
|
+
exports.Utils = Utils;
|
|
44
|
+
var CALL_DIAGNOSTIC_CONFIG = _interopRequireWildcard(require("./call-diagnostic/config"));
|
|
45
|
+
exports.CALL_DIAGNOSTIC_CONFIG = CALL_DIAGNOSTIC_CONFIG;
|
|
46
|
+
var CallDiagnosticUtils = _interopRequireWildcard(require("./call-diagnostic/call-diagnostic-metrics.util"));
|
|
47
|
+
exports.CallDiagnosticUtils = CallDiagnosticUtils;
|
|
48
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
49
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
50
|
/*!
|
|
25
51
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
26
52
|
*/
|
|
@@ -28,4 +54,7 @@ var _config = _interopRequireDefault(require("./config"));
|
|
|
28
54
|
(0, _webexCore.registerInternalPlugin)('metrics', _metrics.default, {
|
|
29
55
|
config: _config.default
|
|
30
56
|
});
|
|
57
|
+
(0, _webexCore.registerInternalPlugin)('newMetrics', _newMetrics.default, {
|
|
58
|
+
config: _config.default
|
|
59
|
+
});
|
|
31
60
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerInternalPlugin","Metrics","config"],"sources":["index.
|
|
1
|
+
{"version":3,"names":["registerInternalPlugin","Metrics","config","NewMetrics"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-device';\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} from './metrics.types';\nimport * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';\nimport * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';\n\nregisterInternalPlugin('metrics', Metrics, {\n config,\n});\n\nregisterInternalPlugin('newMetrics', NewMetrics, {\n config,\n});\n\nexport {default, getOSNameInternal} from './metrics';\nexport {config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils};\nexport type {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitMQE,\n SubmitOperationalEvent,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;AAEA;AAEA;AACA;AACA;AACA;AAAiC;AAUjC;AAAmE;AACnE;AAAsF;AAAA;AAAA;AAtBtF;AACA;AACA;;AAsBA,IAAAA,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
|
@@ -11,13 +11,13 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
11
11
|
value: true
|
|
12
12
|
});
|
|
13
13
|
exports.default = void 0;
|
|
14
|
+
exports.getOSNameInternal = getOSNameInternal;
|
|
14
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
15
16
|
var _webexCore = require("@webex/webex-core");
|
|
16
17
|
var _common = require("@webex/common");
|
|
17
18
|
var _config = require("./config");
|
|
18
19
|
var _batcher = _interopRequireDefault(require("./batcher"));
|
|
19
20
|
var _clientMetricsBatcher = _interopRequireDefault(require("./client-metrics-batcher"));
|
|
20
|
-
var _callDiagnosticEventsBatcher = _interopRequireDefault(require("./call-diagnostic-events-batcher"));
|
|
21
21
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
23
|
var _BrowserDetection = (0, _common.BrowserDetection)(),
|
|
@@ -25,6 +25,10 @@ var _BrowserDetection = (0, _common.BrowserDetection)(),
|
|
|
25
25
|
getOSVersion = _BrowserDetection.getOSVersion,
|
|
26
26
|
getBrowserName = _BrowserDetection.getBrowserName,
|
|
27
27
|
getBrowserVersion = _BrowserDetection.getBrowserVersion;
|
|
28
|
+
function getOSNameInternal() {
|
|
29
|
+
var _OSMap$getOSName;
|
|
30
|
+
return (_OSMap$getOSName = _config.OSMap[getOSName()]) !== null && _OSMap$getOSName !== void 0 ? _OSMap$getOSName : _config.OS_NAME.OTHERS;
|
|
31
|
+
}
|
|
28
32
|
function getSparkUserAgent(webex) {
|
|
29
33
|
var _webex$config;
|
|
30
34
|
var _ref = (_webex$config = webex === null || webex === void 0 ? void 0 : webex.config) !== null && _webex$config !== void 0 ? _webex$config : {},
|
|
@@ -43,8 +47,7 @@ function getSparkUserAgent(webex) {
|
|
|
43
47
|
var Metrics = _webexCore.WebexPlugin.extend({
|
|
44
48
|
children: {
|
|
45
49
|
batcher: _batcher.default,
|
|
46
|
-
clientMetricsBatcher: _clientMetricsBatcher.default
|
|
47
|
-
callDiagnosticEventsBatcher: _callDiagnosticEventsBatcher.default
|
|
50
|
+
clientMetricsBatcher: _clientMetricsBatcher.default
|
|
48
51
|
},
|
|
49
52
|
namespace: 'Metrics',
|
|
50
53
|
submit: function submit(key, value) {
|
|
@@ -53,15 +56,12 @@ var Metrics = _webexCore.WebexPlugin.extend({
|
|
|
53
56
|
}, value));
|
|
54
57
|
},
|
|
55
58
|
/**
|
|
56
|
-
*
|
|
59
|
+
* Returns the payload for submitting client metrics.
|
|
57
60
|
* @param {string} eventName
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
60
|
-
* @returns {Object} HttpResponse object
|
|
61
|
+
* @param {any} props
|
|
62
|
+
* @returns {any} - the payload
|
|
61
63
|
*/
|
|
62
|
-
|
|
63
|
-
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
64
|
-
var preLoginId = arguments.length > 2 ? arguments[2] : undefined;
|
|
64
|
+
getClientMetricsPayload: function getClientMetricsPayload(eventName, props) {
|
|
65
65
|
if (!eventName) {
|
|
66
66
|
throw Error('Missing behavioral metric name. Please provide one');
|
|
67
67
|
}
|
|
@@ -70,25 +70,19 @@ var Metrics = _webexCore.WebexPlugin.extend({
|
|
|
70
70
|
};
|
|
71
71
|
payload.tags = _objectSpread(_objectSpread({}, props.tags), {}, {
|
|
72
72
|
browser: getBrowserName(),
|
|
73
|
-
os:
|
|
73
|
+
os: getOSNameInternal(),
|
|
74
74
|
// Node does not like this so we need to check if it exists or not
|
|
75
75
|
// eslint-disable-next-line no-undef
|
|
76
|
-
domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser'
|
|
77
|
-
// Check what else we could measure
|
|
78
|
-
client_id: this.webex.credentials.config.client_id,
|
|
79
|
-
user_id: this.webex.internal.device.userId
|
|
76
|
+
domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser' // Check what else we could measure
|
|
80
77
|
});
|
|
81
|
-
|
|
82
|
-
payload.tags.org_id = this.webex.credentials.getOrgId();
|
|
83
|
-
} catch (_unused) {
|
|
84
|
-
this.logger.info('metrics: unable to get orgId');
|
|
85
|
-
}
|
|
78
|
+
|
|
86
79
|
payload.fields = _objectSpread(_objectSpread({}, props.fields), {}, {
|
|
87
80
|
browser_version: getBrowserVersion(),
|
|
88
81
|
os_version: getOSVersion(),
|
|
89
82
|
sdk_version: this.webex.version,
|
|
90
83
|
platform: 'Web',
|
|
91
|
-
spark_user_agent: getSparkUserAgent(this.webex)
|
|
84
|
+
spark_user_agent: getSparkUserAgent(this.webex),
|
|
85
|
+
client_id: this.webex.credentials.config.client_id
|
|
92
86
|
});
|
|
93
87
|
payload.type = props.type || this.webex.config.metrics.type;
|
|
94
88
|
payload.context = _objectSpread(_objectSpread({}, props.context), {}, {
|
|
@@ -97,7 +91,7 @@ var Metrics = _webexCore.WebexPlugin.extend({
|
|
|
97
91
|
},
|
|
98
92
|
locale: 'en-US',
|
|
99
93
|
os: {
|
|
100
|
-
name:
|
|
94
|
+
name: getOSNameInternal(),
|
|
101
95
|
version: getOSVersion()
|
|
102
96
|
}
|
|
103
97
|
});
|
|
@@ -108,6 +102,19 @@ var Metrics = _webexCore.WebexPlugin.extend({
|
|
|
108
102
|
// Mocking the time in tests when running in node
|
|
109
103
|
// is impossible so unable to use Date.now()
|
|
110
104
|
payload.timestamp = new Date().valueOf();
|
|
105
|
+
return payload;
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* This corresponds to #sendSemiStructured() in the deprecated metrics handler
|
|
109
|
+
* @param {string} eventName
|
|
110
|
+
* @param {Object} props
|
|
111
|
+
* @param {string} preLoginId
|
|
112
|
+
* @returns {Object} HttpResponse object
|
|
113
|
+
*/
|
|
114
|
+
submitClientMetrics: function submitClientMetrics(eventName) {
|
|
115
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
116
|
+
var preLoginId = arguments.length > 2 ? arguments[2] : undefined;
|
|
117
|
+
var payload = this.getClientMetricsPayload(eventName, props);
|
|
111
118
|
if (preLoginId) {
|
|
112
119
|
var _payload = {
|
|
113
120
|
metrics: [payload]
|
|
@@ -154,14 +161,7 @@ var Metrics = _webexCore.WebexPlugin.extend({
|
|
|
154
161
|
});
|
|
155
162
|
});
|
|
156
163
|
},
|
|
157
|
-
|
|
158
|
-
var event = {
|
|
159
|
-
type: 'diagnostic-event',
|
|
160
|
-
eventPayload: payload
|
|
161
|
-
};
|
|
162
|
-
return this.callDiagnosticEventsBatcher.request(event);
|
|
163
|
-
},
|
|
164
|
-
version: "3.0.0-beta.27"
|
|
164
|
+
version: "3.0.0-beta.270"
|
|
165
165
|
});
|
|
166
166
|
var _default = Metrics;
|
|
167
167
|
exports.default = _default;
|
package/dist/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BrowserDetection","getOSName","getOSVersion","getBrowserName","getBrowserVersion","getSparkUserAgent","webex","config","appName","appVersion","appPlatform","sparkUserAgent","CLIENT_NAME","Metrics","WebexPlugin","extend","children","batcher","Batcher","clientMetricsBatcher","ClientMetricsBatcher","
|
|
1
|
+
{"version":3,"names":["BrowserDetection","getOSName","getOSVersion","getBrowserName","getBrowserVersion","getOSNameInternal","OSMap","OS_NAME","OTHERS","getSparkUserAgent","webex","config","appName","appVersion","appPlatform","sparkUserAgent","CLIENT_NAME","Metrics","WebexPlugin","extend","children","batcher","Batcher","clientMetricsBatcher","ClientMetricsBatcher","namespace","submit","key","value","request","getClientMetricsPayload","eventName","props","Error","payload","metricName","tags","browser","os","domain","window","location","hostname","fields","browser_version","os_version","sdk_version","version","platform","spark_user_agent","client_id","credentials","type","metrics","context","app","locale","name","eventPayload","timestamp","Date","valueOf","submitClientMetrics","preLoginId","_payload","postPreLoginMetric","aliasUser","method","api","resource","headers","body","qs","alias","getClientToken","then","token","authorization","toString"],"sources":["metrics.js"],"sourcesContent":["/* eslint-disable default-param-last */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {BrowserDetection} from '@webex/common';\nimport {OS_NAME, OSMap, CLIENT_NAME} from './config';\n\nimport Batcher from './batcher';\nimport ClientMetricsBatcher from './client-metrics-batcher';\n\nconst {getOSName, getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();\n\nexport function getOSNameInternal() {\n return OSMap[getOSName()] ?? OS_NAME.OTHERS;\n}\n\nfunction getSparkUserAgent(webex) {\n const {appName, appVersion, appPlatform} = webex?.config ?? {};\n\n let sparkUserAgent = CLIENT_NAME;\n\n if (appName) {\n sparkUserAgent += ` ${appName}/${appVersion ?? '0.0'}`;\n }\n\n if (appPlatform) {\n sparkUserAgent += ` ${appPlatform}`;\n }\n\n return sparkUserAgent;\n}\n\nconst Metrics = WebexPlugin.extend({\n children: {\n batcher: Batcher,\n clientMetricsBatcher: ClientMetricsBatcher,\n },\n\n namespace: 'Metrics',\n\n submit(key, value) {\n return this.batcher.request({key, ...value});\n },\n\n /**\n * Returns the payload for submitting client metrics.\n * @param {string} eventName\n * @param {any} props\n * @returns {any} - the payload\n */\n getClientMetricsPayload(eventName, props) {\n if (!eventName) {\n throw Error('Missing behavioral metric name. Please provide one');\n }\n const payload = {metricName: eventName};\n\n payload.tags = {\n ...props.tags,\n browser: getBrowserName(),\n os: getOSNameInternal(),\n\n // Node does not like this so we need to check if it exists or not\n // eslint-disable-next-line no-undef\n domain:\n typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser', // Check what else we could measure\n };\n\n payload.fields = {\n ...props.fields,\n browser_version: getBrowserVersion(),\n os_version: getOSVersion(),\n sdk_version: this.webex.version,\n platform: 'Web',\n spark_user_agent: getSparkUserAgent(this.webex),\n client_id: this.webex.credentials.config.client_id,\n };\n\n payload.type = props.type || this.webex.config.metrics.type;\n\n payload.context = {\n ...props.context,\n app: {\n version: this.webex.version,\n },\n locale: 'en-US',\n os: {\n name: getOSNameInternal(),\n version: getOSVersion(),\n },\n };\n\n if (props.eventPayload) {\n payload.eventPayload = props.eventPayload;\n }\n\n // Mocking the time in tests when running in node\n // is impossible so unable to use Date.now()\n payload.timestamp = new Date().valueOf();\n\n return payload;\n },\n\n /**\n * This corresponds to #sendSemiStructured() in the deprecated metrics handler\n * @param {string} eventName\n * @param {Object} props\n * @param {string} preLoginId\n * @returns {Object} HttpResponse object\n */\n submitClientMetrics(eventName, props = {}, preLoginId) {\n const payload = this.getClientMetricsPayload(eventName, props);\n\n if (preLoginId) {\n const _payload = {\n metrics: [payload],\n };\n\n // Do not batch these because pre-login events occur during onboarding, so we will be partially blind\n // to users' progress through the reg flow if we wait to persist pre-login metrics for people who drop off because\n // their metrics will not post from a queue flush in time\n return this.postPreLoginMetric(_payload, preLoginId);\n }\n\n return this.clientMetricsBatcher.request(payload);\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 aliasUser(preLoginId) {\n return this.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 },\n\n postPreLoginMetric(payload, preLoginId) {\n return this.webex.credentials.getClientToken().then((token) =>\n this.request({\n method: 'POST',\n api: 'metrics',\n resource: 'clientmetrics-prelogin',\n headers: {\n authorization: token.toString(),\n 'x-prelogin-userid': preLoginId,\n },\n body: payload,\n })\n );\n },\n});\n\nexport default Metrics;\n"],"mappings":";;;;;;;;;;;;;;;AAMA;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AC;AAAC,eAEYjB,OAAO;AAAA"}
|
|
@@ -0,0 +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 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};\n\nexport type SubmitMQEOptions = {\n meetingId: string;\n mediaConnections?: any[];\n networkType?: Event['origin']['networkType'];\n};\n\nexport type InternalEvent = {\n name:\n | 'internal.client.meetinginfo.request'\n | 'internal.client.meetinginfo.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 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 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"],"mappings":""}
|
|
@@ -0,0 +1,333 @@
|
|
|
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 _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
11
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
13
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
15
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
17
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
20
|
+
var _webexCore = require("@webex/webex-core");
|
|
21
|
+
var _callDiagnosticMetrics = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics"));
|
|
22
|
+
var _callDiagnosticMetricsLatencies = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics-latencies"));
|
|
23
|
+
var _callDiagnosticMetrics2 = require("./call-diagnostic/call-diagnostic-metrics.util");
|
|
24
|
+
var _utils = require("./utils");
|
|
25
|
+
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); }; }
|
|
26
|
+
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; } }
|
|
27
|
+
/**
|
|
28
|
+
* Metrics plugin to centralize all types of metrics.
|
|
29
|
+
* @class
|
|
30
|
+
*/
|
|
31
|
+
var Metrics = /*#__PURE__*/function (_WebexPlugin) {
|
|
32
|
+
(0, _inherits2.default)(Metrics, _WebexPlugin);
|
|
33
|
+
var _super = _createSuper(Metrics);
|
|
34
|
+
// eslint-disable-next-line no-use-before-define
|
|
35
|
+
|
|
36
|
+
// Call Diagnostic latencies
|
|
37
|
+
|
|
38
|
+
// Helper classes to handle the different types of metrics
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Constructor
|
|
42
|
+
* @param args
|
|
43
|
+
* @constructor
|
|
44
|
+
* @private
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
function Metrics() {
|
|
48
|
+
var _this;
|
|
49
|
+
(0, _classCallCheck2.default)(this, Metrics);
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
54
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticLatencies", void 0);
|
|
55
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticMetrics", void 0);
|
|
56
|
+
_this.onReady();
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* On Ready
|
|
62
|
+
*/
|
|
63
|
+
(0, _createClass2.default)(Metrics, [{
|
|
64
|
+
key: "onReady",
|
|
65
|
+
value: function onReady() {
|
|
66
|
+
var _this2 = this;
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
this.webex.once('ready', function () {
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
_this2.callDiagnosticMetrics = new _callDiagnosticMetrics.default({}, {
|
|
71
|
+
parent: _this2.webex
|
|
72
|
+
});
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
_this2.callDiagnosticLatencies = new _callDiagnosticMetricsLatencies.default({}, {
|
|
75
|
+
parent: _this2.webex
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Used for internal purposes only
|
|
82
|
+
* @param args
|
|
83
|
+
*/
|
|
84
|
+
}, {
|
|
85
|
+
key: "submitInternalEvent",
|
|
86
|
+
value: function submitInternalEvent(_ref) {
|
|
87
|
+
var name = _ref.name,
|
|
88
|
+
payload = _ref.payload,
|
|
89
|
+
options = _ref.options;
|
|
90
|
+
if (name === 'internal.reset.join.latencies') {
|
|
91
|
+
this.callDiagnosticLatencies.clearTimestamps();
|
|
92
|
+
} else {
|
|
93
|
+
this.callDiagnosticLatencies.saveTimestamp({
|
|
94
|
+
key: name
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Behavioral event
|
|
101
|
+
* @param args
|
|
102
|
+
*/
|
|
103
|
+
}, {
|
|
104
|
+
key: "submitBehavioralEvent",
|
|
105
|
+
value: function submitBehavioralEvent(_ref2) {
|
|
106
|
+
var name = _ref2.name,
|
|
107
|
+
payload = _ref2.payload,
|
|
108
|
+
options = _ref2.options;
|
|
109
|
+
this.callDiagnosticLatencies.saveTimestamp({
|
|
110
|
+
key: name
|
|
111
|
+
});
|
|
112
|
+
throw new Error('Not implemented.');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Operational event
|
|
117
|
+
* @param args
|
|
118
|
+
*/
|
|
119
|
+
}, {
|
|
120
|
+
key: "submitOperationalEvent",
|
|
121
|
+
value: function submitOperationalEvent(_ref3) {
|
|
122
|
+
var name = _ref3.name,
|
|
123
|
+
payload = _ref3.payload,
|
|
124
|
+
options = _ref3.options;
|
|
125
|
+
throw new Error('Not implemented.');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Call Analyzer: Media Quality Event
|
|
130
|
+
* @param args
|
|
131
|
+
*/
|
|
132
|
+
}, {
|
|
133
|
+
key: "submitMQE",
|
|
134
|
+
value: function submitMQE(_ref4) {
|
|
135
|
+
var name = _ref4.name,
|
|
136
|
+
payload = _ref4.payload,
|
|
137
|
+
options = _ref4.options;
|
|
138
|
+
this.callDiagnosticLatencies.saveTimestamp({
|
|
139
|
+
key: name
|
|
140
|
+
});
|
|
141
|
+
this.callDiagnosticMetrics.submitMQE({
|
|
142
|
+
name: name,
|
|
143
|
+
payload: payload,
|
|
144
|
+
options: options
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Call Analyzer: Feature Usage Event
|
|
150
|
+
* @param args
|
|
151
|
+
*/
|
|
152
|
+
}, {
|
|
153
|
+
key: "submitFeatureEvent",
|
|
154
|
+
value: function submitFeatureEvent(_ref5) {
|
|
155
|
+
var name = _ref5.name,
|
|
156
|
+
payload = _ref5.payload,
|
|
157
|
+
options = _ref5.options;
|
|
158
|
+
throw new Error('Not implemented.');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Call Analyzer: Client Event
|
|
163
|
+
* @public
|
|
164
|
+
* @param args
|
|
165
|
+
*/
|
|
166
|
+
}, {
|
|
167
|
+
key: "submitClientEvent",
|
|
168
|
+
value: function submitClientEvent(_ref6) {
|
|
169
|
+
var name = _ref6.name,
|
|
170
|
+
payload = _ref6.payload,
|
|
171
|
+
options = _ref6.options;
|
|
172
|
+
if (!this.callDiagnosticLatencies || !this.callDiagnosticMetrics) {
|
|
173
|
+
// @ts-ignore
|
|
174
|
+
this.webex.logger.log("NewMetrics: @submitClientEvent. Attempted to submit before webex.ready. Event name: ".concat(name));
|
|
175
|
+
return _promise.default.resolve();
|
|
176
|
+
}
|
|
177
|
+
this.callDiagnosticLatencies.saveTimestamp({
|
|
178
|
+
key: name,
|
|
179
|
+
options: {
|
|
180
|
+
meetingId: options === null || options === void 0 ? void 0 : options.meetingId
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return this.callDiagnosticMetrics.submitClientEvent({
|
|
184
|
+
name: name,
|
|
185
|
+
payload: payload,
|
|
186
|
+
options: options
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Submit a pre-login metric to clientmetrics
|
|
192
|
+
* @public
|
|
193
|
+
* @param payload
|
|
194
|
+
* @param preLoginId - pre-login ID of user
|
|
195
|
+
* @returns
|
|
196
|
+
*/
|
|
197
|
+
}, {
|
|
198
|
+
key: "postPreLoginMetric",
|
|
199
|
+
value: function postPreLoginMetric(payload, preLoginId) {
|
|
200
|
+
var _this3 = this;
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
return this.webex.request({
|
|
203
|
+
method: 'POST',
|
|
204
|
+
api: 'metrics',
|
|
205
|
+
resource: 'clientmetrics-prelogin',
|
|
206
|
+
headers: {
|
|
207
|
+
authorization: false,
|
|
208
|
+
'x-prelogin-userid': preLoginId
|
|
209
|
+
},
|
|
210
|
+
body: {
|
|
211
|
+
metrics: [payload]
|
|
212
|
+
}
|
|
213
|
+
}).then(function (res) {
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
_this3.webex.logger.log("NewMetrics: @postPreLoginMetric. Request successful:", res);
|
|
216
|
+
return res;
|
|
217
|
+
}).catch(function (err) {
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
_this3.logger.error("NewMetrics: @postPreLoginMetric. Request failed:", "err: ".concat((0, _utils.generateCommonErrorMetadata)(err)));
|
|
220
|
+
return _promise.default.reject(err);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Issue request to alias a user's pre-login ID with their CI UUID
|
|
226
|
+
* @param {string} preLoginId
|
|
227
|
+
* @returns {Object} HttpResponse object
|
|
228
|
+
*/
|
|
229
|
+
}, {
|
|
230
|
+
key: "clientMetricsAliasUser",
|
|
231
|
+
value: function clientMetricsAliasUser(preLoginId) {
|
|
232
|
+
var _this4 = this;
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
return this.webex.request({
|
|
235
|
+
method: 'POST',
|
|
236
|
+
api: 'metrics',
|
|
237
|
+
resource: 'clientmetrics',
|
|
238
|
+
headers: {
|
|
239
|
+
'x-prelogin-userid': preLoginId
|
|
240
|
+
},
|
|
241
|
+
body: {},
|
|
242
|
+
qs: {
|
|
243
|
+
alias: true
|
|
244
|
+
}
|
|
245
|
+
}).then(function (res) {
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
_this4.webex.logger.log("NewMetrics: @clientMetricsAliasUser. Request successful:", res);
|
|
248
|
+
return res;
|
|
249
|
+
}).catch(function (err) {
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
_this4.logger.error("NewMetrics: @clientMetricsAliasUser. Request failed:", "err: ".concat((0, _utils.generateCommonErrorMetadata)(err)));
|
|
252
|
+
return _promise.default.reject(err);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Returns a promise that will resolve to fetch options for submitting a metric.
|
|
258
|
+
*
|
|
259
|
+
* This is to support quickly submitting metrics when the browser/tab is closing.
|
|
260
|
+
* Calling submitClientEvent will not work because there some async steps that will
|
|
261
|
+
* not complete before the browser is closed. Instead, we pre-gather all the
|
|
262
|
+
* information/options needed for the request(s), and then simply and quickly
|
|
263
|
+
* fire the fetch(es) when beforeUnload is triggered.
|
|
264
|
+
*
|
|
265
|
+
* We must use fetch instead of request because fetch has a keepalive option that
|
|
266
|
+
* allows the request it to outlive the page.
|
|
267
|
+
*
|
|
268
|
+
* Note: the timings values will be wrong, but setMetricTimingsAndFetch() will
|
|
269
|
+
* properly adjust them before submitting.
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
* @param {Object} arg
|
|
273
|
+
* @param {String} arg.name - event name
|
|
274
|
+
* @param {Object} arg.payload - event payload
|
|
275
|
+
* @param {Object} arg.options - other options
|
|
276
|
+
* @returns {Promise} promise that resolves to options to be used with fetch
|
|
277
|
+
*/
|
|
278
|
+
}, {
|
|
279
|
+
key: "buildClientEventFetchRequestOptions",
|
|
280
|
+
value: function () {
|
|
281
|
+
var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref7) {
|
|
282
|
+
var name, payload, options;
|
|
283
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
284
|
+
while (1) switch (_context.prev = _context.next) {
|
|
285
|
+
case 0:
|
|
286
|
+
name = _ref7.name, payload = _ref7.payload, options = _ref7.options;
|
|
287
|
+
return _context.abrupt("return", this.callDiagnosticMetrics.buildClientEventFetchRequestOptions({
|
|
288
|
+
name: name,
|
|
289
|
+
payload: payload,
|
|
290
|
+
options: options
|
|
291
|
+
}));
|
|
292
|
+
case 2:
|
|
293
|
+
case "end":
|
|
294
|
+
return _context.stop();
|
|
295
|
+
}
|
|
296
|
+
}, _callee, this);
|
|
297
|
+
}));
|
|
298
|
+
function buildClientEventFetchRequestOptions(_x) {
|
|
299
|
+
return _buildClientEventFetchRequestOptions.apply(this, arguments);
|
|
300
|
+
}
|
|
301
|
+
return buildClientEventFetchRequestOptions;
|
|
302
|
+
}()
|
|
303
|
+
/**
|
|
304
|
+
* Submits a metric from pre-built request options via the fetch API. Updates
|
|
305
|
+
* the "$timings" and "originTime" values to Date.now() since the existing times
|
|
306
|
+
* were set when the options were built (not submitted).
|
|
307
|
+
* @param {any} options - the pre-built request options for submitting a metric
|
|
308
|
+
* @returns {Promise} promise that resolves to the response object
|
|
309
|
+
*/
|
|
310
|
+
}, {
|
|
311
|
+
key: "setMetricTimingsAndFetch",
|
|
312
|
+
value: function setMetricTimingsAndFetch(options) {
|
|
313
|
+
// @ts-ignore
|
|
314
|
+
return this.webex.setTimingsAndFetch((0, _callDiagnosticMetrics2.setMetricTimings)(options));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Returns true if the specified serviceErrorCode maps to an expected error.
|
|
319
|
+
* @param {number} serviceErrorCode the service error code
|
|
320
|
+
* @returns {boolean}
|
|
321
|
+
*/
|
|
322
|
+
}, {
|
|
323
|
+
key: "isServiceErrorExpected",
|
|
324
|
+
value: function isServiceErrorExpected(serviceErrorCode) {
|
|
325
|
+
return this.callDiagnosticMetrics.isServiceErrorExpected(serviceErrorCode);
|
|
326
|
+
}
|
|
327
|
+
}]);
|
|
328
|
+
return Metrics;
|
|
329
|
+
}(_webexCore.WebexPlugin);
|
|
330
|
+
(0, _defineProperty2.default)(Metrics, "instance", void 0);
|
|
331
|
+
var _default = Metrics;
|
|
332
|
+
exports.default = _default;
|
|
333
|
+
//# sourceMappingURL=new-metrics.js.map
|