@webex/internal-plugin-metrics 3.0.0-beta.24 → 3.0.0-beta.241

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.
Files changed (60) hide show
  1. package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +66 -0
  2. package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
  3. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +446 -0
  4. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
  5. package/dist/call-diagnostic/call-diagnostic-metrics.js +704 -0
  6. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
  7. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +281 -0
  8. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
  9. package/dist/call-diagnostic/config.js +582 -0
  10. package/dist/call-diagnostic/config.js.map +1 -0
  11. package/dist/config.js +20 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/index.js +30 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/metrics.js +30 -30
  16. package/dist/metrics.js.map +1 -1
  17. package/dist/metrics.types.js +7 -0
  18. package/dist/metrics.types.js.map +1 -0
  19. package/dist/new-metrics.js +323 -0
  20. package/dist/new-metrics.js.map +1 -0
  21. package/dist/types/batcher.d.ts +2 -0
  22. package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
  23. package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +189 -0
  24. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +385 -0
  25. package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +73 -0
  26. package/dist/types/call-diagnostic/config.d.ts +87 -0
  27. package/dist/types/client-metrics-batcher.d.ts +2 -0
  28. package/dist/types/config.d.ts +35 -0
  29. package/dist/types/index.d.ts +13 -0
  30. package/dist/types/metrics.d.ts +3 -0
  31. package/dist/types/metrics.types.d.ts +99 -0
  32. package/dist/types/new-metrics.d.ts +133 -0
  33. package/dist/types/utils.d.ts +6 -0
  34. package/dist/utils.js +27 -0
  35. package/dist/utils.js.map +1 -0
  36. package/package.json +13 -8
  37. package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +80 -0
  38. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +403 -0
  39. package/src/call-diagnostic/call-diagnostic-metrics.ts +762 -0
  40. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +291 -0
  41. package/src/call-diagnostic/config.ts +580 -0
  42. package/src/config.js +19 -0
  43. package/src/index.ts +43 -0
  44. package/src/metrics.js +25 -27
  45. package/src/metrics.types.ts +152 -0
  46. package/src/new-metrics.ts +314 -0
  47. package/src/utils.ts +17 -0
  48. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +398 -0
  49. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +465 -0
  50. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +1303 -0
  51. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +479 -0
  52. package/test/unit/spec/metrics.js +65 -97
  53. package/test/unit/spec/new-metrics.ts +269 -0
  54. package/test/unit/spec/utils.ts +22 -0
  55. package/tsconfig.json +6 -0
  56. package/dist/call-diagnostic-events-batcher.js +0 -60
  57. package/dist/call-diagnostic-events-batcher.js.map +0 -1
  58. package/src/call-diagnostic-events-batcher.js +0 -62
  59. package/src/index.js +0 -17
  60. 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
@@ -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 = _interopRequireDefault(require("./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.js"],"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';\n\nregisterInternalPlugin('metrics', Metrics, {\n config,\n});\n\nexport {default} from './metrics';\nexport {config};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA;AAEA;AAEA;AACA;AATA;AACA;AACA;;AASA,IAAAA,iCAAsB,EAAC,SAAS,EAAEC,gBAAO,EAAE;EACzCC,MAAM,EAANA;AACF,CAAC,CAAC"}
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
- * This corresponds to #sendSemiStructured() in the deprecated metrics handler
59
+ * Returns the payload for submitting client metrics.
57
60
  * @param {string} eventName
58
- * @param {Object} props
59
- * @param {string} preLoginId
60
- * @returns {Object} HttpResponse object
61
+ * @param {any} props
62
+ * @returns {any} - the payload
61
63
  */
62
- submitClientMetrics: function submitClientMetrics(eventName) {
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: getOSName(),
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
- try {
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: getOSName(),
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
- submitCallDiagnosticEvents: function submitCallDiagnosticEvents(payload) {
158
- var event = {
159
- type: 'diagnostic-event',
160
- eventPayload: payload
161
- };
162
- return this.callDiagnosticEventsBatcher.request(event);
163
- },
164
- version: "3.0.0-beta.24"
164
+ version: "3.0.0-beta.241"
165
165
  });
166
166
  var _default = Metrics;
167
167
  exports.default = _default;
