@webex/internal-plugin-metrics 3.4.0 → 3.5.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.
Files changed (69) hide show
  1. package/dist/behavioral-metrics.js +63 -0
  2. package/dist/behavioral-metrics.js.map +1 -0
  3. package/dist/business-metrics.js +169 -0
  4. package/dist/business-metrics.js.map +1 -0
  5. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +1 -1
  6. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
  7. package/dist/call-diagnostic/call-diagnostic-metrics.js +27 -11
  8. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
  9. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +14 -4
  10. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
  11. package/dist/call-diagnostic/config.js +13 -3
  12. package/dist/call-diagnostic/config.js.map +1 -1
  13. package/dist/{behavioral/behavioral-metrics.js → generic-metrics.js} +77 -92
  14. package/dist/generic-metrics.js.map +1 -0
  15. package/dist/index.js +22 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/metrics.js +1 -1
  18. package/dist/metrics.types.js.map +1 -1
  19. package/dist/new-metrics.js +124 -24
  20. package/dist/new-metrics.js.map +1 -1
  21. package/dist/operational-metrics.js +56 -0
  22. package/dist/operational-metrics.js.map +1 -0
  23. package/dist/rtcMetrics/constants.js +11 -0
  24. package/dist/rtcMetrics/constants.js.map +1 -0
  25. package/dist/rtcMetrics/index.js +202 -0
  26. package/dist/rtcMetrics/index.js.map +1 -0
  27. package/dist/types/behavioral-metrics.d.ts +25 -0
  28. package/dist/types/business-metrics.d.ts +47 -0
  29. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +27 -6
  30. package/dist/types/call-diagnostic/call-diagnostic-metrics.util.d.ts +2 -1
  31. package/dist/types/call-diagnostic/config.d.ts +3 -0
  32. package/dist/types/generic-metrics.d.ts +63 -0
  33. package/dist/types/index.d.ts +5 -2
  34. package/dist/types/metrics.types.d.ts +27 -14
  35. package/dist/types/new-metrics.d.ts +42 -9
  36. package/dist/types/operational-metrics.d.ts +19 -0
  37. package/dist/types/rtcMetrics/constants.d.ts +4 -0
  38. package/dist/types/rtcMetrics/index.d.ts +71 -0
  39. package/package.json +12 -12
  40. package/src/behavioral-metrics.ts +40 -0
  41. package/src/business-metrics.ts +118 -0
  42. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
  43. package/src/call-diagnostic/call-diagnostic-metrics.ts +30 -9
  44. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +17 -4
  45. package/src/call-diagnostic/config.ts +12 -0
  46. package/src/generic-metrics.ts +146 -0
  47. package/src/index.ts +7 -1
  48. package/src/metrics.types.ts +32 -16
  49. package/src/new-metrics.ts +100 -13
  50. package/src/operational-metrics.ts +24 -0
  51. package/src/rtcMetrics/constants.ts +3 -0
  52. package/src/rtcMetrics/index.ts +186 -0
  53. package/test/unit/spec/behavioral/behavioral-metrics.ts +51 -10
  54. package/test/unit/spec/business/business-metrics.ts +182 -0
  55. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +2 -1
  56. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +4 -6
  57. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +418 -12
  58. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +22 -8
  59. package/test/unit/spec/new-metrics.ts +32 -3
  60. package/test/unit/spec/operational/operational-metrics.ts +115 -0
  61. package/test/unit/spec/prelogin-metrics-batcher.ts +3 -1
  62. package/test/unit/spec/rtcMetrics/index.ts +155 -0
  63. package/dist/behavioral/behavioral-metrics.js.map +0 -1
  64. package/dist/behavioral/config.js +0 -11
  65. package/dist/behavioral/config.js.map +0 -1
  66. package/dist/types/behavioral/behavioral-metrics.d.ts +0 -63
  67. package/dist/types/behavioral/config.d.ts +0 -1
  68. package/src/behavioral/behavioral-metrics.ts +0 -179
  69. package/src/behavioral/config.ts +0 -3
