@webex/plugin-meetings 3.12.0-next.101 → 3.12.0-next.103

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.
@@ -33,7 +33,7 @@ import {
33
33
  MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
- import {DataChannelTokenType} from '@webex/internal-plugin-llm';
36
+ import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
37
 
38
38
  import {
39
39
  LocalStream,
@@ -742,6 +742,7 @@ export default class Meeting extends StatelessWebexPlugin {
742
742
  isMoveToInProgress = false;
743
743
  registrationIdStatus: string;
744
744
  brbState: BrbState;
745
+ private emittedBreakoutJoinResponseMoveIds: Set<string> = new Set();
745
746
  private promisesWaitingForPropUpdate: Record<string, Defer> = {};
746
747
 
747
748
  voiceaListenerCallbacks: object = {
@@ -1394,7 +1395,48 @@ export default class Meeting extends StatelessWebexPlugin {
1394
1395
  * @memberof Meeting
1395
1396
  */
1396
1397
  // @ts-ignore - Fix type
1397
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1398
+ this.locusInfo = new LocusInfo(
1399
+ {
1400
+ updateMeeting: this.updateMeetingObject.bind(this),
1401
+ syncLatencyTracker: {
1402
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1403
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1404
+ // facade. Wire each method to the layer that owns that responsibility.
1405
+ saveLatency: (...args) =>
1406
+ // @ts-ignore
1407
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1408
+ saveTimestamp: (saveTimestampOptions: {
1409
+ key: string;
1410
+ value?: number;
1411
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1412
+ }) => {
1413
+ // @ts-ignore
1414
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1415
+ saveTimestampOptions
1416
+ );
1417
+
1418
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1419
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1420
+ // once both the LLM message and the /sync response have arrived (either can come first).
1421
+ if (
1422
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1423
+ saveTimestampOptions.options?.trackingId
1424
+ ) {
1425
+ this.tryCompleteLocusSyncLatency(
1426
+ saveTimestampOptions.options.meetingId,
1427
+ saveTimestampOptions.options.trackingId
1428
+ );
1429
+ }
1430
+ },
1431
+ clearLocusSyncLatency: (...args) =>
1432
+ // @ts-ignore
1433
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1434
+ },
1435
+ },
1436
+ // @ts-ignore
1437
+ this.webex,
1438
+ this.id
1439
+ );
1398
1440
 
1399
1441
  // We had to add listeners first before setting up the locus instance
1400
1442
  /**
@@ -2380,6 +2422,89 @@ export default class Meeting extends StatelessWebexPlugin {
2380
2422
  });
2381
2423
  }
2382
2424
 
2425
+ /**
2426
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2427
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2428
+ * flows) and then tries to complete the metric.
2429
+ * @param {string} meetingId meeting id
2430
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2431
+ * @returns {void}
2432
+ * @private
2433
+ * @memberof Meeting
2434
+ */
2435
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2436
+ // @ts-ignore
2437
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2438
+ meetingId,
2439
+ trackingId
2440
+ );
2441
+
2442
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2443
+ }
2444
+
2445
+ /**
2446
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2447
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2448
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2449
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2450
+ * metric fires as soon as the second milestone is in.
2451
+ * @param {string} meetingId meeting id
2452
+ * @param {string} trackingId sync tracking id used to match the pending record
2453
+ * @returns {void}
2454
+ * @private
2455
+ * @memberof Meeting
2456
+ */
2457
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2458
+ const completed =
2459
+ // @ts-ignore
2460
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2461
+ meetingId,
2462
+ trackingId
2463
+ );
2464
+
2465
+ if (completed) {
2466
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2467
+ }
2468
+ }
2469
+
2470
+ /**
2471
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2472
+ * measurement.
2473
+ * @param {string} meetingId meeting id
2474
+ * @param {object} completed completed sync latency payload from the metrics plugin
2475
+ * @returns {void}
2476
+ * @private
2477
+ * @memberof Meeting
2478
+ */
2479
+ private emitLocusSyncCompleteMetric(
2480
+ meetingId: string,
2481
+ completed: {dataSet: string; syncLatency: object}
2482
+ ) {
2483
+ // @ts-ignore
2484
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2485
+
2486
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2487
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2488
+ const clientEvent = {
2489
+ name: 'client.locus.sync.complete',
2490
+ payload: {
2491
+ identifiers: {
2492
+ llmWebsocketUrl,
2493
+ },
2494
+ llmInfo: {
2495
+ dataSet: completed.dataSet,
2496
+ },
2497
+ syncLatency: completed.syncLatency,
2498
+ },
2499
+ options: {
2500
+ meetingId,
2501
+ },
2502
+ };
2503
+
2504
+ // @ts-ignore
2505
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2506
+ }
2507
+
2383
2508
  /**
2384
2509
  * Proxy function for all the listener set ups
2385
2510
  * @returns {undefined}
@@ -6049,7 +6174,18 @@ export default class Meeting extends StatelessWebexPlugin {
6049
6174
  storeEventForDebugging('llm', event.data);
6050
6175
  }
6051
6176
 
6177
+ const {trackingId} = event;
6178
+
6052
6179
  this.locusInfo.parse(this, event.data);
6180
+
6181
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6182
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6183
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6184
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6185
+ // record for this meeting matches the tracking id.
6186
+ if (trackingId) {
6187
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6188
+ }
6053
6189
  } else {
6054
6190
  LoggerProxy.logger.warn(
6055
6191
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -6458,7 +6594,7 @@ export default class Meeting extends StatelessWebexPlugin {
6458
6594
  this.webex.internal.llm.off('online', this.handleLLMOnline);
6459
6595
  // @ts-ignore
6460
6596
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6461
- this.updateLLMConnection()
6597
+ this.updateLLMConnection({isInitialJoinPhase: true})
6462
6598
  .catch((error) => {
6463
6599
  LoggerProxy.logger.error(
6464
6600
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6729,9 +6865,11 @@ export default class Meeting extends StatelessWebexPlugin {
6729
6865
  /**
6730
6866
  * Connects to low latency mercury and reconnects if the address has changed
6731
6867
  * It will also disconnect if called when the meeting has ended
6868
+ * @param {Object} [options]
6869
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6732
6870
  * @returns {Promise}
6733
6871
  */
