@webex/plugin-meetings 3.3.1 → 3.4.0

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 (126) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +7 -2
  3. package/dist/breakouts/index.js.map +1 -1
  4. package/dist/constants.js +11 -4
  5. package/dist/constants.js.map +1 -1
  6. package/dist/interpretation/index.js +1 -1
  7. package/dist/interpretation/siLanguage.js +1 -1
  8. package/dist/locus-info/selfUtils.js +0 -5
  9. package/dist/locus-info/selfUtils.js.map +1 -1
  10. package/dist/media/MediaConnectionAwaiter.js +70 -15
  11. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  12. package/dist/media/index.js +12 -0
  13. package/dist/media/index.js.map +1 -1
  14. package/dist/meeting/connectionStateHandler.js +67 -0
  15. package/dist/meeting/connectionStateHandler.js.map +1 -0
  16. package/dist/meeting/index.js +552 -357
  17. package/dist/meeting/index.js.map +1 -1
  18. package/dist/meeting/locusMediaRequest.js +7 -0
  19. package/dist/meeting/locusMediaRequest.js.map +1 -1
  20. package/dist/meeting/muteState.js +6 -1
  21. package/dist/meeting/muteState.js.map +1 -1
  22. package/dist/meeting/util.js +1 -0
  23. package/dist/meeting/util.js.map +1 -1
  24. package/dist/meeting-info/index.js +4 -4
  25. package/dist/meeting-info/index.js.map +1 -1
  26. package/dist/meeting-info/meeting-info-v2.js +2 -2
  27. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  28. package/dist/meeting-info/util.js +17 -17
  29. package/dist/meeting-info/util.js.map +1 -1
  30. package/dist/meeting-info/utilv2.js +16 -16
  31. package/dist/meeting-info/utilv2.js.map +1 -1
  32. package/dist/meetings/collection.js +1 -1
  33. package/dist/meetings/collection.js.map +1 -1
  34. package/dist/meetings/index.js +37 -33
  35. package/dist/meetings/index.js.map +1 -1
  36. package/dist/meetings/meetings.types.js +8 -0
  37. package/dist/meetings/meetings.types.js.map +1 -1
  38. package/dist/meetings/util.js +3 -2
  39. package/dist/meetings/util.js.map +1 -1
  40. package/dist/metrics/constants.js +2 -1
  41. package/dist/metrics/constants.js.map +1 -1
  42. package/dist/metrics/index.js +57 -0
  43. package/dist/metrics/index.js.map +1 -1
  44. package/dist/personal-meeting-room/index.js +1 -1
  45. package/dist/personal-meeting-room/index.js.map +1 -1
  46. package/dist/reachability/clusterReachability.js +108 -53
  47. package/dist/reachability/clusterReachability.js.map +1 -1
  48. package/dist/reachability/index.js +415 -56
  49. package/dist/reachability/index.js.map +1 -1
  50. package/dist/types/constants.d.ts +11 -3
  51. package/dist/types/media/MediaConnectionAwaiter.d.ts +24 -4
  52. package/dist/types/meeting/connectionStateHandler.d.ts +30 -0
  53. package/dist/types/meeting/index.d.ts +27 -7
  54. package/dist/types/meeting/locusMediaRequest.d.ts +2 -0
  55. package/dist/types/meeting-info/index.d.ts +3 -2
  56. package/dist/types/meeting-info/meeting-info-v2.d.ts +3 -2
  57. package/dist/types/meeting-info/util.d.ts +5 -4
  58. package/dist/types/meeting-info/utilv2.d.ts +3 -2
  59. package/dist/types/meetings/collection.d.ts +3 -2
  60. package/dist/types/meetings/index.d.ts +4 -3
  61. package/dist/types/meetings/meetings.types.d.ts +9 -0
  62. package/dist/types/metrics/constants.d.ts +1 -0
  63. package/dist/types/metrics/index.d.ts +15 -0
  64. package/dist/types/reachability/clusterReachability.d.ts +31 -3
  65. package/dist/types/reachability/index.d.ts +93 -2
  66. package/dist/webinar/index.js +1 -1
  67. package/package.json +23 -23
  68. package/src/breakouts/index.ts +7 -1
  69. package/src/constants.ts +13 -17
  70. package/src/locus-info/selfUtils.ts +0 -5
  71. package/src/media/MediaConnectionAwaiter.ts +89 -14
  72. package/src/media/index.ts +13 -0
  73. package/src/meeting/connectionStateHandler.ts +65 -0
  74. package/src/meeting/index.ts +526 -292
  75. package/src/meeting/locusMediaRequest.ts +5 -0
  76. package/src/meeting/muteState.ts +6 -1
  77. package/src/meeting/util.ts +1 -0
  78. package/src/meeting-info/index.ts +9 -6
  79. package/src/meeting-info/meeting-info-v2.ts +4 -4
  80. package/src/meeting-info/util.ts +23 -28
  81. package/src/meeting-info/utilv2.ts +18 -24
  82. package/src/meetings/collection.ts +3 -3
  83. package/src/meetings/index.ts +39 -40
  84. package/src/meetings/meetings.types.ts +11 -0
  85. package/src/meetings/util.ts +5 -4
  86. package/src/metrics/constants.ts +1 -0
  87. package/src/metrics/index.ts +44 -0
  88. package/src/personal-meeting-room/index.ts +2 -2
  89. package/src/reachability/clusterReachability.ts +86 -25
  90. package/src/reachability/index.ts +316 -27
  91. package/test/unit/spec/breakouts/index.ts +51 -32
  92. package/test/unit/spec/locus-info/selfUtils.js +25 -23
  93. package/test/unit/spec/media/MediaConnectionAwaiter.ts +131 -32
  94. package/test/unit/spec/media/index.ts +42 -27
  95. package/test/unit/spec/meeting/connectionStateHandler.ts +102 -0
  96. package/test/unit/spec/meeting/index.js +758 -179
  97. package/test/unit/spec/meeting/locusMediaRequest.ts +7 -0
  98. package/test/unit/spec/meeting/muteState.js +24 -0
  99. package/test/unit/spec/meeting-info/index.js +4 -4
  100. package/test/unit/spec/meeting-info/meetinginfov2.js +24 -28
  101. package/test/unit/spec/meeting-info/request.js +2 -2
  102. package/test/unit/spec/meeting-info/utilv2.js +41 -49
  103. package/test/unit/spec/meetings/index.js +14 -0
  104. package/test/unit/spec/metrics/index.js +126 -0
  105. package/test/unit/spec/multistream/mediaRequestManager.ts +2 -2
  106. package/test/unit/spec/personal-meeting-room/personal-meeting-room.js +2 -2
  107. package/test/unit/spec/reachability/clusterReachability.ts +116 -22
  108. package/test/unit/spec/reachability/index.ts +1153 -84
  109. package/test/unit/spec/rtcMetrics/index.ts +1 -0
  110. package/dist/mediaQualityMetrics/config.js +0 -321
  111. package/dist/mediaQualityMetrics/config.js.map +0 -1
  112. package/dist/statsAnalyzer/global.js +0 -44
  113. package/dist/statsAnalyzer/global.js.map +0 -1
  114. package/dist/statsAnalyzer/index.js +0 -1072
  115. package/dist/statsAnalyzer/index.js.map +0 -1
  116. package/dist/statsAnalyzer/mqaUtil.js +0 -368
  117. package/dist/statsAnalyzer/mqaUtil.js.map +0 -1
  118. package/dist/types/mediaQualityMetrics/config.d.ts +0 -247
  119. package/dist/types/statsAnalyzer/global.d.ts +0 -36
  120. package/dist/types/statsAnalyzer/index.d.ts +0 -217
  121. package/dist/types/statsAnalyzer/mqaUtil.d.ts +0 -48
  122. package/src/mediaQualityMetrics/config.ts +0 -255
  123. package/src/statsAnalyzer/global.ts +0 -37
  124. package/src/statsAnalyzer/index.ts +0 -1318
  125. package/src/statsAnalyzer/mqaUtil.ts +0 -463
  126. package/test/unit/spec/stats-analyzer/index.js +0 -1819
