@webex/internal-plugin-metrics 3.5.0-next.9 → 3.5.0-wxcc.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.
Files changed (50) hide show
  1. package/dist/behavioral/behavioral-metrics.js +199 -0
  2. package/dist/behavioral/behavioral-metrics.js.map +1 -0
  3. package/dist/behavioral/config.js +11 -0
  4. package/dist/behavioral/config.js.map +1 -0
  5. package/dist/business-metrics.js +7 -114
  6. package/dist/business-metrics.js.map +1 -1
  7. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +1 -1
  8. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
  9. package/dist/call-diagnostic/call-diagnostic-metrics.js +7 -15
  10. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
  11. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +2 -7
  12. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
  13. package/dist/call-diagnostic/config.js +3 -13
  14. package/dist/call-diagnostic/config.js.map +1 -1
  15. package/dist/index.js +0 -7
  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/types/behavioral/behavioral-metrics.d.ts +63 -0
  20. package/dist/types/behavioral/config.d.ts +1 -0
  21. package/dist/types/business-metrics.d.ts +4 -32
  22. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +1 -6
  23. package/dist/types/call-diagnostic/config.d.ts +0 -3
  24. package/dist/types/index.d.ts +1 -2
  25. package/dist/types/metrics.types.d.ts +0 -1
  26. package/dist/types/new-metrics.d.ts +1 -1
  27. package/package.json +11 -11
  28. package/src/business-metrics.ts +4 -92
  29. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +1 -1
  30. package/src/call-diagnostic/call-diagnostic-metrics.ts +7 -13
  31. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +5 -11
  32. package/src/call-diagnostic/config.ts +0 -12
  33. package/src/index.ts +0 -2
  34. package/src/metrics.types.ts +0 -2
  35. package/test/unit/spec/business/business-metrics.ts +1 -63
  36. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +1 -2
  37. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +6 -4
  38. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +12 -406
  39. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +3 -7
  40. package/test/unit/spec/new-metrics.ts +3 -0
  41. package/test/unit/spec/prelogin-metrics-batcher.ts +1 -3
  42. package/dist/rtcMetrics/constants.js +0 -11
  43. package/dist/rtcMetrics/constants.js.map +0 -1
  44. package/dist/rtcMetrics/index.js +0 -202
  45. package/dist/rtcMetrics/index.js.map +0 -1
  46. package/dist/types/rtcMetrics/constants.d.ts +0 -4
  47. package/dist/types/rtcMetrics/index.d.ts +0 -71
  48. package/src/rtcMetrics/constants.ts +0 -3
  49. package/src/rtcMetrics/index.ts +0 -186
  50. package/test/unit/spec/rtcMetrics/index.ts +0 -155
@@ -1,5 +1,5 @@
1
1
  import GenericMetrics from './generic-metrics';
2
- import {EventPayload, Table} from './metrics.types';
2
+ import {EventPayload} from './metrics.types';
3
3
 
4
4
  /**
5
5
  * @description Util class to handle Buisness Metrics
@@ -8,71 +8,16 @@ import {EventPayload, Table} from './metrics.types';
8
8
  */