6734
- async updateLLMConnection() {
6872
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6735
6873
  // @ts-ignore - Fix type
6736
6874
  const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6737
6875
 
@@ -6869,10 +7007,114 @@ export default class Meeting extends StatelessWebexPlugin {
6869
7007
 
6870
7008
  this.startLLMHealthCheckTimer();
6871
7009
 
7010
+ if (registerAndConnectResult) {
7011
+ if (isInitialJoinPhase) {
7012
+ this.sendLLMConnectMetric(registerAndConnectResult);
7013
+ }
7014
+
7015
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7016
+ meeting: this,
7017
+ llmLatency: registerAndConnectResult,
7018
+ });
7019
+ }
7020
+
6872
7021
  return Promise.resolve(registerAndConnectResult);
7022
+ })
7023
+ .catch((error) => {
7024
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
7025
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
7026
+ const llmLatency = {
7027
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
7028
+ clientLLMWebSocketConnectTime: 0,
7029
+ };
7030
+
7031
+ if (isInitialJoinPhase) {
7032
+ this.sendLLMConnectMetric(llmLatency, error);
7033
+ }
7034
+
7035
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7036
+ meeting: this,
7037
+ llmLatency,
7038
+ error,
7039
+ });
7040
+
7041
+ return Promise.reject(error);
6873
7042
  });
6874
7043
  }
6875
7044
 
