@webex/internal-plugin-metrics 3.12.0-next.46 → 3.12.0-next.47

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/README.md CHANGED
@@ -9,6 +9,7 @@ This is an internal Cisco Webex plugin. As such, it does not strictly adhere to
9
9
  - [Install](#install)
10
10
  - [Usage](#usage)
11
11
  - [Unhandled exception telemetry](#unhandled-exception-telemetry)
12
+ - [Network request telemetry](#network-request-telemetry)
12
13
  - [Contribute](#contribute)
13
14
  - [Maintainers](#maintainers)
14
15
  - [License](#license)
@@ -47,7 +48,7 @@ Telemetry is disabled by default. Enable it with
47
48
  include application context such as `orgId` and `dataCenter`. Metadata must not contain personally
48
49
  identifiable information or credentials.
49
50
 
50
- ```js
51
+ ````js
51
52
  import Webex from 'webex';
52
53
 
53
54
  const webex = Webex.init({
@@ -63,6 +64,243 @@ const webex = Webex.init({
63
64
  },
64
65
  },
65
66
  });
67
+ ## Network request telemetry
68
+
69
+ Network request telemetry is disabled by default. Enable it with
70
+ `metrics.networkTelemetry.enabled: true`. When enabled, the metrics plugin summarizes requests
71
+ made through the Webex SDK request pipeline. The reporting interval is configurable with
72
+ `metrics.networkTelemetry.intervalMs` and defaults to ten minutes. It listens to the SDK-wide `request:start`,
73
+ `request:success`, and `request:failure` events, so individual plugins do not need to wrap or
74
+ replace `webex.request()`.
75
+
76
+ For example, to collect one-minute windows:
77
+
78
+ ```js
79
+ const webex = Webex.init({
80
+ config: {
81
+ metrics: {
82
+ networkTelemetry: {
83
+ enabled: true,
84
+ intervalMs: 60 * 1_000,
85
+ },
86
+ },
87
+ },
88
+ });
89
+ ```
90
+
91
+ The listeners are installed once for each Webex instance when `webex.internal.metrics` is
92
+ constructed and the feature is enabled. The metrics package must be imported before constructing
93
+ the Webex instance. Standard Webex SDK bundles already import and register the metrics plugin.
94
+
95
+ ### Scope
96
+
97
+ The collector counts request and response outcomes that pass through `webex.request()` and its interceptors. For failures, it also records aggregated error details covering:
98
+
99
+ - HTTP responses rejected by the SDK, such as `4xx` and `5xx` responses.
100
+ - Network or CORS failures where no HTTP response is available.
101
+ - Aborted and timed-out SDK requests when the error exposes that information.
102
+ - Request preparation failures that emit `request:failure`.
103
+
104
+ It does not monitor arbitrary application `fetch()`, `XMLHttpRequest`, WebSocket, or other traffic outside the SDK request pipeline. It also does not use `PerformanceObserver` or browser-wide request interception.
105
+
106
+ ### Event flow
107
+
108
+ ```text
109
+ webex.request()
110
+ -> SDK request interceptors
111
+ -> request:start(options)
112
+ -> request:success(options, response) or request:failure(options, reason)
113
+ -> metrics request outcome listeners
114
+ -> aggregate host, endpoint, response, and error counts
115
+ -> every configured interval, submit JS_SDK_NETWORK_REQUEST_SUMMARY
116
+ ````
117
+
118
+ The listeners and ten-minute accumulator are registered during metrics plugin initialization:
119
+
120
+ ```js
121
+ initialize(...args) {
122
+ WebexPlugin.prototype.initialize.call(this, ...args);
123
+ if (this.webex.config.metrics.networkTelemetry.enabled !== true) {
124
+ return;
125
+ }
126
+ this.networkTelemetry = createNetworkTelemetryCollector(/* submission callbacks */);
127
+ this.listenTo(this.webex, 'request:start', this.recordNetworkRequestStart);
128
+ this.listenTo(this.webex, 'request:success', this.recordNetworkRequestSuccess);
129
+ this.listenTo(this.webex, 'request:failure', this.recordNetworkRequestFailure);
130
+ }
131
+ ```
132
+
133
+ The metrics plugin exposes `flushNetworkTelemetry()` for callers that need to submit the current
134
+ non-empty window immediately, such as after an early call failure. When the metrics plugin is
135
+ stopped, any non-empty partial window is submitted once before the collector is disposed. Empty
136
+ windows are not submitted during shutdown, and the shutdown hook waits for the submission attempt
137
+ to settle.
138
+
139
+ ```js
140
+ await webex.internal.metrics.flushNetworkTelemetry();
141
+ ```
142
+
143
+ ### Metric schema
144
+
145
+ One operational client metric named `JS_SDK_NETWORK_REQUEST_SUMMARY` is submitted at the configured
146
+ interval. Its `eventPayload` has this shape:
147
+
148
+ ```ts
149
+ type NetworkTelemetry = {
150
+ metricsSummary: {
151
+ totalSendRequest: number;
152
+ totalFailedRequest: number;
153
+ totalRecvdResponse: number;
154
+ totalFailedResponse: number;
155
+ };
156
+ metrics: Array<{
157
+ host: string;
158
+ endPoint: string;
159
+ countSendRequest: number;
160
+ countFailedRequest: number;
161
+ countRecvdResponse: number;
162
+ countFailedResponse: number;
163
+ averageNetworkDurationMs: number;
164
+ maxNetworkDurationP90Ms: number;
165
+ maxNetworkDurationP99Ms: number;
166
+ }>;
167
+ errorMetrics: Array<{
168
+ host: string;
169
+ endPoint: string;
170
+ statusCode: number;
171
+ errorCode: string;
172
+ method: string;
173
+ errorType: string;
174
+ errorMessage: string;
175
+ trackingIds: string[];
176
+ countError: number;
177
+ }>;
178
+ errorMetricsSummary: Record<string, {count: number}>;
179
+ };
180
+ ```
181
+
182
+ The SDK adds application metadata to the outer client metric when it wraps this `eventPayload`:
183
+
184
+ | Property | Source |
185
+ | -------------------- | --------------------------------------------------------------------------- |
186
+ | `tags.app_name` | `webex.config.appName`, or `unknown` |
187
+ | `tags.app_version` | `webex.config.appVersion`, or `unknown` |
188
+ | `tags.app_url` | Browser origin without path/query data, hostname fallback, or `non-browser` |
189
+ | `fields.sdk_version` | `webex.version` |
190
+
191
+ Counter mapping:
192
+
193
+ | Event or outcome | Summary and endpoint counters |
194
+ | --------------------------------------------------- | --------------------------------------------------------------------------- |
195
+ | `request:start` | `totalSendRequest`, `countSendRequest` |
196
+ | `request:success` | `totalRecvdResponse`, `countRecvdResponse` |
197
+ | `request:failure` without an HTTP response | `totalFailedRequest`, `countFailedRequest` |
198
+ | `request:failure` with an HTTP status (`4xx`/`5xx`) | Received-response counters plus `totalFailedResponse`/`countFailedResponse` |
199
+
200
+ The `metrics` array is grouped by `host` and `endPoint`. For service-based SDK requests, `host` is the normalized logical service name. Direct-URI requests use the URI host. `endPoint` is a sanitized resource or URI path. `averageNetworkDurationMs` is the average measured network duration for completed requests in the group, while `maxNetworkDurationP90Ms` and `maxNetworkDurationP99Ms` are the maximum durations at the nearest-rank 90th and 99th percentiles. All values are in milliseconds.
201
+
202
+ The `errorMetrics` array groups identical failures by host, endpoint, status code, error code, method, error type, and error message. `countError` records the number of occurrences, while `trackingIds` retains at most ten unique identifiers. `errorMetricsSummary` counts errors by status code; status `0` means no HTTP response was available.
203
+
204
+ Example:
205
+
206
+ ```js
207
+ {
208
+ metricName: 'JS_SDK_NETWORK_REQUEST_SUMMARY',
209
+ type: 'operational',
210
+ fields: {
211
+ totalSendRequest: 14,
212
+ totalFailedRequest: 1,
213
+ totalRecvdResponse: 13,
214
+ totalFailedResponse: 1
215
+ },
216
+ eventPayload: {
217
+ metricsSummary: {
218
+ totalSendRequest: 14,
219
+ totalFailedRequest: 1,
220
+ totalRecvdResponse: 13,
221
+ totalFailedResponse: 1
222
+ },
223
+ metrics: [{
224
+ host: 'hydra',
225
+ endPoint: 'rooms/:id/messages',
226
+ countSendRequest: 2,
227
+ countFailedRequest: 0,
228
+ countRecvdResponse: 2,
229
+ countFailedResponse: 1,
230
+ averageNetworkDurationMs: 410,
231
+ maxNetworkDurationP90Ms: 510,
232
+ maxNetworkDurationP99Ms: 640
233
+ }],
234
+ errorMetrics: [{
235
+ host: 'hydra',
236
+ endPoint: 'rooms/:id/messages',
237
+ statusCode: 503,
238
+ errorCode: 'SERVICE_UNAVAILABLE',
239
+ method: 'POST',
240
+ errorType: 'server_error',
241
+ errorMessage: 'Service unavailable',
242
+ trackingIds: ['example-tracking-id'],
243
+ countError: 1
244
+ }],
245
+ errorMetricsSummary: {
246
+ 503: {count: 1}
247
+ }
248
+ }
249
+ }
250
+ ```
251
+
252
+ ### Failure classification
253
+
254
+ Classification is evaluated in the following order:
255
+
256
+ | Condition | `errorType` |
257
+ | --------------------------------------------------------------------------------------------------------- | --------------- |
258
+ | Error name is `AbortError` | `aborted` |
259
+ | Status is `408` or `504`, timeout appears in the error details, or the configured request timeout elapsed | `timeout` |
260
+ | Status is `429` | `rate_limited` |
261
+ | Status is `5xx` | `server_error` |
262
+ | Status is `4xx` | `client_error` |
263
+ | No response status is available, or the error name contains `network` | `network_error` |
264
+ | Any other SDK request failure | `request_error` |
265
+
266
+ ### Telemetry request exclusion
267
+
268
+ Requests to the `metrics` and `unifiedTelemetry` services are excluded from both success and failure collection. The exclusion also covers the legacy `api: 'metrics'` request option. This prevents a telemetry upload from affecting its own summary.
269
+
270
+ The exclusion is centralized in the collector; telemetry request call sites do not require special flags.
271
+
272
+ ### Endpoint normalization and cardinality
273
+
274
+ The `endPoint` value is derived from `options.resource`, or from the URI path for a direct-URI request:
275
+
276
+ - Query parameters and fragments are removed.
277
+ - Numeric, percent-encoded, uppercase, and otherwise non-route-looking segments are replaced with `:id`.
278
+
279
+ For example:
280
+
281
+ ```text
282
+ rooms/Y2lzY29zcGFyazovL3VzL1JPT00/messages?personId=secret
283
+ ```
284
+
285
+ becomes:
286
+
287
+ ```text
288
+ rooms/:id/messages
289
+ ```
290
+
291
+ Endpoint normalization is heuristic. A short lowercase alphabetic identifier can resemble a static route segment. Do not place sensitive values directly in a resource path; use normal SDK resource identifiers and avoid embedding credentials or personal data in route names. Error messages are included because they are part of the requested error aggregate schema; callers should not put credentials or personal data in thrown error messages.
292
+
293
+ ### Submission behavior
294
+
295
+ Each ten-minute summary uses the existing `submitClientMetrics()` batching and transport path. The accumulator resets at the reporting boundary before asynchronous submission, so requests received while a summary is being sent belong to the next window. A telemetry submission failure is caught and logged.
296
+
297
+ ### Tests
298
+
299
+ Run the focused unit tests with Node.js 22.14:
300
+
301
+ ```bash
302
+ nvm use 22.14
303
+ yarn workspace @webex/internal-plugin-metrics test:unit --targets network-telemetry.ts
66
304
  ```
67
305
 
68
306
  ## Maintainers
package/dist/config.js CHANGED
@@ -23,6 +23,10 @@ var _default = exports.default = {
23
23
  unhandledExceptionTelemetry: {
24
24
  enabled: false
25
25
  },
26
+ networkTelemetry: {
27
+ enabled: false,
28
+ intervalMs: 10 * 60 * 1000
29
+ },
26
30
  batcherWait: 500,
27
31
  batcherMaxCalls: 50,
28
32
  batcherMaxWait: 1500,
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","CLIENT_NAME","exports","_default","default","device","preDiscoveryServices","metricsServiceUrl","process","env","METRICS_SERVICE_URL","metrics","appType","inBrowser","unhandledExceptionTelemetry","enabled","batcherWait","batcherMaxCalls","batcherMaxWait","batcherRetryPlateau","batcherRetryOnNetworkError","waitForServiceTimeout","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 unhandledExceptionTelemetry: {\n enabled: false,\n },\n batcherWait: 500,\n batcherMaxCalls: 50,\n batcherMaxWait: 1500,\n batcherRetryPlateau: 32000,\n batcherRetryOnNetworkError: true,\n waitForServiceTimeout: 30,\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,IAAAA,OAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIO,IAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,cAAc;AAAC,IAAAE,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAC3B;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,2BAA2B,EAAE;MAC3BC,OAAO,EAAE;IACX,CAAC;IACDC,WAAW,EAAE,GAAG;IAChBC,eAAe,EAAE,EAAE;IACnBC,cAAc,EAAE,IAAI;IACpBC,mBAAmB,EAAE,KAAK;IAC1BC,0BAA0B,EAAE,IAAI;IAChCC,qBAAqB,EAAE;EACzB;AACF,CAAC;AAEM,IAAMC,OAAO,GAAApB,OAAA,CAAAoB,OAAA,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;AAEM,IAAMC,KAAK,GAAA5B,OAAA,CAAA4B,KAAA,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","ignoreList":[]}
1
+ {"version":3,"names":["_common","require","CLIENT_NAME","exports","_default","default","device","preDiscoveryServices","metricsServiceUrl","process","env","METRICS_SERVICE_URL","metrics","appType","inBrowser","unhandledExceptionTelemetry","enabled","networkTelemetry","intervalMs","batcherWait","batcherMaxCalls","batcherMaxWait","batcherRetryPlateau","batcherRetryOnNetworkError","waitForServiceTimeout","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 unhandledExceptionTelemetry: {\n enabled: false,\n },\n networkTelemetry: {\n enabled: false,\n intervalMs: 10 * 60 * 1_000,\n },\n batcherWait: 500,\n batcherMaxCalls: 50,\n batcherMaxWait: 1500,\n batcherRetryPlateau: 32000,\n batcherRetryOnNetworkError: true,\n waitForServiceTimeout: 30,\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,IAAAA,OAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIO,IAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,cAAc;AAAC,IAAAE,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAC3B;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,2BAA2B,EAAE;MAC3BC,OAAO,EAAE;IACX,CAAC;IACDC,gBAAgB,EAAE;MAChBD,OAAO,EAAE,KAAK;MACdE,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG;IACxB,CAAC;IACDC,WAAW,EAAE,GAAG;IAChBC,eAAe,EAAE,EAAE;IACnBC,cAAc,EAAE,IAAI;IACpBC,mBAAmB,EAAE,KAAK;IAC1BC,0BAA0B,EAAE,IAAI;IAChCC,qBAAqB,EAAE;EACzB;AACF,CAAC;AAEM,IAAMC,OAAO,GAAAtB,OAAA,CAAAsB,OAAA,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;AAEM,IAAMC,KAAK,GAAA9B,OAAA,CAAA8B,KAAA,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","ignoreList":[]}
package/dist/index.js CHANGED
@@ -114,8 +114,17 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var
114
114
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
115
115
  */
116
116
 
117
+ /* eslint-disable valid-jsdoc */
118
+
117
119
  (0, _webexCore.registerInternalPlugin)('metrics', _metrics.default, {
118
- config: _config.default
120
+ config: _config.default,
121
+ /**
122
+ * Stops network telemetry before SDK logout.
123
+ * @returns
124
+ */
125
+ onBeforeLogout: function onBeforeLogout() {
126
+ return this.stopNetworkTelemetry();
127
+ }
119
128
  });
120
129
  (0, _webexCore.registerInternalPlugin)('newMetrics', _newMetrics.default, {
121
130
  config: _config.default
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_webexCore","require","_metrics","_interopRequireWildcard","_config","_interopRequireDefault","_newMetrics","Utils","exports","AutomatedUserUtils","CALL_DIAGNOSTIC_CONFIG","CallDiagnosticUtils","_callDiagnosticMetrics2","_callDiagnosticMetricsLatencies","_behavioralMetrics","_operationalMetrics","_businessMetrics","_rtcMetrics","_preloginMetrics","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor","registerInternalPlugin","Metrics","config","NewMetrics"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerInternalPlugin} from '@webex/webex-core';\n\nimport Metrics from './metrics';\nimport config from './config';\nimport NewMetrics from './new-metrics';\nimport * as Utils from './utils';\nimport * as AutomatedUserUtils from './automated-user';\nimport {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n SubmitMQE,\n PreComputedLatencies,\n SubmitFeatureEvent,\n LocusSyncLatencyEventName,\n PrivacyAndSecurityPermission,\n} from './metrics.types';\nimport * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';\nimport * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';\nimport CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';\nimport CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';\nimport BehavioralMetrics from './behavioral-metrics';\nimport OperationalMetrics from './operational-metrics';\nimport BusinessMetrics from './business-metrics';\nimport RtcMetrics from './rtcMetrics';\nimport PreLoginMetrics from './prelogin-metrics';\n\nregisterInternalPlugin('metrics', Metrics, {\n config,\n});\n\nregisterInternalPlugin('newMetrics', NewMetrics, {\n config,\n});\n\nexport {default, getOSNameInternal} from './metrics';\n\nexport {\n config,\n CALL_DIAGNOSTIC_CONFIG,\n AutomatedUserUtils,\n NewMetrics,\n Utils,\n CallDiagnosticUtils,\n CallDiagnosticLatencies,\n CallDiagnosticMetrics,\n BehavioralMetrics,\n OperationalMetrics,\n BusinessMetrics,\n RtcMetrics,\n PreLoginMetrics,\n};\nexport {isAutomatedUser, isAutomatedUserAgent} from './automated-user';\nexport type {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitMQE,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n PreComputedLatencies,\n SubmitFeatureEvent,\n LocusSyncLatencyEventName,\n PrivacyAndSecurityPermission,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,KAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAAiCO,OAAA,CAAAD,KAAA,GAAAA,KAAA;AACjC,IAAAE,kBAAA,GAAAN,uBAAA,CAAAF,OAAA;AAAuDO,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAevD,IAAAC,sBAAA,GAAAP,uBAAA,CAAAF,OAAA;AAAmEO,OAAA,CAAAE,sBAAA,GAAAA,sBAAA;AACnE,IAAAC,mBAAA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CAAA,EAAAO,EAAA,EAAAR,CAAA,IAAAC,CAAA,CAAAO,EAAA,IAAAf,CAAA,CAAAe,EAAA,WAAAP,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAjCjD;AACA;AACA;;AAiCA,IAAAmB,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","ignoreList":[]}
1
+ {"version":3,"names":["_webexCore","require","_metrics","_interopRequireWildcard","_config","_interopRequireDefault","_newMetrics","Utils","exports","AutomatedUserUtils","CALL_DIAGNOSTIC_CONFIG","CallDiagnosticUtils","_callDiagnosticMetrics2","_callDiagnosticMetricsLatencies","_behavioralMetrics","_operationalMetrics","_businessMetrics","_rtcMetrics","_preloginMetrics","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","_typeof","has","get","set","_t","hasOwnProperty","call","_Object$defineProperty","_Object$getOwnPropertyDescriptor","registerInternalPlugin","Metrics","config","onBeforeLogout","stopNetworkTelemetry","NewMetrics"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-disable valid-jsdoc */\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 * as AutomatedUserUtils from './automated-user';\nimport {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n SubmitMQE,\n PreComputedLatencies,\n SubmitFeatureEvent,\n LocusSyncLatencyEventName,\n PrivacyAndSecurityPermission,\n} from './metrics.types';\nimport * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';\nimport * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';\nimport CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';\nimport CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';\nimport BehavioralMetrics from './behavioral-metrics';\nimport OperationalMetrics from './operational-metrics';\nimport BusinessMetrics from './business-metrics';\nimport RtcMetrics from './rtcMetrics';\nimport PreLoginMetrics from './prelogin-metrics';\n\nregisterInternalPlugin('metrics', Metrics, {\n config,\n /**\n * Stops network telemetry before SDK logout.\n * @returns\n */\n onBeforeLogout() {\n return this.stopNetworkTelemetry();\n },\n});\n\nregisterInternalPlugin('newMetrics', NewMetrics, {\n config,\n});\n\nexport {default, getOSNameInternal} from './metrics';\n\nexport {\n config,\n CALL_DIAGNOSTIC_CONFIG,\n AutomatedUserUtils,\n NewMetrics,\n Utils,\n CallDiagnosticUtils,\n CallDiagnosticLatencies,\n CallDiagnosticMetrics,\n BehavioralMetrics,\n OperationalMetrics,\n BusinessMetrics,\n RtcMetrics,\n PreLoginMetrics,\n};\nexport {isAutomatedUser, isAutomatedUserAgent} from './automated-user';\nexport type {\n ClientEvent,\n ClientEventLeaveReason,\n SubmitBehavioralEvent,\n SubmitClientEvent,\n SubmitInternalEvent,\n SubmitMQE,\n SubmitOperationalEvent,\n SubmitBusinessEvent,\n PreComputedLatencies,\n SubmitFeatureEvent,\n LocusSyncLatencyEventName,\n PrivacyAndSecurityPermission,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,KAAA,GAAAJ,uBAAA,CAAAF,OAAA;AAAiC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AAAf,CAAA,gBAAAe,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,EAAA,OAAAR,CAAA,IAAAD,CAAA,GAAAY,sBAAA,KAAAC,gCAAA,CAAAnB,CAAA,EAAAe,EAAA,OAAAR,CAAA,CAAAM,GAAA,IAAAN,CAAA,CAAAO,GAAA,IAAAR,CAAA,CAAAE,CAAA,EAAAO,EAAA,EAAAR,CAAA,IAAAC,CAAA,CAAAO,EAAA,IAAAf,CAAA,CAAAe,EAAA,WAAAP,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAnCjD;AACA;AACA;;AAEA;;AAiCA,IAAAmB,iCAAsB,EAAC,SAAS,EAAEC,gBAAO,EAAE;EACzCC,MAAM,EAANA,eAAM;EACN;AACF;AACA;AACA;EACEC,cAAc,WAAdA,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACC,oBAAoB,CAAC,CAAC;EACpC;AACF,CAAC,CAAC;AAEF,IAAAJ,iCAAsB,EAAC,YAAY,EAAEK,mBAAU,EAAE;EAC/CH,MAAM,EAANA;AACF,CAAC,CAAC","ignoreList":[]}
package/dist/metrics.js CHANGED
@@ -13,14 +13,16 @@ _Object$defineProperty(exports, "__esModule", {
13
13
  exports.default = void 0;
14
14
  exports.getOSNameInternal = getOSNameInternal;
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
16
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
16
17
  var _webexCore = require("@webex/webex-core");
17
18
  var _common = require("@webex/common");
18
19
  var _config = require("./config");
19
20
  var _batcher = _interopRequireDefault(require("./batcher"));
20
21
  var _clientMetricsBatcher = _interopRequireDefault(require("./client-metrics-batcher"));
21
22
  var _clientMetricsPreloginBatcher = _interopRequireDefault(require("./client-metrics-prelogin-batcher"));
23
+ var _networkTelemetry = require("./network-telemetry");
22
24
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable default-param-last */ /*!
25
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable default-param-last */ /* eslint-disable valid-jsdoc */ /*!
24
26
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
25
27
  */
26
28
  var _BrowserDetection = (0, _common.BrowserDetection)(),
@@ -54,6 +56,110 @@ var Metrics = _webexCore.WebexPlugin.extend({
54
56
  clientMetricsPreloginBatcher: _clientMetricsPreloginBatcher.default
55
57
  },
56
58
  namespace: 'Metrics',
59
+ /**
60
+ * Registers SDK request outcome monitoring.
61
+ * @param args
62
+ * @returns
63
+ */
64
+ initialize: function initialize() {
65
+ var _WebexPlugin$prototyp,
66
+ _this = this;
67
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
68
+ args[_key] = arguments[_key];
69
+ }
70
+ (_WebexPlugin$prototyp = _webexCore.WebexPlugin.prototype.initialize).call.apply(_WebexPlugin$prototyp, [this].concat(args));
71
+
72
+ // Metrics may also be constructed as a standalone plugin. Request events are
73
+ // available only when it is attached to a Webex instance.
74
+ if (!this.parent && !this.collection) {
75
+ return;
76
+ }
77
+ var initializeNetworkTelemetry = function initializeNetworkTelemetry() {
78
+ var _this$webex, _this$webex$config, _this$webex$config$me, _this$webex$config$me2;
79
+ if (_this.networkTelemetry || ((_this$webex = _this.webex) === null || _this$webex === void 0 ? void 0 : (_this$webex$config = _this$webex.config) === null || _this$webex$config === void 0 ? void 0 : (_this$webex$config$me = _this$webex$config.metrics) === null || _this$webex$config$me === void 0 ? void 0 : (_this$webex$config$me2 = _this$webex$config$me.networkTelemetry) === null || _this$webex$config$me2 === void 0 ? void 0 : _this$webex$config$me2.enabled) !== true) {
80
+ return;
81
+ }
82
+ _this.networkTelemetry = (0, _networkTelemetry.createNetworkTelemetryCollector)({
83
+ intervalMs: _this.webex.config.metrics.networkTelemetry.intervalMs,
84
+ submitMetric: _this.submitNetworkTelemetryMetric.bind(_this),
85
+ onSubmissionFailure: _this.handleNetworkTelemetrySubmissionFailure.bind(_this)
86
+ });
87
+ _this.listenTo(_this.webex, 'request:start', _this.recordNetworkRequestStart);
88
+ _this.listenTo(_this.webex, 'request:success', _this.recordNetworkRequestSuccess);
89
+ _this.listenTo(_this.webex, 'request:failure', _this.recordNetworkRequestFailure);
90
+ };
91
+
92
+ // Ampersand initializes children before WebexCore.initialize() populates
93
+ // webex.config. Run immediately for already-configured hosts (including
94
+ // MockWebex), and listen for the real core's post-initialization notification.
95
+ this.listenToOnce(this.webex, 'change:config', initializeNetworkTelemetry);
96
+ initializeNetworkTelemetry();
97
+ },
98
+ /**
99
+ * Records an SDK request being sent in the current reporting window.
100
+ * @param options
101
+ * @returns
102
+ */
103
+ recordNetworkRequestStart: function recordNetworkRequestStart(options) {
104
+ this.networkTelemetry.recordRequest(options);
105
+ },
106
+ /**
107
+ * Records a successful SDK request for the current reporting window.
108
+ * @param options
109
+ * @returns
110
+ */
111
+ recordNetworkRequestSuccess: function recordNetworkRequestSuccess(options) {
112
+ this.networkTelemetry.recordResponse(options);
113
+ },
114
+ /**
115
+ * Records a failed SDK request for the current reporting window.
116
+ * @param options
117
+ * @param reason
118
+ * @returns
119
+ */
120
+ recordNetworkRequestFailure: function recordNetworkRequestFailure(options, reason) {
121
+ this.networkTelemetry.recordFailure(options, reason);
122
+ },
123
+ /**
124
+ * Submits the current network telemetry window immediately.
125
+ * @returns
126
+ */
127
+ flushNetworkTelemetry: function flushNetworkTelemetry() {
128
+ if (!this.networkTelemetry) {
129
+ return _promise.default.resolve();
130
+ }
131
+ return this.networkTelemetry.flush();
132
+ },
133
+ /**
134
+ * Submits a completed network telemetry window through client metrics.
135
+ * @param name
136
+ * @param properties
137
+ * @returns
138
+ */
139
+ submitNetworkTelemetryMetric: function submitNetworkTelemetryMetric(name, properties) {
140
+ return this.submitClientMetrics(name, properties);
141
+ },
142
+ /**
143
+ * Logs a network telemetry submission failure without affecting SDK requests.
144
+ * @returns
145
+ */
146
+ handleNetworkTelemetrySubmissionFailure: function handleNetworkTelemetrySubmissionFailure() {
147
+ var _this$webex$logger;
148
+ (_this$webex$logger = this.webex.logger) === null || _this$webex$logger === void 0 ? void 0 : _this$webex$logger.warn('metrics: failed to submit network request summary telemetry');
149
+ },
150
+ /**
151
+ * Stops network telemetry collection and submission.
152
+ * @returns
153
+ */
154
+ stopNetworkTelemetry: function stopNetworkTelemetry() {
155
+ if (!this.networkTelemetry) {
156
+ return _promise.default.resolve();
157
+ }
158
+ this.stopListening(this.webex, 'request:start', this.recordNetworkRequestStart);
159
+ this.stopListening(this.webex, 'request:success', this.recordNetworkRequestSuccess);
160
+ this.stopListening(this.webex, 'request:failure', this.recordNetworkRequestFailure);
161
+ return this.networkTelemetry.stop();
162
+ },
57
163
  submit: function submit(key, value) {
58
164
  return this.batcher.request(_objectSpread({
59
165
  key: key
@@ -75,13 +181,20 @@ var Metrics = _webexCore.WebexPlugin.extend({
75
181
  };
76
182
  // @ts-ignore
77
183
  var providedClientVersion = (_this$webex$meetings = this.webex.meetings) === null || _this$webex$meetings === void 0 ? void 0 : (_this$webex$meetings$ = _this$webex$meetings.config) === null || _this$webex$meetings$ === void 0 ? void 0 : (_this$webex$meetings$2 = _this$webex$meetings$.metrics) === null || _this$webex$meetings$2 === void 0 ? void 0 : _this$webex$meetings$2.clientVersion;
184
+ var _this$webex$config2 = this.webex.config,
185
+ appName = _this$webex$config2.appName,
186
+ appVersion = _this$webex$config2.appVersion;
187
+ // Browser location is unavailable when the SDK runs in Node.js.
188
+ // eslint-disable-next-line no-undef
189
+ var browserLocation = typeof window !== 'undefined' ? window.location : undefined;
78
190
  payload.tags = _objectSpread(_objectSpread({}, props.tags), {}, {
191
+ app_name: appName !== null && appName !== void 0 ? appName : 'unknown',
192
+ app_url: (browserLocation === null || browserLocation === void 0 ? void 0 : browserLocation.origin) || (browserLocation === null || browserLocation === void 0 ? void 0 : browserLocation.hostname) || 'non-browser',
193
+ app_version: appVersion !== null && appVersion !== void 0 ? appVersion : 'unknown',
79
194
  browser: getBrowserName(),
80
195
  os: getOSNameInternal(),
81
196
  appVersion: providedClientVersion,
82
- // Node does not like this so we need to check if it exists or not
83
- // eslint-disable-next-line no-undef
84
- domain: typeof window !== 'undefined' ? window.location.hostname || 'non-browser' : 'non-browser' // Check what else we could measure
197
+ domain: (browserLocation === null || browserLocation === void 0 ? void 0 : browserLocation.hostname) || 'non-browser'
85
198
  });
86
199
  payload.fields = _objectSpread(_objectSpread({}, props.fields), {}, {
87
200
  browser_version: getBrowserVersion(),
@@ -147,7 +260,7 @@ var Metrics = _webexCore.WebexPlugin.extend({
147
260
  }
148
261
  });
149
262
  },
150
- version: "3.12.0-next.46"
263
+ version: "3.12.0-next.47"
151
264
  });
152
265
  var _default = exports.default = Metrics;
153
266
  //# sourceMappingURL=metrics.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_webexCore","require","_common","_config","_batcher","_interopRequireDefault","_clientMetricsBatcher","_clientMetricsPreloginBatcher","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_BrowserDetection","BrowserDetection","getOSName","getOSVersion","getBrowserName","getBrowserVersion","getOSNameInternal","_OSMap$getOSName","OSMap","OS_NAME","OTHERS","getSparkUserAgent","webex","_webex$config","_ref","config","appName","appVersion","appPlatform","sparkUserAgent","CLIENT_NAME","concat","Metrics","WebexPlugin","extend","children","batcher","Batcher","clientMetricsBatcher","ClientMetricsBatcher","clientMetricsPreloginBatcher","ClientMetricsPreloginBatcher","namespace","submit","key","value","request","getClientMetricsPayload","eventName","props","_this$webex$meetings","_this$webex$meetings$","_this$webex$meetings$2","Error","payload","metricName","providedClientVersion","meetings","metrics","clientVersion","tags","browser","os","domain","window","location","hostname","fields","browser_version","os_version","sdk_version","version","platform","spark_user_agent","client_id","credentials","type","context","app","locale","name","eventPayload","timestamp","Date","valueOf","submitClientMetrics","undefined","preLoginId","savePreLoginId","aliasUser","method","api","resource","headers","body","qs","alias","_default","exports"],"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';\nimport ClientMetricsPreloginBatcher from './client-metrics-prelogin-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 clientMetricsPreloginBatcher: ClientMetricsPreloginBatcher,\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 // @ts-ignore\n const providedClientVersion = this.webex.meetings?.config?.metrics?.clientVersion;\n\n payload.tags = {\n ...props.tags,\n browser: getBrowserName(),\n os: getOSNameInternal(),\n appVersion: providedClientVersion,\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 this.clientMetricsPreloginBatcher.savePreLoginId(preLoginId);\n\n return this.clientMetricsPreloginBatcher.request(payload);\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\nexport default Metrics;\n"],"mappings":";;;;;;;;;;;;;;;AAMA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,6BAAA,GAAAF,sBAAA,CAAAJ,OAAA;AAA6E,SAAAO,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAG,CAAA,YAAAH,CAAA;AAAA,SAAAS,cAAAX,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAC,CAAA,WAAAU,SAAA,CAAAX,CAAA,IAAAW,SAAA,CAAAX,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAe,MAAA,CAAAZ,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,CA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AK,GAAAhD,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAqF,SAAA,GAAArF,SAAA,MAAG,CAAC,CAAC;IAAA,IAAEsF,UAAU,GAAAtF,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAqF,SAAA;IACnD,IAAMhC,OAAO,GAAG,IAAI,CAACP,uBAAuB,CAACC,SAAS,EAAEC,KAAK,CAAC;IAE9D,IAAIsC,UAAU,EAAE;MACd,IAAI,CAAC/C,4BAA4B,CAACgD,cAAc,CAACD,UAAU,CAAC;MAE5D,OAAO,IAAI,CAAC/C,4BAA4B,CAACM,OAAO,CAACQ,OAAO,CAAC;IAC3D;IAEA,OAAO,IAAI,CAAChB,oBAAoB,CAACQ,OAAO,CAACQ,OAAO,CAAC;EACnD,CAAC;EAED;AACF;AACA;AACA;AACA;EACEmC,SAAS,WAATA,SAASA,CAACF,UAAU,EAAE;IACpB,OAAO,IAAI,CAACzC,OAAO,CAAC;MAClB4C,MAAM,EAAE,MAAM;MACdC,GAAG,EAAE,SAAS;MACdC,QAAQ,EAAE,eAAe;MACzBC,OAAO,EAAE;QACP,mBAAmB,EAAEN;MACvB,CAAC;MACDO,IAAI,EAAE,CAAC,CAAC;MACRC,EAAE,EAAE;QACFC,KAAK,EAAE;MACT;IACF,CAAC,CAAC;EACJ,CAAC;EAAAzB,OAAA;AACH,CAAC,CAAC;AAAC,IAAA0B,QAAA,GAAAC,OAAA,CAAA5F,OAAA,GAEY0B,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["_webexCore","require","_common","_config","_batcher","_interopRequireDefault","_clientMetricsBatcher","_clientMetricsPreloginBatcher","_networkTelemetry","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","_BrowserDetection","BrowserDetection","getOSName","getOSVersion","getBrowserName","getBrowserVersion","getOSNameInternal","_OSMap$getOSName","OSMap","OS_NAME","OTHERS","getSparkUserAgent","webex","_webex$config","_ref","config","appName","appVersion","appPlatform","sparkUserAgent","CLIENT_NAME","concat","Metrics","WebexPlugin","extend","children","batcher","Batcher","clientMetricsBatcher","ClientMetricsBatcher","clientMetricsPreloginBatcher","ClientMetricsPreloginBatcher","namespace","initialize","_WebexPlugin$prototyp","_this","_len","args","Array","_key","prototype","call","parent","collection","initializeNetworkTelemetry","_this$webex","_this$webex$config","_this$webex$config$me","_this$webex$config$me2","networkTelemetry","metrics","enabled","createNetworkTelemetryCollector","intervalMs","submitMetric","submitNetworkTelemetryMetric","bind","onSubmissionFailure","handleNetworkTelemetrySubmissionFailure","listenTo","recordNetworkRequestStart","recordNetworkRequestSuccess","recordNetworkRequestFailure","listenToOnce","options","recordRequest","recordResponse","reason","recordFailure","flushNetworkTelemetry","_promise","resolve","flush","name","properties","submitClientMetrics","_this$webex$logger","logger","warn","stopNetworkTelemetry","stopListening","stop","submit","key","value","request","getClientMetricsPayload","eventName","props","_this$webex$meetings","_this$webex$meetings$","_this$webex$meetings$2","Error","payload","metricName","providedClientVersion","meetings","clientVersion","_this$webex$config2","browserLocation","window","location","undefined","tags","app_name","app_url","origin","hostname","app_version","browser","os","domain","fields","browser_version","os_version","sdk_version","version","platform","spark_user_agent","client_id","credentials","type","context","app","locale","eventPayload","timestamp","Date","valueOf","preLoginId","savePreLoginId","aliasUser","method","api","resource","headers","body","qs","alias","_default","exports"],"sources":["metrics.js"],"sourcesContent":["/* eslint-disable default-param-last */\n/* eslint-disable valid-jsdoc */\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';\nimport ClientMetricsPreloginBatcher from './client-metrics-prelogin-batcher';\nimport {createNetworkTelemetryCollector} from './network-telemetry';\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 clientMetricsPreloginBatcher: ClientMetricsPreloginBatcher,\n },\n\n namespace: 'Metrics',\n\n /**\n * Registers SDK request outcome monitoring.\n * @param args\n * @returns\n */\n initialize(...args) {\n WebexPlugin.prototype.initialize.call(this, ...args);\n\n // Metrics may also be constructed as a standalone plugin. Request events are\n // available only when it is attached to a Webex instance.\n if (!this.parent && !this.collection) {\n return;\n }\n\n const initializeNetworkTelemetry = () => {\n if (\n this.networkTelemetry ||\n this.webex?.config?.metrics?.networkTelemetry?.enabled !== true\n ) {\n return;\n }\n\n this.networkTelemetry = createNetworkTelemetryCollector({\n intervalMs: this.webex.config.metrics.networkTelemetry.intervalMs,\n submitMetric: this.submitNetworkTelemetryMetric.bind(this),\n onSubmissionFailure: this.handleNetworkTelemetrySubmissionFailure.bind(this),\n });\n this.listenTo(this.webex, 'request:start', this.recordNetworkRequestStart);\n this.listenTo(this.webex, 'request:success', this.recordNetworkRequestSuccess);\n this.listenTo(this.webex, 'request:failure', this.recordNetworkRequestFailure);\n };\n\n // Ampersand initializes children before WebexCore.initialize() populates\n // webex.config. Run immediately for already-configured hosts (including\n // MockWebex), and listen for the real core's post-initialization notification.\n this.listenToOnce(this.webex, 'change:config', initializeNetworkTelemetry);\n initializeNetworkTelemetry();\n },\n\n /**\n * Records an SDK request being sent in the current reporting window.\n * @param options\n * @returns\n */\n recordNetworkRequestStart(options) {\n this.networkTelemetry.recordRequest(options);\n },\n\n /**\n * Records a successful SDK request for the current reporting window.\n * @param options\n * @returns\n */\n recordNetworkRequestSuccess(options) {\n this.networkTelemetry.recordResponse(options);\n },\n\n /**\n * Records a failed SDK request for the current reporting window.\n * @param options\n * @param reason\n * @returns\n */\n recordNetworkRequestFailure(options, reason) {\n this.networkTelemetry.recordFailure(options, reason);\n },\n\n /**\n * Submits the current network telemetry window immediately.\n * @returns\n */\n flushNetworkTelemetry() {\n if (!this.networkTelemetry) {\n return Promise.resolve();\n }\n\n return this.networkTelemetry.flush();\n },\n\n /**\n * Submits a completed network telemetry window through client metrics.\n * @param name\n * @param properties\n * @returns\n */\n submitNetworkTelemetryMetric(name, properties) {\n return this.submitClientMetrics(name, properties);\n },\n\n /**\n * Logs a network telemetry submission failure without affecting SDK requests.\n * @returns\n */\n handleNetworkTelemetrySubmissionFailure() {\n this.webex.logger?.warn('metrics: failed to submit network request summary telemetry');\n },\n\n /**\n * Stops network telemetry collection and submission.\n * @returns\n */\n stopNetworkTelemetry() {\n if (!this.networkTelemetry) {\n return Promise.resolve();\n }\n\n this.stopListening(this.webex, 'request:start', this.recordNetworkRequestStart);\n this.stopListening(this.webex, 'request:success', this.recordNetworkRequestSuccess);\n this.stopListening(this.webex, 'request:failure', this.recordNetworkRequestFailure);\n\n return this.networkTelemetry.stop();\n },\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 // @ts-ignore\n const providedClientVersion = this.webex.meetings?.config?.metrics?.clientVersion;\n const {appName, appVersion} = this.webex.config;\n // Browser location is unavailable when the SDK runs in Node.js.\n // eslint-disable-next-line no-undef\n const browserLocation = typeof window !== 'undefined' ? window.location : undefined;\n\n payload.tags = {\n ...props.tags,\n app_name: appName ?? 'unknown',\n app_url: browserLocation?.origin || browserLocation?.hostname || 'non-browser',\n app_version: appVersion ?? 'unknown',\n browser: getBrowserName(),\n os: getOSNameInternal(),\n appVersion: providedClientVersion,\n domain: browserLocation?.hostname || 'non-browser',\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 this.clientMetricsPreloginBatcher.savePreLoginId(preLoginId);\n\n return this.clientMetricsPreloginBatcher.request(payload);\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\nexport default Metrics;\n"],"mappings":";;;;;;;;;;;;;;;;AAOA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GA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