@@ -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","callDiagnosticEventsBatcher","CallDiagnosticEventsBatcher","namespace","submit","key","value","request","submitClientMetrics","eventName","props","preLoginId","Error","payload","metricName","tags","browser","os","domain","window","location","hostname","client_id","credentials","user_id","internal","device","userId","org_id","getOrgId","logger","info","fields","browser_version","os_version","sdk_version","version","platform","spark_user_agent","type","metrics","context","app","locale","name","eventPayload","timestamp","Date","valueOf","_payload","postPreLoginMetric","aliasUser","method","api","resource","headers","body","qs","alias","getClientToken","then","token","authorization","toString","submitCallDiagnosticEvents","event"],"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';\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 {getOSName, getOSVersion, getBrowserName, getBrowserVersion} = BrowserDetection();\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 callDiagnosticEventsBatcher: CallDiagnosticEventsBatcher,\n },\n\n namespace: 'Metrics',\n\n submit(key, value) {\n return this.batcher.request({key, ...value});\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 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:\n 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 try {\n payload.tags.org_id = this.webex.credentials.getOrgId();\n } catch {\n this.logger.info('metrics: unable to get orgId');\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 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: getOSName(),\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 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 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"],"mappings":";;;;;;;;;;;;;;AAMA;AACA;AAEA;AACA;AACA;AACA;AAA2E;AAAA;AAE3E,wBAAqE,IAAAA,wBAAgB,GAAE;EAAhFC,SAAS,qBAATA,SAAS;EAAEC,YAAY,qBAAZA,YAAY;EAAEC,cAAc,qBAAdA,cAAc;EAAEC,iBAAiB,qBAAjBA,iBAAiB;AAEjE,SAASC,iBAAiB,CAACC,KAAK,EAAE;EAAA;EAChC,4BAA2CA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,MAAM,yDAAI,CAAC,CAAC;IAAvDC,OAAO,QAAPA,OAAO;IAAEC,UAAU,QAAVA,UAAU;IAAEC,WAAW,QAAXA,WAAW;EAEvC,IAAIC,cAAc,GAAGC,mBAAW;EAEhC,IAAIJ,OAAO,EAAE;IACXG,cAAc,eAAQH,OAAO,cAAIC,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,KAAK,CAAE;EACxD;EAEA,IAAIC,WAAW,EAAE;IACfC,cAAc,eAAQD,WAAW,CAAE;EACrC;EAEA,OAAOC,cAAc;AACvB;AAEA,IAAME,OAAO,GAAGC,sBAAW,CAACC,MAAM,CAAC;EACjCC,QAAQ,EAAE;IACRC,OAAO,EAAEC,gBAAO;IAChBC,oBAAoB,EAAEC,6BAAoB;IAC1CC,2BAA2B,EAAEC;EAC/B,CAAC;EAEDC,SAAS,EAAE,SAAS;EAEpBC,MAAM,kBAACC,GAAG,EAAEC,KAAK,EAAE;IACjB,OAAO,IAAI,CAACT,OAAO,CAACU,OAAO;MAAEF,GAAG,EAAHA;IAAG,GAAKC,KAAK,EAAE;EAC9C,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,mB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,SAAS;QACdC,QAAQ,EAAE,wBAAwB;QAClCC,OAAO,EAAE;UACPO,aAAa,EAAED,KAAK,CAACE,QAAQ,EAAE;UAC/B,mBAAmB,EAAEpD;QACvB,CAAC;QACD6C,IAAI,EAAE3C;MACR,CAAC,CAAC;IAAA,EACH;EACH,CAAC;EAEDmD,0BAA0B,sCAACnD,OAAO,EAAE;IAClC,IAAMoD,KAAK,GAAG;MACZ1B,IAAI,EAAE,kBAAkB;MACxBM,YAAY,EAAEhC;IAChB,CAAC;IAED,OAAO,IAAI,CAACZ,2BAA2B,CAACM,OAAO,CAAC0D,KAAK,CAAC;EACxD,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEYxE,OAAO;AAAA"}
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;AACA;AACA;AAEA;AACA;AAA4D;AAAA;AAE5D,wBAAqE,IAAAA,wBAAgB,GAAE;EAAhFC,SAAS,qBAATA,SAAS;EAAEC,YAAY,qBAAZA,YAAY;EAAEC,cAAc,qBAAdA,cAAc;EAAEC,iBAAiB,qBAAjBA,iBAAiB;AAE1D,SAASC,iBAAiB,GAAG;EAAA;EAClC,2BAAOC,aAAK,CAACL,SAAS,EAAE,CAAC,+DAAIM,eAAO,CAACC,MAAM;AAC7C;AAEA,SAASC,iBAAiB,CAACC,KAAK,EAAE;EAAA;EAChC,4BAA2CA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,MAAM,yDAAI,CAAC,CAAC;IAAvDC,OAAO,QAAPA,OAAO;IAAEC,UAAU,QAAVA,UAAU;IAAEC,WAAW,QAAXA,WAAW;EAEvC,IAAIC,cAAc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IACpB,OAAO,IAAI,CAAClC,OAAO,CAAC;MAClBsC,MAAM,EAAE,MAAM;MACdC,GAAG,EAAE,SAAS;MACdC,QAAQ,EAAE,eAAe;MACzBC,OAAO,EAAE;QACP,mBAAmB,EAAEP;MACvB,CAAC;MACDQ,IAAI,EAAE,CAAC,CAAC;MACRC,EAAE,EAAE;QACFC,KAAK,EAAE;MACT;IACF,CAAC,CAAC;EACJ,CAAC;EAEDR,kBAAkB,8BAAC/B,OAAO,EAAE6B,UAAU,EAAE;IAAA;IACtC,OAAO,IAAI,CAACrD,KAAK,CAACyC,WAAW,CAACuB,cAAc,EAAE,CAACC,IAAI,CAAC,UAACC,KAAK;MAAA,OACxD,KAAI,CAAC/C,OAAO,CAAC;QACXsC,MAAM,EAAE,MAAM;QACdC,GAAG,EAAE,SAAS;QACdC,QAAQ,EAAE,wBAAwB;QAClCC,OAAO,EAAE;UACPO,aAAa,EAAED,KAAK,CAACE,QAAQ,EAAE;UAC/B,mBAAmB,EAAEf;QACvB,CAAC;QACDQ,IAAI,EAAErC;MACR,CAAC,CAAC;IAAA,EACH;EACH,CAAC;EAAA;AACH,CAAC,CAAC;AAAC,eAEYjB,OAAO;AAAA"}
@@ -0,0 +1,7 @@
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
+ //# sourceMappingURL=metrics.types.js.map
@@ -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,323 @@
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 _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
13
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
15
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
17
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
19
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
20
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
21
+ var _webexCore = require("@webex/webex-core");
22
+ var _callDiagnosticMetrics = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics"));
23
+ var _callDiagnosticMetricsLatencies = _interopRequireDefault(require("./call-diagnostic/call-diagnostic-metrics-latencies"));
24
+ var _callDiagnosticMetrics2 = require("./call-diagnostic/call-diagnostic-metrics.util");
25
+ var _utils = require("./utils");
26
+ 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); }; }
27
+ 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; } }
28
+ /**
29
+ * Metrics plugin to centralize all types of metrics.
30
+ * @class
31
+ */
32
+ var Metrics = /*#__PURE__*/function (_WebexPlugin) {
33
+ (0, _inherits2.default)(Metrics, _WebexPlugin);
34
+ var _super = _createSuper(Metrics);
35
+ // eslint-disable-next-line no-use-before-define
36
+
37
+ // Call Diagnostic latencies
38
+
39
+ // Helper classes to handle the different types of metrics
40
+
41
+ /**
42
+ * Constructor
43
+ * @param args
44
+ * @constructor
45
+ * @private
46
+ * @returns
47
+ */
48
+ function Metrics() {
49
+ var _this;
50
+ (0, _classCallCheck2.default)(this, Metrics);
51
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
52
+ args[_key] = arguments[_key];
53
+ }
54
+ _this = _super.call.apply(_super, [this].concat(args));
55
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticLatencies", void 0);
56
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "callDiagnosticMetrics", void 0);
57
+ _this.onReady();
58
+ return _this;
59
+ }
60
+
61
+ /**
62
+ * On Ready
63
+ */
64
+ (0, _createClass2.default)(Metrics, [{
65
+ key: "onReady",
66
+ value: function onReady() {
67
+ var _this2 = this;
68
+ // @ts-ignore
69
+ this.webex.once('ready', function () {
70
+ // @ts-ignore
71
+ _this2.callDiagnosticMetrics = new _callDiagnosticMetrics.default({}, {
72
+ parent: _this2.webex
73
+ });
74
+ // @ts-ignore
75
+ _this2.callDiagnosticLatencies = new _callDiagnosticMetricsLatencies.default({}, {
76
+ parent: _this2.webex
77
+ });
78
+ });
79
+ }
80
+
81
+ /**
82
+ * Used for internal purposes only
83
+ * @param args
84
+ */
85
+ }, {
86
+ key: "submitInternalEvent",
87
+ value: function submitInternalEvent(_ref) {
88
+ var name = _ref.name,
89
+ payload = _ref.payload,
90
+ options = _ref.options;
91
+ if (name === 'internal.reset.join.latencies') {
92
+ this.callDiagnosticLatencies.clearTimestamps();
93
+ } else {
94
+ this.callDiagnosticLatencies.saveTimestamp({
95
+ key: name
96
+ });
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Behavioral event
102
+ * @param args
103
+ */
104
+ }, {
105
+ key: "submitBehavioralEvent",
106
+ value: function submitBehavioralEvent(_ref2) {
107
+ var name = _ref2.name,
108
+ payload = _ref2.payload,
109
+ options = _ref2.options;
110
+ this.callDiagnosticLatencies.saveTimestamp({
111
+ key: name
112
+ });
113
+ throw new Error('Not implemented.');
114
+ }
115
+
116
+ /**
117
+ * Operational event
118
+ * @param args
119
+ */
120
+ }, {
121
+ key: "submitOperationalEvent",
122
+ value: function submitOperationalEvent(_ref3) {
123
+ var name = _ref3.name,
124
+ payload = _ref3.payload,
125
+ options = _ref3.options;
126
+ throw new Error('Not implemented.');
127
+ }
128
+
129
+ /**
130
+ * Call Analyzer: Media Quality Event
131
+ * @param args
132
+ */
133
+ }, {
134
+ key: "submitMQE",
135
+ value: function submitMQE(_ref4) {
136
+ var name = _ref4.name,
137
+ payload = _ref4.payload,
138
+ options = _ref4.options;
139
+ this.callDiagnosticLatencies.saveTimestamp({
140
+ key: name
141
+ });
142
+ this.callDiagnosticMetrics.submitMQE({
143
+ name: name,
144
+ payload: payload,
145
+ options: options
146
+ });
147
+ }
148
+
149
+ /**
150
+ * Call Analyzer: Feature Usage Event
151
+ * @param args
152
+ */
153
+ }, {
154
+ key: "submitFeatureEvent",
155
+ value: function submitFeatureEvent(_ref5) {
156
+ var name = _ref5.name,
157
+ payload = _ref5.payload,
158
+ options = _ref5.options;
159
+ throw new Error('Not implemented.');
160
+ }
161
+
162
+ /**
163
+ * Call Analyzer: Client Event
164
+ * @public
165
+ * @param args
166
+ */
167
+ }, {
168
+ key: "submitClientEvent",
169
+ value: function submitClientEvent(_ref6) {
170
+ var name = _ref6.name,
171
+ payload = _ref6.payload,
172
+ options = _ref6.options;
173
+ if (!this.callDiagnosticLatencies || !this.callDiagnosticMetrics) {
174
+ // @ts-ignore
175
+ this.webex.logger.log("NewMetrics: @submitClientEvent. Attempted to submit before webex.ready. Event name: ".concat(name));
176
+ return _promise.default.resolve();
177
+ }
178
+ this.callDiagnosticLatencies.saveTimestamp({
179
+ key: name,
180
+ options: {
181
+ meetingId: options === null || options === void 0 ? void 0 : options.meetingId
182
+ }
183
+ });
184
+ return this.callDiagnosticMetrics.submitClientEvent({
185
+ name: name,
186
+ payload: payload,
187
+ options: options
188
+ });
189
+ }
190
+
191
+ /**
192
+ * Submit a pre-login metric to clientmetrics
193
+ * @public
194
+ * @param payload
195
+ * @param preLoginId - pre-login ID of user
196
+ * @returns
197
+ */
198
+ }, {
199
+ key: "postPreLoginMetric",
200
+ value: function postPreLoginMetric(payload, preLoginId) {
201
+ var _this3 = this;
202
+ // @ts-ignore
203
+ return this.webex.request({
204
+ method: 'POST',
205
+ api: 'metrics',
206
+ resource: 'clientmetrics-prelogin',
207
+ headers: {
208
+ authorization: false,
209
+ 'x-prelogin-userid': preLoginId
210
+ },
211
+ body: {
212
+ metrics: [payload]
213
+ }
214
+ }).then(function (res) {
215
+ // @ts-ignore
216
+ _this3.webex.logger.log("NewMetrics: @postPreLoginMetric. Request successful:", "res: ".concat((0, _stringify.default)(res)));
217
+ return res;
218
+ }).catch(function (err) {
219
+ // @ts-ignore
220
+ _this3.logger.error("NewMetrics: @postPreLoginMetric. Request failed:", "err: ".concat((0, _utils.generateCommonErrorMetadata)(err)));
221
+ return _promise.default.reject(err);
222
+ });
223
+ }
224
+
225
+ /**
226
+ * Issue request to alias a user's pre-login ID with their CI UUID
227
+ * @param {string} preLoginId
228
+ * @returns {Object} HttpResponse object
229
+ */
230
+ }, {
231
+ key: "clientMetricsAliasUser",
232
+ value: function clientMetricsAliasUser(preLoginId) {
233
+ var _this4 = this;
234
+ // @ts-ignore
235
+ return this.webex.request({
236
+ method: 'POST',
237
+ api: 'metrics',
238
+ resource: 'clientmetrics',
239
+ headers: {
240
+ 'x-prelogin-userid': preLoginId
241
+ },
242
+ body: {},
243
+ qs: {
244
+ alias: true
245
+ }
246
+ }).then(function (res) {
247
+ // @ts-ignore
248
+ _this4.webex.logger.log("NewMetrics: @clientMetricsAliasUser. Request successful:", "res: ".concat((0, _stringify.default)(res)));
249
+ return res;
250
+ }).catch(function (err) {
251
+ // @ts-ignore
252
+ _this4.logger.error("NewMetrics: @clientMetricsAliasUser. Request failed:", "err: ".concat((0, _utils.generateCommonErrorMetadata)(err)));
253
+ return _promise.default.reject(err);
254
+ });
255
+ }
256
+
257
+ /**
258
+ * Returns a promise that will resolve to fetch options for submitting a metric.
259
+ *
260
+ * This is to support quickly submitting metrics when the browser/tab is closing.
261
+ * Calling submitClientEvent will not work because there some async steps that will
262
+ * not complete before the browser is closed. Instead, we pre-gather all the
263
+ * information/options needed for the request(s), and then simply and quickly
264
+ * fire the fetch(es) when beforeUnload is triggered.
265
+ *
266
+ * We must use fetch instead of request because fetch has a keepalive option that
267
+ * allows the request it to outlive the page.
268
+ *
269
+ * Note: the timings values will be wrong, but setMetricTimingsAndFetch() will
270
+ * properly adjust them before submitting.
271
+ *
272
+ * @public
273
+ * @param {Object} arg
274
+ * @param {String} arg.name - event name
275
+ * @param {Object} arg.payload - event payload
276
+ * @param {Object} arg.options - other options
277
+ * @returns {Promise} promise that resolves to options to be used with fetch
278
+ */
279
+ }, {
280
+ key: "buildClientEventFetchRequestOptions",
281
+ value: function () {
282
+ var _buildClientEventFetchRequestOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref7) {
283
+ var name, payload, options;
284
+ return _regenerator.default.wrap(function _callee$(_context) {
285
+ while (1) switch (_context.prev = _context.next) {
286
+ case 0:
287
+ name = _ref7.name, payload = _ref7.payload, options = _ref7.options;
288
+ return _context.abrupt("return", this.callDiagnosticMetrics.buildClientEventFetchRequestOptions({
289
+ name: name,
290
+ payload: payload,
291
+ options: options
292
+ }));
293
+ case 2:
294
+ case "end":
295
+ return _context.stop();
296
+ }
297
+ }, _callee, this);
298
+ }));
299
+ function buildClientEventFetchRequestOptions(_x) {
300
+ return _buildClientEventFetchRequestOptions.apply(this, arguments);
301
+ }
302
+ return buildClientEventFetchRequestOptions;
303
+ }()
304
+ /**
305
+ * Submits a metric from pre-built request options via the fetch API. Updates
306
+ * the "$timings" and "originTime" values to Date.now() since the existing times
307
+ * were set when the options were built (not submitted).
308
+ * @param {any} options - the pre-built request options for submitting a metric
309
+ * @returns {Promise} promise that resolves to the response object
310
+ */
311
+ }, {
312
+ key: "setMetricTimingsAndFetch",
313
+ value: function setMetricTimingsAndFetch(options) {
314
+ // @ts-ignore
315
+ return this.webex.setTimingsAndFetch((0, _callDiagnosticMetrics2.setMetricTimings)(options));
316
+ }
317
+ }]);
318
+ return Metrics;
319
+ }(_webexCore.WebexPlugin);
320
+ (0, _defineProperty2.default)(Metrics, "instance", void 0);
321
+ var _default = Metrics;
322
+ exports.default = _default;
323
+ //# sourceMappingURL=new-metrics.js.map