7045
+ /**
7046
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
7047
+ * @param {string | undefined} breakoutMoveId
7048
+ * @param {boolean} [hasLLMLatency=false]
7049
+ * @returns {boolean}
7050
+ */
7051
+ private shouldEmitBreakoutJoinResponseMetric(
7052
+ breakoutMoveId?: string,
7053
+ hasLLMLatency = false
7054
+ ): boolean {
7055
+ if (!breakoutMoveId) {
7056
+ return false;
7057
+ }
7058
+
7059
+ if (!hasLLMLatency) {
7060
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
7061
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
7062
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
7063
+ // where the first one would be missing the LLM-specific fields we want to validate.
7064
+ // @ts-ignore - config coming from registerPlugin
7065
+ return !this.config.enableAutomaticLLM;
7066
+ }
7067
+
7068
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
7069
+ return false;
7070
+ }
7071
+
7072
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
7073
+
7074
+ return true;
7075
+ }
7076
+
7077
+ /**
7078
+ * Sends LLM connect latencies for initial join flow.
7079
+ * @param {RegisterAndConnectTiming} timings
7080
+ * @param {any} [error]
7081
+ * @returns {void}
7082
+ */
7083
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
7084
+ // @ts-ignore
7085
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
7086
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
7087
+
7088
+ const llmLatency: any = {
7089
+ clientLLMDatachannelResponseTime,
7090
+ };
7091
+
7092
+ if (clientLLMWebSocketConnectTime !== undefined) {
7093
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
7094
+ }
7095
+
7096
+ const payload: any = {
7097
+ identifiers: {
7098
+ llmWebsocketUrl,
7099
+ },
7100
+ llmLatency,
7101
+ };
7102
+
7103
+ const options: any = {
7104
+ meetingId: this.id,
7105
+ ...(error && {rawError: error}),
7106
+ };
7107
+
7108
+ const metricEvent = {
7109
+ name: 'client.llm.connect.response',
7110
+ payload,
7111
+ options,
7112
+ };
7113
+
7114
+ // @ts-ignore
7115
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7116
+ }
7117
+
6876
7118
  /**
6877
7119
  * Use phone for meeting audio
6878
7120
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -5,6 +5,7 @@ import breakoutEvent from "../../../../src/breakouts/events";
5
5
 
6
6
  describe('plugin-meetings', () => {
7
7
  describe('breakoutEvent', () => {
8
+ const originalPostMoveCallAnalyzer = breakoutEvent.postMoveCallAnalyzer;
8
9
  let webex;
9
10
  let mockMeeting = {};
10
11
  let breakoutMoveId;
@@ -24,20 +25,35 @@ describe('plugin-meetings', () => {
24
25
  groupId: "groupId",
25
26
  };
26
27
  breakoutMoveId = 'breakoutMoveId';
28
+ breakoutEvent.postMoveCallAnalyzer = originalPostMoveCallAnalyzer;
27
29
 
28
30
  });
29
31
  describe('postMoveCallAnalyzer', () => {
30
32
  it('send metric as expected', () => {
31
33
  const submitClientEvent = sinon.stub();
32
- const eventInfo = {currentSession: newSession, meeting: mockMeeting, breakoutMoveId};
34
+ const eventInfo = {
35
+ currentSession: newSession,
36
+ meeting: mockMeeting,
37
+ breakoutMoveId,
38
+ llmLatency: {
39
+ clientLLMDatachannelResponseTime: 10,
40
+ clientLLMWebSocketConnectTime: 20,
41
+ },
42
+ llmWebsocketUrl: 'wss://example.com/ws',
43
+ };
33
44
  breakoutEvent.postMoveCallAnalyzer('client.breakout-session.join.response', eventInfo, submitClientEvent);
34
45
  assert.calledWithMatch(submitClientEvent, {
35
46
  name: 'client.breakout-session.join.response',
36
47
  payload: {
48
+ llmLatency: {
49
+ clientLLMDatachannelResponseTime: 10,
50
+ clientLLMWebSocketConnectTime: 20,
51
+ },
37
52
  identifiers: {
38
53
  breakoutMoveId: 'breakoutMoveId',
39
54
  breakoutSessionId: 'sessionId',
40
55
  breakoutGroupId: 'groupId',
56
+ llmWebsocketUrl: 'wss://example.com/ws',
41
57
  },
42
58
  },
43
59
  options: {meetingId: 'activeMeetingId'},
@@ -79,10 +95,112 @@ describe('plugin-meetings', () => {
79
95
  sinon.stub(submitClientEvent, 'bind').returns(webex.internal.newMetrics.submitClientEvent);
80
96
 
81
97
  breakoutEvent.postMoveCallAnalyzer = sinon.stub();
82
- const eventInfo = {newSession, mockMeeting, breakoutMoveId};
98
+ const eventInfo = {
99
+ newSession,
100
+ mockMeeting,
101
+ breakoutMoveId,
102
+ llmLatency: {clientLLMDatachannelResponseTime: 10, clientLLMWebSocketConnectTime: 20},
103
+ };
83
104
  breakoutEvent.onBreakoutJoinResponse(eventInfo, submitClientEvent);
84
105
  assert.calledWith(breakoutEvent.postMoveCallAnalyzer, 'client.breakout-session.join.response', eventInfo, submitClientEvent);
85
106
  });
107
+
108
+ it('emits join response metric without llmLatency', () => {
109
+ const submitClientEvent = sinon.stub();
110
+
111
+ breakoutEvent.postMoveCallAnalyzer(
112
+ 'client.breakout-session.join.response',
113
+ {currentSession: newSession, meeting: mockMeeting, breakoutMoveId},
114
+ submitClientEvent
115
+ );
116
+
117
+ assert.calledOnceWithExactly(submitClientEvent, {
118
+ name: 'client.breakout-session.join.response',
119
+ payload: {
120
+ llmLatency: undefined,
121
+ identifiers: {
122
+ breakoutMoveId: 'breakoutMoveId',
123
+ breakoutSessionId: 'sessionId',
124
+ breakoutGroupId: 'groupId',
125
+ llmWebsocketUrl: undefined,
126
+ },
127
+ },
128
+ options: {meetingId: 'activeMeetingId', rawError: undefined},
129
+ });
130
+ });
131
+
132
+ it('does not emit duplicate join response metric with llmLatency for the same breakoutMoveId', () => {
133
+ const submitClientEvent = sinon.stub();
134
+ const shouldEmitBreakoutJoinResponseMetric = sinon.stub();
135
+
136
+ shouldEmitBreakoutJoinResponseMetric.onFirstCall().returns(true);
137
+ shouldEmitBreakoutJoinResponseMetric.onSecondCall().returns(false);
138
+
139
+ const eventInfo = {
140
+ currentSession: newSession,
141
+ meeting: {
142
+ ...mockMeeting,
143
+ shouldEmitBreakoutJoinResponseMetric,
144
+ },
145
+ breakoutMoveId,
146
+ llmLatency: {clientLLMDatachannelResponseTime: 10, clientLLMWebSocketConnectTime: 20},
147
+ };
148
+
149
+ breakoutEvent.postMoveCallAnalyzer(
150
+ 'client.breakout-session.join.response',
151
+ eventInfo,
152
+ submitClientEvent
153
+ );
154
+ breakoutEvent.postMoveCallAnalyzer(
155
+ 'client.breakout-session.join.response',
156
+ eventInfo,
157
+ submitClientEvent
158
+ );
159
+
160
+ assert.calledTwice(shouldEmitBreakoutJoinResponseMetric);
161
+ assert.calledWithExactly(shouldEmitBreakoutJoinResponseMetric, breakoutMoveId, true);
162
+ assert.calledOnce(submitClientEvent);
163
+ });
164
+
165
+ it('allows llmLatency join response after join response without llmLatency', () => {
166
+ const submitClientEvent = sinon.stub();
167
+ const shouldEmitBreakoutJoinResponseMetric = sinon.stub();
168
+
169
+ shouldEmitBreakoutJoinResponseMetric.onFirstCall().returns(true);
170
+ shouldEmitBreakoutJoinResponseMetric.onSecondCall().returns(true);
171
+
172
+ const baseEventInfo = {
173
+ currentSession: newSession,
174
+ meeting: {
175
+ ...mockMeeting,
176
+ shouldEmitBreakoutJoinResponseMetric,
177
+ },
178
+ breakoutMoveId,
179
+ };
180
+
181
+ breakoutEvent.postMoveCallAnalyzer(
182
+ 'client.breakout-session.join.response',
183
+ baseEventInfo,
184
+ submitClientEvent
185
+ );
186
+ breakoutEvent.postMoveCallAnalyzer(
187
+ 'client.breakout-session.join.response',
188
+ {
189
+ ...baseEventInfo,
190
+ llmLatency: {clientLLMDatachannelResponseTime: 10, clientLLMWebSocketConnectTime: 20},
191
+ },
192
+ submitClientEvent
193
+ );
194
+
195
+ assert.calledTwice(shouldEmitBreakoutJoinResponseMetric);
196
+ assert.calledWithExactly(shouldEmitBreakoutJoinResponseMetric.firstCall, breakoutMoveId, false);
197
+ assert.calledWithExactly(shouldEmitBreakoutJoinResponseMetric.secondCall, breakoutMoveId, true);
198
+ assert.calledTwice(submitClientEvent);
199
+ assert.deepEqual(submitClientEvent.secondCall.args[0].payload.llmLatency, {
200
+ clientLLMDatachannelResponseTime: 10,
201
+ clientLLMWebSocketConnectTime: 20,
202
+ });
203
+ });
86
204
  });
87
205
 
88
206
  });
@@ -7,8 +7,7 @@ import sinon from 'sinon';
7
7
  import MockWebex from '@webex/test-helper-mock-webex';
8
8
  import testUtils from '../../../utils/testUtils';
9
9
  import BreakoutEditLockedError from '@webex/plugin-meetings/src/breakouts/edit-lock-error';
10
- import breakoutEvent from '../../../../src/breakouts/events';
11
-
10
+ import breakoutEvent from '../../../../src/breakouts/events'
12
11
  const getBOResponse = (status: string) => {
13
12
  return {
14
13
  url: 'url',
@@ -217,6 +216,21 @@ describe('plugin-meetings', () => {
217
216
  });
218
217
  assert.calledThrice(breakouts.queryPreAssignments);
219
218
  });
219
+
220
+ it('wires LLM_CONNECT_RESPONSE to handleLLMBreakoutJoinResponseMetric', () => {
221
+ const handleStub = sinon.stub(Breakouts.prototype, 'handleLLMBreakoutJoinResponseMetric');
222
+ const bo = new Breakouts({}, {parent: webex});
223
+
224
+ const eventInfo = {
225
+ meeting: {id: 'meeting-id'},
226
+ llmLatency: {clientLLMWebSocketConnectTime: 1},
227
+ };
228
+ bo.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, eventInfo);
229
+
230
+ assert.calledOnceWithExactly(handleStub, eventInfo);
231
+
232
+ handleStub.restore();
233
+ });
220
234
  });
221
235
 
222
236
  describe('#listenToCurrentSessionTypeChange', () => {
@@ -374,6 +388,27 @@ describe('plugin-meetings', () => {
374
388
  assert.calledOnce(breakouts.clearBreakouts);
375
389
  });
376
390
 
391
+ it('preserves the last non-empty breakoutMoveId when a later update omits it', () => {
392
+ breakouts.updateBreakout({
393
+ sessionId: 'sessionId',
394
+ groupId: 'groupId',
395
+ sessionType: 'BREAKOUT',
396
+ status: 'active',
397
+ breakoutMoveId: 'move-id-1',
398
+ });
399
+ assert.equal(breakouts.breakoutMoveId, 'move-id-1');
400
+
401
+ // a later controls update arrives without a replaces entry -> null move id
402
+ breakouts.updateBreakout({
403
+ sessionId: 'sessionId',
404
+ groupId: 'groupId',
405
+ sessionType: 'BREAKOUT',
406
+ status: 'active',
407
+ breakoutMoveId: null,
408
+ });
409
+ assert.equal(breakouts.breakoutMoveId, 'move-id-1');
410
+ });
411
+
377
412
  it('updates the current breakout session, call onBreakoutJoinResponse when session changed', () => {
378
413
  breakouts.webex.meetings = {
379
414
  getMeetingByType: sinon.stub().returns({
@@ -431,6 +466,111 @@ describe('plugin-meetings', () => {
431
466
  });
432
467
  });
433
468
 
469
+ describe('#submitLLMBreakoutJoinResponseMetric', () => {
470
+ let onBreakoutJoinResponseSpy;
471
+
472
+ const setupReadyToEmit = () => {
473
+ breakouts.webex.meetings = {
474
+ getMeetingByType: sinon.stub().returns({id: 'meeting-id'}),
475
+ };
476
+ breakouts.webex.internal.newMetrics = {submitClientEvent: sinon.stub()};
477
+ breakouts.webex.internal.llm.getWebSocketUrl = sinon.stub().returns('wss://llm');
478
+ breakouts.breakoutMoveId = 'moveId';
479
+ breakouts.currentBreakoutSession.set({sessionId: 'sessionId', groupId: 'groupId'});
480
+ breakouts.llmBreakoutJoinResponseInfo = {
481
+ breakoutMoveId: 'moveId',
482
+ meeting: {id: 'meeting-id'},
483
+ llmLatency: {clientLLMWebSocketConnectTime: 1},
484
+ };
485
+ };
486
+
487
+ beforeEach(() => {
488
+ onBreakoutJoinResponseSpy = sinon.stub(breakoutEvent, 'onBreakoutJoinResponse');
489
+ });
490
+
491
+ afterEach(() => {
492
+ onBreakoutJoinResponseSpy.restore();
493
+ });
494
+
495
+ it('emits the join response while an active breakout is in progress', () => {
496
+ setupReadyToEmit();
497
+ breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.BREAKOUT);
498
+ breakouts.set('status', BREAKOUTS.STATUS.OPEN);
499
+
500
+ breakouts.submitLLMBreakoutJoinResponseMetric();
501
+
502
+ assert.calledOnce(onBreakoutJoinResponseSpy);
503
+ const eventInfoArg = onBreakoutJoinResponseSpy.getCall(0).args[0];
504
+ assert.equal(eventInfoArg.breakoutMoveId, 'moveId');
505
+ assert.deepEqual(eventInfoArg.llmLatency, {clientLLMWebSocketConnectTime: 1});
506
+ assert.equal(eventInfoArg.llmWebsocketUrl, 'wss://llm');
507
+ assert.equal(eventInfoArg.meeting.id, 'meeting-id');
508
+ assert.equal(eventInfoArg.currentSession.sessionId, 'sessionId');
509
+ assert.equal(eventInfoArg.currentSession.groupId, 'groupId');
510
+ assert.isUndefined(eventInfoArg.error);
511
+ assert.isUndefined(breakouts.llmBreakoutJoinResponseInfo);
512
+ });
513
+
514
+ it('emits the join response after returning to the main session', () => {
515
+ setupReadyToEmit();
516
+ breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.MAIN);
517
+ breakouts.currentBreakoutSession.set({sessionType: BREAKOUTS.SESSION_TYPES.MAIN});
518
+
519
+ breakouts.submitLLMBreakoutJoinResponseMetric();
520
+
521
+ assert.calledOnce(onBreakoutJoinResponseSpy);
522
+ const eventInfoArg = onBreakoutJoinResponseSpy.getCall(0).args[0];
523
+ assert.equal(eventInfoArg.breakoutMoveId, 'moveId');
524
+ assert.deepEqual(eventInfoArg.llmLatency, {clientLLMWebSocketConnectTime: 1});
525
+ assert.equal(eventInfoArg.llmWebsocketUrl, 'wss://llm');
526
+ assert.equal(eventInfoArg.meeting.id, 'meeting-id');
527
+ assert.equal(eventInfoArg.currentSession.sessionId, 'sessionId');
528
+ assert.equal(eventInfoArg.currentSession.groupId, 'groupId');
529
+ assert.isUndefined(eventInfoArg.error);
530
+ assert.isUndefined(breakouts.llmBreakoutJoinResponseInfo);
531
+ });
532
+
533
+ it('does not emit without a breakoutMoveId (non-breakout meeting)', () => {
534
+ setupReadyToEmit();
535
+ breakouts.breakoutMoveId = undefined;
536
+ breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.MAIN);
537
+
538
+ breakouts.submitLLMBreakoutJoinResponseMetric();
539
+
540
+ assert.notCalled(onBreakoutJoinResponseSpy);
541
+ });
542
+
543
+ it('does not emit when the LLM latency belongs to a different move id', () => {
544
+ setupReadyToEmit();
545
+ breakouts.set('sessionType', BREAKOUTS.SESSION_TYPES.MAIN);
546
+ breakouts.llmBreakoutJoinResponseInfo.breakoutMoveId = 'staleMoveId';
547
+
548
+ breakouts.submitLLMBreakoutJoinResponseMetric();
549
+
550
+ assert.notCalled(onBreakoutJoinResponseSpy);
551
+ });
552
+ });
553
+
554
+ describe('#handleLLMBreakoutJoinResponseMetric', () => {
555
+ it('stores the LLM connect response with the current breakoutMoveId and tries to emit', () => {
556
+ breakouts.breakoutMoveId = 'moveId';
557
+ breakouts.submitLLMBreakoutJoinResponseMetric = sinon.stub();
558
+
559
+ const eventInfo = {
560
+ meeting: {id: 'meeting-id'},
561
+ llmLatency: {clientLLMWebSocketConnectTime: 1},
562
+ };
563
+
564
+ breakouts.handleLLMBreakoutJoinResponseMetric(eventInfo);
565
+
566
+ assert.deepEqual(breakouts.llmBreakoutJoinResponseInfo, {
567
+ ...eventInfo,
568
+ breakoutMoveId: 'moveId',
569
+ });
570
+ assert.calledOnce(breakouts.submitLLMBreakoutJoinResponseMetric);
571
+ });
572
+ });
573
+
434
574
  describe('#updateBreakoutSessions', () => {
435
575
  const checkBreakout = (breakout, sessionId, state) => {
436
576
  assert.deepEqual(breakout.attributes, {