@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.
@@ -1,4 +1,5 @@
1
1
  import {cloneDeep, isEmpty, zip} from 'lodash';
2
+ import type {LocusSyncLatencyEventName} from '@webex/internal-plugin-metrics';
2
3
  import HashTree, {LeafDataItem} from './hashTree';
3
4
  import LoggerProxy from '../common/logs/logger-proxy';
4
5
  import Metrics from '../metrics';
@@ -61,6 +62,7 @@ interface InternalDataSet extends DataSet {
61
62
  }
62
63
 
63
64
  type WebexRequestMethod = (options: Record<string, any>) => Promise<any>;
65
+ type GenerateTrackingId = () => string | undefined;
64
66
 
65
67
  export const LocusInfoUpdateType = {
66
68
  OBJECTS_UPDATED: 'OBJECTS_UPDATED',
@@ -84,6 +86,38 @@ export type LocusInfoUpdate = {
84
86
 
85
87
  export type LocusInfoUpdateCallback = (update: LocusInfoUpdate) => void;
86
88
 
89
+ export type SyncLatencyTracker = {
90
+ saveLatency: (
91
+ key: 'internal.client.locus.sync.random.backoff',
92
+ value: number,
93
+ options: {
94
+ meetingId: string;
95
+ dataSetName: string;
96
+ }
97
+ ) => void;
98
+ saveTimestamp: (options: {
99
+ key: LocusSyncLatencyEventName;
100
+ options: {
101
+ meetingId: string;
102
+ dataSetName: string;
103
+ trackingId?: string;
104
+ };
105
+ }) => void;
106
+ clearLocusSyncLatency: (dataSetName: string, meetingId: string, trackingId?: string) => void;
107
+ };
108
+
109
+ export type HashTreeParserCallbacks = {
110
+ locusInfoUpdateCallback: LocusInfoUpdateCallback;
111
+ syncLatencyTracker?: SyncLatencyTracker;
112
+ generateTrackingId?: GenerateTrackingId;
113
+ };
114
+
115
+ const SYNC_METRICS_DATA_SETS = [
116
+ DataSetNames.MAIN,
117
+ DataSetNames.ATD_ACTIVE,
118
+ DataSetNames.ATD_UNMUTED,
119
+ ];
120
+
87
121
  interface LeafInfo {
88
122
  type: ObjectType;
89
123
  id: number;
@@ -122,12 +156,18 @@ class HashTreeParser {
122
156
  dataSets: Record<string, InternalDataSet> = {};
123
157
  visibleDataSetsUrl: string; // url from which we can get info about all data sets
124
158
  webexRequest: WebexRequestMethod;
125
- locusInfoUpdateCallback: LocusInfoUpdateCallback;
159
+ private callbacks: HashTreeParserCallbacks;
160
+ private syncLatencyMeetingId: string;
126
161
  visibleDataSets: VisibleDataSetInfo[];
127
162
  debugId: string;
128
163
  private excludedDataSets: string[];
129
164
  state: 'active' | 'stopped';
130
- private syncQueue: Array<{dataSetName: string; reason: string; isInitialization?: boolean}> = [];
165
+ private syncQueue: Array<{
166
+ dataSetName: string;
167
+ reason: string;
168
+ isInitialization?: boolean;
169
+ }> = [];
170
+
131
171
  private isSyncInProgress = false;
132
172
  // tracks whether syncAllDatasets is currently in its backoff delay phase and with what scope
133
173
  private syncAllBackoffType: SyncAllBackoffType = SyncAllBackoffType.NONE;
@@ -136,7 +176,6 @@ class HashTreeParser {
136
176
  private syncQueueProcessingPromise: Promise<void> = Promise.resolve();
137
177
  // top-level heartbeat interval from the most recent message, used as fallback when dataset-level value is missing
138
178
  private topLevelHeartbeatIntervalMs?: number;
139
-
140
179
  /**
141
180
  * Constructor for HashTreeParser
142
181
  * @param {Object} options
@@ -149,15 +188,17 @@ class HashTreeParser {
149
188
  };
150
189
  metadata: Metadata | null;
151
190
  webexRequest: WebexRequestMethod;
152
- locusInfoUpdateCallback: LocusInfoUpdateCallback;
191
+ callbacks: HashTreeParserCallbacks;
153
192
  debugId: string;
154
193
  excludedDataSets?: string[];
194
+ syncLatencyMeetingId: string;
155
195
  }) {
156
196
  const {dataSets, locus} = options.initialLocus; // extract dataSets from initialLocus
157
197
 
158
198
  this.debugId = options.debugId;
159
199
  this.webexRequest = options.webexRequest;
160
- this.locusInfoUpdateCallback = options.locusInfoUpdateCallback;
200
+ this.callbacks = options.callbacks;
201
+ this.syncLatencyMeetingId = options.syncLatencyMeetingId;
161
202
  this.excludedDataSets = options.excludedDataSets || [];
162
203
  this.visibleDataSetsUrl = locus?.links?.resources?.visibleDataSets?.url;
163
204
  this.setVisibleDataSets(options.metadata?.visibleDataSets || [], dataSets);
@@ -1175,6 +1216,10 @@ class HashTreeParser {
1175
1216
  this.handleRootHashHeartBeatMessage(message);
1176
1217
  this.resetHeartbeatWatchdogs(message.dataSets);
1177
1218
  } else {
1219
+ // Completion of the sync latency metric (client.locus.sync.complete) is driven solely from
1220
+ // Meeting#processLocusLLMEvent once the matching LLM message arrives. body-mode syncs return
1221
+ // the locus state elements in the /sync HTTP response body, but per design the CA metric is
1222
+ // emitted only from the LLM message path, so no completion happens here.
1178
1223
  const updatedObjects = this.parseMessage(message, debugText);
1179
1224
 
1180
1225
  this.resetHeartbeatWatchdogs(message.dataSets);
@@ -1185,6 +1230,40 @@ class HashTreeParser {
1185
1230
  }
1186
1231
  }
1187
1232
 
1233
+ /**
1234
+ * Checks if Locus sync latency metrics should be collected for a dataset.
1235
+ *
1236
+ * @param {string} dataSetName dataset name
1237
+ * @param {boolean} [isInitialization=false] whether this is an initialization sync
1238
+ * @returns {boolean}
1239
+ */
1240
+ private shouldCollectSyncMetrics(dataSetName: string, isInitialization = false): boolean {
1241
+ return Boolean(
1242
+ this.callbacks.syncLatencyTracker &&
1243
+ !isInitialization &&
1244
+ SYNC_METRICS_DATA_SETS.includes(dataSetName)
1245
+ );
1246
+ }
1247
+
1248
+ private saveSyncBackoffLatency(
1249
+ dataSetName: string,
1250
+ randomBackoffTime: number,
1251
+ isInitialization = false
1252
+ ) {
1253
+ if (!this.shouldCollectSyncMetrics(dataSetName, isInitialization)) {
1254
+ return;
1255
+ }
1256
+
1257
+ this.callbacks.syncLatencyTracker?.saveLatency(
1258
+ 'internal.client.locus.sync.random.backoff',
1259
+ Math.round(randomBackoffTime),
1260
+ {
1261
+ meetingId: this.syncLatencyMeetingId,
1262
+ dataSetName,
1263
+ }
1264
+ );
1265
+ }
1266
+
1188
1267
  /**
1189
1268
  * Calls the updateInfo callback if there are any updates to report
1190
1269
  *
@@ -1238,10 +1317,10 @@ class HashTreeParser {
1238
1317
  });
1239
1318
 
1240
1319
  if (filteredUpdates.length > 0) {
1241
- this.locusInfoUpdateCallback({updateType, updatedObjects: filteredUpdates});
1320
+ this.callbacks.locusInfoUpdateCallback({updateType, updatedObjects: filteredUpdates});
1242
1321
  }
1243
1322
  } else if (updateType !== LocusInfoUpdateType.OBJECTS_UPDATED) {
1244
- this.locusInfoUpdateCallback({updateType});
1323
+ this.callbacks.locusInfoUpdateCallback({updateType});
1245
1324
  }
1246
1325
  }
1247
1326
 
@@ -1281,6 +1360,29 @@ class HashTreeParser {
1281
1360
 
1282
1361
  const {hashTree} = dataSet;
1283
1362
  const rootHash = hashTree.getRootHash();
1363
+ const shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization);
1364
+ // Generate two distinct tracking ids up-front. Each Locus request must carry its own unique
1365
+ // tracking id, so the /hashtree and /sync requests must not share one. hashtreeTrackingId is
1366
+ // generated first so that syncTrackingId (forced onto the /sync request, stored in metrics, and
1367
+ // used to match the LLM broadcast message) ends up with the later/higher sequence number,
1368
+ // matching the order in which Locus sees the requests. If we never call /hashtree (single-leaf
1369
+ // or initialization syncs), hashtreeTrackingId is simply unused.
1370
+ const hashtreeTrackingId = shouldCollectMetrics
1371
+ ? this.callbacks.generateTrackingId?.()
1372
+ : undefined;
1373
+ const syncTrackingId = shouldCollectMetrics ? this.callbacks.generateTrackingId?.() : undefined;
1374
+ let syncRequestSent = false;
1375
+
1376
+ if (shouldCollectMetrics) {
1377
+ this.callbacks.syncLatencyTracker?.saveTimestamp({
1378
+ key: 'internal.client.locus.sync.start',
1379
+ options: {
1380
+ meetingId: this.syncLatencyMeetingId,
1381
+ dataSetName: dataSet.name,
1382
+ trackingId: syncTrackingId,
1383
+ },
1384
+ });
1385
+ }
1284
1386
 
1285
1387
  try {
1286
1388
  LoggerProxy.logger.info(
@@ -1295,7 +1397,10 @@ class HashTreeParser {
1295
1397
 
1296
1398
  try {
1297
1399
  // request hashes from sender
1298
- const hashesResult = await this.getHashesFromLocus(dataSet.name, rootHash);
1400
+ const hashesResult = await this.getHashesFromLocus(dataSet.name, rootHash, {
1401
+ requestTrackingId: hashtreeTrackingId,
1402
+ metricTrackingId: syncTrackingId,
1403
+ });
1299
1404
 
1300
1405
  if (!hashesResult) {
1301
1406
  // hashes match, no sync needed
@@ -1339,11 +1444,21 @@ class HashTreeParser {
1339
1444
  let syncResponse: HashTreeMessage | null = null;
1340
1445
 
1341
1446
  if (isInitialization) {
1342
- syncResponse = await this.sendSyncRequestToLocus(dataSet, {isInitialization: true});
1447
+ syncResponse = await this.sendSyncRequestToLocus(
1448
+ dataSet,
1449
+ {isInitialization: true},
1450
+ syncTrackingId
1451
+ );
1452
+
1453
+ syncRequestSent = true;
1343
1454
  } else if (Object.keys(leavesData).length > 0) {
1344
- syncResponse = await this.sendSyncRequestToLocus(dataSet, {
1345
- mismatchedLeavesData: leavesData,
1346
- });
1455
+ syncResponse = await this.sendSyncRequestToLocus(
1456
+ dataSet,
1457
+ {mismatchedLeavesData: leavesData},
1458
+ syncTrackingId
1459
+ );
1460
+
1461
+ syncRequestSent = true;
1347
1462
  }
1348
1463
 
1349
1464
  // sync API may return nothing (in that case data will arrive via messages)
@@ -1373,6 +1488,16 @@ class HashTreeParser {
1373
1488
  );
1374
1489
  }
1375
1490
  } finally {
1491
+ if (shouldCollectMetrics && !syncRequestSent) {
1492
+ // Drop only this sync's in-progress record (matched by its tracking id) rather than the
1493
+ // whole dataset, so a still-pending record from an earlier successful sync isn't wiped.
1494
+ // This mirrors the native client's onSyncError(syncId) which discards a single record.
1495
+ this.callbacks.syncLatencyTracker?.clearLocusSyncLatency(
1496
+ dataSet.name,
1497
+ this.syncLatencyMeetingId,
1498
+ syncTrackingId
1499
+ );
1500
+ }
1376
1501
  dataSet.syncAbortController = undefined;
1377
1502
  }
1378
1503
  }
@@ -1598,6 +1723,7 @@ class HashTreeParser {
1598
1723
  );
1599
1724
 
1600
1725
  for (const ds of effectiveDataSetsToSync) {
1726
+ this.saveSyncBackoffLatency(ds.name, delay);
1601
1727
  this.enqueueSyncForDataset(ds.name, 'syncAllDatasets');
1602
1728
  }
1603
1729
 
@@ -1648,13 +1774,16 @@ class HashTreeParser {
1648
1774
 
1649
1775
  dataSet.hashTree.resize(receivedDataSet.leafCount);
1650
1776
 
1651
- const delay = dataSet.idleMs + this.getWeightedBackoffTime(dataSet.backoff);
1777
+ const randomBackoffTime = this.getWeightedBackoffTime(dataSet.backoff);
1778
+ const delay = dataSet.idleMs + randomBackoffTime;
1652
1779
 
1653
1780
  if (delay > 0) {
1654
1781
  if (dataSet.timer) {
1655
1782
  clearTimeout(dataSet.timer);
1656
1783
  }
1657
1784
 
1785
+ this.saveSyncBackoffLatency(dataSet.name, randomBackoffTime);
1786
+
1658
1787
  dataSet.timer = setTimeout(() => {
1659
1788
  dataSet.timer = undefined;
1660
1789
 
@@ -1723,6 +1852,8 @@ class HashTreeParser {
1723
1852
  dataSetName: dataSet.name,
1724
1853
  });
1725
1854
 
1855
+ this.saveSyncBackoffLatency(dataSet.name, backoffTime);
1856
+
1726
1857
  this.enqueueSyncForDataset(dataSet.name, `heartbeat watchdog expired`);
1727
1858
  this.resetHeartbeatWatchdogs([dataSet]);
1728
1859
  }, delay);
@@ -1786,7 +1917,6 @@ class HashTreeParser {
1786
1917
  * @returns {void}
1787
1918
  */
1788
1919
  public resumeFromMessage(message: HashTreeMessage) {
1789
- // check that message contains metadata with visible data sets - this is essential to be able to resume
1790
1920
  const metadataObject = message.locusStateElements?.find((el) => isMetadata(el));
1791
1921
 
1792
1922
  if (!metadataObject?.data?.visibleDataSets) {
@@ -1875,9 +2005,18 @@ class HashTreeParser {
1875
2005
  * Gets the current hashes from the locus for a specific data set.
1876
2006
  * @param {string} dataSetName
1877
2007
  * @param {string} currentRootHash
2008
+ * @param {Object} [trackingIds] tracking ids for the /hashtree request
2009
+ * @param {string} [trackingIds.requestTrackingId] tracking id forced onto the /hashtree HTTP request header (kept distinct from the /sync request's tracking id)
2010
+ * @param {string} [trackingIds.metricTrackingId] tracking id (the /sync request's) under which the hashtree latency milestones are recorded, so they belong to the same sync latency record
1878
2011
  * @returns {Object|null} An object containing the hashes and leaf count, or null if the hashes match and no sync is needed
1879
2012
  */
1880
- private getHashesFromLocus(dataSetName: string, currentRootHash: string) {
2013
+ private getHashesFromLocus(
2014
+ dataSetName: string,
2015
+ currentRootHash: string,
2016
+ trackingIds?: {requestTrackingId?: string; metricTrackingId?: string}
2017
+ ) {
2018
+ const {requestTrackingId, metricTrackingId} = trackingIds ?? {};
2019
+
1881
2020
  LoggerProxy.logger.info(
1882
2021
  `HashTreeParser#getHashesFromLocus --> ${this.debugId} Requesting hashes for data set "${dataSetName}"`
1883
2022
  );
@@ -1886,14 +2025,39 @@ class HashTreeParser {
1886
2025
 
1887
2026
  const url = `${dataSet.url}/hashtree`;
1888
2027
 
2028
+ if (this.shouldCollectSyncMetrics(dataSetName)) {
2029
+ this.callbacks.syncLatencyTracker?.saveTimestamp({
2030
+ key: 'internal.client.locus.hashtree.request',
2031
+ options: {
2032
+ meetingId: this.syncLatencyMeetingId,
2033
+ dataSetName,
2034
+ trackingId: metricTrackingId,
2035
+ },
2036
+ });
2037
+ }
2038
+
1889
2039
  return this.webexRequest({
1890
2040
  method: HTTP_VERBS.GET,
1891
2041
  uri: url,
1892
2042
  qs: {
1893
2043
  rootHash: currentRootHash,
1894
2044
  },
2045
+ // Force a dedicated tracking id onto the /hashtree request so it does not share the /sync
2046
+ // request's tracking id; the tracking id interceptor leaves an already-set header untouched.
2047
+ ...(requestTrackingId ? {headers: {trackingid: requestTrackingId}} : {}),
1895
2048
  })
1896
2049
  .then((response) => {
2050
+ if (this.shouldCollectSyncMetrics(dataSetName)) {
2051
+ this.callbacks.syncLatencyTracker?.saveTimestamp({
2052
+ key: 'internal.client.locus.hashtree.response',
2053
+ options: {
2054
+ meetingId: this.syncLatencyMeetingId,
2055
+ dataSetName,
2056
+ trackingId: metricTrackingId,
2057
+ },
2058
+ });
2059
+ }
2060
+
1897
2061
  if (!response.body || isEmpty(response.body)) {
1898
2062
  // 204 with empty body means our hashes match Locus, no sync needed
1899
2063
  LoggerProxy.logger.info(
@@ -1948,11 +2112,13 @@ class HashTreeParser {
1948
2112
  *
1949
2113
  * @param {InternalDataSet} dataSet The data set to sync.
1950
2114
  * @param {Object} options Either `{ isInitialization: true }` for init syncs (uses leafCount=1 with empty leaf data) or `{ mismatchedLeavesData }` for normal syncs.
1951
- * @returns {Promise<HashTreeMessage|null>}
2115
+ * @param {string} [trackingId] tracking id
2116
+ * @returns {Promise<HashTreeMessage | null>}
1952
2117
  */
1953
2118
  private sendSyncRequestToLocus(
1954
2119
  dataSet: InternalDataSet,
1955
- options: {isInitialization: true} | {mismatchedLeavesData: Record<number, LeafDataItem[]>}
2120
+ options: {isInitialization: true} | {mismatchedLeavesData: Record<number, LeafDataItem[]>},
2121
+ trackingId?: string
1956
2122
  ): Promise<HashTreeMessage | null> {
1957
2123
  LoggerProxy.logger.info(
1958
2124
  `HashTreeParser#sendSyncRequestToLocus --> ${this.debugId} Sending sync request for data set "${dataSet.name}"`
@@ -1986,6 +2152,18 @@ class HashTreeParser {
1986
2152
  }
1987
2153
 
1988
2154
  const ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : EMPTY_HASH;
2155
+ const shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization);
2156
+
2157
+ if (shouldCollectMetrics) {
2158
+ this.callbacks.syncLatencyTracker?.saveTimestamp({
2159
+ key: 'internal.client.locus.sync.request',
2160
+ options: {
2161
+ meetingId: this.syncLatencyMeetingId,
2162
+ dataSetName: dataSet.name,
2163
+ trackingId,
2164
+ },
2165
+ });
2166
+ }
1989
2167
 
1990
2168
  return this.webexRequest({
1991
2169
  method: HTTP_VERBS.POST,
@@ -1993,9 +2171,23 @@ class HashTreeParser {
1993
2171
  qs: {
1994
2172
  rootHash: ourCurrentRootHash,
1995
2173
  },
2174
+ // Force the pre-generated tracking id onto the /sync request so Locus echoes it back on the
2175
+ // resulting LLM message; the tracking id interceptor leaves an already-set header untouched.
2176
+ ...(trackingId ? {headers: {trackingid: trackingId}} : {}),
1996
2177
  body,
1997
2178
  })
1998
2179
  .then((resp) => {
2180
+ if (shouldCollectMetrics) {
2181
+ this.callbacks.syncLatencyTracker?.saveTimestamp({
2182
+ key: 'internal.client.locus.sync.response',
2183
+ options: {
2184
+ meetingId: this.syncLatencyMeetingId,
2185
+ dataSetName: dataSet.name,
2186
+ trackingId,
2187
+ },
2188
+ });
2189
+ }
2190
+
1999
2191
  if (!resp.body || isEmpty(resp.body)) {
2000
2192
  LoggerProxy.logger.info(
2001
2193
  `HashTreeParser#sendSyncRequestToLocus --> ${this.debugId} Got ${resp.statusCode} with empty body for sync request for data set "${dataSet.name}", data should arrive via messages`
@@ -1,4 +1,6 @@
1
1
  import {isEqual, assignWith, cloneDeep, isEmpty} from 'lodash';
2
+ import uuid from 'uuid';
3
+ import {webexTrackingIdSequenceNumbers} from '@webex/webex-core';
2
4
 
3
5
  import LoggerProxy from '../common/logs/logger-proxy';
4
6
  import EventsScope from '../common/events/events-scope';
@@ -37,6 +39,7 @@ import HashTreeParser, {
37
39
  LocusInfoUpdate,
38
40
  LocusInfoUpdateType,
39
41
  Metadata,
42
+ SyncLatencyTracker,
40
43
  } from '../hashTree/hashTreeParser';
41
44
  import {HashTreeObject, ObjectType, ObjectTypeToLocusKeyMap} from '../hashTree/types';
42
45
  import {isMetadata, isSelf} from '../hashTree/utils';
@@ -46,6 +49,7 @@ import {MEETING_KEY} from '../meetings/meetings.types';
46
49
  import MeetingCollection from '../meetings/collection';
47
50
 
48
51
  export type LocusLLMEvent = {
52
+ trackingId?: string;
49
53
  data: {
50
54
  eventType: typeof LOCUSEVENT.HASH_TREE_DATA_UPDATED;
51
55
  stateElementsMessage: HashTreeMessage;
@@ -94,6 +98,11 @@ export type HashTreeParserEntry = {
94
98
  initializedFromHashTree: boolean;
95
99
  };
96
100
 
101
+ export type LocusInfoCallbacks = {
102
+ updateMeeting: (object: any) => void;
103
+ syncLatencyTracker?: SyncLatencyTracker;
104
+ };
105
+
97
106
  /**
98
107
  * Gets the replacement information
99
108
  *
@@ -262,7 +271,6 @@ export default class LocusInfo extends EventsScope {
262
271
  locusParser: any;
263
272
  meetingId: any;
264
273
  parsedLocus: any;
265
- updateMeeting: any;
266
274
  webex: any;
267
275
  aclUrl: any;
268
276
  baseSequence: any;
@@ -286,25 +294,27 @@ export default class LocusInfo extends EventsScope {
286
294
  hashTreeParsers: Map<string, HashTreeParserEntry>;
287
295
  hashTreeObjectId2ParticipantId: Map<number, string>; // mapping of hash tree object ids to participant ids
288
296
  classicVsHashTreeMismatchMetricCounter = 0;
297
+ private callbacks: LocusInfoCallbacks;
289
298
  private destroyMeetingSuspended = false;
290
299
 
291
300
  /**
292
301
  * Constructor
293
- * @param {function} updateMeeting callback to update the meeting object from an object
302
+ * @param {Object} callbacks callbacks used by LocusInfo
303
+ * @param {function} callbacks.updateMeeting callback to update the meeting object from an object
294
304
  * @param {object} webex
295
305
  * @param {string} meetingId
296
306
  * @returns {undefined}
297
307
  */
298
- constructor(updateMeeting, webex, meetingId) {
308
+ constructor(callbacks: LocusInfoCallbacks, webex: any, meetingId: any) {
299
309
  super();
300
310
  this.parsedLocus = {
301
311
  states: [],
302
312
  };
313
+ this.callbacks = callbacks;
303
314
  this.webex = webex;
304
315
  this.emitChange = false;
305
316
  this.compareAndUpdateFlags = {};
306
317
  this.meetingId = meetingId;
307
- this.updateMeeting = updateMeeting;
308
318
  this.locusParser = new LocusDeltaParser();
309
319
  this.hashTreeParsers = new Map();
310
320
  this.hashTreeObjectId2ParticipantId = new Map();
@@ -555,9 +565,26 @@ export default class LocusInfo extends EventsScope {
555
565
  initialLocus,
556
566
  metadata,
557
567
  webexRequest: this.webex.request.bind(this.webex),
558
- locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
568
+ callbacks: {
569
+ locusInfoUpdateCallback: this.updateFromHashTree.bind(this, locusUrl),
570
+ syncLatencyTracker: this.callbacks.syncLatencyTracker,
571
+ // Reuse webex-core's tracking-id interceptor sequence (exposed publicly via
572
+ // webexTrackingIdSequenceNumbers) so Locus requests share the client's unified
573
+ // ${sessionId}_${sequence} tracking id space instead of minting an unrelated id. Fall
574
+ // back to a uuid on the rare chance the interceptor hasn't issued any request yet (and so
575
+ // isn't in the map). The value is opaque to the metrics layer and is forced onto the
576
+ // /hashtree and /sync request headers.
577
+ generateTrackingId: () => {
578
+ const interceptor = [...webexTrackingIdSequenceNumbers.keys()].find(
579
+ (candidate) => candidate?.webex === this.webex
580
+ );
581
+
582
+ return `${this.webex.sessionId}_${interceptor ? interceptor.sequence : uuid.v4()}`;
583
+ },
584
+ },
559
585
  debugId: `HT-${locusUrl.split('/')?.pop()?.substring(0, 4)}`,
560
586
  excludedDataSets: this.webex.config.meetings.locus?.excludedDataSets,
587
+ syncLatencyMeetingId: this.meetingId,
561
588
  });
562
589
 
563
590
  // When a new HashTreeParser is created, previous one should be stopped.
@@ -1753,7 +1780,7 @@ export default class LocusInfo extends EventsScope {
1753
1780
  // @ts-ignore
1754
1781
  const partner = this.getLocusPartner(this.participants, this.self);
1755
1782
 
1756
- this.updateMeeting({partner});
1783
+ this.callbacks.updateMeeting({partner});
1757
1784
 
1758
1785
  // Check if guest user needs to be checked here
1759
1786
 
@@ -2302,7 +2329,7 @@ export default class LocusInfo extends EventsScope {
2302
2329
  if (hasEntryExitToneChanged) {
2303
2330
  const {entryExitTone} = current;
2304
2331
 
2305
- this.updateMeeting({entryExitTone});
2332
+ this.callbacks.updateMeeting({entryExitTone});
2306
2333
 
2307
2334
  this.emitScoped(
2308
2335
  {
@@ -2321,7 +2348,7 @@ export default class LocusInfo extends EventsScope {
2321
2348
  if (hasVideoEnabledChanged) {
2322
2349
  const {videoEnabled} = current;
2323
2350
 
2324
- this.updateMeeting({unmuteVideoAllowed: videoEnabled});
2351
+ this.callbacks.updateMeeting({unmuteVideoAllowed: videoEnabled});
2325
2352
 
2326
2353
  this.emitScoped(
2327
2354
  {
@@ -2413,14 +2440,14 @@ export default class LocusInfo extends EventsScope {
2413
2440
  updateConversationUrl(conversationUrl: string, info: any) {
2414
2441
  if (conversationUrl && !isEqual(this.conversationUrl, conversationUrl)) {
2415
2442
  this.conversationUrl = conversationUrl;
2416
- this.updateMeeting({conversationUrl});
2443
+ this.callbacks.updateMeeting({conversationUrl});
2417
2444
  } else if (
2418
2445
  info &&
2419
2446
  info.conversationUrl &&
2420
2447
  !isEqual(this.conversationUrl, info.conversationUrl)
2421
2448
  ) {
2422
2449
  this.conversationUrl = info.conversationUrl;
2423
- this.updateMeeting({conversationUrl: info.conversationUrl});
2450
+ this.callbacks.updateMeeting({conversationUrl: info.conversationUrl});
2424
2451
  }
2425
2452
  }
2426
2453
 
@@ -2482,7 +2509,7 @@ export default class LocusInfo extends EventsScope {
2482
2509
  if (fullState && !isEqual(this.fullState, fullState)) {
2483
2510
  const result = FullState.getFullState(this.fullState, fullState);
2484
2511
 
2485
- this.updateMeeting(result.current);
2512
+ this.callbacks.updateMeeting(result.current);
2486
2513
 
2487
2514
  if (result.updates.meetingStateChangedTo) {
2488
2515
  this.emitScoped(
@@ -2526,7 +2553,7 @@ export default class LocusInfo extends EventsScope {
2526
2553
  if (host && !isEqual(this.host, host)) {
2527
2554
  const parsedHosts = HostUtils.getHosts(this.host, host);
2528
2555
 
2529
- this.updateMeeting(parsedHosts.current);
2556
+ this.callbacks.updateMeeting(parsedHosts.current);
2530
2557
  this.parsedLocus.host = parsedHosts.current;
2531
2558
  if (parsedHosts.updates.isNewHost) {
2532
2559
  this.compareAndUpdateFlags.compareSelfAndHost = true;
@@ -2594,7 +2621,7 @@ export default class LocusInfo extends EventsScope {
2594
2621
  this.info = infoToParse;
2595
2622
  this.parsedLocus.info = parsedInfo.current;
2596
2623
  // Parses the info and adds necessary values
2597
- this.updateMeeting(parsedInfo.current);
2624
+ this.callbacks.updateMeeting(parsedInfo.current);
2598
2625
 
2599
2626
  this.emitScoped(
2600
2627
  {
@@ -2623,7 +2650,7 @@ export default class LocusInfo extends EventsScope {
2623
2650
 
2624
2651
  const parsedEmbeddedApps = EmbeddedAppsUtils.parse(embeddedApps);
2625
2652
 
2626
- this.updateMeeting({embeddedApps: parsedEmbeddedApps});
2653
+ this.callbacks.updateMeeting({embeddedApps: parsedEmbeddedApps});
2627
2654
 
2628
2655
  this.emitScoped(
2629
2656
  {
@@ -2648,7 +2675,7 @@ export default class LocusInfo extends EventsScope {
2648
2675
  if (mediaShares && (!isEqual(this.mediaShares, mediaShares) || forceUpdate)) {
2649
2676
  const parsedMediaShares = MediaSharesUtils.getMediaShares(this.mediaShares, mediaShares);
2650
2677
 
2651
- this.updateMeeting(parsedMediaShares.current);
2678
+ this.callbacks.updateMeeting(parsedMediaShares.current);
2652
2679
  this.parsedLocus.mediaShares = parsedMediaShares.current;
2653
2680
  this.mediaShares = mediaShares;
2654
2681
  this.emitScoped(
@@ -2694,7 +2721,7 @@ export default class LocusInfo extends EventsScope {
2694
2721
  this.participants // using this.participants instead of locus.participants here, because with delta DTOs locus.participants will only contain a small subset of participants
2695
2722
  );
2696
2723
 
2697
- this.updateMeeting(parsedSelves.current);
2724
+ this.callbacks.updateMeeting(parsedSelves.current);
2698
2725
  this.parsedLocus.self = parsedSelves.current;
2699
2726
 
2700
2727
  const element = this.parsedLocus.states[this.parsedLocus.states.length - 1];
@@ -2712,7 +2739,7 @@ export default class LocusInfo extends EventsScope {
2712
2739
  );
2713
2740
 
2714
2741
  if (result?.sipUri) {
2715
- this.updateMeeting(result);
2742
+ this.callbacks.updateMeeting(result);
2716
2743
  }
2717
2744
 
2718
2745
  if (parsedSelves.updates.moderatorChanged) {
@@ -2979,7 +3006,7 @@ export default class LocusInfo extends EventsScope {
2979
3006
  updateLocusUrl(url: string, isMainLocus = true) {
2980
3007
  if (url && this.url !== url) {
2981
3008
  this.url = url;
2982
- this.updateMeeting({locusUrl: url});
3009
+ this.callbacks.updateMeeting({locusUrl: url});
2983
3010
  this.emitScoped(
2984
3011
  {
2985
3012
  file: 'locus-info',