@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.
@@ -63,6 +63,7 @@ var LocusInfoUpdateType = exports.LocusInfoUpdateType = {
63
63
  MEETING_ENDED: 'MEETING_ENDED',
64
64
  LOCUS_NOT_FOUND: 'LOCUS_NOT_FOUND'
65
65
  };
66
+ var SYNC_METRICS_DATA_SETS = [_constants3.DataSetNames.MAIN, _constants3.DataSetNames.ATD_ACTIVE, _constants3.DataSetNames.ATD_UNMUTED];
66
67
  /**
67
68
  * This error is thrown if we receive information that the meeting has ended while we're processing some hash messages.
68
69
  * It's handled internally by HashTreeParser and results in MEETING_ENDED being sent up.
@@ -110,7 +111,8 @@ var HashTreeParser = /*#__PURE__*/function () {
110
111
  (0, _defineProperty2.default)(this, "visibleDataSetsUrl", void 0);
111
112
  // url from which we can get info about all data sets
112
113
  (0, _defineProperty2.default)(this, "webexRequest", void 0);
113
- (0, _defineProperty2.default)(this, "locusInfoUpdateCallback", void 0);
114
+ (0, _defineProperty2.default)(this, "callbacks", void 0);
115
+ (0, _defineProperty2.default)(this, "syncLatencyMeetingId", void 0);
114
116
  (0, _defineProperty2.default)(this, "visibleDataSets", void 0);
115
117
  (0, _defineProperty2.default)(this, "debugId", void 0);
116
118
  (0, _defineProperty2.default)(this, "excludedDataSets", void 0);
@@ -130,7 +132,8 @@ var HashTreeParser = /*#__PURE__*/function () {
130
132
 
131
133
  this.debugId = options.debugId;
132
134
  this.webexRequest = options.webexRequest;
133
- this.locusInfoUpdateCallback = options.locusInfoUpdateCallback;
135
+ this.callbacks = options.callbacks;
136
+ this.syncLatencyMeetingId = options.syncLatencyMeetingId;
134
137
  this.excludedDataSets = options.excludedDataSets || [];
135
138
  this.visibleDataSetsUrl = locus === null || locus === void 0 ? void 0 : (_locus$links = locus.links) === null || _locus$links === void 0 ? void 0 : (_locus$links$resource = _locus$links.resources) === null || _locus$links$resource === void 0 ? void 0 : (_locus$links$resource2 = _locus$links$resource.visibleDataSets) === null || _locus$links$resource2 === void 0 ? void 0 : _locus$links$resource2.url;
136
139
  this.setVisibleDataSets(((_options$metadata = options.metadata) === null || _options$metadata === void 0 ? void 0 : _options$metadata.visibleDataSets) || [], dataSets);
@@ -1271,6 +1274,10 @@ var HashTreeParser = /*#__PURE__*/function () {
1271
1274
  this.handleRootHashHeartBeatMessage(message);
1272
1275
  this.resetHeartbeatWatchdogs(message.dataSets);
1273
1276
  } else {
1277
+ // Completion of the sync latency metric (client.locus.sync.complete) is driven solely from
1278
+ // Meeting#processLocusLLMEvent once the matching LLM message arrives. body-mode syncs return
1279
+ // the locus state elements in the /sync HTTP response body, but per design the CA metric is
1280
+ // emitted only from the LLM message path, so no completion happens here.
1274
1281
  var updatedObjects = this.parseMessage(message, debugText);
1275
1282
  this.resetHeartbeatWatchdogs(message.dataSets);
1276
1283
  this.callLocusInfoUpdateCallback({
@@ -1280,6 +1287,33 @@ var HashTreeParser = /*#__PURE__*/function () {
1280
1287
  }
1281
1288
  }
1282
1289
 
1290
+ /**
1291
+ * Checks if Locus sync latency metrics should be collected for a dataset.
1292
+ *
1293
+ * @param {string} dataSetName dataset name
1294
+ * @param {boolean} [isInitialization=false] whether this is an initialization sync
1295
+ * @returns {boolean}
1296
+ */
1297
+ }, {
1298
+ key: "shouldCollectSyncMetrics",
1299
+ value: function shouldCollectSyncMetrics(dataSetName) {
1300
+ var isInitialization = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1301
+ return Boolean(this.callbacks.syncLatencyTracker && !isInitialization && SYNC_METRICS_DATA_SETS.includes(dataSetName));
1302
+ }
1303
+ }, {
1304
+ key: "saveSyncBackoffLatency",
1305
+ value: function saveSyncBackoffLatency(dataSetName, randomBackoffTime) {
1306
+ var _this$callbacks$syncL;
1307
+ var isInitialization = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1308
+ if (!this.shouldCollectSyncMetrics(dataSetName, isInitialization)) {
1309
+ return;
1310
+ }
1311
+ (_this$callbacks$syncL = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL === void 0 ? void 0 : _this$callbacks$syncL.saveLatency('internal.client.locus.sync.random.backoff', Math.round(randomBackoffTime), {
1312
+ meetingId: this.syncLatencyMeetingId,
1313
+ dataSetName: dataSetName
1314
+ });
1315
+ }
1316
+
1283
1317
  /**
1284
1318
  * Calls the updateInfo callback if there are any updates to report
1285
1319
  *
@@ -1330,13 +1364,13 @@ var HashTreeParser = /*#__PURE__*/function () {
1330
1364
  return true;
1331
1365
  });
1332
1366
  if (filteredUpdates.length > 0) {
1333
- this.locusInfoUpdateCallback({
1367
+ this.callbacks.locusInfoUpdateCallback({
1334
1368
  updateType: updateType,
1335
1369
  updatedObjects: filteredUpdates
1336
1370
  });
1337
1371
  }
1338
1372
  } else if (updateType !== LocusInfoUpdateType.OBJECTS_UPDATED) {
1339
- this.locusInfoUpdateCallback({
1373
+ this.callbacks.locusInfoUpdateCallback({
1340
1374
  updateType: updateType
1341
1375
  });
1342
1376
  }
@@ -1369,8 +1403,8 @@ var HashTreeParser = /*#__PURE__*/function () {
1369
1403
  key: "performSync",
1370
1404
  value: (function () {
1371
1405
  var _performSync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(dataSet, reason, isInitialization) {
1372
- var _dataSet$syncAbortCon;
1373
- var abortController, hashTree, rootHash, leavesData, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, _t3, _t4;
1406
+ var _dataSet$syncAbortCon, _this$callbacks$gener, _this$callbacks, _this$callbacks$gener2, _this$callbacks2;
1407
+ var abortController, hashTree, rootHash, shouldCollectMetrics, hashtreeTrackingId, syncTrackingId, syncRequestSent, _this$callbacks$syncL2, leavesData, receivedHashes, hashesResult, mismatchedLeaveIndexes, syncResponse, _this$callbacks$syncL3, _t3, _t4;
1374
1408
  return _regenerator.default.wrap(function (_context7) {
1375
1409
  while (1) switch (_context7.prev = _context7.next) {
1376
1410
  case 0:
@@ -1384,6 +1418,25 @@ var HashTreeParser = /*#__PURE__*/function () {
1384
1418
  dataSet.syncAbortController = abortController;
1385
1419
  hashTree = dataSet.hashTree;
1386
1420
  rootHash = hashTree.getRootHash();
1421
+ shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization); // Generate two distinct tracking ids up-front. Each Locus request must carry its own unique
1422
+ // tracking id, so the /hashtree and /sync requests must not share one. hashtreeTrackingId is
1423
+ // generated first so that syncTrackingId (forced onto the /sync request, stored in metrics, and
1424
+ // used to match the LLM broadcast message) ends up with the later/higher sequence number,
1425
+ // matching the order in which Locus sees the requests. If we never call /hashtree (single-leaf
1426
+ // or initialization syncs), hashtreeTrackingId is simply unused.
1427
+ hashtreeTrackingId = shouldCollectMetrics ? (_this$callbacks$gener = (_this$callbacks = this.callbacks).generateTrackingId) === null || _this$callbacks$gener === void 0 ? void 0 : _this$callbacks$gener.call(_this$callbacks) : undefined;
1428
+ syncTrackingId = shouldCollectMetrics ? (_this$callbacks$gener2 = (_this$callbacks2 = this.callbacks).generateTrackingId) === null || _this$callbacks$gener2 === void 0 ? void 0 : _this$callbacks$gener2.call(_this$callbacks2) : undefined;
1429
+ syncRequestSent = false;
1430
+ if (shouldCollectMetrics) {
1431
+ (_this$callbacks$syncL2 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL2 === void 0 ? void 0 : _this$callbacks$syncL2.saveTimestamp({
1432
+ key: 'internal.client.locus.sync.start',
1433
+ options: {
1434
+ meetingId: this.syncLatencyMeetingId,
1435
+ dataSetName: dataSet.name,
1436
+ trackingId: syncTrackingId
1437
+ }
1438
+ });
1439
+ }
1387
1440
  _context7.prev = 2;
1388
1441
  _loggerProxy.default.logger.info("HashTreeParser#performSync --> ".concat(this.debugId, " ").concat(reason, ", syncing data set \"").concat(dataSet.name, "\""));
1389
1442
  leavesData = {};
@@ -1397,7 +1450,10 @@ var HashTreeParser = /*#__PURE__*/function () {
1397
1450
  }
1398
1451
  _context7.prev = 3;
1399
1452
  _context7.next = 4;
1400
- return this.getHashesFromLocus(dataSet.name, rootHash);
1453
+ return this.getHashesFromLocus(dataSet.name, rootHash, {
1454
+ requestTrackingId: hashtreeTrackingId,
1455
+ metricTrackingId: syncTrackingId
1456
+ });
1401
1457
  case 4:
1402
1458
  hashesResult = _context7.sent;
1403
1459
  if (hashesResult) {
@@ -1451,9 +1507,10 @@ var HashTreeParser = /*#__PURE__*/function () {
1451
1507
  _context7.next = 12;
1452
1508
  return this.sendSyncRequestToLocus(dataSet, {
1453
1509
  isInitialization: true
1454
- });
1510
+ }, syncTrackingId);
1455
1511
  case 12:
1456
1512
  syncResponse = _context7.sent;
1513
+ syncRequestSent = true;
1457
1514
  _context7.next = 15;
1458
1515
  break;
1459
1516
  case 13:
@@ -1464,9 +1521,10 @@ var HashTreeParser = /*#__PURE__*/function () {
1464
1521
  _context7.next = 14;
1465
1522
  return this.sendSyncRequestToLocus(dataSet, {
1466
1523
  mismatchedLeavesData: leavesData
1467
- });
1524
+ }, syncTrackingId);
1468
1525
  case 14:
1469
1526
  syncResponse = _context7.sent;
1527
+ syncRequestSent = true;
1470
1528
  case 15:
1471
1529
  // sync API may return nothing (in that case data will arrive via messages)
1472
1530
  // or it may return a response in the same format as messages
@@ -1491,6 +1549,12 @@ var HashTreeParser = /*#__PURE__*/function () {
1491
1549
  }
1492
1550
  case 17:
1493
1551
  _context7.prev = 17;
1552
+ if (shouldCollectMetrics && !syncRequestSent) {
1553
+ // Drop only this sync's in-progress record (matched by its tracking id) rather than the
1554
+ // whole dataset, so a still-pending record from an earlier successful sync isn't wiped.
1555
+ // This mirrors the native client's onSyncError(syncId) which discards a single record.
1556
+ (_this$callbacks$syncL3 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL3 === void 0 ? void 0 : _this$callbacks$syncL3.clearLocusSyncLatency(dataSet.name, this.syncLatencyMeetingId, syncTrackingId);
1557
+ }
1494
1558
  dataSet.syncAbortController = undefined;
1495
1559
  return _context7.finish(17);
1496
1560
  case 18:
@@ -1788,6 +1852,7 @@ var HashTreeParser = /*#__PURE__*/function () {
1788
1852
  try {
1789
1853
  for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
1790
1854
  ds = _step1.value;
1855
+ this.saveSyncBackoffLatency(ds.name, delay);
1791
1856
  this.enqueueSyncForDataset(ds.name, 'syncAllDatasets');
1792
1857
  }
1793
1858
  } catch (err) {
@@ -1856,11 +1921,13 @@ var HashTreeParser = /*#__PURE__*/function () {
1856
1921
  return;
1857
1922
  }
1858
1923
  dataSet.hashTree.resize(receivedDataSet.leafCount);
1859
- var delay = dataSet.idleMs + this.getWeightedBackoffTime(dataSet.backoff);
1924
+ var randomBackoffTime = this.getWeightedBackoffTime(dataSet.backoff);
1925
+ var delay = dataSet.idleMs + randomBackoffTime;
1860
1926
  if (delay > 0) {
1861
1927
  if (dataSet.timer) {
1862
1928
  clearTimeout(dataSet.timer);
1863
1929
  }
1930
+ this.saveSyncBackoffLatency(dataSet.name, randomBackoffTime);
1864
1931
  dataSet.timer = setTimeout(function () {
1865
1932
  dataSet.timer = undefined;
1866
1933
  if (!dataSet.hashTree) {
@@ -1917,6 +1984,7 @@ var HashTreeParser = /*#__PURE__*/function () {
1917
1984
  debugId: _this11.debugId,
1918
1985
  dataSetName: dataSet.name
1919
1986
  });
1987
+ _this11.saveSyncBackoffLatency(dataSet.name, backoffTime);
1920
1988
  _this11.enqueueSyncForDataset(dataSet.name, "heartbeat watchdog expired");
1921
1989
  _this11.resetHeartbeatWatchdogs([dataSet]);
1922
1990
  }, delay);
@@ -1996,7 +2064,6 @@ var HashTreeParser = /*#__PURE__*/function () {
1996
2064
  key: "resumeFromMessage",
1997
2065
  value: function resumeFromMessage(message) {
1998
2066
  var _message$locusStateEl3, _metadataObject$data;
1999
- // check that message contains metadata with visible data sets - this is essential to be able to resume
2000
2067
  var metadataObject = (_message$locusStateEl3 = message.locusStateElements) === null || _message$locusStateEl3 === void 0 ? void 0 : _message$locusStateEl3.find(function (el) {
2001
2068
  return (0, _utils.isMetadata)(el);
2002
2069
  });
@@ -2083,23 +2150,55 @@ var HashTreeParser = /*#__PURE__*/function () {
2083
2150
  * Gets the current hashes from the locus for a specific data set.
2084
2151
  * @param {string} dataSetName
2085
2152
  * @param {string} currentRootHash
2153
+ * @param {Object} [trackingIds] tracking ids for the /hashtree request
2154
+ * @param {string} [trackingIds.requestTrackingId] tracking id forced onto the /hashtree HTTP request header (kept distinct from the /sync request's tracking id)
2155
+ * @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
2086
2156
  * @returns {Object|null} An object containing the hashes and leaf count, or null if the hashes match and no sync is needed
2087
2157
  */
2088
2158
  }, {
2089
2159
  key: "getHashesFromLocus",
2090
- value: function getHashesFromLocus(dataSetName, currentRootHash) {
2160
+ value: function getHashesFromLocus(dataSetName, currentRootHash, trackingIds) {
2091
2161
  var _this12 = this;
2162
+ var _ref9 = trackingIds !== null && trackingIds !== void 0 ? trackingIds : {},
2163
+ requestTrackingId = _ref9.requestTrackingId,
2164
+ metricTrackingId = _ref9.metricTrackingId;
2092
2165
  _loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(this.debugId, " Requesting hashes for data set \"").concat(dataSetName, "\""));
2093
2166
  var dataSet = this.dataSets[dataSetName];
2094
2167
  var url = "".concat(dataSet.url, "/hashtree");
2095
- return this.webexRequest({
2168
+ if (this.shouldCollectSyncMetrics(dataSetName)) {
2169
+ var _this$callbacks$syncL4;
2170
+ (_this$callbacks$syncL4 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL4 === void 0 ? void 0 : _this$callbacks$syncL4.saveTimestamp({
2171
+ key: 'internal.client.locus.hashtree.request',
2172
+ options: {
2173
+ meetingId: this.syncLatencyMeetingId,
2174
+ dataSetName: dataSetName,
2175
+ trackingId: metricTrackingId
2176
+ }
2177
+ });
2178
+ }
2179
+ return this.webexRequest(_objectSpread({
2096
2180
  method: _constants2.HTTP_VERBS.GET,
2097
2181
  uri: url,
2098
2182
  qs: {
2099
2183
  rootHash: currentRootHash
2100
2184
  }
2101
- }).then(function (response) {
2185
+ }, requestTrackingId ? {
2186
+ headers: {
2187
+ trackingid: requestTrackingId
2188
+ }
2189
+ } : {})).then(function (response) {
2102
2190
  var _response$body, _response$body2;
2191
+ if (_this12.shouldCollectSyncMetrics(dataSetName)) {
2192
+ var _this12$callbacks$syn;
2193
+ (_this12$callbacks$syn = _this12.callbacks.syncLatencyTracker) === null || _this12$callbacks$syn === void 0 ? void 0 : _this12$callbacks$syn.saveTimestamp({
2194
+ key: 'internal.client.locus.hashtree.response',
2195
+ options: {
2196
+ meetingId: _this12.syncLatencyMeetingId,
2197
+ dataSetName: dataSetName,
2198
+ trackingId: metricTrackingId
2199
+ }
2200
+ });
2201
+ }
2103
2202
  if (!response.body || (0, _lodash.isEmpty)(response.body)) {
2104
2203
  // 204 with empty body means our hashes match Locus, no sync needed
2105
2204
  _loggerProxy.default.logger.info("HashTreeParser#getHashesFromLocus --> ".concat(_this12.debugId, " Got ").concat(response.statusCode, " with empty body for data set \"").concat(dataSetName, "\", hashes match - no sync needed"));
@@ -2135,11 +2234,12 @@ var HashTreeParser = /*#__PURE__*/function () {
2135
2234
  *
2136
2235
  * @param {InternalDataSet} dataSet The data set to sync.
2137
2236
  * @param {Object} options Either `{ isInitialization: true }` for init syncs (uses leafCount=1 with empty leaf data) or `{ mismatchedLeavesData }` for normal syncs.
2138
- * @returns {Promise<HashTreeMessage|null>}
2237
+ * @param {string} [trackingId] tracking id
2238
+ * @returns {Promise<HashTreeMessage | null>}
2139
2239
  */
2140
2240
  }, {
2141
2241
  key: "sendSyncRequestToLocus",
2142
- value: function sendSyncRequestToLocus(dataSet, options) {
2242
+ value: function sendSyncRequestToLocus(dataSet, options, trackingId) {
2143
2243
  var _this13 = this;
2144
2244
  _loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(this.debugId, " Sending sync request for data set \"").concat(dataSet.name, "\""));
2145
2245
  var isInitialization = 'isInitialization' in options;
@@ -2165,14 +2265,42 @@ var HashTreeParser = /*#__PURE__*/function () {
2165
2265
  });
2166
2266
  }
2167
2267
  var ourCurrentRootHash = dataSet.hashTree ? dataSet.hashTree.getRootHash() : _constants3.EMPTY_HASH;
2168
- return this.webexRequest({
2268
+ var shouldCollectMetrics = this.shouldCollectSyncMetrics(dataSet.name, isInitialization);
2269
+ if (shouldCollectMetrics) {
2270
+ var _this$callbacks$syncL5;
2271
+ (_this$callbacks$syncL5 = this.callbacks.syncLatencyTracker) === null || _this$callbacks$syncL5 === void 0 ? void 0 : _this$callbacks$syncL5.saveTimestamp({
2272
+ key: 'internal.client.locus.sync.request',
2273
+ options: {
2274
+ meetingId: this.syncLatencyMeetingId,
2275
+ dataSetName: dataSet.name,
2276
+ trackingId: trackingId
2277
+ }
2278
+ });
2279
+ }
2280
+ return this.webexRequest(_objectSpread(_objectSpread({
2169
2281
  method: _constants2.HTTP_VERBS.POST,
2170
2282
  uri: url,
2171
2283
  qs: {
2172
2284
  rootHash: ourCurrentRootHash
2173
- },
2285
+ }
2286
+ }, trackingId ? {
2287
+ headers: {
2288
+ trackingid: trackingId
2289
+ }
2290
+ } : {}), {}, {
2174
2291
  body: body
2175
- }).then(function (resp) {
2292
+ })).then(function (resp) {
2293
+ if (shouldCollectMetrics) {
2294
+ var _this13$callbacks$syn;
2295
+ (_this13$callbacks$syn = _this13.callbacks.syncLatencyTracker) === null || _this13$callbacks$syn === void 0 ? void 0 : _this13$callbacks$syn.saveTimestamp({
2296
+ key: 'internal.client.locus.sync.response',
2297
+ options: {
2298
+ meetingId: _this13.syncLatencyMeetingId,
2299
+ dataSetName: dataSet.name,
2300
+ trackingId: trackingId
2301
+ }
2302
+ });
2303
+ }
2176
2304
  if (!resp.body || (0, _lodash.isEmpty)(resp.body)) {
2177
2305
  _loggerProxy.default.logger.info("HashTreeParser#sendSyncRequestToLocus --> ".concat(_this13.debugId, " Got ").concat(resp.statusCode, " with empty body for sync request for data set \"").concat(dataSet.name, "\", data should arrive via messages"));
2178
2306
  return null;