9
9
  export default class BusinessMetrics extends GenericMetrics {
10
10
  /**
11
- * unfortunately, the pinot team does not allow changes to the schema of wbxapp_callend_metrics
12
- * so we have to shim this layer specifically for this
13
- * @param {EventPayload} payload payload of the metric
14
- * @returns {Promise<any>}
15
- */
16
- private submitCallEndEvent({payload}: {payload: EventPayload}) {
17
- const event = {
18
- type: ['business'],
19
- eventPayload: {
20
- key: 'callEnd',
21
- client_timestamp: Date.now(),
22
- appType: 'Web Client',
23
- value: {
24
- ...payload,
25
- },
26
- },
27
- };
28
-
29
- return this.submitEvent({
30
- kind: 'buisness-events:wbxapp_callend_metrics -> ',
31
- name: 'wbxapp_callend_metrics',
32
- event,
33
- });
34
- }
35
-
36
- /**
37
- * Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
38
- * all event payload keys are converted into a hex string value
39
- * unfortunately, the pinot team does not allow changes to the schema of business_metrics
40
- * so we have to shim this layer specifically for this
41
- * @param {string} name of the metric
42
- * @param {EventPayload} payload payload of the metric
43
- * @returns {Promise<any>}
44
- */
45
- private submitBusinessMetricsEvent({name, payload}: {name: string; payload: EventPayload}) {
46
- const event = {
47
- type: ['business'],
48
- eventPayload: {
49
- key: name,
50
- client_timestamp: Date.now(),
51
- appType: 'Web Client',
52
- value: {
53
- ...this.getContext(),
54
- ...this.getBrowserDetails(),
55
- ...payload,
56
- },
57
- },
58
- };
59
-
60
- return this.submitEvent({kind: 'buisness-events:business_metrics -> ', name, event});
61
- }
62
-
63
- /**
64
- * Submit a buisness metric to our metrics endpoint, going to the default business_ucf table
65
- * all event payload keys are converted into a hex string value
11
+ * Submit a buisness metric to our metrics endpoint.
66
12
  * @param {string} name of the metric
67
13
  * @param {EventPayload} user payload of the metric
68
14
  * @returns {Promise<any>}
69
15
  */
70
- private submitDefaultEvent({name, payload}: {name: string; payload: EventPayload}) {
16
+ public submitBusinessEvent({name, payload}: {name: string; payload: EventPayload}) {
71
17
  const event = {
72
18
  type: ['business'],
73
19
  eventPayload: {
74
20
  key: name,
75
- appType: 'Web Client',
76
21
  client_timestamp: Date.now(),
77
22
  context: this.getContext(),
78
23
  browserDetails: this.getBrowserDetails(),
@@ -80,39 +25,6 @@ export default class BusinessMetrics extends GenericMetrics {
80
25
  },
81
26
  };
82
27
 
83
- return this.submitEvent({kind: 'buisness-events:default -> ', name, event});
84
- }
85
-
86
- /**
87
- * Submit a buisness metric to our metrics endpoint.
88
- * routes to the correct table with the correct schema payload by table
89
- * @param {string} name of the metric, ignored if going to wbxapp_callend_metrics
90
- * @param {EventPayload} payload user payload of the metric
91
- * @param {Table} table optional - to submit the metric to and adapt the sent schema
92
- * @returns {Promise<any>}
93
- */
94
- public submitBusinessEvent({
95
- name,
96
- payload,
97
- table,
98
- }: {
99
- name: string;
100
- payload: EventPayload;
101
- table?: Table;
102
- }): Promise<void> {
103
- if (!table) {
104
- table = 'default';
105
- }
106
- switch (table) {
107
- case 'wbxapp_callend_metrics':
108
- return this.submitCallEndEvent({payload});
109
- case 'business_metrics':
110
- return this.submitBusinessMetricsEvent({name, payload});
111
- case 'business_ucf':
112
- return this.submitDefaultEvent({name, payload});
113
- case 'default':
114
- default:
115
- return this.submitDefaultEvent({name, payload});
116
- }
28
+ this.submitEvent({kind: 'buisness-events -> ', name, event});
117
29
  }
118
30
  }
@@ -49,7 +49,7 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
49
49
  private getMeeting() {
50
50
  if (this.meetingId) {
51
51
  // @ts-ignore
52
- return this.webex.meetings.getBasicMeetingInformation(this.meetingId);
52
+ return this.webex.meetings.meetingCollection.get(this.meetingId);
53
53
  }
54
54
 
55
55
  return undefined;
@@ -139,7 +139,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
139
139
  getIsConvergedArchitectureEnabled({meetingId}: {meetingId?: string}): boolean {
140
140
  if (meetingId) {
141
141
  // @ts-ignore
142
- const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
142
+ const meeting = this.webex.meetings.meetingCollection.get(meetingId);
143
143
 
144
144
  return meeting?.meetingInfo?.enableConvergedArchitecture;
145
145
  }
@@ -245,7 +245,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
245
245
 
246
246
  if (meetingId) {
247
247
  // @ts-ignore
248
- const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
248
+ const meeting = this.webex.meetings.meetingCollection.get(meetingId);
249
249
  if (meeting?.environment) {
250
250
  origin.environment = meeting.environment;
251
251
  }
@@ -289,14 +289,11 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
289
289
  sessionCorrelationId,
290
290
  } = options;
291
291
  const identifiers: Event['event']['identifiers'] = {
292
- correlationId: 'unknown', // concerned with setting this to unknown. This will fail diagnostic events parsing because it's not a uuid pattern
292
+ correlationId: 'unknown',
293
293
  };
294
294
 
295
295
  if (meeting) {
296
296
  identifiers.correlationId = meeting.correlationId;
297
- if (meeting.sessionCorrelationId) {
298
- identifiers.sessionCorrelationId = meeting.sessionCorrelationId;
299
- }
300
297
  }
301
298
 
302
299
  if (sessionCorrelationId) {
@@ -307,8 +304,6 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
307
304
  identifiers.correlationId = correlationId;
308
305
  }
309
306
 
310
- // TODO: should we use patterns.uuid to validate correlationId and session correlation id? they will fail the diagnostic events validation pipeline if improperly formatted
311
-
312
307
  if (this.device) {
313
308
  const {device} = this;
314
309
  const {installationId} = device?.config || {};
@@ -430,7 +425,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
430
425
  // events that will most likely happen in join phase
431
426
  if (meetingId) {
432
427
  // @ts-ignore
433
- const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
428
+ const meeting = this.webex.meetings.meetingCollection.get(meetingId);
434
429
 
435
430
  if (!meeting) {
436
431
  console.warn(
@@ -631,11 +626,10 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
631
626
  });
632
627
  }
633
628
 
634
- // otherwise return unkown error but passing serviceErrorCode and serviceErrorName so that we know the issue
629
+ // otherwise return unkown error
635
630
  return this.getErrorPayloadForClientErrorCode({
636
631
  clientErrorCode: UNKNOWN_ERROR,
637
- serviceErrorCode: serviceErrorCode || UNKNOWN_ERROR,
638
- serviceErrorName: rawError?.name,
632
+ serviceErrorCode: UNKNOWN_ERROR,
639
633
  payloadOverrides: rawError.payloadOverrides,
640
634
  rawErrorMessage,
641
635
  httpStatusCode,
@@ -667,7 +661,7 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
667
661
  } = options;
668
662
 
669
663
  // @ts-ignore
670
- const meeting = this.webex.meetings.getBasicMeetingInformation(meetingId);
664
+ const meeting = this.webex.meetings.meetingCollection.get(meetingId);
671
665
 
672
666
  if (!meeting) {
673
667
  console.warn(
@@ -231,19 +231,13 @@ export const getBuildType = (
231
231
  * @returns {Object} prepared item
232
232
  */
233
233
  export const prepareDiagnosticMetricItem = (webex: any, item: any) => {
234
- const buildType = getBuildType(
235
- webex,
236
- item.eventPayload?.event?.eventData?.webClientDomain,
237
- item.eventPayload?.event?.eventData?.markAsTestEvent
238
- );
239
-
240
- // Set upgradeChannel to 'gold' if buildType is 'prod', otherwise to the buildType value
241
- const upgradeChannel = buildType === 'prod' ? 'gold' : buildType;
242
-
243
234
  const origin: Partial<Event['origin']> = {
244
- buildType,
235
+ buildType: getBuildType(
236
+ webex,
237
+ item.eventPayload?.event?.eventData?.webClientDomain,
238
+ item.eventPayload?.event?.eventData?.markAsTestEvent
239
+ ),
245
240
  networkType: 'unknown',
246
- upgradeChannel,
247
241
  };
248
242
 
249
243
  // check event names and append latencies?
@@ -129,7 +129,6 @@ export const ERROR_DESCRIPTIONS = {
129
129
  ICE_AND_REACHABILITY_FAILED: 'ICEAndReachabilityFailed',
130
130
  SDP_OFFER_CREATION_ERROR: 'SdpOfferCreationError',
131
131
  SDP_OFFER_CREATION_ERROR_MISSING_CODEC: 'SdpOfferCreationErrorMissingCodec',
132
- WDM_RESTRICTED_REGION: 'WdmRestrictedRegion',
133
132
  };
134
133
 
135
134
  export const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP = {
@@ -289,12 +288,6 @@ export const SERVICE_ERROR_CODES_TO_CLIENT_ERROR_CODES_MAP = {
289
288
  100005: 4103, // Depracated because of an issue in the UCF Clients
290
289
  // If both email-hash and domain-hash are null or undefined.
291
290
  100004: 4103,
292
-
293
- // ---- WDM ----
294
- // WDM_BLOCKED_ACCESS_BY_COUNTRY_CODE_BANNED_COUNTRY_ERROR_CODE
295
- 4404002: 13000,
296
- // WDM_BLOCKED_ACCESS_BY_COUNTRY_CODE_RESTRICTED_COUNTRY_ERROR_CODE
297
- 4404003: 13000,
298
291
  };
299
292
 
300
293
  export const CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD: Record<number, Partial<ClientEventError>> = {
@@ -694,11 +687,6 @@ export const CLIENT_ERROR_CODE_TO_ERROR_PAYLOAD: Record<number, Partial<ClientEv
694
687
  category: 'expected',
695
688
  fatal: true,
696
689
  },
697
- 13000: {
698
- errorDescription: ERROR_DESCRIPTIONS.WDM_RESTRICTED_REGION,
699
- category: 'expected',
700
- fatal: true,
701
- },
702
690
  };
703
691
 
704
692
  export const CALL_DIAGNOSTIC_EVENT_FAILED_TO_SEND = 'js_sdk_call_diagnostic_event_failed_to_send';
package/src/index.ts CHANGED
@@ -25,7 +25,6 @@ import CallDiagnosticLatencies from './call-diagnostic/call-diagnostic-metrics-l
25
25
  import BehavioralMetrics from './behavioral-metrics';
26
26
  import OperationalMetrics from './operational-metrics';
27
27
  import BusinessMetrics from './business-metrics';
28
- import RtcMetrics from './rtcMetrics';
29
28
 
30
29
  registerInternalPlugin('metrics', Metrics, {
31
30
  config,
@@ -48,7 +47,6 @@ export {
48
47
  BehavioralMetrics,
49
48
  OperationalMetrics,
50
49
  BusinessMetrics,
51
- RtcMetrics,
52
50
  };
53
51
  export type {
54
52
  ClientEvent,
@@ -115,8 +115,6 @@ export interface DeviceContext {
115
115
 
116
116
  export type MetricType = 'behavioral' | 'operational' | 'business';
117
117
 
118
- export type Table = 'wbxapp_callend_metrics' | 'business_metrics' | 'business_ucf' | 'default';
119
-
120
118
  type InternalEventPayload = string | number | boolean;
121
119
  export type EventPayload = Record<string, InternalEventPayload>;
122
120
  export type BehavioralEventPayload = EventPayload; // for compatibilty, can be remove after wxcc-desktop did change their imports.
@@ -74,7 +74,7 @@ describe('internal-plugin-metrics', () => {
74
74
  });
75
75
 
76
76
  describe('#sendEvent', () => {
77
- it('should send correctly shaped business event (check name building and internal tagged event building) and default correctly', () => {
77
+ it('should send correctly shaped business event (check name building and internal tagged event building)', () => {
78
78
  // For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
79
79
  const requestCalls = [];
80
80
  const request = function(arg) { requestCalls.push(arg) }
@@ -86,7 +86,6 @@ describe('internal-plugin-metrics', () => {
86
86
  assert.equal(requestCalls.length, 1)
87
87
  assert.deepEqual(requestCalls[0], {
88
88
  eventPayload: {
89
- appType: 'Web Client',
90
89
  context: {
91
90
  app: {version: 'webex-version'},
92
91
  device: {id: 'deviceId'},
@@ -116,67 +115,6 @@ describe('internal-plugin-metrics', () => {
116
115
  });
117
116
  assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
118
117
  })
119
-
120
- describe('when table is provided', () => {
121
- it('should send correctly shaped business event with table: wbx_app_callend_metrics and ignore the key name', () => {
122
- // For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
123
- const requestCalls = [];
124
- const request = function(arg) { requestCalls.push(arg) }
125
-
126
- businessMetrics.clientMetricsBatcher.request = request;
127
-
128
- assert.equal(requestCalls.length, 0)
129
- businessMetrics.submitBusinessEvent({ name: "foobar", payload: {bar:"gee"}, table: 'wbxapp_callend_metrics' })
130
- assert.equal(requestCalls.length, 1)
131
- assert.deepEqual(requestCalls[0], {
132
- eventPayload: {
133
- key: 'callEnd',
134
- client_timestamp: requestCalls[0].eventPayload.client_timestamp, // This is to bypass time check, which is checked below.
135
- appType: 'Web Client',
136
- value: {
137
- bar: 'gee'
138
- }
139
- },
140
- type: ['business'],
141
- });
142
- assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
143
- });
144
-
145
- it('should send correctly shaped business event with table: business_metrics', () => {
146
- // For some reasons `jest` isn't available when testing form build server - so can't use `jest.fn()` here...
147
- const requestCalls = [];
148
- const request = function(arg) { requestCalls.push(arg) }
149
-
150
- businessMetrics.clientMetricsBatcher.request = request;
151
-
152
- assert.equal(requestCalls.length, 0)
153
- businessMetrics.submitBusinessEvent({ name: "foobar", payload: {bar:"gee"}, table: 'business_metrics' })
154
- assert.equal(requestCalls.length, 1)
155
- assert.deepEqual(requestCalls[0], {
156
- eventPayload: {
157
- key: 'foobar',
158
- appType: 'Web Client',
159
- client_timestamp: requestCalls[0].eventPayload.client_timestamp, // This is to bypass time check, which is checked below.
160
- value: {
161
- bar: "gee",
162
- browser: getBrowserName(),
163
- browserHeight: window.innerHeight,
164
- browserVersion: getBrowserVersion(),
165
- browserWidth: window.innerWidth,
166
- domain: window.location.hostname,
167
- inIframe: false,
168
- locale: window.navigator.language,
169
- os: getOSNameInternal(),
170
- app: {version: 'webex-version'},
171
- device: {id: 'deviceId'},
172
- locale: 'language',
173
- }
174
- },
175
- type: ['business'],
176
- });
177
- assert.isNumber(requestCalls[0].eventPayload.client_timestamp)
178
- });
179
- });
180
118
  })
181
119
  });
182
120
  });
@@ -441,7 +441,7 @@ describe('plugin-metrics', () => {
441
441
  // item also gets assigned a delay property but the key is a Symbol and haven't been able to test that..
442
442
  assert.deepEqual(calls.args[0].eventPayload, {
443
443
  event: 'my.event',
444
- origin: {buildType: 'test', networkType: 'unknown', upgradeChannel: 'test'},
444
+ origin: {buildType: 'test', networkType: 'unknown'},
445
445
  });
446
446
 
447
447
  assert.deepEqual(calls.args[0].type, ['diagnostic-event']);
@@ -455,7 +455,6 @@ describe('plugin-metrics', () => {
455
455
  origin: {
456
456
  buildType: 'test',
457
457
  networkType: 'unknown',
458
- upgradeChannel: 'test',
459
458
  },
460
459
  });
461
460
  assert.deepEqual(prepareDiagnosticMetricItemCalls[0].args[1].type, ['diagnostic-event']);
@@ -12,10 +12,12 @@ describe('internal-plugin-metrics', () => {
12
12
  sinon.useFakeTimers(now.getTime());
13
13
  const webex = {
14
14
  meetings: {
15
- getBasicMeetingInformation: (id: string) => {
16
- if (id === 'meeting-id') {
17
- return {id: 'meeting-id', allowMediaInLobby: true};
18
- }
15
+ meetingCollection: {
16
+ get: (id: string) => {
17
+ if (id === 'meeting-id') {
18
+ return {id: 'meeting-id', allowMediaInLobby: true};
19
+ }
20
+ },
19
21
  },
20
22
  },
21
23
  };