@webex/internal-plugin-metrics 1.156.0 → 1.156.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/metrics.js +84 -28
- package/dist/metrics.js.map +1 -1
- package/package.json +5 -5
- package/src/config.js +1 -0
- package/src/metrics.js +74 -19
- package/test/unit/spec/metrics.js +37 -0
package/dist/config.js
CHANGED
|
@@ -6,13 +6,15 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
exports.default = void 0;
|
|
9
|
+
exports.default = exports.CLIENT_NAME = void 0;
|
|
10
10
|
|
|
11
11
|
var _common = require("@webex/common");
|
|
12
12
|
|
|
13
13
|
/*!
|
|
14
14
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
15
15
|
*/
|
|
16
|
+
var CLIENT_NAME = 'webex-js-sdk';
|
|
17
|
+
exports.CLIENT_NAME = CLIENT_NAME;
|
|
16
18
|
var _default = {
|
|
17
19
|
device: {
|
|
18
20
|
preDiscoveryServices: {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["config.js"],"names":["device","preDiscoveryServices","metricsServiceUrl","process","env","METRICS_SERVICE_URL","metrics","appType","inBrowser","batcherWait","batcherMaxCalls","batcherMaxWait","batcherRetryPlateau"],"mappings":";;;;;;;;;;AAIA;;AAJA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["config.js"],"names":["CLIENT_NAME","device","preDiscoveryServices","metricsServiceUrl","process","env","METRICS_SERVICE_URL","metrics","appType","inBrowser","batcherWait","batcherMaxCalls","batcherMaxWait","batcherRetryPlateau"],"mappings":";;;;;;;;;;AAIA;;AAJA;AACA;AACA;AAIO,IAAMA,WAAW,GAAG,cAApB;;eACQ;AACbC,EAAAA,MAAM,EAAE;AACNC,IAAAA,oBAAoB,EAAE;AACpBC,MAAAA,iBAAiB,EAAEC,OAAO,CAACC,GAAR,CAAYC,mBAAZ,IAAmC,2CADlC;AAEpBC,MAAAA,OAAO,EAAEH,OAAO,CAACC,GAAR,CAAYC,mBAAZ,IAAmC;AAFxB;AADhB,GADK;AAObC,EAAAA,OAAO,EAAE;AACPC,IAAAA,OAAO,EAAEC,oBAAY,SAAZ,GAAwB,QAD1B;AAEPC,IAAAA,WAAW,EAAE,GAFN;AAGPC,IAAAA,eAAe,EAAE,EAHV;AAIPC,IAAAA,cAAc,EAAE,IAJT;AAKPC,IAAAA,mBAAmB,EAAE;AALd;AAPI,C","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: 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"]}
|
package/dist/metrics.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
4
|
+
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
6
|
+
|
|
7
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
8
|
+
|
|
9
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
10
|
+
|
|
11
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
12
|
+
|
|
3
13
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
14
|
|
|
5
15
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
@@ -10,36 +20,62 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
10
20
|
|
|
11
21
|
exports.default = void 0;
|
|
12
22
|
|
|
23
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
24
|
+
|
|
13
25
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
14
26
|
|
|
15
27
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
16
28
|
|
|
17
|
-
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
|
|
18
|
-
|
|
19
|
-
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
20
|
-
|
|
21
29
|
var _webexCore = require("@webex/webex-core");
|
|
22
30
|
|
|
23
31
|
var _common = require("@webex/common");
|
|
24
32
|
|
|
33
|
+
var _config = require("./config");
|
|
34
|
+
|
|
25
35
|
var _batcher = _interopRequireDefault(require("./batcher"));
|
|
26
36
|
|
|
27
37
|
var _clientMetricsBatcher = _interopRequireDefault(require("./client-metrics-batcher"));
|
|
28
38
|
|
|
29
39
|
var _callDiagnosticEventsBatcher = _interopRequireDefault(require("./call-diagnostic-events-batcher"));
|
|
30
40
|
|
|
31
|
-
var
|
|
41
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
32
42
|
|
|
33
|
-
var
|
|
43
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
44
|
+
|
|
45
|
+
var _BrowserDetection = (0, _common.BrowserDetection)(),
|
|
46
|
+
getOSName = _BrowserDetection.getOSName,
|
|
47
|
+
getOSVersion = _BrowserDetection.getOSVersion,
|
|
48
|
+
getBrowserName = _BrowserDetection.getBrowserName,
|
|
49
|
+
getBrowserVersion = _BrowserDetection.getBrowserVersion;
|
|
50
|
+
|
|
51
|
+
function getSparkUserAgent(webex) {
|
|
52
|
+
var _webex$config;
|
|
53
|
+
|
|
54
|
+
var _ref = (_webex$config = webex === null || webex === void 0 ? void 0 : webex.config) !== null && _webex$config !== void 0 ? _webex$config : {},
|
|
55
|
+
appName = _ref.appName,
|
|
56
|
+
appVersion = _ref.appVersion,
|
|
57
|
+
appPlatform = _ref.appPlatform;
|
|
58
|
+
|
|
59
|
+
var sparkUserAgent = _config.CLIENT_NAME;
|
|
60
|
+
|
|
61
|
+
if (appName) {
|
|
62
|
+
sparkUserAgent += " ".concat(appName, "/").concat(appVersion !== null && appVersion !== void 0 ? appVersion : '0.0');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (appPlatform) {
|
|
66
|
+
sparkUserAgent += " ".concat(appPlatform);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return sparkUserAgent;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var Metrics = _webexCore.WebexPlugin.extend({
|
|
34
73
|
children: {
|
|
35
74
|
batcher: _batcher.default,
|
|
36
75
|
clientMetricsBatcher: _clientMetricsBatcher.default,
|
|
37
76
|
callDiagnosticEventsBatcher: _callDiagnosticEventsBatcher.default
|
|
38
77
|
},
|
|
39
78
|
namespace: 'Metrics',
|
|
40
|
-
sendUnstructured: function sendUnstructured(key, value) {
|
|
41
|
-
return this.submit(key, value);
|
|
42
|
-
},
|
|
43
79
|
submit: function submit(key, value) {
|
|
44
80
|
return this.batcher.request((0, _assign.default)({
|
|
45
81
|
key: key
|
|
@@ -53,26 +89,46 @@ var Metrics = _webexCore.WebexPlugin.extend((_dec = (0, _common.deprecated)('Met
|
|
|
53
89
|
* @param {string} preLoginId
|
|
54
90
|
* @returns {Object} HttpResponse object
|
|
55
91
|
*/
|
|
56
|
-
submitClientMetrics: function submitClientMetrics(eventName
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
if (props.tags) {
|
|
62
|
-
payload.tags = props.tags;
|
|
63
|
-
}
|
|
92
|
+
submitClientMetrics: function submitClientMetrics(eventName) {
|
|
93
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
94
|
+
var preLoginId = arguments.length > 2 ? arguments[2] : undefined;
|
|
64
95
|
|
|
65
|
-
if (
|
|
66
|
-
|
|
96
|
+
if (!eventName) {
|
|
97
|
+
throw Error('Missing behavioral metric name. Please provide one');
|
|
67
98
|
}
|
|
68
99
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
var payload = {
|
|
101
|
+
metricName: eventName
|
|
102
|
+
};
|
|
103
|
+
payload.tags = _objectSpread(_objectSpread({}, props.tags), {}, {
|
|
104
|
+
browser: getBrowserName(),
|
|
105
|
+
org_id: this.webex.credentials.getOrgId(),
|
|
106
|
+
os: getOSName(),
|
|
107
|
+
// Node does not like this so we need to check if it exists or not
|
|
108
|
+
// eslint-disable-next-line no-undef
|
|
109
|
+
domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser',
|
|
110
|
+
// Check what else we could measure
|
|
111
|
+
client_id: this.webex.credentials.config.client_id,
|
|
112
|
+
user_id: this.webex.internal.device.userId
|
|
113
|
+
});
|
|
114
|
+
payload.fields = _objectSpread(_objectSpread({}, props.fields), {}, {
|
|
115
|
+
browser_version: getBrowserVersion(),
|
|
116
|
+
os_version: getOSVersion(),
|
|
117
|
+
sdk_version: this.webex.version,
|
|
118
|
+
platform: 'Web',
|
|
119
|
+
spark_user_agent: getSparkUserAgent(this.webex)
|
|
120
|
+
});
|
|
121
|
+
payload.type = props.type || this.webex.config.metrics.type;
|
|
122
|
+
payload.context = _objectSpread(_objectSpread({}, props.context), {}, {
|
|
123
|
+
app: {
|
|
124
|
+
version: this.webex.version
|
|
125
|
+
},
|
|
126
|
+
locale: 'en-US',
|
|
127
|
+
os: {
|
|
128
|
+
name: getOSName(),
|
|
129
|
+
version: getOSVersion()
|
|
130
|
+
}
|
|
131
|
+
});
|
|
76
132
|
|
|
77
133
|
if (props.eventPayload) {
|
|
78
134
|
payload.eventPayload = props.eventPayload;
|
|
@@ -135,8 +191,8 @@ var Metrics = _webexCore.WebexPlugin.extend((_dec = (0, _common.deprecated)('Met
|
|
|
135
191
|
};
|
|
136
192
|
return this.callDiagnosticEventsBatcher.request(event);
|
|
137
193
|
},
|
|
138
|
-
version: "1.156.
|
|
139
|
-
}
|
|
194
|
+
version: "1.156.3"
|
|
195
|
+
});
|
|
140
196
|
|
|
141
197
|
var _default = Metrics;
|
|
142
198
|
exports.default = _default;
|
package/dist/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["metrics.js"],"names":["Metrics","WebexPlugin","extend","children","batcher","Batcher","clientMetricsBatcher","ClientMetricsBatcher","callDiagnosticEventsBatcher","CallDiagnosticEventsBatcher","namespace","
|
|
1
|
+
{"version":3,"sources":["metrics.js"],"names":["getOSName","getOSVersion","getBrowserName","getBrowserVersion","getSparkUserAgent","webex","config","appName","appVersion","appPlatform","sparkUserAgent","CLIENT_NAME","Metrics","WebexPlugin","extend","children","batcher","Batcher","clientMetricsBatcher","ClientMetricsBatcher","callDiagnosticEventsBatcher","CallDiagnosticEventsBatcher","namespace","submit","key","value","request","submitClientMetrics","eventName","props","preLoginId","Error","payload","metricName","tags","browser","org_id","credentials","getOrgId","os","domain","window","location","hostname","client_id","user_id","internal","device","userId","fields","browser_version","os_version","sdk_version","version","platform","spark_user_agent","type","metrics","context","app","locale","name","eventPayload","timestamp","_payload","postPreLoginMetric","aliasUser","method","api","resource","headers","body","qs","alias","getClientToken","then","token","authorization","toString","submitCallDiagnosticEvents","event"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAEA,wBAKI,+BALJ;AAAA,IACEA,SADF,qBACEA,SADF;AAAA,IAEEC,YAFF,qBAEEA,YAFF;AAAA,IAGEC,cAHF,qBAGEA,cAHF;AAAA,IAIEC,iBAJF,qBAIEA,iBAJF;;AAOA,SAASC,iBAAT,CAA2BC,KAA3B,EAAkC;AAAA;;AAChC,8BAIIA,KAJJ,aAIIA,KAJJ,uBAIIA,KAAK,CAAEC,MAJX,yDAIqB,EAJrB;AAAA,MACEC,OADF,QACEA,OADF;AAAA,MAEEC,UAFF,QAEEA,UAFF;AAAA,MAGEC,WAHF,QAGEA,WAHF;;AAMA,MAAIC,cAAc,GAAGC,mBAArB;;AAEA,MAAIJ,OAAJ,EAAa;AACXG,IAAAA,cAAc,eAAQH,OAAR,cAAmBC,UAAnB,aAAmBA,UAAnB,cAAmBA,UAAnB,GAAiC,KAAjC,CAAd;AACD;;AAED,MAAIC,WAAJ,EAAiB;AACfC,IAAAA,cAAc,eAAQD,WAAR,CAAd;AACD;;AAED,SAAOC,cAAP;AACD;;AAGD,IAAME,OAAO,GAAGC,uBAAYC,MAAZ,CAAmB;AACjCC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,OAAO,EAA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Fa;AAGlBC,MAAAA,QAAQ,EAAE,eAHQ;AAIlBC,MAAAA,OAAO,EAAE;AACP,6BAAqBxC;AADd,OAJS;AAOlByC,MAAAA,IAAI,EAAE,EAPY;AAQlBC,MAAAA,EAAE,EAAE;AACFC,QAAAA,KAAK,EAAE;AADL;AARc,KAAb,CAAP;AAYD,GAzGgC;AA2GjCR,EAAAA,kBA3GiC,8BA2GdjC,OA3Gc,EA2GLF,UA3GK,EA2GO;AAAA;;AACtC,WAAO,KAAKzB,KAAL,CAAWgC,WAAX,CAAuBqC,cAAvB,GAAwCC,IAAxC,CAA6C,UAACC,KAAD;AAAA,aAClD,KAAI,CAAClD,OAAL,CAAa;AACXyC,QAAAA,MAAM,EAAE,MADG;AAEXC,QAAAA,GAAG,EAAE,SAFM;AAGXC,QAAAA,QAAQ,EAAE,wBAHC;AAIXC,QAAAA,OAAO,EAAE;AACPO,UAAAA,aAAa,EAAED,KAAK,CAACE,QAAN,EADR;AAEP,+BAAqBhD;AAFd,SAJE;AAQXyC,QAAAA,IAAI,EAAEvC;AARK,OAAb,CADkD;AAAA,KAA7C,CAAP;AAWD,GAvHgC;AAyHjC+C,EAAAA,0BAzHiC,sCAyHN/C,OAzHM,EAyHG;AAClC,QAAMgD,KAAK,GAAG;AACZxB,MAAAA,IAAI,EAAE,kBADM;AAEZM,MAAAA,YAAY,EAAE9B;AAFF,KAAd;AAKA,WAAO,KAAKZ,2BAAL,CAAiCM,OAAjC,CAAyCsD,KAAzC,CAAP;AACD,GAhIgC;AAAA;AAAA,CAAnB,CAAhB;;eAmIepE,O","sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {BrowserDetection} from '@webex/common';\n\nimport {CLIENT_NAME} from './config';\nimport Batcher from './batcher';\nimport ClientMetricsBatcher from './client-metrics-batcher';\nimport CallDiagnosticEventsBatcher from './call-diagnostic-events-batcher';\n\nconst {\n getOSName,\n getOSVersion,\n getBrowserName,\n getBrowserVersion\n} = BrowserDetection();\n\nfunction getSparkUserAgent(webex) {\n const {\n appName,\n appVersion,\n appPlatform\n } = 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\n\nconst Metrics = WebexPlugin.extend({\n children: {\n batcher: Batcher,\n clientMetricsBatcher: ClientMetricsBatcher,\n callDiagnosticEventsBatcher: CallDiagnosticEventsBatcher\n },\n\n namespace: 'Metrics',\n\n submit(key, value) {\n return this.batcher.request(Object.assign({key}, value));\n },\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 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 org_id: this.webex.credentials.getOrgId(),\n os: getOSName(),\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: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser', // Check what else we could measure\n client_id: this.webex.credentials.config.client_id,\n user_id: this.webex.internal.device.userId\n };\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 };\n\n\n payload.type = props.type || this.webex.config.metrics.type;\n\n\n payload.context = {\n ...props.context,\n app: {\n version: this.webex.version\n },\n locale: 'en-US',\n os: {\n name: getOSName(),\n version: getOSVersion()\n }\n };\n\n\n if (props.eventPayload) {\n payload.eventPayload = props.eventPayload;\n }\n\n payload.timestamp = Date.now();\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 submitCallDiagnosticEvents(payload) {\n const event = {\n type: 'diagnostic-event',\n eventPayload: payload\n };\n\n return this.callDiagnosticEventsBatcher.request(event);\n }\n});\n\nexport default Metrics;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-metrics",
|
|
3
|
-
"version": "1.156.
|
|
3
|
+
"version": "1.156.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ian W. Remmel <iremmel@cisco.com>",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime-corejs2": "^7.14.8",
|
|
20
|
-
"@webex/internal-plugin-device": "1.156.
|
|
21
|
-
"@webex/webex-core": "1.156.
|
|
22
|
-
"@webex/common": "1.156.
|
|
23
|
-
"@webex/common-timers": "1.156.
|
|
20
|
+
"@webex/internal-plugin-device": "1.156.3",
|
|
21
|
+
"@webex/webex-core": "1.156.3",
|
|
22
|
+
"@webex/common": "1.156.3",
|
|
23
|
+
"@webex/common-timers": "1.156.3",
|
|
24
24
|
"envify": "^4.1.0"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/config.js
CHANGED
package/src/metrics.js
CHANGED
|
@@ -3,12 +3,41 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import {WebexPlugin} from '@webex/webex-core';
|
|
6
|
-
import {
|
|
6
|
+
import {BrowserDetection} from '@webex/common';
|
|
7
7
|
|
|
8
|
+
import {CLIENT_NAME} from './config';
|
|
8
9
|
import Batcher from './batcher';
|
|
9
10
|
import ClientMetricsBatcher from './client-metrics-batcher';
|
|
10
11
|
import CallDiagnosticEventsBatcher from './call-diagnostic-events-batcher';
|
|
11
12
|
|
|
13
|
+
const {
|
|
14
|
+
getOSName,
|
|
15
|
+
getOSVersion,
|
|
16
|
+
getBrowserName,
|
|
17
|
+
getBrowserVersion
|
|
18
|
+
} = BrowserDetection();
|
|
19
|
+
|
|
20
|
+
function getSparkUserAgent(webex) {
|
|
21
|
+
const {
|
|
22
|
+
appName,
|
|
23
|
+
appVersion,
|
|
24
|
+
appPlatform
|
|
25
|
+
} = webex?.config ?? {};
|
|
26
|
+
|
|
27
|
+
let sparkUserAgent = CLIENT_NAME;
|
|
28
|
+
|
|
29
|
+
if (appName) {
|
|
30
|
+
sparkUserAgent += ` ${appName}/${appVersion ?? '0.0'}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (appPlatform) {
|
|
34
|
+
sparkUserAgent += ` ${appPlatform}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return sparkUserAgent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
12
41
|
const Metrics = WebexPlugin.extend({
|
|
13
42
|
children: {
|
|
14
43
|
batcher: Batcher,
|
|
@@ -18,15 +47,11 @@ const Metrics = WebexPlugin.extend({
|
|
|
18
47
|
|
|
19
48
|
namespace: 'Metrics',
|
|
20
49
|
|
|
21
|
-
@deprecated('Metrics#sendUnstructured() is deprecated; please use Metrics#submit()')
|
|
22
|
-
sendUnstructured(key, value) {
|
|
23
|
-
return this.submit(key, value);
|
|
24
|
-
},
|
|
25
|
-
|
|
26
50
|
submit(key, value) {
|
|
27
51
|
return this.batcher.request(Object.assign({key}, value));
|
|
28
52
|
},
|
|
29
53
|
|
|
54
|
+
|
|
30
55
|
/**
|
|
31
56
|
* This corresponds to #sendSemiStructured() in the deprecated metrics handler
|
|
32
57
|
* @param {string} eventName
|
|
@@ -34,21 +59,51 @@ const Metrics = WebexPlugin.extend({
|
|
|
34
59
|
* @param {string} preLoginId
|
|
35
60
|
* @returns {Object} HttpResponse object
|
|
36
61
|
*/
|
|
37
|
-
submitClientMetrics(eventName, props, preLoginId) {
|
|
62
|
+
submitClientMetrics(eventName, props = {}, preLoginId) {
|
|
63
|
+
if (!eventName) {
|
|
64
|
+
throw Error('Missing behavioral metric name. Please provide one');
|
|
65
|
+
}
|
|
38
66
|
const payload = {metricName: eventName};
|
|
39
67
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
68
|
+
payload.tags = {
|
|
69
|
+
...props.tags,
|
|
70
|
+
browser: getBrowserName(),
|
|
71
|
+
org_id: this.webex.credentials.getOrgId(),
|
|
72
|
+
os: getOSName(),
|
|
73
|
+
|
|
74
|
+
// Node does not like this so we need to check if it exists or not
|
|
75
|
+
// eslint-disable-next-line no-undef
|
|
76
|
+
domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser', // Check what else we could measure
|
|
77
|
+
client_id: this.webex.credentials.config.client_id,
|
|
78
|
+
user_id: this.webex.internal.device.userId
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
payload.fields = {
|
|
83
|
+
...props.fields,
|
|
84
|
+
browser_version: getBrowserVersion(),
|
|
85
|
+
os_version: getOSVersion(),
|
|
86
|
+
sdk_version: this.webex.version,
|
|
87
|
+
platform: 'Web',
|
|
88
|
+
spark_user_agent: getSparkUserAgent(this.webex)
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
payload.type = props.type || this.webex.config.metrics.type;
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
payload.context = {
|
|
96
|
+
...props.context,
|
|
97
|
+
app: {
|
|
98
|
+
version: this.webex.version
|
|
99
|
+
},
|
|
100
|
+
locale: 'en-US',
|
|
101
|
+
os: {
|
|
102
|
+
name: getOSName(),
|
|
103
|
+
version: getOSVersion()
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
52
107
|
|
|
53
108
|
if (props.eventPayload) {
|
|
54
109
|
payload.eventPayload = props.eventPayload;
|
|
@@ -84,6 +84,25 @@ describe('plugin-metrics', () => {
|
|
|
84
84
|
options
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
|
+
|
|
88
|
+
webex.credentials = {
|
|
89
|
+
...webex.credentials,
|
|
90
|
+
getOrgId: sinon.stub().returns('orgId'),
|
|
91
|
+
config: {
|
|
92
|
+
client_id: 'client_id'
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
webex.internal = {...webex.internal, device: {userId: 'userId'}};
|
|
96
|
+
webex.config = {
|
|
97
|
+
...webex.config,
|
|
98
|
+
appName: 'appName',
|
|
99
|
+
appPlatform: 'appPlatform',
|
|
100
|
+
appVersion: 'appVersion'
|
|
101
|
+
|
|
102
|
+
};
|
|
103
|
+
webex.config.metrics.type = ['operational'];
|
|
104
|
+
webex.config.metrics.appType = 'sdk';
|
|
105
|
+
|
|
87
106
|
sinon.spy(webex, 'request');
|
|
88
107
|
sinon.spy(metrics, 'postPreLoginMetric');
|
|
89
108
|
sinon.spy(metrics, 'aliasUser');
|
|
@@ -174,6 +193,24 @@ describe('plugin-metrics', () => {
|
|
|
174
193
|
assert.property(metric, 'context');
|
|
175
194
|
assert.property(metric, 'eventPayload');
|
|
176
195
|
|
|
196
|
+
assert.property(metric.tags, 'browser');
|
|
197
|
+
assert.property(metric.tags, 'org_id');
|
|
198
|
+
assert.property(metric.tags, 'os');
|
|
199
|
+
assert.property(metric.tags, 'domain');
|
|
200
|
+
assert.property(metric.tags, 'client_id');
|
|
201
|
+
assert.property(metric.tags, 'user_id');
|
|
202
|
+
|
|
203
|
+
assert.property(metric.fields, 'browser_version');
|
|
204
|
+
assert.property(metric.fields, 'os_version');
|
|
205
|
+
assert.property(metric.fields, 'sdk_version');
|
|
206
|
+
assert.property(metric.fields, 'platform');
|
|
207
|
+
assert.property(metric.fields, 'spark_user_agent');
|
|
208
|
+
|
|
209
|
+
assert.property(metric.context, 'app');
|
|
210
|
+
assert.property(metric.context, 'locale');
|
|
211
|
+
assert.property(metric.context, 'os');
|
|
212
|
+
|
|
213
|
+
|
|
177
214
|
assert.equal(metric.timestamp, date);
|
|
178
215
|
assert.equal(metric.metricName, 'test');
|
|
179
216
|
assert.equal(metric.tags.success, true);
|