@webex/internal-plugin-metrics 3.11.0 → 3.12.0-llmrefactor.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automated-user.js +19 -0
- package/dist/automated-user.js.map +1 -0
- package/dist/batcher.js +3 -0
- package/dist/batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +639 -65
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.js +168 -76
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +18 -4
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
- package/dist/call-diagnostic/config.js +17 -3
- package/dist/call-diagnostic/config.js.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/generic-metrics.js +8 -6
- package/dist/generic-metrics.js.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +1 -1
- package/dist/metrics.types.js +4 -0
- package/dist/metrics.types.js.map +1 -1
- package/dist/new-metrics.js +69 -23
- package/dist/new-metrics.js.map +1 -1
- package/dist/prelogin-metrics.js +106 -0
- package/dist/prelogin-metrics.js.map +1 -0
- package/dist/types/automated-user.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +208 -5
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +79 -15
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +5 -0
- package/dist/types/call-diagnostic/config.d.ts +5 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.d.ts +6 -3
- package/dist/types/metrics.types.d.ts +6 -4
- package/dist/types/new-metrics.d.ts +16 -0
- package/dist/types/prelogin-metrics.d.ts +47 -0
- package/package.json +12 -11
- package/src/automated-user.ts +16 -0
- package/src/batcher.js +4 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +800 -75
- package/src/call-diagnostic/call-diagnostic-metrics.ts +102 -15
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +22 -2
- package/src/call-diagnostic/config.ts +15 -0
- package/src/config.js +1 -0
- package/src/generic-metrics.ts +6 -6
- package/src/index.ts +7 -0
- package/src/metrics.types.ts +18 -5
- package/src/new-metrics.ts +54 -4
- package/src/prelogin-metrics.ts +94 -0
- package/test/unit/spec/automated-user.ts +43 -0
- package/test/unit/spec/batcher.js +43 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +47 -11
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +1550 -416
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +887 -159
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +61 -3
- package/test/unit/spec/new-metrics.ts +39 -2
- package/test/unit/spec/prelogin-metrics-batcher.ts +71 -36
- package/test/unit/spec/prelogin-metrics.ts +132 -0
|
@@ -3,6 +3,7 @@ import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
|
|
|
3
3
|
import BehavioralMetrics from './behavioral-metrics';
|
|
4
4
|
import OperationalMetrics from './operational-metrics';
|
|
5
5
|
import BusinessMetrics from './business-metrics';
|
|
6
|
+
import PreLoginMetrics from './prelogin-metrics';
|
|
6
7
|
import { RecursivePartial, MetricEventProduct, MetricEventAgent, MetricEventVerb, ClientEvent, FeatureEvent, EventPayload, MediaQualityEvent, InternalEvent, SubmitClientEventOptions, Table, DelayedClientEvent, DelayedClientFeatureEvent } from './metrics.types';
|
|
7
8
|
import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
|
|
8
9
|
/**
|
|
@@ -17,6 +18,7 @@ declare class Metrics extends WebexPlugin {
|
|
|
17
18
|
behavioralMetrics: BehavioralMetrics;
|
|
18
19
|
operationalMetrics: OperationalMetrics;
|
|
19
20
|
businessMetrics: BusinessMetrics;
|
|
21
|
+
preLoginMetrics: PreLoginMetrics;
|
|
20
22
|
isReady: boolean;
|
|
21
23
|
/**
|
|
22
24
|
* Whether or not to delay the submission of client events.
|
|
@@ -76,6 +78,10 @@ declare class Metrics extends WebexPlugin {
|
|
|
76
78
|
* @returns true once we have the deviceId we need to submit business events
|
|
77
79
|
*/
|
|
78
80
|
isReadyToSubmitBusinessEvents(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* @returns whether the current user agent belongs to an automated user
|
|
83
|
+
*/
|
|
84
|
+
isAutomatedUser(): boolean;
|
|
79
85
|
/**
|
|
80
86
|
* Behavioral event
|
|
81
87
|
* @param args
|
|
@@ -105,6 +111,16 @@ declare class Metrics extends WebexPlugin {
|
|
|
105
111
|
table?: Table;
|
|
106
112
|
metadata?: EventPayload;
|
|
107
113
|
}): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Call Analyzer: Pre-Login Event
|
|
116
|
+
* @param args
|
|
117
|
+
*/
|
|
118
|
+
submitPreLoginEvent({ name, preLoginId, payload, metadata, }: {
|
|
119
|
+
name: string;
|
|
120
|
+
preLoginId: string;
|
|
121
|
+
payload: EventPayload;
|
|
122
|
+
metadata?: EventPayload;
|
|
123
|
+
}): Promise<void>;
|
|
108
124
|
/**
|
|
109
125
|
* Call Analyzer: Media Quality Event
|
|
110
126
|
* @param args
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import GenericMetrics from './generic-metrics';
|
|
2
|
+
import { EventPayload } from './metrics.types';
|
|
3
|
+
import PreLoginMetricsBatcher from './prelogin-metrics-batcher';
|
|
4
|
+
/**
|
|
5
|
+
* @description Util class to handle PreLogin Metrics
|
|
6
|
+
* @export
|
|
7
|
+
* @class PreLoginMetrics
|
|
8
|
+
*/
|
|
9
|
+
export default class PreLoginMetrics extends GenericMetrics {
|
|
10
|
+
private preLoginMetricsBatcher;
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
* @param {PreLoginMetricsBatcher} preLoginMetricsBatcher - Pre-login metrics batcher
|
|
14
|
+
* @param {any} attrs - Attributes
|
|
15
|
+
* @param {any} options - Options
|
|
16
|
+
* @constructor
|
|
17
|
+
*/
|
|
18
|
+
constructor(preLoginMetricsBatcher: typeof PreLoginMetricsBatcher, attrs?: any, options?: {
|
|
19
|
+
parent?: any;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Submit a business metric to our metrics endpoint.
|
|
23
|
+
* Routes to the correct table with the correct schema payload by table.
|
|
24
|
+
* @see https://confluence-eng-gpk2.cisco.com/conf/display/WAP/Business+metrics++-%3E+ROMA
|
|
25
|
+
* @param {Object} options - The options object
|
|
26
|
+
* @param {string} options.name - Name of the metric
|
|
27
|
+
* @param {string} options.preLoginId - ID to identify pre-login user
|
|
28
|
+
* @param {EventPayload} options.payload - User payload of the metric
|
|
29
|
+
* @param {EventPayload} [options.metadata] - Optional metadata to include outside of eventPayload.value
|
|
30
|
+
* @returns {Promise<void>} Promise that resolves when the metric is submitted
|
|
31
|
+
*/
|
|
32
|
+
submitPreLoginEvent({ name, preLoginId, payload, metadata, }: {
|
|
33
|
+
name: string;
|
|
34
|
+
preLoginId: string;
|
|
35
|
+
payload: EventPayload;
|
|
36
|
+
metadata?: EventPayload;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Builds a formatted event object for metrics submission.
|
|
40
|
+
* @param {string} metricName - Metric name
|
|
41
|
+
* @param {string} preLoginId - Pre-login user identifier
|
|
42
|
+
* @param {EventPayload} payload - Metric payload data
|
|
43
|
+
* @param {EventPayload} metadata - Additional metadata to include in the event
|
|
44
|
+
* @returns {object} Formatted metrics event object with type, eventPayload, and timestamp
|
|
45
|
+
*/
|
|
46
|
+
private buildEvent;
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -26,22 +26,23 @@
|
|
|
26
26
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
27
27
|
"@webex/jest-config-legacy": "0.0.0",
|
|
28
28
|
"@webex/legacy-tools": "0.0.0",
|
|
29
|
-
"@webex/test-helper-chai": "3.
|
|
30
|
-
"@webex/test-helper-mocha": "3.
|
|
31
|
-
"@webex/test-helper-mock-webex": "3.
|
|
32
|
-
"@webex/test-helper-test-users": "3.
|
|
29
|
+
"@webex/test-helper-chai": "3.12.0-llmrefactor.1",
|
|
30
|
+
"@webex/test-helper-mocha": "3.12.0-llmrefactor.1",
|
|
31
|
+
"@webex/test-helper-mock-webex": "3.12.0-llmrefactor.1",
|
|
32
|
+
"@webex/test-helper-test-users": "3.12.0-llmrefactor.1",
|
|
33
33
|
"eslint": "^8.24.0",
|
|
34
34
|
"prettier": "^2.7.1",
|
|
35
35
|
"sinon": "^9.2.4"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@webex/common": "3.
|
|
39
|
-
"@webex/common-timers": "3.
|
|
40
|
-
"@webex/event-dictionary-ts": "^1.0.
|
|
41
|
-
"@webex/test-helper-chai": "3.
|
|
42
|
-
"@webex/test-helper-mock-webex": "3.
|
|
43
|
-
"@webex/webex-core": "3.
|
|
38
|
+
"@webex/common": "3.12.0-llmrefactor.1",
|
|
39
|
+
"@webex/common-timers": "3.12.0-llmrefactor.1",
|
|
40
|
+
"@webex/event-dictionary-ts": "^1.0.2220",
|
|
41
|
+
"@webex/test-helper-chai": "3.12.0-llmrefactor.1",
|
|
42
|
+
"@webex/test-helper-mock-webex": "3.12.0-llmrefactor.1",
|
|
43
|
+
"@webex/webex-core": "3.12.0-llmrefactor.1",
|
|
44
44
|
"ip-anonymize": "^0.1.0",
|
|
45
|
+
"isbot": "5.2.1",
|
|
45
46
|
"lodash": "^4.17.21",
|
|
46
47
|
"uuid": "^3.3.2"
|
|
47
48
|
},
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"test:style": "eslint ./src/**/*.*",
|
|
54
55
|
"test:unit": "webex-legacy-tools test --unit --runner mocha"
|
|
55
56
|
},
|
|
56
|
-
"version": "3.
|
|
57
|
+
"version": "3.12.0-llmrefactor.1"
|
|
57
58
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {isBot} from 'isbot';
|
|
2
|
+
|
|
3
|
+
export const isAutomatedUserAgent = (userAgent?: string | null): boolean => isBot(userAgent);
|
|
4
|
+
|
|
5
|
+
let automatedUser: boolean | undefined;
|
|
6
|
+
|
|
7
|
+
export const isAutomatedUser = (): boolean => {
|
|
8
|
+
if (automatedUser === undefined) {
|
|
9
|
+
automatedUser =
|
|
10
|
+
typeof window !== 'undefined' &&
|
|
11
|
+
typeof navigator !== 'undefined' &&
|
|
12
|
+
(Boolean(navigator.webdriver) || isAutomatedUserAgent(navigator.userAgent));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return automatedUser;
|
|
16
|
+
};
|
package/src/batcher.js
CHANGED
|
@@ -75,6 +75,10 @@ const MetricsBatcher = Batcher.extend({
|
|
|
75
75
|
*/
|
|
76
76
|
handleHttpError(reason) {
|
|
77
77
|
if (reason instanceof WebexHttpError.NetworkOrCORSError) {
|
|
78
|
+
if (!this.config.batcherRetryOnNetworkError) {
|
|
79
|
+
return Reflect.apply(Batcher.prototype.handleHttpError, this, [reason]);
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
this.logger.warn(
|
|
79
83
|
'metrics-batcher: received network error submitting metrics, reenqueuing payload'
|
|
80
84
|
);
|