@webex/internal-plugin-metrics 3.0.0-beta.27 → 3.0.0-beta.271
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/call-diagnostic/call-diagnostic-metrics-batcher.js +65 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-batcher.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +456 -0
- package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js +744 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js +310 -0
- package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -0
- package/dist/call-diagnostic/config.js +575 -0
- package/dist/call-diagnostic/config.js.map +1 -0
- package/dist/config.js +20 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics.js +30 -30
- 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 +333 -0
- package/dist/new-metrics.js.map +1 -0
- package/dist/types/batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-batcher.d.ts +2 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +194 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +392 -0
- package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +87 -0
- package/dist/types/call-diagnostic/config.d.ts +93 -0
- package/dist/types/client-metrics-batcher.d.ts +2 -0
- package/dist/types/config.d.ts +35 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/metrics.d.ts +3 -0
- package/dist/types/metrics.types.d.ts +99 -0
- package/dist/types/new-metrics.d.ts +139 -0
- package/dist/types/utils.d.ts +6 -0
- package/dist/utils.js +27 -0
- package/dist/utils.js.map +1 -0
- package/package.json +13 -8
- package/src/call-diagnostic/call-diagnostic-metrics-batcher.ts +82 -0
- package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +414 -0
- package/src/call-diagnostic/call-diagnostic-metrics.ts +808 -0
- package/src/call-diagnostic/call-diagnostic-metrics.util.ts +320 -0
- package/src/call-diagnostic/config.ts +632 -0
- package/src/config.js +19 -0
- package/src/index.ts +43 -0
- package/src/metrics.js +25 -27
- package/src/metrics.types.ts +155 -0
- package/src/new-metrics.ts +317 -0
- package/src/utils.ts +17 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +394 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +477 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +1607 -0
- package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +541 -0
- package/test/unit/spec/metrics.js +65 -97
- package/test/unit/spec/new-metrics.ts +269 -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/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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Event } from '../metrics.types';
|
|
2
|
+
export declare const anonymizeIPAddress: (localIp: any) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Returns a formated string of the user agent.
|
|
5
|
+
*
|
|
6
|
+
* @returns {string} formatted user agent information
|
|
7
|
+
*/
|
|
8
|
+
export declare const userAgentToString: ({ clientName, webexVersion }: {
|
|
9
|
+
clientName: any;
|
|
10
|
+
webexVersion: any;
|
|
11
|
+
}) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Iterates object recursively and removes any
|
|
14
|
+
* property that returns isEmpty for it's associated value
|
|
15
|
+
* isEmpty = implementation from Lodash.
|
|
16
|
+
*
|
|
17
|
+
* It modifies the object in place (mutable)
|
|
18
|
+
*
|
|
19
|
+
* @param obj - input
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare const clearEmptyKeysRecursively: (obj: any) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Locus error codes start with 2. The next three digits are the
|
|
25
|
+
* HTTP status code related to the error code (like 400, 403, 502, etc.)
|
|
26
|
+
* The remaining three digits are just an increasing integer.
|
|
27
|
+
* If it is 7 digits and starts with a 2, it is locus.
|
|
28
|
+
*
|
|
29
|
+
* @param errorCode
|
|
30
|
+
* @returns {boolean}
|
|
31
|
+
*/
|
|
32
|
+
export declare const isLocusServiceErrorCode: (errorCode: string | number) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* MeetingInfo errors sometimes has body.data.meetingInfo object
|
|
35
|
+
* MeetingInfo errors come with a wbxappapi url
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} rawError
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export declare const isMeetingInfoServiceError: (rawError: any) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if the raw error is a network related error
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} rawError
|
|
45
|
+
* @returns {boolean}
|
|
46
|
+
*/
|
|
47
|
+
export declare const isNetworkError: (rawError: any) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if the error is an unauthorized error
|
|
50
|
+
*
|
|
51
|
+
* @param {Object} rawError
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
export declare const isUnauthorizedError: (rawError: any) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* MDN Media Devices getUserMedia() method returns a name if it errs
|
|
57
|
+
* Documentation can be found here: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
|
|
58
|
+
*
|
|
59
|
+
* @param errorCode
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
export declare const isBrowserMediaErrorName: (errorName: any) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @param webClientDomain
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
export declare const getBuildType: (webClientDomain: any, markAsTestEvent?: boolean) => Event['origin']['buildType'];
|
|
68
|
+
/**
|
|
69
|
+
* Prepare metric item for submission.
|
|
70
|
+
* @param {Object} webex sdk instance
|
|
71
|
+
* @param {Object} item
|
|
72
|
+
* @returns {Object} prepared item
|
|
73
|
+
*/
|
|
74
|
+
export declare const prepareDiagnosticMetricItem: (webex: any, item: any) => any;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the originTime value(s) before the request/fetch.
|
|
77
|
+
* This function is only useful if you are about to submit a metrics
|
|
78
|
+
* request using pre-built fetch options;
|
|
79
|
+
*
|
|
80
|
+
* @param {any} options
|
|
81
|
+
* @returns {any} the updated options object
|
|
82
|
+
*/
|
|
83
|
+
export declare const setMetricTimings: (options: any) => any;
|
|
84
|
+
export declare const extractVersionMetadata: (version: string) => {
|
|
85
|
+
majorVersion: number;
|
|
86
|
+
minorVersion: number;
|
|
87
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ClientEventError } from '../metrics.types';
|
|
2
|
+
export declare const CALL_DIAGNOSTIC_LOG_IDENTIFIER = "call-diagnostic-events -> ";
|
|
3
|
+
export declare const AUTHENTICATION_FAILED_CODE = 1010;
|
|
4
|
+
export declare const NETWORK_ERROR = 1026;
|
|
5
|
+
export declare const NEW_LOCUS_ERROR_CLIENT_CODE = 4008;
|
|
6
|
+
export declare const MEETING_INFO_LOOKUP_ERROR_CLIENT_CODE = 4100;
|
|
7
|
+
export declare const UNKNOWN_ERROR = 9999;
|
|
8
|
+
export declare const ICE_FAILURE_CLIENT_CODE = 2004;
|
|
9
|
+
export declare const WBX_APP_API_URL = "wbxappapi";
|
|
10
|
+
export declare const BROWSER_MEDIA_ERROR_NAME_TO_CLIENT_ERROR_CODES_MAP: {
|
|
11
|
+
[x: string]: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP: {
|
|
14
|
+
58400: number;
|
|
15
|
+
99002: number;
|
|
16
|
+
99009: number;
|
|
17
|
+
58500: number;
|
|
18
|
+
400001: number;
|
|
19
|
+
403004: number;
|
|
20
|
+
403028: number;
|
|
21
|
+
403032: number;
|
|
22
|
+
403034: number;
|
|
23
|
+
403036: number;
|
|
24
|
+
403038: number;
|
|
25
|
+
403040: number;
|
|
26
|
+
403041: number;
|
|
27
|
+
403047: number;
|
|
28
|
+
403408: number;
|
|
29
|
+
403043: number;
|
|
30
|
+
403048: number;
|
|
31
|
+
403049: number;
|
|
32
|
+
403100: number;
|
|
33
|
+
403101: number;
|
|
34
|
+
403102: number;
|
|
35
|
+
403103: number;
|
|
36
|
+
403104: number;
|
|
37
|
+
404001: number;
|
|
38
|
+
404006: number;
|
|
39
|
+
423001: number;
|
|
40
|
+
423005: number;
|
|
41
|
+
423006: number;
|
|
42
|
+
423010: number;
|
|
43
|
+
423012: number;
|
|
44
|
+
423013: number;
|
|
45
|
+
429005: number;
|
|
46
|
+
2403001: number;
|
|
47
|
+
2403002: number;
|
|
48
|
+
2403003: number;
|
|
49
|
+
2403004: number;
|
|
50
|
+
2403018: number;
|
|
51
|
+
2403019: number;
|
|
52
|
+
2423003: number;
|
|
53
|
+
2423004: number;
|
|
54
|
+
2423005: number;
|
|
55
|
+
2423006: number;
|
|
56
|
+
2423016: number;
|
|
57
|
+
2423017: number;
|
|
58
|
+
2423018: number;
|
|
59
|
+
2423012: number;
|
|
60
|
+
2423021: number;
|
|
61
|
+
2423007: number;
|
|
62
|
+
2403010: number;
|
|
63
|
+
2403014: number;
|
|
64
|
+
2403015: number;
|
|
65
|
+
2423010: number;
|
|
66
|
+
2400008: number;
|
|
67
|
+
2400011: number;
|
|
68
|
+
2400012: number;
|
|
69
|
+
2403007: number;
|
|
70
|
+
2401002: number;
|
|
71
|
+
2404002: number;
|
|
72
|
+
2400009: number;
|
|
73
|
+
2400025: number;
|
|
74
|
+
2423009: number;
|
|
75
|
+
2403022: number;
|
|
76
|
+
2423008: number;
|
|
77
|
+
2400006: number;
|
|
78
|
+
2400014: number;
|
|
79
|
+
2404001: number;
|
|
80
|
+
2403025: number;
|
|
81
|
+
2405001: number;
|
|
82
|
+
2409005: number;
|
|
83
|
+
2409062: number;
|
|
84
|
+
2423025: number;
|
|
85
|
+
100002: number;
|
|
86
|
+
100007: number;
|
|
87
|
+
100001: number;
|
|
88
|
+
100006: number;
|
|
89
|
+
100005: number;
|
|
90
|
+
100004: number;
|
|
91
|
+
};
|
|
92
|
+
export declare const CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD: Record<number, Partial<ClientEventError>>;
|
|
93
|
+
export declare const CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND = "js_sdk_call_diagnostic_event_failed_to_send";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const CLIENT_NAME: "webex-js-sdk";
|
|
2
|
+
declare namespace _default {
|
|
3
|
+
export namespace device {
|
|
4
|
+
namespace preDiscoveryServices {
|
|
5
|
+
const metricsServiceUrl: string;
|
|
6
|
+
const metrics: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export namespace metrics_1 {
|
|
10
|
+
const appType: string;
|
|
11
|
+
const batcherWait: number;
|
|
12
|
+
const batcherMaxCalls: number;
|
|
13
|
+
const batcherMaxWait: number;
|
|
14
|
+
const batcherRetryPlateau: number;
|
|
15
|
+
}
|
|
16
|
+
export { metrics_1 as metrics };
|
|
17
|
+
}
|
|
18
|
+
export default _default;
|
|
19
|
+
export namespace OS_NAME {
|
|
20
|
+
const WINDOWS: string;
|
|
21
|
+
const MAC: string;
|
|
22
|
+
const IOS: string;
|
|
23
|
+
const ANDROID: string;
|
|
24
|
+
const CHROME: string;
|
|
25
|
+
const LINUX: string;
|
|
26
|
+
const OTHERS: string;
|
|
27
|
+
}
|
|
28
|
+
export const OSMap: {
|
|
29
|
+
'Chrome OS': string;
|
|
30
|
+
macOS: string;
|
|
31
|
+
Windows: string;
|
|
32
|
+
iOS: string;
|
|
33
|
+
Android: string;
|
|
34
|
+
Linux: string;
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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 } 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
|
+
export { default, getOSNameInternal } from './metrics';
|
|
12
|
+
export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils };
|
|
13
|
+
export type { ClientEvent, ClientEventLeaveReason, SubmitBehavioralEvent, SubmitClientEvent, SubmitInternalEvent, SubmitMQE, SubmitOperationalEvent, };
|
|
@@ -0,0 +1,99 @@
|
|
|
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 SubmitClientEventOptions = {
|
|
10
|
+
meetingId?: string;
|
|
11
|
+
mediaConnections?: any[];
|
|
12
|
+
rawError?: any;
|
|
13
|
+
correlationId?: string;
|
|
14
|
+
preLoginId?: string;
|
|
15
|
+
environment?: EnvironmentType;
|
|
16
|
+
newEnvironmentType?: NewEnvironmentType;
|
|
17
|
+
clientLaunchMethod?: ClientLaunchMethodType;
|
|
18
|
+
};
|
|
19
|
+
export type SubmitMQEOptions = {
|
|
20
|
+
meetingId: string;
|
|
21
|
+
mediaConnections?: any[];
|
|
22
|
+
networkType?: Event['origin']['networkType'];
|
|
23
|
+
};
|
|
24
|
+
export type InternalEvent = {
|
|
25
|
+
name: 'internal.client.meetinginfo.request' | 'internal.client.meetinginfo.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';
|
|
26
|
+
payload?: never;
|
|
27
|
+
options?: never;
|
|
28
|
+
};
|
|
29
|
+
export interface ClientEvent {
|
|
30
|
+
name: RawClientEvent['name'];
|
|
31
|
+
payload?: RawClientEvent;
|
|
32
|
+
options?: SubmitClientEventOptions;
|
|
33
|
+
}
|
|
34
|
+
export interface BehavioralEvent {
|
|
35
|
+
name: 'host.meeting.participant.admitted' | 'sdk.media-flow.started';
|
|
36
|
+
payload?: never;
|
|
37
|
+
options?: never;
|
|
38
|
+
}
|
|
39
|
+
export interface OperationalEvent {
|
|
40
|
+
name: never;
|
|
41
|
+
payload?: never;
|
|
42
|
+
options?: never;
|
|
43
|
+
}
|
|
44
|
+
export interface FeatureEvent {
|
|
45
|
+
name: never;
|
|
46
|
+
payload?: never;
|
|
47
|
+
options?: never;
|
|
48
|
+
}
|
|
49
|
+
export interface MediaQualityEvent {
|
|
50
|
+
name: RawMediaQualityEvent['name'];
|
|
51
|
+
payload?: RawMediaQualityEvent;
|
|
52
|
+
options: SubmitMQEOptions;
|
|
53
|
+
}
|
|
54
|
+
export type RecursivePartial<T> = {
|
|
55
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
56
|
+
};
|
|
57
|
+
export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['name'] | OperationalEvent['name'] | FeatureEvent['name'] | MediaQualityEvent['name'];
|
|
58
|
+
export type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;
|
|
59
|
+
export type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];
|
|
60
|
+
export type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];
|
|
61
|
+
export type NetworkType = NonNullable<RawEvent['origin']>['networkType'];
|
|
62
|
+
export type ClientEventPayload = RecursivePartial<ClientEvent['payload']>;
|
|
63
|
+
export type ClientEventLeaveReason = ClientEvent['payload']['leaveReason'];
|
|
64
|
+
export type ClientEventPayloadError = ClientEvent['payload']['errors'];
|
|
65
|
+
export type MediaQualityEventAudioSetupDelayPayload = NonNullable<MediaQualityEvent['payload']>['audioSetupDelay'];
|
|
66
|
+
export type MediaQualityEventVideoSetupDelayPayload = NonNullable<MediaQualityEvent['payload']>['videoSetupDelay'];
|
|
67
|
+
export type SubmitMQEPayload = RecursivePartial<MediaQualityEvent['payload']> & {
|
|
68
|
+
intervals: NonNullable<MediaQualityEvent['payload']>['intervals'];
|
|
69
|
+
};
|
|
70
|
+
export type SubmitInternalEvent = (args: {
|
|
71
|
+
name: InternalEvent['name'];
|
|
72
|
+
payload?: RecursivePartial<InternalEvent['payload']>;
|
|
73
|
+
options?: any;
|
|
74
|
+
}) => void;
|
|
75
|
+
export type SubmitBehavioralEvent = (args: {
|
|
76
|
+
name: BehavioralEvent['name'];
|
|
77
|
+
payload?: RecursivePartial<BehavioralEvent['payload']>;
|
|
78
|
+
options?: any;
|
|
79
|
+
}) => void;
|
|
80
|
+
export type SubmitClientEvent = (args: {
|
|
81
|
+
name: ClientEvent['name'];
|
|
82
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
83
|
+
options?: SubmitClientEventOptions;
|
|
84
|
+
}) => Promise<any>;
|
|
85
|
+
export type SubmitOperationalEvent = (args: {
|
|
86
|
+
name: OperationalEvent['name'];
|
|
87
|
+
payload?: RecursivePartial<OperationalEvent['payload']>;
|
|
88
|
+
options?: any;
|
|
89
|
+
}) => void;
|
|
90
|
+
export type SubmitMQE = (args: {
|
|
91
|
+
name: MediaQualityEvent['name'];
|
|
92
|
+
payload: SubmitMQEPayload;
|
|
93
|
+
options: any;
|
|
94
|
+
}) => void;
|
|
95
|
+
export type BuildClientEventFetchRequestOptions = (args: {
|
|
96
|
+
name: ClientEvent['name'];
|
|
97
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
98
|
+
options?: SubmitClientEventOptions;
|
|
99
|
+
}) => Promise<any>;
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
* Submit a pre-login metric to clientmetrics
|
|
84
|
+
* @public
|
|
85
|
+
* @param payload
|
|
86
|
+
* @param preLoginId - pre-login ID of user
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
postPreLoginMetric(payload: any, preLoginId: string): Promise<any>;
|
|
90
|
+
/**
|
|
91
|
+
* Issue request to alias a user's pre-login ID with their CI UUID
|
|
92
|
+
* @param {string} preLoginId
|
|
93
|
+
* @returns {Object} HttpResponse object
|
|
94
|
+
*/
|
|
95
|
+
clientMetricsAliasUser(preLoginId: string): any;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a promise that will resolve to fetch options for submitting a metric.
|
|
98
|
+
*
|
|
99
|
+
* This is to support quickly submitting metrics when the browser/tab is closing.
|
|
100
|
+
* Calling submitClientEvent will not work because there some async steps that will
|
|
101
|
+
* not complete before the browser is closed. Instead, we pre-gather all the
|
|
102
|
+
* information/options needed for the request(s), and then simply and quickly
|
|
103
|
+
* fire the fetch(es) when beforeUnload is triggered.
|
|
104
|
+
*
|
|
105
|
+
* We must use fetch instead of request because fetch has a keepalive option that
|
|
106
|
+
* allows the request it to outlive the page.
|
|
107
|
+
*
|
|
108
|
+
* Note: the timings values will be wrong, but setMetricTimingsAndFetch() will
|
|
109
|
+
* properly adjust them before submitting.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
* @param {Object} arg
|
|
113
|
+
* @param {String} arg.name - event name
|
|
114
|
+
* @param {Object} arg.payload - event payload
|
|
115
|
+
* @param {Object} arg.options - other options
|
|
116
|
+
* @returns {Promise} promise that resolves to options to be used with fetch
|
|
117
|
+
*/
|
|
118
|
+
buildClientEventFetchRequestOptions({ name, payload, options, }: {
|
|
119
|
+
name: ClientEvent['name'];
|
|
120
|
+
payload?: RecursivePartial<ClientEvent['payload']>;
|
|
121
|
+
options?: SubmitClientEventOptions;
|
|
122
|
+
}): Promise<any>;
|
|
123
|
+
/**
|
|
124
|
+
* Submits a metric from pre-built request options via the fetch API. Updates
|
|
125
|
+
* the "$timings" and "originTime" values to Date.now() since the existing times
|
|
126
|
+
* were set when the options were built (not submitted).
|
|
127
|
+
|
|
128
|
+
* @param {any} options - the pre-built request options for submitting a metric
|
|
129
|
+
* @returns {Promise} promise that resolves to the response object
|
|
130
|
+
*/
|
|
131
|
+
setMetricTimingsAndFetch(options: any): Promise<any>;
|
|
132
|
+
/**
|
|
133
|
+
* Returns true if the specified serviceErrorCode maps to an expected error.
|
|
134
|
+
* @param {number} serviceErrorCode the service error code
|
|
135
|
+
* @returns {boolean}
|
|
136
|
+
*/
|
|
137
|
+
isServiceErrorExpected(serviceErrorCode: number): boolean;
|
|
138
|
+
}
|
|
139
|
+
export default Metrics;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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 = 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
|
+
exports.generateCommonErrorMetadata = generateCommonErrorMetadata;
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["generateCommonErrorMetadata","error","Error","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,GAAG,SAA9BA,2BAA2B,CAAIC,KAAK,EAAK;EACpD,IAAIA,KAAK,YAAYC,KAAK,EAAE;IAC1B,OAAO,wBAAe;MACpBC,OAAO,EAAEF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,OAAO;MACvBC,IAAI,EAAEH,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEG,IAAI;MACjBC,KAAK,EAAEJ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEI;IAChB,CAAC,CAAC;EACJ;EAEA,OAAOJ,KAAK;AACd,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-metrics",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.271",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"devMain": "src/index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "https://github.com/webex/webex-js-sdk.git",
|
|
@@ -23,13 +24,17 @@
|
|
|
23
24
|
"@sinonjs/fake-timers": "^6.0.1",
|
|
24
25
|
"sinon": "^9.2.4"
|
|
25
26
|
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "yarn run -T tsc --declaration true --declarationDir ./dist/types"
|
|
29
|
+
},
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@webex/common": "3.0.0-beta.
|
|
28
|
-
"@webex/common-timers": "3.0.0-beta.
|
|
29
|
-
"@webex/
|
|
30
|
-
"@webex/internal-plugin-
|
|
31
|
-
"@webex/
|
|
32
|
-
"@webex/test-helper-
|
|
33
|
-
"@webex/webex
|
|
31
|
+
"@webex/common": "3.0.0-beta.271",
|
|
32
|
+
"@webex/common-timers": "3.0.0-beta.271",
|
|
33
|
+
"@webex/event-dictionary-ts": "^1.0.1290",
|
|
34
|
+
"@webex/internal-plugin-device": "3.0.0-beta.271",
|
|
35
|
+
"@webex/internal-plugin-metrics": "3.0.0-beta.271",
|
|
36
|
+
"@webex/test-helper-chai": "3.0.0-beta.271",
|
|
37
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.271",
|
|
38
|
+
"@webex/webex-core": "3.0.0-beta.271"
|
|
34
39
|
}
|
|
35
40
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
/* eslint-disable valid-jsdoc */
|
|
3
|
+
|
|
4
|
+
import {uniqueId} from 'lodash';
|
|
5
|
+
import Batcher from '../batcher';
|
|
6
|
+
import {prepareDiagnosticMetricItem} from './call-diagnostic-metrics.util';
|
|
7
|
+
import {CALL_DIAGNOSTIC_LOG_IDENTIFIER} from './config';
|
|
8
|
+
import {generateCommonErrorMetadata} from '../utils';
|
|
9
|
+
|
|
10
|
+
const CallDiagnosticEventsBatcher = Batcher.extend({
|
|
11
|
+
namespace: 'Metrics',
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Prepare item
|
|
15
|
+
* @param item
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
prepareItem(item) {
|
|
19
|
+
return Promise.resolve(prepareDiagnosticMetricItem(this.webex, item));
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Prepare request, add time sensitive date etc.
|
|
24
|
+
* @param queue
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
prepareRequest(queue) {
|
|
28
|
+
// Add sent timestamp
|
|
29
|
+
queue.forEach((item) => {
|
|
30
|
+
item.eventPayload.originTime = item.eventPayload.originTime || {};
|
|
31
|
+
item.eventPayload.originTime.sent = new Date().toISOString();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return Promise.resolve(queue);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param payload
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
submitHttpRequest(payload) {
|
|
43
|
+
const batchId = uniqueId('call-diagnostic-metrics-batch-');
|
|
44
|
+
this.webex.logger.log(
|
|
45
|
+
CALL_DIAGNOSTIC_LOG_IDENTIFIER,
|
|
46
|
+
`CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Sending the request:`,
|
|
47
|
+
'payload:',
|
|
48
|
+
payload
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return this.webex
|
|
52
|
+
.request({
|
|
53
|
+
method: 'POST',
|
|
54
|
+
service: 'metrics',
|
|
55
|
+
resource: 'clientmetrics',
|
|
56
|
+
body: {
|
|
57
|
+
metrics: payload,
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
.then((res) => {
|
|
61
|
+
this.webex.logger.log(
|
|
62
|
+
CALL_DIAGNOSTIC_LOG_IDENTIFIER,
|
|
63
|
+
`CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request successful:`,
|
|
64
|
+
`response:`,
|
|
65
|
+
res
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return res;
|
|
69
|
+
})
|
|
70
|
+
.catch((err) => {
|
|
71
|
+
this.webex.logger.error(
|
|
72
|
+
CALL_DIAGNOSTIC_LOG_IDENTIFIER,
|
|
73
|
+
`CallDiagnosticEventsBatcher: @submitHttpRequest#${batchId}. Request failed:`,
|
|
74
|
+
`error: ${generateCommonErrorMetadata(err)}`
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return Promise.reject(err);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export default CallDiagnosticEventsBatcher;
|