@@ -0,0 +1,25 @@
1
+ import { MetricEventProduct, MetricEventAgent, MetricEventVerb, EventPayload } from './metrics.types';
2
+ import GenericMetrics from './generic-metrics';
3
+ /**
4
+ * @description Util class to handle Behavioral Metrics
5
+ * @export
6
+ * @class BehavioralMetrics
7
+ */
8
+ export default class BehavioralMetrics extends GenericMetrics {
9
+ /**
10
+ * Submit a behavioral metric to our metrics endpoint.
11
+ * @param {MetricEventProduct} product the product from which the metric is being submitted, e.g. 'webex' web client, 'wxcc_desktop'
12
+ * @param {MetricEventAgent} agent the source of the action for this metric
13
+ * @param {string} target the 'thing' that this metric includes information about
14
+ * @param {MetricEventVerb} verb the action that this metric includes information about
15
+ * @param {EventPayload} payload information specific to this event. This should be flat, i.e. it should not include nested objects.
16
+ * @returns {Promise<any>}
17
+ */
18
+ submitBehavioralEvent({ product, agent, target, verb, payload, }: {
19
+ product: MetricEventProduct;
20
+ agent: MetricEventAgent;
21
+ target: string;
22
+ verb: MetricEventVerb;
23
+ payload?: EventPayload;
24
+ }): void;
25
+ }
@@ -0,0 +1,47 @@
1
+ import GenericMetrics from './generic-metrics';
2
+ import { EventPayload, Table } from './metrics.types';
3
+ /**
4
+ * @description Util class to handle Buisness Metrics
5
+ * @export
6
+ * @class BusinessMetrics
7
+ */
8
+ export default class BusinessMetrics extends GenericMetrics {
9
+ /**
10
+ * unfortunately, the pinot team does not allow changes to the schema of wbxapp_callend_metrics
11
+ * so we have to shim this layer specifically for this
12
+ * @param {EventPayload} payload payload of the metric
13
+ * @returns {Promise<any>}
14
+ */
15
+ private submitCallEndEvent;
16
+ /**
17
+ * Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
18
+ * all event payload keys are converted into a hex string value
19
+ * unfortunately, the pinot team does not allow changes to the schema of business_metrics
20
+ * so we have to shim this layer specifically for this
21
+ * @param {string} name of the metric
22
+ * @param {EventPayload} payload payload of the metric
23
+ * @returns {Promise<any>}
24
+ */
25
+ private submitBusinessMetricsEvent;
26
+ /**
27
+ * Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
28
+ * all event payload keys are converted into a hex string value
29
+ * @param {string} name of the metric
30
+ * @param {EventPayload} user payload of the metric
31
+ * @returns {Promise<any>}
32
+ */
33
+ private submitDefaultEvent;
34
+ /**
35
+ * Submit a buisness metric to our metrics endpoint.
36
+ * routes to the correct table with the correct schema payload by table
37
+ * @param {string} name of the metric, ignored if going to wbxapp_callend_metrics
38
+ * @param {EventPayload} payload user payload of the metric
39
+ * @param {Table} table optional - to submit the metric to and adapt the sent schema
40
+ * @returns {Promise<any>}
41
+ */
42
+ submitBusinessEvent({ name, payload, table, }: {
43
+ name: string;
44
+ payload: EventPayload;
45
+ table?: Table;
46
+ }): Promise<void>;
47
+ }
@@ -13,6 +13,7 @@ type GetIdentifiersOptions = {
13
13
  meeting?: any;
14
14
  mediaConnections?: any[];
15
15
  correlationId?: string;
16
+ sessionCorrelationId?: string;
16
17
  preLoginId?: string;
17
18
  globalMeetingId?: string;
18
19
  webexConferenceIdStr?: string;
@@ -65,7 +66,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
65
66
  * @returns
66
67
  */
67
68
  getOrigin(options: GetOriginOptions, meetingId?: string): {
68
- name: "endpoint" | "antares" | "beech" | "breakout" | "cb" | "cloudproxy" | "edonus" | "givr" | "hecate" | "hedge" | "hesiod" | "homer" | "superhomer" | "l2sip" | "linus" | "locus" | "mcc" | "mcs" | "mercury" | "mes" | "mjs" | "mmp" | "mygdon" | "orpheus" | "page" | "poros" | "rhesos" | "terminus" | "tpgw" | "ucc" | "wdm" | "webexivr";
69
+ name: "endpoint" | "addin" | "antares" | "appapi" | "beech" | "breakout" | "calendar" | "cb" | "cca" | "ccc" | "cloudproxy" | "edonus" | "givr" | "hecate" | "hedge" | "hesiod" | "homer" | "superhomer" | "l2sip" | "linus" | "locus" | "mbs" | "mcc" | "mcs" | "mercury" | "mes" | "mjs" | "mmp" | "mygdon" | "ngservice" | "orpheus" | "page" | "poros" | "publicapi" | "rhesos" | "terminus" | "tpgw" | "ucc" | "wdm" | "webexivr";
69
70
  userAgent: string;
70
71
  buildType?: "debug" | "test" | "prod" | "tap" | "analyzer-test";
71
72
  upgradeChannel?: string;
@@ -77,7 +78,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
77
78
  environment?: string;
78
79
  newEnvironment?: string;
79
80
  clientInfo?: {
80
- os?: "other" | "chrome" | "windows" | "mac" | "ios" | "android" | "linux" | "android-x64" | "android-arm64" | "uwp-arm64";
81
+ os?: "windows" | "mac" | "ios" | "android" | "chrome" | "linux" | "other" | "android-x64" | "android-arm64" | "uwp-arm64";
81
82
  osVersion?: string;
82
83
  localIP?: string;
83
84
  gatewayIP?: string;
@@ -89,7 +90,8 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
89
90
  browser?: string;
90
91
  browserVersion?: string;
91
92
  clientType?: "MEETING_CENTER" | "EVENT_CENTER" | "TRAINING_CENTER" | "TEAMS_CLIENT" | "TEAMS_DEVICE" | "TEAMS_SHARE" | "SIP" | "RECORDING" | "CLOUD_AWARE_SIP" | "TEAMS_WXC_CLIENT" | "WXC_CLIENT" | "WXC_DEVICE" | "WEBEX_JS_SDK" | "VOICEA_CLIENT" | "CISCO_SIP_GW" | "WEBEX_SDK" | "CPAAS_THIRD_PARTY_SDK" | "WXC_THIRD_PARTY" | "WXCC";
92
- subClientType?: "TEAMS_DEVICE" | "DESKTOP_APP" | "DESKTOP_APP_VDI" | "DEVICE_CURRENT" | "DEVICE_LEGACY_2020" | "HOLOGRAM_HEADSET_APP" | "HVDI_APP" | "MIXED" | "MOBILE_APP" | "MOBILE_NETWORK" | "PAGE" | "VDI_APP" | "WEB_APP";
93
+ subClientType?: "TEAMS_DEVICE" | "AUTOMOTIVE_APP" | "DESKTOP_APP" | "DESKTOP_APP_VDI" | "DEVICE_CURRENT" | "DEVICE_LEGACY_2020" | "HOLOGRAM_HEADSET_APP" | "HVDI_APP" | "MIXED" | "MOBILE_APP" | "MOBILE_NETWORK" | "PAGE" | "VDI_APP" | "WEB_APP";
94
+ schedulingClientType?: "TEAMS_CLIENT" | "GOOGLE_ADDON" | "PT" | "PUBLIC_API" | "UNIFIED_PAGE" | "WEBEX_PAGE" | "GOOGLE_NOTIFICATION_CALENDAR" | "MSFT_NOTIFICATION_ADDIN" | "MSFT_NOTIFICATION_CALENDAR" | "OUTLOOK_ADDIN";
93
95
  clientVersion?: string;
94
96
  clientVersionStatus?: "CURRENT" | "LEGACY" | "UNSUPPORTED";
95
97
  localClientVersion?: string;
@@ -113,10 +115,15 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
113
115
  isValidClientVersion?: boolean;
114
116
  cpuInfo?: {
115
117
  description: string;
116
- clockSpeedGigaHertz: number;
117
118
  numberOfCores: number;
118
- architecture: "unknown" | "intel32" | "intel64" | "amd32" | "amd64" | "arm32" | "arm64";
119
+ architecture: "unknown" | "intel32" | "intel64" | "amd32" | "amd64" | "arm32" | "arm64"; /**
120
+ * Get origin object for Call Diagnostic Event payload.
121
+ * @param options
122
+ * @param meetingId
123
+ * @returns
124
+ */
119
125
  staticPerformance?: string;
126
+ clockSpeedGigaHertz?: number;
120
127
  additionalProperties?: false;
121
128
  };
122
129
  shareType?: "cb-normal-share" | "ce-airplay-share" | "ce-direct-share" | "ce-gui-loopback-share" | "ce-input-source-share" | "ce-input-source-share-hdmi" | "ce-input-source-share-usbc" | "ce-jpg-share" | "ce-miracast-share" | "mcs-normal-share" | "mcs-normal-audio-share" | "mcs-hfps-share" | "mcs-hfps-audio-share";
@@ -147,6 +154,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
147
154
  breakoutGroupId?: string;
148
155
  breakoutMoveId?: string;
149
156
  breakoutSessionId?: string;
157
+ ciExchangeTokenUrl?: string;
150
158
  confluenceId?: string;
151
159
  cpaasIdentifiers?: {
152
160
  imiTenantId: string;
@@ -164,11 +172,14 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
164
172
  destinationVenueId?: string;
165
173
  deviceId?: string;
166
174
  globalMeetingId?: string;
175
+ installationId?: string;
176
+ webexMeetingUUID?: string;
167
177
  ivrCallId?: string;
168
178
  ivrDialogId?: string;
169
179
  ivrId?: string;
170
180
  callId?: string;
171
181
  locusId?: string;
182
+ locusJoinUrl?: string;
172
183
  locusSessionId?: string;
173
184
  locusStartTime?: string;
174
185
  locusUrl?: string;
@@ -179,6 +190,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
179
190
  meetingInstanceId?: string;
180
191
  meetingLookupUrl?: string;
181
192
  meetingOrgId?: string;
193
+ metricServiceUrl?: string;
182
194
  msteamsTenantGuid?: string;
183
195
  msteamsConferenceId?: string;
184
196
  msteamsMeetingId?: string;
@@ -186,6 +198,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
186
198
  orgId?: string;
187
199
  provisionalCorrelationId?: string;
188
200
  roomId?: string;
201
+ sessionCorrelationId?: string;
189
202
  sipCallId?: string;
190
203
  sipSessionId?: {
191
204
  local?: string;
@@ -200,6 +213,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
200
213
  venueId?: string;
201
214
  venueUrl?: string;
202
215
  whiteboardUrl?: string;
216
+ wdmDeviceRegistrationUrl?: string;
203
217
  webexConferenceId?: number;
204
218
  webexClusterName?: string;
205
219
  webexConferenceIdStr?: string;
@@ -219,6 +233,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
219
233
  breakoutGroupId?: string;
220
234
  breakoutMoveId?: string;
221
235
  breakoutSessionId?: string;
236
+ ciExchangeTokenUrl?: string;
222
237
  confluenceId?: string;
223
238
  cpaasIdentifiers?: {
224
239
  imiTenantId: string;
@@ -236,11 +251,14 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
236
251
  destinationVenueId?: string;
237
252
  deviceId?: string;
238
253
  globalMeetingId?: string;
254
+ installationId?: string;
255
+ webexMeetingUUID?: string;
239
256
  ivrCallId?: string;
240
257
  ivrDialogId?: string;
241
258
  ivrId?: string;
242
259
  callId?: string;
243
260
  locusId?: string;
261
+ locusJoinUrl?: string;
244
262
  locusSessionId?: string;
245
263
  locusStartTime?: string;
246
264
  locusUrl?: string;
@@ -251,6 +269,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
251
269
  meetingInstanceId?: string;
252
270
  meetingLookupUrl?: string;
253
271
  meetingOrgId?: string;
272
+ metricServiceUrl?: string;
254
273
  msteamsTenantGuid?: string;
255
274
  msteamsConferenceId?: string;
256
275
  msteamsMeetingId?: string;
@@ -258,6 +277,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
258
277
  orgId?: string;
259
278
  provisionalCorrelationId?: string;
260
279
  roomId?: string;
280
+ sessionCorrelationId?: string;
261
281
  sipCallId?: string;
262
282
  sipSessionId?: {
263
283
  local?: string;
@@ -272,6 +292,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
272
292
  venueId?: string;
273
293
  venueUrl?: string;
274
294
  whiteboardUrl?: string;
295
+ wdmDeviceRegistrationUrl?: string;
275
296
  webexConferenceId?: number;
276
297
  webexClusterName?: string;
277
298
  webexConferenceIdStr?: string;
@@ -336,7 +357,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
336
357
  */
337
358
  generateClientEventErrorPayload(rawError: any): {
338
359
  fatal: boolean;
339
- category: "signaling" | "media" | "network" | "other" | "expected";
360
+ category: "other" | "signaling" | "media" | "network" | "expected";
340
361
  errorDescription?: string;
341
362
  errorCode?: number;
342
363
  errorCodeStr?: string;
@@ -68,10 +68,11 @@ export declare const isSdpOfferCreationError: (rawError: any) => boolean;
68
68
  */
69
69
  export declare const isBrowserMediaErrorName: (errorName: any) => boolean;
70
70
  /**
71
+ * @param {Object} webex sdk instance
71
72
  * @param webClientDomain
72
73
  * @returns
73
74
  */
74
- export declare const getBuildType: (webClientDomain: any, markAsTestEvent?: boolean) => Event['origin']['buildType'];
75
+ export declare const getBuildType: (webex: any, webClientDomain: any, markAsTestEvent?: boolean) => Event['origin']['buildType'];
75
76
  /**
76
77
  * Prepare metric item for submission.
77
78
  * @param {Object} webex sdk instance
@@ -96,6 +96,7 @@ export declare const ERROR_DESCRIPTIONS: {
96
96
  ICE_AND_REACHABILITY_FAILED: string;
97
97
  SDP_OFFER_CREATION_ERROR: string;
98
98
  SDP_OFFER_CREATION_ERROR_MISSING_CODEC: string;
99
+ WDM_RESTRICTED_REGION: string;
99
100
  };
100
101
  export declare const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP: {
101
102
  58400: number;
@@ -175,6 +176,8 @@ export declare const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP: {
175
176
  100006: number;
176
177
  100005: number;
177
178
  100004: number;
179
+ 4404002: number;
180
+ 4404003: number;
178
181
  };
179
182
  export declare const CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD: Record<number, Partial<ClientEventError>>;
180
183
  export declare const CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND = "js_sdk_call_diagnostic_event_failed_to_send";
@@ -0,0 +1,63 @@
1
+ import { StatelessWebexPlugin } from '@webex/webex-core';
2
+ import { DeviceContext, TaggedEvent, EventPayload, MetricType } from './metrics.types';
3
+ /**
4
+ * @description top-level abstract class to handle Metrics and common routines.
5
+ * @export
6
+ * @class GenericMetrics
7
+ */
8
+ export default abstract class GenericMetrics extends StatelessWebexPlugin {
9
+ private clientMetricsBatcher;
10
+ private logger;
11
+ private device;
12
+ private version;
13
+ private deviceId;
14
+ /**
15
+ * Constructor
16
+ * @param {any[]} args
17
+ */
18
+ constructor(...args: any[]);
19
+ /**
20
+ * Submit a buisness metric to our metrics endpoint.
21
+ * @param {string} kind of metric for logging
22
+ * @param {string} name of the metric
23
+ * @param {object} event
24
+ * @returns {Promise<any>}
25
+ */
26
+ protected submitEvent({ kind, name, event }: {
27
+ kind: string;
28
+ name: string;
29
+ event: object;
30
+ }): any;
31
+ /**
32
+ * Returns the deviceId from our registration with WDM.
33
+ * @returns {string} deviceId or empty string
34
+ */
35
+ protected getDeviceId(): string;
36
+ /**
37
+ * Returns the context object to be submitted with all metrics.
38
+ * @returns {DeviceContext}
39
+ */
40
+ protected getContext(): DeviceContext;
41
+ /**
42
+ * Returns the browser details to be included with all metrics.
43
+ * @returns {object}
44
+ */
45
+ protected getBrowserDetails(): object;
46
+ /**
47
+ * Returns true once we have the deviceId we need to submit behavioral/operational/buisness events
48
+ * @returns {boolean}
49
+ */
50
+ isReadyToSubmitEvents(): boolean;
51
+ /**
52
+ * Creates the object to send to our metrics endpoint for a tagged event (i.e. behavoral or operational)
53
+ * @param {[MetricType]} list of event type (i.e. ['behavioral'], ['operational', 'behavioral'])
54
+ * @param {string} metric name
55
+ * @param {EventPayload} user payload
56
+ * @returns {EventPayload}
57
+ */
58
+ protected createTaggedEventObject({ type, name, payload, }: {
59
+ type: [MetricType];
60
+ name: string;
61
+ payload: EventPayload;
62
+ }): TaggedEvent;
63
+ }
@@ -9,7 +9,10 @@ import * as CALL_DIAGNOSTIC_CONFIG from './call-diagnostic/config';
9
9
  import * as CallDiagnosticUtils from './call-diagnostic/call-diagnostic-metrics.util';
10
10
  import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
11
11
  import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
12
- import BehavioralMetrics from './behavioral/behavioral-metrics';
12
+ import BehavioralMetrics from './behavioral-metrics';
13
+ import OperationalMetrics from './operational-metrics';
14
+ import BusinessMetrics from './business-metrics';
15
+ import RtcMetrics from './rtcMetrics';
13
16
  export { default, getOSNameInternal } from './metrics';
14
- export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, BehavioralMetrics, };
17
+ export { config, CALL_DIAGNOSTIC_CONFIG, NewMetrics, Utils, CallDiagnosticUtils, CallDiagnosticLatencies, CallDiagnosticMetrics, BehavioralMetrics, OperationalMetrics, BusinessMetrics, RtcMetrics, };
15
18
  export type { ClientEvent, ClientEventLeaveReason, SubmitBehavioralEvent, SubmitClientEvent, SubmitInternalEvent, SubmitMQE, SubmitOperationalEvent, PreComputedLatencies, };
@@ -15,6 +15,7 @@ export type SubmitClientEventOptions = {
15
15
  mediaConnections?: any[];
16
16
  rawError?: any;
17
17
  correlationId?: string;
18
+ sessionCorrelationId?: string;
18
19
  preLoginId?: string;
19
20
  environment?: EnvironmentType;
20
21
  newEnvironmentType?: NewEnvironmentType;
@@ -40,7 +41,7 @@ export interface ClientEvent {
40
41
  payload?: RawClientEvent;
41
42
  options?: SubmitClientEventOptions;
42
43
  }
43
- export interface BehavioralEventContext {
44
+ export interface DeviceContext {
44
45
  app: {
45
46
  version: string;
46
47
  };
@@ -53,19 +54,31 @@ export interface BehavioralEventContext {
53
54
  version: string;
54
55
  };
55
56
  }
56
- export interface BehavioralEvent {
57
- context: BehavioralEventContext;
57
+ export type MetricType = 'behavioral' | 'operational' | 'business';
58
+ export type Table = 'wbxapp_callend_metrics' | 'business_metrics' | 'business_ucf' | 'default';
59
+ type InternalEventPayload = string | number | boolean;
60
+ export type EventPayload = Record<string, InternalEventPayload>;
61
+ export type BehavioralEventPayload = EventPayload;
62
+ export interface BusinessEventPayload {
58
63
  metricName: string;
59
- tags: Record<string, string | number | boolean>;
60
64
  timestamp: number;
65
+ context: DeviceContext;
66
+ browserDetails: EventPayload;
67
+ value: EventPayload;
68
+ }
69
+ export interface BusinessEvent {
61
70
  type: string[];
71
+ eventPayload: BusinessEventPayload;
62
72
  }
63
- export type BehavioralEventPayload = BehavioralEvent['tags'];
64
- export interface OperationalEvent {
65
- name: never;
66
- payload?: never;
67
- options?: never;
73
+ export interface TaggedEvent {
74
+ context: DeviceContext;
75
+ metricName: string;
76
+ tags: EventPayload;
77
+ timestamp: number;
78
+ type: [MetricType];
68
79
  }
80
+ export type BehavioralEvent = TaggedEvent;
81
+ export type OperationalEvent = TaggedEvent;
69
82
  export interface FeatureEvent {
70
83
  name: never;
71
84
  payload?: never;
@@ -79,7 +92,7 @@ export interface MediaQualityEvent {
79
92
  export type RecursivePartial<T> = {
80
93
  [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
81
94
  };
82
- export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['metricName'] | OperationalEvent['name'] | FeatureEvent['name'] | MediaQualityEvent['name'];
95
+ export type MetricEventNames = InternalEvent['name'] | ClientEvent['name'] | BehavioralEvent['metricName'] | OperationalEvent['metricName'] | BusinessEvent['eventPayload']['metricName'] | FeatureEvent['name'] | MediaQualityEvent['name'];
83
96
  export type ClientInfo = NonNullable<RawEvent['origin']['clientInfo']>;
84
97
  export type ClientType = NonNullable<RawEvent['origin']['clientInfo']>['clientType'];
85
98
  export type SubClientType = NonNullable<RawEvent['origin']['clientInfo']>['subClientType'];
@@ -103,7 +116,7 @@ export type SubmitBehavioralEvent = (args: {
103
116
  agent: MetricEventAgent;
104
117
  target: string;
105
118
  verb: MetricEventVerb;
106
- payload?: BehavioralEventPayload;
119
+ payload?: EventPayload;
107
120
  }) => void;
108
121
  export type SubmitClientEvent = (args: {
109
122
  name: ClientEvent['name'];
@@ -111,9 +124,8 @@ export type SubmitClientEvent = (args: {
111
124
  options?: SubmitClientEventOptions;
112
125
  }) => Promise<any>;
113
126
  export type SubmitOperationalEvent = (args: {
114
- name: OperationalEvent['name'];
115
- payload?: RecursivePartial<OperationalEvent['payload']>;
116
- options?: any;
127
+ name: OperationalEvent['metricName'];
128
+ payload: EventPayload;
117
129
  }) => void;
118
130
  export type SubmitMQE = (args: {
119
131
  name: MediaQualityEvent['name'];
@@ -126,3 +138,4 @@ export type BuildClientEventFetchRequestOptions = (args: {
126
138
  options?: SubmitClientEventOptions;
127
139
  }) => Promise<any>;
128
140
  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';
141
+ export {};
@@ -1,7 +1,9 @@
1
1
  import { WebexPlugin } from '@webex/webex-core';
2
2
  import CallDiagnosticMetrics from './call-diagnostic/call-diagnostic-metrics';
3
- import BehavioralMetrics from './behavioral/behavioral-metrics';
4
- import { RecursivePartial, MetricEventProduct, MetricEventAgent, MetricEventVerb, ClientEvent, FeatureEvent, BehavioralEventPayload, OperationalEvent, MediaQualityEvent, InternalEvent, SubmitClientEventOptions } from './metrics.types';
3
+ import BehavioralMetrics from './behavioral-metrics';
4
+ import OperationalMetrics from './operational-metrics';
5
+ import BusinessMetrics from './business-metrics';
6
+ import { RecursivePartial, MetricEventProduct, MetricEventAgent, MetricEventVerb, ClientEvent, FeatureEvent, EventPayload, MediaQualityEvent, InternalEvent, SubmitClientEventOptions, Table } from './metrics.types';
5
7
  import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-latencies';
6
8
  /**
7
9
  * Metrics plugin to centralize all types of metrics.
@@ -12,6 +14,9 @@ declare class Metrics extends WebexPlugin {
12
14
  callDiagnosticLatencies: CallDiagnosticLatencies;
13
15
  callDiagnosticMetrics: CallDiagnosticMetrics;
14
16
  behavioralMetrics: BehavioralMetrics;
17
+ operationalMetrics: OperationalMetrics;
18
+ businessMetrics: BusinessMetrics;
19
+ isReady: boolean;
15
20
  /**
16
21
  * Constructor
17
22
  * @param args
@@ -33,10 +38,30 @@ declare class Metrics extends WebexPlugin {
33
38
  payload?: RecursivePartial<InternalEvent['payload']>;
34
39
  options?: any;
35
40
  }): void;
41
+ /**
42
+ * if webex metrics is ready, build behavioral metric backend if not already done.
43
+ */
44
+ private lazyBuildBehavioralMetrics;
45
+ /**
46
+ * if webex metrics is ready, build operational metric backend if not already done.
47
+ */
48
+ private lazyBuildOperationalMetrics;
49
+ /**
50
+ * if webex metrics is ready, build business metric backend if not already done.
51
+ */
52
+ private lazyBuildBusinessMetrics;
36
53
  /**
37
54
  * @returns true once we have the deviceId we need to submit behavioral events to Amplitude
38
55
  */
39
56
  isReadyToSubmitBehavioralEvents(): boolean;
57
+ /**
58
+ * @returns true once we have the deviceId we need to submit operational events
59
+ */
60
+ isReadyToSubmitOperationalEvents(): boolean;
61
+ /**
62
+ * @returns true once we have the deviceId we need to submit buisness events
63
+ */
64
+ isReadyToSubmitBusinessEvents(): boolean;
40
65
  /**
41
66
  * Behavioral event
42
67
  * @param args
@@ -46,17 +71,25 @@ declare class Metrics extends WebexPlugin {
46
71
  agent: MetricEventAgent;
47
72
  target: string;
48
73
  verb: MetricEventVerb;
49
- payload?: BehavioralEventPayload;
50
- }): any;
74
+ payload?: EventPayload;
75
+ }): void | Promise<void>;
51
76
  /**
52
77
  * Operational event
53
78
  * @param args
54
79
  */
55
- submitOperationalEvent({ name, payload, options, }: {
56
- name: OperationalEvent['name'];
57
- payload?: RecursivePartial<OperationalEvent['payload']>;
58
- options?: any;
59
- }): void;
80
+ submitOperationalEvent({ name, payload }: {
81
+ name: string;
82
+ payload?: EventPayload;
83
+ }): void | Promise<void>;
84
+ /**
85
+ * Buisness event
86
+ * @param args
87
+ */
88
+ submitBusinessEvent({ name, payload, table, }: {
89
+ name: string;
90
+ payload: EventPayload;
91
+ table?: Table;
92
+ }): Promise<void>;
60
93
  /**
61
94
  * Call Analyzer: Media Quality Event
62
95
  * @param args
@@ -0,0 +1,19 @@
1
+ import GenericMetrics from './generic-metrics';
2
+ import { EventPayload } from './metrics.types';
3
+ /**
4
+ * @description Util class to handle Operational Metrics
5
+ * @export
6
+ * @class OperationalMetrics
7
+ */
8
+ export default class OperationalMetrics extends GenericMetrics {
9
+ /**
10
+ * Submit an operational metric to our metrics endpoint.
11
+ * @param {string} name of the metric
12
+ * @param {EventPayload} user payload of the metric
13
+ * @returns {Promise<any>}
14
+ */
15
+ submitOperationalEvent({ name, payload }: {
16
+ name: string;
17
+ payload: EventPayload;
18
+ }): void;
19
+ }
@@ -0,0 +1,4 @@
1
+ declare const RTC_METRICS: {
2
+ APP_ID: string;
3
+ };
4
+ export { RTC_METRICS as default };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Rtc Metrics
3
+ */
4
+ export default class RtcMetrics {
5
+ /**
6
+ * Array of MetricData items to be sent to the metrics service.
7
+ */
8
+ metricsQueue: any[];
9
+ intervalId: number;
10
+ webex: any;
11
+ meetingId: string;
12
+ correlationId: string;
13
+ connectionId: string;
14
+ shouldSendMetricsOnNextStatsReport: boolean;
15
+ /**
16
+ * Initialize the interval.
17
+ *
18
+ * @param {object} webex - The main `webex` object.
19
+ * @param {string} meetingId - The meeting id.
20
+ * @param {string} correlationId - The correlation id.
21
+ */
22
+ constructor(webex: any, meetingId: any, correlationId: any);
23
+ /**
24
+ * Check to see if the metrics queue has any items.
25
+ *
26
+ * @returns {void}
27
+ */
28
+ sendMetricsInQueue(): void;
29
+ /**
30
+ * Forces sending metrics when we get the next stats-report
31
+ *
32
+ * This is useful for cases when something important happens that affects the media connection,
33
+ * for example when we move from lobby into the meeting.
34
+ *
35
+ * @returns {void}
36
+ */
37
+ sendNextMetrics(): void;
38
+ /**
39
+ * Add metrics items to the metrics queue.
40
+ *
41
+ * @param {object} data - An object with a payload array of metrics items.
42
+ *
43
+ * @returns {void}
44
+ */
45
+ addMetrics(data: any): void;
46
+ /**
47
+ * Clear the metrics interval.
48
+ *
49
+ * @returns {void}
50
+ */
51
+ closeMetrics(): void;
52
+ /**
53
+ * Anonymize IP addresses.
54
+ *
55
+ * @param {array} stats - An RTCStatsReport organized into an array of strings.
56
+ * @returns {string}
57
+ */
58
+ anonymizeIp(stats: string): string;
59
+ /**
60
+ * Set a new connection id.
61
+ *
62
+ * @returns {void}
63
+ */
64
+ private resetConnection;
65
+ /**
66
+ * Send metrics to the metrics service.
67
+ *
68
+ * @returns {void}
69
+ */
70
+ private sendMetrics;
71
+ }
package/package.json CHANGED
@@ -26,22 +26,22 @@
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.4.0",
30
- "@webex/test-helper-mocha": "3.4.0",
31
- "@webex/test-helper-mock-webex": "3.4.0",
32
- "@webex/test-helper-test-users": "3.4.0",
29
+ "@webex/test-helper-chai": "3.5.0-next.10",
30
+ "@webex/test-helper-mocha": "3.5.0-next.10",
31
+ "@webex/test-helper-mock-webex": "3.5.0-next.10",
32
+ "@webex/test-helper-test-users": "3.5.0-next.10",
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.4.0",
39
- "@webex/common-timers": "3.4.0",
40
- "@webex/event-dictionary-ts": "^1.0.1406",
41
- "@webex/internal-plugin-metrics": "3.4.0",
42
- "@webex/test-helper-chai": "3.4.0",
43
- "@webex/test-helper-mock-webex": "3.4.0",
44
- "@webex/webex-core": "3.4.0",
38
+ "@webex/common": "3.5.0-next.10",
39
+ "@webex/common-timers": "3.5.0-next.10",
40
+ "@webex/event-dictionary-ts": "^1.0.1546",
41
+ "@webex/internal-plugin-metrics": "3.5.0-next.10",
42
+ "@webex/test-helper-chai": "3.5.0-next.10",
43
+ "@webex/test-helper-mock-webex": "3.5.0-next.10",
44
+ "@webex/webex-core": "3.5.0-next.10",
45
45
  "ip-anonymize": "^0.1.0",
46
46
  "lodash": "^4.17.21",
47
47
  "uuid": "^3.3.2"
@@ -54,5 +54,5 @@
54
54
  "test:style": "eslint ./src/**/*.*",
55
55
  "test:unit": "webex-legacy-tools test --unit --runner mocha"
56
56
  },
57
- "version": "3.4.0"
57
+ "version": "3.5.0-next.10"
58
58
  }