@webex/internal-plugin-metrics 3.0.0-bnr.5 → 3.0.0-next.10
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/.eslintrc.js +6 -0
- package/babel.config.js +3 -0
- package/dist/batcher.js +41 -3
- package/dist/batcher.js.map +1 -1
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js +64 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +550 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +858 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +356 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +609 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/client-metrics-batcher.js +3 -3
- package/dist/client-metrics-batcher.js.map +1 -1
- package/dist/config.js +6 -9
- package/dist/config.js.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +28 -22
- package/dist/metrics.js.map +1 -1
- package/dist/metrics.types.js +7 -0
- package/dist/metrics.types.js.map +1 -0
- package/dist/new-metrics.js +303 -0
- package/dist/new-metrics.js.map +1 -0
- package/dist/prelogin-metrics-batcher.js +81 -0
- package/dist/prelogin-metrics-batcher.js.map +1 -0
- package/dist/types/batcher.d.ts +5 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +237 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +425 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +103 -0
- package/dist/types/call-diagnostic/config.d.ts +178 -0
- package/dist/types/config.d.ts +18 -0
- package/dist/types/index.d.ts +15 -3
- package/dist/types/metrics.d.ts +1 -0
- package/dist/types/metrics.types.d.ts +107 -0
- package/dist/types/new-metrics.d.ts +131 -0
- package/dist/types/prelogin-metrics-batcher.d.ts +2 -0
- package/dist/types/utils.d.ts +6 -0
- package/dist/utils.js +26 -0
- package/dist/utils.js.map +1 -0
- package/jest.config.js +3 -0
- package/package.json +34 -10
- package/process +1 -0
- package/src/batcher.js +38 -0
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +72 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +511 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +925 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +399 -0
- package/src/call-diagnostic/config.ts +685 -0
- package/src/client-metrics-batcher.js +1 -0
- package/src/config.js +1 -0
- package/src/index.ts +56 -0
- package/src/metrics.js +20 -16
- package/src/metrics.types.ts +179 -0
- package/src/new-metrics.ts +278 -0
- package/src/prelogin-metrics-batcher.ts +95 -0
- package/src/utils.ts +17 -0
- package/test/unit/spec/batcher.js +2 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +469 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +718 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +2371 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +637 -0
- package/test/unit/spec/client-metrics-batcher.js +2 -0
- package/test/unit/spec/metrics.js +76 -95
- package/test/unit/spec/new-metrics.ts +231 -0
- package/test/unit/spec/prelogin-metrics-batcher.ts +253 -0
- package/test/unit/spec/utils.ts +22 -0
- package/tsconfig.json +6 -0
- package/dist/call-diagnostic-events-batcher.js +0 -60
- package/dist/call-diagnostic-events-batcher.js.map +0 -1
- package/dist/internal-plugin-metrics.d.ts +0 -21
- package/dist/tsdoc-metadata.json +0 -11
- package/src/call-diagnostic-events-batcher.js +0 -62
- package/src/index.js +0 -17
- package/test/unit/spec/call-diagnostic-events-batcher.js +0 -195
- package/dist/types/{call-diagnostic-events-batcher.d.ts → call-diagnostic/call-diagnostic-metrics-batcher.d.ts} +1 -1
package/dist/types/config.d.ts
CHANGED
|
@@ -12,7 +12,25 @@ declare namespace _default {
|
|
|
12
12
|
const batcherMaxCalls: number;
|
|
13
13
|
const batcherMaxWait: number;
|
|
14
14
|
const batcherRetryPlateau: number;
|
|
15
|
+
const waitForServiceTimeout: number;
|
|
15
16
|
}
|
|
16
17
|
export { metrics_1 as metrics };
|
|
17
18
|
}
|
|
18
19
|
export default _default;
|
|
20
|
+
export namespace OS_NAME {
|
|
21
|
+
const WINDOWS: string;
|
|
22
|
+
const MAC: string;
|
|
23
|
+
const IOS: string;
|
|
24
|
+
const ANDROID: string;
|
|
25
|
+
const CHROME: string;
|
|
26
|
+
const LINUX: string;
|
|
27
|
+
const OTHERS: string;
|
|
28
|
+
}
|
|
29
|
+
export const OSMap: {
|
|
30
|
+
'Chrome OS': string;
|
|
31
|
+
macOS: string;
|
|
32
|
+
Windows: string;
|
|
33
|
+
iOS: string;
|
|
34
|
+
Android: string;
|
|
35
|
+
Linux: string;
|
|
36
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
import '@webex/internal-plugin-device';
|
|
5
|
+
import config from './config';
|
|
6
|
+
import NewMetrics from './new-metrics';
|
|
7
|
+
import * as Utils from './utils';
|
|
8
|
+
import { ClientEvent, ClientEventLeaveReason, SubmitBehavioralEvent, SubmitClientEvent, SubmitInternalEvent, SubmitOperationalEvent, SubmitMQE, PreComputedLatencies } from './metrics.types';
|
|
9
|
+
import * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';
|
|
10
|
+
import * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';
|
|
11
|
+
import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
|
|
12
|
+
import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
|
|
13
|
+
export { default, getOSNameInternal } from './metrics';
|
|
14
|
+
export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, };
|
|
15
|
+
export type { ClientEvent, ClientEventLeaveReason, SubmitBehavioralEvent, SubmitClientEvent, SubmitInternalEvent, SubmitMQE, SubmitOperationalEvent, PreComputedLatencies, };
|
package/dist/types/metrics.d.ts
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ClientEvent as RawClientEvent, Event as RawEvent, MediaQualityEvent as RawMediaQualityEvent } from '@webex/event-dictionary-ts';
|
|
2
|
+
export type Event = Omit<RawEvent, 'event'> & {
|
|
3
|
+
event: RawClientEvent | RawMediaQualityEvent;
|
|
4
|
+
};
|
|
5
|
+
export type ClientEventError = NonNullable<RawClientEvent['errors']>[0];
|
|
6
|
+
export type EnvironmentType = NonNullable<RawEvent['origin']['environment']>;
|
|
7
|
+
export type NewEnvironmentType = NonNullable<RawEvent['origin']['newEnvironment']>;
|
|
8
|
+
export type ClientLaunchMethodType = NonNullable<RawEvent['origin']['clientInfo']>['clientLaunchMethod'];
|
|
9
|
+
export type BrowserLaunchMethodType = NonNullable<RawEvent['origin']['clientInfo']>['browserLaunchMethod'];
|
|
10
|
+
export type SubmitClientEventOptions = {
|
|
11
|
+
meetingId?: string;
|
|
12
|
+
mediaConnections?: any[];
|
|
13
|
+
rawError?: any;
|
|
14
|
+
correlationId?: string;
|
|
15
|
+
preLoginId?: string;
|
|
16
|
+
environment?: EnvironmentType;
|
|
17
|
+
newEnvironmentType?: NewEnvironmentType;
|
|
18
|
+
clientLaunchMethod?: ClientLaunchMethodType;
|
|
19
|
+
browserLaunchMethod?: BrowserLaunchMethodType;
|
|
20
|
+
webexConferenceIdStr?: string;
|
|
21
|
+
globalMeetingId?: string;
|
|
22
|
+
};
|
|
23
|
+
export type SubmitMQEOptions = {
|
|
24
|
+
meetingId: string;
|
|
25
|
+
mediaConnections?: any[];
|
|
26
|
+
networkType?: Event['origin']['networkType'];
|
|
27
|
+
webexConferenceIdStr?: string;
|
|
28
|
+
globalMeetingId?: string;
|
|
29
|
+
};
|
|
30
|
+
export type InternalEvent = {
|
|
31
|
+
name: 'internal.client.meetinginfo.request' | 'internal.client.meetinginfo.response' | 'internal.register.device.request' | 'internal.register.device.response' | 'internal.reset.join.latencies' | 'internal.client.meeting.click.joinbutton' | 'internal.host.meeting.participant.admitted' | 'internal.client.meeting.interstitial-window.showed' | 'internal.client.interstitial-window.click.joinbutton' | 'internal.client.add-media.turn-discovery.start' | 'internal.client.add-media.turn-discovery.end';
|
|
32
|
+
payload?: never;
|
|
33
|
+
options?: never;
|
|
34
|
+
};
|
|
35
|
+
export interface ClientEvent {
|
|
36
|
+
name: RawClientEvent['name'];
|
|
37
|
+
payload?: RawClientEvent;
|
|
38
|
+
options?: SubmitClientEventOptions;
|
|
39
|
+
}
|
|
40
|
+
export interface BehavioralEvent {
|
|
41
|
+
name: 'host.meeting.participant.admitted' | 'sdk.media-flow.started';
|
|
42
|
+
payload?: never;
|
|
43
|
+
options?: never;
|
|
44
|
+
}
|
|
45
|
+
export interface OperationalEvent {
|
|
46
|
+
name: never;
|
|
47
|
+
payload?: never;
|
|
48
|
+
options?: never;
|
|
49
|
+
}
|
|
50
|
+
export interface FeatureEvent {
|
|
51
|
+
name: never;
|
|
52
|
+
payload?: never;
|
|
53
|
+
options?: never;
|
|
54
|
+
}
|
|
55
|
+
export interface MediaQualityEvent {
|
|
56
|
+
name: RawMediaQualityEvent['name'];
|
|
57
|
+
payload?: RawMediaQualityEvent;
|
|
58
|
+
options: SubmitMQEOptions;
|
|
59
|
+
}
|
|
60
|
+
export type RecursivePartial<T> = {
|
|
61
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
62
|
+
};
|
|
63
|
+
export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['name'] | OperationalEvent['name'] | FeatureEvent['name'] | MediaQualityEvent['name'];
|
|
64
|
+
export type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;
|
|
65
|
+
export type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];
|
|
66
|
+
export type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];
|
|
67
|
+
export type NetworkType = NonNullable<RawEvent['origin']>['networkType'];
|
|
68
|
+
export type ClientSubServiceType = ClientEvent['payload']['webexSubServiceType'];
|
|
69
|
+
export type ClientEventPayload = RecursivePartial<ClientEvent['payload']>;
|
|
70
|
+
export type ClientEventLeaveReason = ClientEvent['payload']['leaveReason'];
|
|
71
|
+
export type ClientEventPayloadError = ClientEvent['payload']['errors'];
|
|
72
|
+
export type MediaQualityEventAudioSetupDelayPayload = NonNullable<MediaQualityEvent['payload']>['audioSetupDelay'];
|
|
73
|
+
export type MediaQualityEventVideoSetupDelayPayload = NonNullable<MediaQualityEvent['payload']>['videoSetupDelay'];
|
|
74
|
+
export type SubmitMQEPayload = RecursivePartial<MediaQualityEvent['payload']> & {
|
|
75
|
+
intervals: NonNullable<MediaQualityEvent['payload']>['intervals'];
|
|
76
|
+
};
|
|
77
|
+
export type SubmitInternalEvent = (args: {
|
|
78
|
+
name: InternalEvent['name'];
|
|
79
|
+
payload?: RecursivePartial<InternalEvent['payload']>;
|
|
80
|
+
options?: any;
|
|
81
|
+
}) => void;
|
|
82
|
+
export type SubmitBehavioralEvent = (args: {
|
|
83
|
+
name: BehavioralEvent['name'];
|
|
84
|
+
payload?: RecursivePartial<BehavioralEvent['payload']>;
|
|
85
|
+
options?: any;
|
|
86
|
+
}) => void;
|
|
87
|
+
export type SubmitClientEvent = (args: {
|
|
88
|
+
name: ClientEvent['name'];
|
|
89
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
90
|
+
options?: SubmitClientEventOptions;
|
|
91
|
+
}) => Promise<any>;
|
|
92
|
+
export type SubmitOperationalEvent = (args: {
|
|
93
|
+
name: OperationalEvent['name'];
|
|
94
|
+
payload?: RecursivePartial<OperationalEvent['payload']>;
|
|
95
|
+
options?: any;
|
|
96
|
+
}) => void;
|
|
97
|
+
export type SubmitMQE = (args: {
|
|
98
|
+
name: MediaQualityEvent['name'];
|
|
99
|
+
payload: SubmitMQEPayload;
|
|
100
|
+
options: any;
|
|
101
|
+
}) => void;
|
|
102
|
+
export type BuildClientEventFetchRequestOptions = (args: {
|
|
103
|
+
name: ClientEvent['name'];
|
|
104
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
105
|
+
options?: SubmitClientEventOptions;
|
|
106
|
+
}) => Promise<any>;
|
|
107
|
+
export type PreComputedLatencies = 'internal.client.pageJMT' | 'internal.download.time' | 'internal.get.cluster.time' | 'internal.click.to.interstitial' | 'internal.refresh.captcha.time' | 'internal.exchange.ci.token.time' | 'internal.get.u2c.time' | 'internal.call.init.join.req' | 'internal.other.app.api.time' | 'internal.api.fetch.intelligence.models';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { WebexPlugin } from '@webex/webex-core';
|
|
2
|
+
import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
|
|
3
|
+
import { RecursivePartial, ClientEvent, FeatureEvent, BehavioralEvent, OperationalEvent, MediaQualityEvent, InternalEvent, SubmitClientEventOptions } from './metrics.types';
|
|
4
|
+
import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
|
|
5
|
+
/**
|
|
6
|
+
* Metrics plugin to centralize all types of metrics.
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
declare class Metrics extends WebexPlugin {
|
|
10
|
+
static instance: Metrics;
|
|
11
|
+
callDiagnosticLatencies: CallDiagnosticLatencies;
|
|
12
|
+
callDiagnosticMetrics: CallDiagnosticMetrics;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
* @param args
|
|
16
|
+
* @constructor
|
|
17
|
+
* @private
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
constructor(...args: any[]);
|
|
21
|
+
/**
|
|
22
|
+
* On Ready
|
|
23
|
+
*/
|
|
24
|
+
private onReady;
|
|
25
|
+
/**
|
|
26
|
+
* Used for internal purposes only
|
|
27
|
+
* @param args
|
|
28
|
+
*/
|
|
29
|
+
submitInternalEvent({ name, payload, options, }: {
|
|
30
|
+
name: InternalEvent['name'];
|
|
31
|
+
payload?: RecursivePartial<InternalEvent['payload']>;
|
|
32
|
+
options?: any;
|
|
33
|
+
}): void;
|
|
34
|
+
/**
|
|
35
|
+
* Behavioral event
|
|
36
|
+
* @param args
|
|
37
|
+
*/
|
|
38
|
+
submitBehavioralEvent({ name, payload, options, }: {
|
|
39
|
+
name: BehavioralEvent['name'];
|
|
40
|
+
payload?: RecursivePartial<BehavioralEvent['payload']>;
|
|
41
|
+
options?: any;
|
|
42
|
+
}): void;
|
|
43
|
+
/**
|
|
44
|
+
* Operational event
|
|
45
|
+
* @param args
|
|
46
|
+
*/
|
|
47
|
+
submitOperationalEvent({ name, payload, options, }: {
|
|
48
|
+
name: OperationalEvent['name'];
|
|
49
|
+
payload?: RecursivePartial<OperationalEvent['payload']>;
|
|
50
|
+
options?: any;
|
|
51
|
+
}): void;
|
|
52
|
+
/**
|
|
53
|
+
* Call Analyzer: Media Quality Event
|
|
54
|
+
* @param args
|
|
55
|
+
*/
|
|
56
|
+
submitMQE({ name, payload, options, }: {
|
|
57
|
+
name: MediaQualityEvent['name'];
|
|
58
|
+
payload: RecursivePartial<MediaQualityEvent['payload']> & {
|
|
59
|
+
intervals: MediaQualityEvent['payload']['intervals'];
|
|
60
|
+
};
|
|
61
|
+
options: any;
|
|
62
|
+
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Call Analyzer: Feature Usage Event
|
|
65
|
+
* @param args
|
|
66
|
+
*/
|
|
67
|
+
submitFeatureEvent({ name, payload, options, }: {
|
|
68
|
+
name: FeatureEvent['name'];
|
|
69
|
+
payload?: RecursivePartial<FeatureEvent['payload']>;
|
|
70
|
+
options: any;
|
|
71
|
+
}): void;
|
|
72
|
+
/**
|
|
73
|
+
* Call Analyzer: Client Event
|
|
74
|
+
* @public
|
|
75
|
+
* @param args
|
|
76
|
+
*/
|
|
77
|
+
submitClientEvent({ name, payload, options, }: {
|
|
78
|
+
name: ClientEvent['name'];
|
|
79
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
80
|
+
options?: SubmitClientEventOptions;
|
|
81
|
+
}): Promise<any>;
|
|
82
|
+
/**
|
|
83
|
+
* Issue request to alias a user's pre-login ID with their CI UUID
|
|
84
|
+
* @param {string} preLoginId
|
|
85
|
+
* @returns {Object} HttpResponse object
|
|
86
|
+
*/
|
|
87
|
+
clientMetricsAliasUser(preLoginId: string): any;
|
|
88
|
+
/**
|
|
89
|
+
* Returns a promise that will resolve to fetch options for submitting a metric.
|
|
90
|
+
*
|
|
91
|
+
* This is to support quickly submitting metrics when the browser/tab is closing.
|
|
92
|
+
* Calling submitClientEvent will not work because there some async steps that will
|
|
93
|
+
* not complete before the browser is closed. Instead, we pre-gather all the
|
|
94
|
+
* information/options needed for the request(s), and then simply and quickly
|
|
95
|
+
* fire the fetch(es) when beforeUnload is triggered.
|
|
96
|
+
*
|
|
97
|
+
* We must use fetch instead of request because fetch has a keepalive option that
|
|
98
|
+
* allows the request it to outlive the page.
|
|
99
|
+
*
|
|
100
|
+
* Note: the timings values will be wrong, but setMetricTimingsAndFetch() will
|
|
101
|
+
* properly adjust them before submitting.
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
* @param {Object} arg
|
|
105
|
+
* @param {String} arg.name - event name
|
|
106
|
+
* @param {Object} arg.payload - event payload
|
|
107
|
+
* @param {Object} arg.options - other options
|
|
108
|
+
* @returns {Promise} promise that resolves to options to be used with fetch
|
|
109
|
+
*/
|
|
110
|
+
buildClientEventFetchRequestOptions({ name, payload, options, }: {
|
|
111
|
+
name: ClientEvent['name'];
|
|
112
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
113
|
+
options?: SubmitClientEventOptions;
|
|
114
|
+
}): Promise<any>;
|
|
115
|
+
/**
|
|
116
|
+
* Submits a metric from pre-built request options via the fetch API. Updates
|
|
117
|
+
* the "$timings" and "originTime" values to Date.now() since the existing times
|
|
118
|
+
* were set when the options were built (not submitted).
|
|
119
|
+
|
|
120
|
+
* @param {any} options - the pre-built request options for submitting a metric
|
|
121
|
+
* @returns {Promise} promise that resolves to the response object
|
|
122
|
+
*/
|
|
123
|
+
setMetricTimingsAndFetch(options: any): Promise<any>;
|
|
124
|
+
/**
|
|
125
|
+
* Returns true if the specified serviceErrorCode maps to an expected error.
|
|
126
|
+
* @param {number} serviceErrorCode the service error code
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
isServiceErrorExpected(serviceErrorCode: number): boolean;
|
|
130
|
+
}
|
|
131
|
+
export default Metrics;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.generateCommonErrorMetadata = void 0;
|
|
9
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
10
|
+
/* eslint-disable import/prefer-default-export */
|
|
11
|
+
/**
|
|
12
|
+
* Generates common metadata for errors
|
|
13
|
+
* @param {any} error
|
|
14
|
+
* @returns {object}
|
|
15
|
+
*/
|
|
16
|
+
var generateCommonErrorMetadata = exports.generateCommonErrorMetadata = function generateCommonErrorMetadata(error) {
|
|
17
|
+
if (error instanceof Error) {
|
|
18
|
+
return (0, _stringify.default)({
|
|
19
|
+
message: error === null || error === void 0 ? void 0 : error.message,
|
|
20
|
+
name: error === null || error === void 0 ? void 0 : error.name,
|
|
21
|
+
stack: error === null || error === void 0 ? void 0 : error.stack
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return error;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["generateCommonErrorMetadata","exports","error","Error","_stringify","default","message","name","stack"],"sources":["utils.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n/**\n * Generates common metadata for errors\n * @param {any} error\n * @returns {object}\n */\nexport const generateCommonErrorMetadata = (error) => {\n if (error instanceof Error) {\n return JSON.stringify({\n message: error?.message,\n name: error?.name,\n stack: error?.stack,\n });\n }\n\n return error;\n};\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,SAA9BA,2BAA2BA,CAAIE,KAAK,EAAK;EACpD,IAAIA,KAAK,YAAYC,KAAK,EAAE;IAC1B,OAAO,IAAAC,UAAA,CAAAC,OAAA,EAAe;MACpBC,OAAO,EAAEJ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEI,OAAO;MACvBC,IAAI,EAAEL,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEK,IAAI;MACjBC,KAAK,EAAEN,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEM;IAChB,CAAC,CAAC;EACJ;EAEA,OAAON,KAAK;AACd,CAAC"}
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-metrics",
|
|
3
|
-
"version": "3.0.0-bnr.5",
|
|
4
3
|
"description": "",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"main": "dist/index.js",
|
|
7
6
|
"devMain": "src/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/webex/webex-js-sdk.git",
|
|
@@ -20,16 +20,40 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@babel/core": "^7.17.10",
|
|
23
24
|
"@sinonjs/fake-timers": "^6.0.1",
|
|
25
|
+
"@webex/babel-config-legacy": "0.0.0",
|
|
26
|
+
"@webex/eslint-config-legacy": "0.0.0",
|
|
27
|
+
"@webex/jest-config-legacy": "0.0.0",
|
|
28
|
+
"@webex/legacy-tools": "0.0.0",
|
|
29
|
+
"@webex/test-helper-chai": "3.0.0-next.10",
|
|
30
|
+
"@webex/test-helper-mocha": "3.0.0-next.10",
|
|
31
|
+
"@webex/test-helper-mock-webex": "3.0.0-next.10",
|
|
32
|
+
"@webex/test-helper-test-users": "3.0.0-next.10",
|
|
33
|
+
"eslint": "^8.24.0",
|
|
34
|
+
"prettier": "^2.7.1",
|
|
24
35
|
"sinon": "^9.2.4"
|
|
25
36
|
},
|
|
26
37
|
"dependencies": {
|
|
27
|
-
"@webex/common": "3.0.0-
|
|
28
|
-
"@webex/common-timers": "3.0.0-
|
|
29
|
-
"@webex/
|
|
30
|
-
"@webex/internal-plugin-
|
|
31
|
-
"@webex/
|
|
32
|
-
"@webex/test-helper-
|
|
33
|
-
"@webex/webex
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
"@webex/common": "3.0.0-next.10",
|
|
39
|
+
"@webex/common-timers": "3.0.0-next.10",
|
|
40
|
+
"@webex/event-dictionary-ts": "^1.0.1406",
|
|
41
|
+
"@webex/internal-plugin-device": "3.0.0-next.10",
|
|
42
|
+
"@webex/internal-plugin-metrics": "3.0.0-next.10",
|
|
43
|
+
"@webex/test-helper-chai": "3.0.0-next.10",
|
|
44
|
+
"@webex/test-helper-mock-webex": "3.0.0-next.10",
|
|
45
|
+
"@webex/webex-core": "3.0.0-next.10",
|
|
46
|
+
"ip-anonymize": "^0.1.0",
|
|
47
|
+
"lodash": "^4.17.21",
|
|
48
|
+
"uuid": "^3.3.2"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": " yarn run -T tsc --declaration true --declarationDir ./dist/types",
|
|
52
|
+
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps && yarn build",
|
|
53
|
+
"deploy:npm": "yarn npm publish",
|
|
54
|
+
"test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
55
|
+
"test:style": "eslint ./src/**/*.*",
|
|
56
|
+
"test:unit": "webex-legacy-tools test --unit --runner mocha"
|
|
57
|
+
},
|
|
58
|
+
"version": "3.0.0-next.10"
|
|
59
|
+
}
|
package/process
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {browser: true};
|
package/src/batcher.js
CHANGED
|
@@ -7,9 +7,18 @@ import {safeSetTimeout} from '@webex/common-timers';
|
|
|
7
7
|
|
|
8
8
|
const sym = Symbol('metric id');
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @class
|
|
12
|
+
* @extends Batcher
|
|
13
|
+
* @memberof Metrics
|
|
14
|
+
*/
|
|
10
15
|
const MetricsBatcher = Batcher.extend({
|
|
11
16
|
namespace: 'Metrics',
|
|
12
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @param {any} item
|
|
20
|
+
* @returns {Promise<any>}
|
|
21
|
+
*/
|
|
13
22
|
prepareItem(item) {
|
|
14
23
|
// Keep non-prod data out of metrics
|
|
15
24
|
const env = process.env.NODE_ENV === 'production' ? null : 'TEST';
|
|
@@ -22,6 +31,10 @@ const MetricsBatcher = Batcher.extend({
|
|
|
22
31
|
return Promise.resolve(item);
|
|
23
32
|
},
|
|
24
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @param {any[]} queue
|
|
36
|
+
* @returns {Promise<any[]>}
|
|
37
|
+
*/
|
|
25
38
|
prepareRequest(queue) {
|
|
26
39
|
return Promise.resolve(
|
|
27
40
|
queue.map((item) => {
|
|
@@ -32,6 +45,10 @@ const MetricsBatcher = Batcher.extend({
|
|
|
32
45
|
);
|
|
33
46
|
},
|
|
34
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @param {any} payload
|
|
50
|
+
* @returns {Promise<any>}
|
|
51
|
+
*/
|
|
35
52
|
submitHttpRequest(payload) {
|
|
36
53
|
return this.webex.request({
|
|
37
54
|
method: 'POST',
|
|
@@ -40,13 +57,22 @@ const MetricsBatcher = Batcher.extend({
|
|
|
40
57
|
body: {
|
|
41
58
|
metrics: payload,
|
|
42
59
|
},
|
|
60
|
+
waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout,
|
|
43
61
|
});
|
|
44
62
|
},
|
|
45
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @param {any} res
|
|
66
|
+
* @returns {Promise<any>}
|
|
67
|
+
*/
|
|
46
68
|
handleHttpSuccess(res) {
|
|
47
69
|
return Promise.all(res.options.body.metrics.map((item) => this.acceptItem(item)));
|
|
48
70
|
},
|
|
49
71
|
|
|
72
|
+
/**
|
|
73
|
+
* @param {any} reason
|
|
74
|
+
* @returns {Promise<any>}
|
|
75
|
+
*/
|
|
50
76
|
handleHttpError(reason) {
|
|
51
77
|
if (reason instanceof WebexHttpError.NetworkOrCORSError) {
|
|
52
78
|
this.logger.warn(
|
|
@@ -73,6 +99,10 @@ const MetricsBatcher = Batcher.extend({
|
|
|
73
99
|
return Reflect.apply(Batcher.prototype.handleHttpError, this, [reason]);
|
|
74
100
|
},
|
|
75
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @param {any} item
|
|
104
|
+
* @returns {Promise<any>}
|
|
105
|
+
*/
|
|
76
106
|
rerequest(item) {
|
|
77
107
|
return Promise.all([this.getDeferredForRequest(item), this.prepareItem(item)]).then(
|
|
78
108
|
([defer, req]) => {
|
|
@@ -83,6 +113,10 @@ const MetricsBatcher = Batcher.extend({
|
|
|
83
113
|
);
|
|
84
114
|
},
|
|
85
115
|
|
|
116
|
+
/**
|
|
117
|
+
* @param {any} item
|
|
118
|
+
* @returns {Promise<any>}
|
|
119
|
+
*/
|
|
86
120
|
fingerprintRequest(item) {
|
|
87
121
|
item[sym] = item[sym] || {
|
|
88
122
|
nextDelay: 1000,
|
|
@@ -91,6 +125,10 @@ const MetricsBatcher = Batcher.extend({
|
|
|
91
125
|
return Promise.resolve(item[sym]);
|
|
92
126
|
},
|
|
93
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @param {any} item
|
|
130
|
+
* @returns {Promise<any>}
|
|
131
|
+
*/
|
|
94
132
|
fingerprintResponse(item) {
|
|
95
133
|
return Promise.resolve(item[sym]);
|
|
96
134
|
},
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {uniqueId} from 'lodash';
|
|
2
|
+
import Batcher from '../batcher';
|
|
3
|
+
import {prepareDiagnosticMetricItem} from './call-diagnostic-metrics.util';
|
|
4
|
+
import {CALL_DIAGNOSTIC_LOG_IDENTIFIER} from './config';
|
|
5
|
+
import {generateCommonErrorMetadata} from '../utils';
|
|
6
|
+
|
|
7
|
+
const CallDiagnosticEventsBatcher = Batcher.extend({
|
|
8
|
+
namespace: 'Metrics',
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Prepare item
|
|
12
|
+
* @param {any} item
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
*/
|
|
15
|
+
prepareItem(item) {
|
|
16
|
+
return Promise.resolve(prepareDiagnosticMetricItem(this.webex, item));
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Prepare request, add time sensitive date etc.
|
|
21
|
+
* @param {any[]} queue
|
|
22
|
+
* @returns {Promise<any[]>}
|
|
23
|
+
*/
|
|
24
|
+
prepareRequest(queue) {
|
|
25
|
+
// Add sent timestamp
|
|
26
|
+
queue.forEach((item) => {
|
|
27
|
+
item.eventPayload.originTime = item.eventPayload.originTime || {};
|
|
28
|
+
item.eventPayload.originTime.sent = new Date().toISOString();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return Promise.resolve(queue);
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {any} payload
|
|
37
|
+
* @returns {Promise<any>}
|
|
38
|
+
*/
|
|
39
|
+
submitHttpRequest(payload) {
|
|
40
|
+
const batchId = uniqueId('ca-batch-');
|
|
41
|
+
|
|
42
|
+
return this.webex
|
|
43
|
+
.request({
|
|
44
|
+
method: 'POST',
|
|
45
|
+
service: 'metrics',
|
|
46
|
+
resource: 'clientmetrics',
|
|
47
|
+
body: {
|
|
48
|
+
metrics: payload,
|
|
49
|
+
},
|
|
50
|
+
waitForServiceTimeout: this.webex.config.metrics.waitForServiceTimeout,
|
|
51
|
+
})
|
|
52
|
+
.then((res) => {
|
|
53
|
+
this.webex.logger.log(
|
|
54
|
+
CALL_DIAGNOSTIC_LOG_IDENTIFIER,
|
|
55
|
+
`CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request successful.`
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return res;
|
|
59
|
+
})
|
|
60
|
+
.catch((err) => {
|
|
61
|
+
this.webex.logger.error(
|
|
62
|
+
CALL_DIAGNOSTIC_LOG_IDENTIFIER,
|
|
63
|
+
`CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request failed:`,
|
|
64
|
+
`error: ${generateCommonErrorMetadata(err)}`
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return Promise.reject(err);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default CallDiagnosticEventsBatcher;
|