@@ -69,6 +69,7 @@ const BEHAVIORAL_METRICS = {
69
69
  ROAP_OFFER_TO_ANSWER_LATENCY: 'js_sdk_roap_offer_to_answer_latency',
70
70
  ROAP_HTTP_RESPONSE_MISSING: 'js_sdk_roap_http_response_missing',
71
71
  TURN_DISCOVERY_REQUIRES_OK: 'js_sdk_turn_discovery_requires_ok',
72
+ REACHABILITY_COMPLETED: 'js_sdk_reachability_completed',
72
73
  };
73
74
 
74
75
  export {BEHAVIORAL_METRICS as default};
@@ -65,6 +65,50 @@ class Metrics {
65
65
  tags: metricTags,
66
66
  });
67
67
  }
68
+
69
+ /**
70
+ * Flattens an object into one that has no nested properties. Each level of nesting is represented
71
+ * by "_" in the flattened object property names.
72
+ * This function is needed, because Amplitude doesn't allow passing nested objects as metricFields.
73
+ * Use this function for metricFields before calling sendBehavioralMetric() if you want to send
74
+ * nested objects in your metrics.
75
+ *
76
+ * If the function is called with a literal, it returns an object with a single property "value"
77
+ * and the literal value in it.
78
+ *
79
+ * @param {any} payload object you want to flatten
80
+ * @param {string} prefix string prefix prepended to any property names in flatten object
81
+ * @returns {Object}
82
+ */
83
+ prepareMetricFields(payload: any = {}, prefix = '') {
84
+ let output = {};
85
+
86
+ if (Array.isArray(payload)) {
87
+ payload.forEach((item, index) => {
88
+ const propName = prefix.length > 0 ? `${prefix}_${index}` : `${index}`;
89
+
90
+ output = {...output, ...this.prepareMetricFields(item, propName)};
91
+ });
92
+
93
+ return output;
94
+ }
95
+
96
+ if (typeof payload !== 'object' || payload === null) {
97
+ if (prefix.length > 0) {
98
+ return {[prefix]: payload};
99
+ }
100
+
101
+ return {value: payload};
102
+ }
103
+
104
+ Object.entries(payload).forEach(([key, value]) => {
105
+ const propName = prefix.length > 0 ? `${prefix}_${key}` : key;
106
+
107
+ output = {...output, ...this.prepareMetricFields(value, propName)};
108
+ });
109
+
110
+ return output;
111
+ }
68
112
  }
69
113
 
70
114
  // Export Metrics singleton ---------------------------------------------------
@@ -1,7 +1,7 @@
1
1
  // @ts-ignore
2
2
  import {StatelessWebexPlugin} from '@webex/webex-core';
3
3
 
4
- import {MEETINGS, _PERSONAL_ROOM_} from '../constants';
4
+ import {MEETINGS, DESTINATION_TYPE} from '../constants';
5
5
  import ParameterError from '../common/errors/parameter';
6
6
 
7
7
  import PersonalMeetingRoomRequest from './request';
@@ -141,7 +141,7 @@ export default class PersonalMeetingRoom extends StatelessWebexPlugin {
141
141
  */
142
142
  public get() {
143
143
  const options = {
144
- type: _PERSONAL_ROOM_,
144
+ type: DESTINATION_TYPE.PERSONAL_ROOM,
145
145
  };
146
146
 
147
147
  return this.meetingInfo.fetchMeetingInfo(options).then((pmr) => {
@@ -3,11 +3,9 @@ import {Defer} from '@webex/common';
3
3
  import LoggerProxy from '../common/logs/logger-proxy';
4
4
  import {ClusterNode} from './request';
5
5
  import {convertStunUrlToTurn, convertStunUrlToTurnTls} from './util';
6
+ import EventsScope from '../common/events/events-scope';
6
7
 
7
- import {ICE_GATHERING_STATE, CONNECTION_STATE} from '../constants';
8
-
9
- const DEFAULT_TIMEOUT = 3000;
10
- const VIDEO_MESH_TIMEOUT = 1000;
8
+ import {CONNECTION_STATE, Enum, ICE_GATHERING_STATE} from '../constants';
11
9
 
12
10
  // result for a specific transport protocol (like udp or tcp)
13
11
  export type TransportResult = {
@@ -23,10 +21,32 @@ export type ClusterReachabilityResult = {
23
21
  xtls: TransportResult;
24
22
  };
25
23
 
24
+ // data for the Events.resultReady event
25
+ export type ResultEventData = {
26
+ protocol: 'udp' | 'tcp' | 'xtls';
27
+ result: 'reachable' | 'unreachable' | 'untested';
28
+ latencyInMilliseconds: number; // amount of time it took to get the ICE candidate
29
+ clientMediaIPs?: string[];
30
+ };
31
+
32
+ // data for the Events.clientMediaIpsUpdated event
33
+ export type ClientMediaIpsUpdatedEventData = {
34
+ protocol: 'udp' | 'tcp' | 'xtls';
35
+ clientMediaIPs: string[];
36
+ };
37
+
38
+ export const Events = {
39
+ resultReady: 'resultReady', // emitted when a cluster is reached successfully using specific protocol
40
+ clientMediaIpsUpdated: 'clientMediaIpsUpdated', // emitted when more public IPs are found after resultReady was already sent for a given protocol
41
+ } as const;
42
+
43
+ export type Events = Enum<typeof Events>;
44
+
26
45
  /**
27
46
  * A class that handles reachability checks for a single cluster.
47
+ * It emits events from Events enum
28
48
  */
29
- export class ClusterReachability {
49
+ export class ClusterReachability extends EventsScope {
30
50
  private numUdpUrls: number;
31
51
  private numTcpUrls: number;
32
52
  private numXTlsUrls: number;
@@ -43,6 +63,7 @@ export class ClusterReachability {
43
63
  * @param {ClusterNode} clusterInfo information about the media cluster
44
64
  */
45
65
  constructor(name: string, clusterInfo: ClusterNode) {
66
+ super();
46
67
  this.name = name;
47
68
  this.isVideoMesh = clusterInfo.isVideoMesh;
48
69
  this.numUdpUrls = clusterInfo.udp.length;
@@ -162,23 +183,54 @@ export class ClusterReachability {
162
183
  this.defer.resolve();
163
184
  }
164
185
 
186
+ /**
187
+ * Aborts the cluster reachability checks by closing the peer connection
188
+ *
189
+ * @returns {void}
190
+ */
191
+ public abort() {
192
+ const {CLOSED} = CONNECTION_STATE;
193
+
194
+ if (this.pc.connectionState !== CLOSED) {
195
+ this.closePeerConnection();
196
+ this.finishReachabilityCheck();
197
+ }
198
+ }
199
+
165
200
  /**
166
201
  * Adds public IP (client media IPs)
167
202
  * @param {string} protocol
168
203
  * @param {string} publicIP
169
204
  * @returns {void}
170
205
  */
171
- private addPublicIP(protocol: 'udp' | 'tcp', publicIP?: string | null) {
206
+ private addPublicIP(protocol: 'udp' | 'tcp' | 'xtls', publicIP?: string | null) {
172
207
  const result = this.result[protocol];
173
208
 
174
209
  if (publicIP) {
210
+ let ipAdded = false;
211
+
175
212
  if (result.clientMediaIPs) {
176
213
  if (!result.clientMediaIPs.includes(publicIP)) {
177
214
  result.clientMediaIPs.push(publicIP);
215
+ ipAdded = true;
178
216
  }
179
217
  } else {
180
218
  result.clientMediaIPs = [publicIP];
219
+ ipAdded = true;
181
220
  }
221
+
222
+ if (ipAdded)
223
+ this.emit(
224
+ {
225
+ file: 'clusterReachability',
226
+ function: 'addPublicIP',
227
+ },
228
+ Events.clientMediaIpsUpdated,
229
+ {
230
+ protocol,
231
+ clientMediaIPs: result.clientMediaIPs,
232
+ }
233
+ );
182
234
  }
183
235
  }
184
236
 
@@ -211,22 +263,43 @@ export class ClusterReachability {
211
263
  }
212
264
 
213
265
  /**
214
- * Stores the latency in the result for the given protocol and marks it as reachable
266
+ * Saves the latency in the result for the given protocol and marks it as reachable,
267
+ * emits the "resultReady" event if this is the first result for that protocol,
268
+ * emits the "clientMediaIpsUpdated" event if we already had a result and only found
269
+ * a new client IP
215
270
  *
216
271
  * @param {string} protocol
217
272
  * @param {number} latency
273
+ * @param {string|null} [publicIp]
218
274
  * @returns {void}
219
275
  */
220
- private storeLatencyResult(protocol: 'udp' | 'tcp' | 'xtls', latency: number) {
276
+ private saveResult(protocol: 'udp' | 'tcp' | 'xtls', latency: number, publicIp?: string | null) {
221
277
  const result = this.result[protocol];
222
278
 
223
279
  if (result.latencyInMilliseconds === undefined) {
224
280
  LoggerProxy.logger.log(
225
281
  // @ts-ignore
226
- `Reachability:index#storeLatencyResult --> Successfully reached ${this.name} over ${protocol}: ${latency}ms`
282
+ `Reachability:index#saveResult --> Successfully reached ${this.name} over ${protocol}: ${latency}ms`
227
283
  );
228
284
  result.latencyInMilliseconds = latency;
229
285
  result.result = 'reachable';
286
+ if (publicIp) {
287
+ result.clientMediaIPs = [publicIp];
288
+ }
289
+
290
+ this.emit(
291
+ {
292
+ file: 'clusterReachability',
293
+ function: 'saveResult',
294
+ },
295
+ Events.resultReady,
296
+ {
297
+ protocol,
298
+ ...result,
299
+ }
300
+ );
301
+ } else {
302
+ this.addPublicIP(protocol, publicIp);
230
303
  }
231
304
  }
232
305
 
@@ -243,15 +316,16 @@ export class ClusterReachability {
243
316
  RELAY: 'relay',
244
317
  };
245
318
 
319
+ const latencyInMilliseconds = this.getElapsedTime();
320
+
246
321
  if (e.candidate) {
247
322
  if (e.candidate.type === CANDIDATE_TYPES.SERVER_REFLEXIVE) {
248
- this.storeLatencyResult('udp', this.getElapsedTime());
249
- this.addPublicIP('udp', e.candidate.address);
323
+ this.saveResult('udp', latencyInMilliseconds, e.candidate.address);
250
324
  }
251
325
 
252
326
  if (e.candidate.type === CANDIDATE_TYPES.RELAY) {
253
327
  const protocol = e.candidate.port === TURN_TLS_PORT ? 'xtls' : 'tcp';
254
- this.storeLatencyResult(protocol, this.getElapsedTime());
328
+ this.saveResult(protocol, latencyInMilliseconds);
255
329
  // we don't add public IP for TCP, because in the case of relay candidates
256
330
  // e.candidate.address is the TURN server address, not the client's public IP
257
331
  }
@@ -314,22 +388,9 @@ export class ClusterReachability {
314
388
  * @returns {Promise} promise that's resolved once reachability checks for this cluster are completed or timeout is reached
315
389
  */
316
390
  private gatherIceCandidates() {
317
- const timeout = this.isVideoMesh ? VIDEO_MESH_TIMEOUT : DEFAULT_TIMEOUT;
318
-
319
391
  this.registerIceGatheringStateChangeListener();
320
392
  this.registerIceCandidateListener();
321
393
 
322
- // Set maximum timeout
323
- setTimeout(() => {
324
- const {CLOSED} = CONNECTION_STATE;
325
-
326
- // Close any open peerConnections
327
- if (this.pc.connectionState !== CLOSED) {
328
- this.closePeerConnection();
329
- this.finishReachabilityCheck();
330
- }
331
- }, timeout);
332
-
333
394
  return this.defer.promise;
334
395
  }
335
396
  }