@atlaskit/collab-provider 9.43.2 → 9.44.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.44.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#158040](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158040)
8
+ [`3dbb9d2f67580`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3dbb9d2f67580) -
9
+ log when error processing steps from different clientId, same userId
10
+
11
+ ## 9.43.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#154186](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154186)
16
+ [`5c316170d29dd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c316170d29dd) -
17
+ Bump @atlaskit/adf-schema to 42.3.1
18
+ - Updated dependencies
19
+
3
20
  ## 9.43.2
4
21
 
5
22
  ### Patch Changes
@@ -5,8 +5,7 @@
5
5
  "target": "es5",
6
6
  "composite": true,
7
7
  "outDir": "../dist",
8
- "rootDir": "../",
9
- "baseUrl": "../"
8
+ "rootDir": "../"
10
9
  },
11
10
  "include": [
12
11
  "../src/**/*.ts",
@@ -189,12 +189,37 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
189
189
  }
190
190
  }, _callee2, null, [[0, 12]]);
191
191
  })));
192
+ (0, _defineProperty2.default)(this, "isStepsFromNewClientIdForSameUserId", function (steps) {
193
+ try {
194
+ if (!Array.isArray(steps) || steps.length === 0) {
195
+ return false;
196
+ }
197
+ var clientIds = new Set(steps.map(function (_ref3) {
198
+ var clientId = _ref3.clientId;
199
+ return clientId;
200
+ }));
201
+ if (!clientIds.has(_this.clientId)) {
202
+ var userIds = new Set(steps.map(function (_ref4) {
203
+ var userId = _ref4.userId;
204
+ return userId;
205
+ }));
206
+ if (userIds.has(_this.getUserId())) {
207
+ return true;
208
+ }
209
+ }
210
+ return false;
211
+ } catch (err) {
212
+ var _this$analyticsHelper8;
213
+ (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
214
+ return false;
215
+ }
216
+ });
192
217
  (0, _defineProperty2.default)(this, "getUnconfirmedStepsOrigins", function () {
193
218
  var _this$getState3, _sendableSteps;
194
219
  var state = (_this$getState3 = _this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(_this);
195
220
  if (!state) {
196
- var _this$analyticsHelper8;
197
- (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
221
+ var _this$analyticsHelper9;
222
+ (_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
198
223
  return;
199
224
  }
200
225
  return (_sendableSteps = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
@@ -203,8 +228,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
203
228
  var _this$getState4, _sendableSteps2;
204
229
  var state = (_this$getState4 = _this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(_this);
205
230
  if (!state) {
206
- var _this$analyticsHelper9;
207
- (_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
231
+ var _this$analyticsHelper10;
232
+ (_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
208
233
  return;
209
234
  }
210
235
  return (_sendableSteps2 = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
@@ -239,13 +264,13 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
239
264
  _this.stepQueue.queueSteps(data);
240
265
  _this.throttledCatchupv2(_const.CatchupEventReason.STEPS_ADDED);
241
266
  }
242
- _this.participantsService.updateLastActive(data.steps.map(function (_ref3) {
243
- var userId = _ref3.userId;
267
+ _this.participantsService.updateLastActive(data.steps.map(function (_ref5) {
268
+ var userId = _ref5.userId;
244
269
  return userId;
245
270
  }));
246
271
  } catch (stepsAddedError) {
247
- var _this$analyticsHelper10;
248
- (_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
272
+ var _this$analyticsHelper11;
273
+ (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
249
274
  _this.onErrorHandled({
250
275
  message: 'Error while adding steps in the provider',
251
276
  data: {
@@ -258,12 +283,12 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
258
283
  });
259
284
  // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
260
285
  (0, _defineProperty2.default)(this, "onRestore", /*#__PURE__*/function () {
261
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref4) {
262
- var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper11, _this$analyticsHelper12, _this$analyticsHelper13;
286
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref6) {
287
+ var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper14;
263
288
  return _regenerator.default.wrap(function _callee3$(_context3) {
264
289
  while (1) switch (_context3.prev = _context3.next) {
265
290
  case 0:
266
- doc = _ref4.doc, version = _ref4.version, metadata = _ref4.metadata, targetClientId = _ref4.targetClientId;
291
+ doc = _ref6.doc, version = _ref6.version, metadata = _ref6.metadata, targetClientId = _ref6.targetClientId;
267
292
  if (!(targetClientId && _this.clientId !== targetClientId)) {
268
293
  _context3.next = 3;
269
294
  break;
@@ -310,7 +335,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
310
335
  _this.applyLocalSteps(unconfirmedSteps);
311
336
  }
312
337
  case 17:
313
- (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
338
+ (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
314
339
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
315
340
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
316
341
  useReconcile: useReconcile,
@@ -323,14 +348,14 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
323
348
  case 20:
324
349
  _context3.prev = 20;
325
350
  _context3.t0 = _context3["catch"](8);
326
- (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
351
+ (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
327
352
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
328
353
  useReconcile: useReconcile,
329
354
  clientId: _this.clientId,
330
355
  targetClientId: targetClientId,
331
356
  triggeredByCatchup: targetClientId ? true : false
332
357
  });
333
- (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
358
+ (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_context3.t0, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
334
359
  _this.onErrorHandled({
335
360
  message: 'Caught error while trying to recover the document',
336
361
  data: {
@@ -346,11 +371,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
346
371
  }, _callee3, null, [[8, 20]]);
347
372
  }));
348
373
  return function (_x2) {
349
- return _ref5.apply(this, arguments);
374
+ return _ref7.apply(this, arguments);
350
375
  };
351
376
  }());
352
377
  (0, _defineProperty2.default)(this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
353
- var _this$analyticsHelper14, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper15, _this$analyticsHelper16, _measure2;
378
+ var _this$analyticsHelper15, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper16, _this$analyticsHelper17, _measure2;
354
379
  return _regenerator.default.wrap(function _callee4$(_context4) {
355
380
  while (1) switch (_context4.prev = _context4.next) {
356
381
  case 0:
@@ -385,7 +410,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
385
410
  };
386
411
  case 20:
387
412
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
388
- (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
413
+ (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
389
414
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
390
415
  });
391
416
  _this.aggressiveCatchup = false;
@@ -395,10 +420,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
395
420
  _context4.t1 = _context4["catch"](1);
396
421
  _this.aggressiveCatchup = false;
397
422
  _measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
398
- (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
423
+ (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
399
424
  latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
400
425
  });
401
- (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
426
+ (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
402
427
  throw _context4.t1;
403
428
  case 33:
404
429
  case "end":
@@ -406,11 +431,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
406
431
  }
407
432
  }, _callee4, null, [[1, 26], [3, 11]]);
408
433
  })));
409
- (0, _defineProperty2.default)(this, "updateDocument", function (_ref7) {
410
- var doc = _ref7.doc,
411
- version = _ref7.version,
412
- metadata = _ref7.metadata,
413
- reserveCursor = _ref7.reserveCursor;
434
+ (0, _defineProperty2.default)(this, "updateDocument", function (_ref9) {
435
+ var doc = _ref9.doc,
436
+ version = _ref9.version,
437
+ metadata = _ref9.metadata,
438
+ reserveCursor = _ref9.reserveCursor;
414
439
  _this.providerEmitCallback('init', _objectSpread({
415
440
  doc: doc,
416
441
  version: version,
@@ -426,7 +451,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
426
451
  // ESS-5023: only emit error event if updated client version is still behind server version
427
452
  // client version could become higher than server version due to user editing or plugin adding steps
428
453
  if (updatedVersion < version) {
429
- var _doc$content, _this$analyticsHelper17;
454
+ var _doc$content, _this$analyticsHelper18;
430
455
  var error = new _customErrors.UpdateDocumentError('Failed to update the document', {
431
456
  newVersion: version,
432
457
  editorVersion: updatedVersion,
@@ -434,7 +459,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
434
459
  docHasContent: (doc === null || doc === void 0 || (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
435
460
  isDocContentValid: isDocContentValid
436
461
  });
437
- (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(error, 'Failed to update the document in document service');
462
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendErrorEvent(error, 'Failed to update the document in document service');
438
463
  if (_this.enableErrorOnFailedDocumentApply) {
439
464
  _this.onErrorHandled({
440
465
  message: 'The provider failed to apply changes to the editor',
@@ -451,8 +476,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
451
476
  }
452
477
  // Otherwise just fail silently for now
453
478
  } else {
454
- var _this$analyticsHelper18, _doc$content2;
455
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.UPDATE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
479
+ var _this$analyticsHelper19, _doc$content2;
480
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.UPDATE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
456
481
  newVersion: version,
457
482
  editorVersion: updatedVersion,
458
483
  isDocTruthy: !!doc,
@@ -465,8 +490,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
465
490
  try {
466
491
  var _this$getState5;
467
492
  if (!((_this$getState5 = _this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(_this))) {
468
- var _this$analyticsHelper19;
469
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
493
+ var _this$analyticsHelper20;
494
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
470
495
  }
471
496
  var state = _this.getState();
472
497
  var content = (doc.content || []).map(function (child) {
@@ -489,7 +514,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
489
514
  * @throws {Error} Couldn't sync the steps after retrying 30 times
490
515
  */
491
516
  (0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
492
- var unconfirmedSteps, _this$getState6, _this$analyticsHelper21, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper20, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper22, _this$analyticsHelper23, _measure3;
517
+ var unconfirmedSteps, _this$getState6, _this$analyticsHelper22, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper21, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper23, _this$analyticsHelper24, _measure3;
493
518
  return _regenerator.default.wrap(function _callee5$(_context5) {
494
519
  while (1) switch (_context5.prev = _context5.next) {
495
520
  case 0:
@@ -508,7 +533,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
508
533
  lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
509
534
  isLastTrConfirmed = false;
510
535
  if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
511
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
536
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
512
537
  }
513
538
  case 9:
514
539
  if (isLastTrConfirmed) {
@@ -555,7 +580,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
555
580
  break;
556
581
  case 22:
557
582
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
558
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
583
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
559
584
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
560
585
  // upon success, emit the total number of unconfirmed steps we synced
561
586
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -567,11 +592,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
567
592
  _context5.prev = 26;
568
593
  _context5.t0 = _context5["catch"](1);
569
594
  _measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
570
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
595
+ (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
571
596
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
572
597
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
573
598
  });
574
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
599
+ (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
575
600
  throw _context5.t0;
576
601
  case 32:
577
602
  case "end":
@@ -580,17 +605,17 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
580
605
  }, _callee5, null, [[1, 26]]);
581
606
  })));
582
607
  (0, _defineProperty2.default)(this, "onStepRejectedError", function () {
583
- var _this$analyticsHelper24;
608
+ var _this$analyticsHelper25;
584
609
  _this.stepRejectCounter++;
585
610
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
586
- (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
611
+ (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
587
612
  count: _this.stepRejectCounter
588
613
  });
589
614
  var maxRetries = _this.aggressiveCatchup ? _provider.MAX_STEP_REJECTED_ERROR_AGGRESSIVE : _provider.MAX_STEP_REJECTED_ERROR;
590
615
  if (_this.stepRejectCounter >= maxRetries) {
591
- var _this$analyticsHelper25;
616
+ var _this$analyticsHelper26;
592
617
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
593
- (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
618
+ (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
594
619
  _this.throttledCatchupv2(_const.CatchupEventReason.STEPS_REJECTED);
595
620
  } else {
596
621
  // If committing steps failed try again automatically in 1s
@@ -621,15 +646,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
621
646
  value: function getVersionFromCollabState(state, resource) {
622
647
  var collabState = (0, _prosemirrorCollab.getCollabState)(state);
623
648
  if (!collabState) {
624
- var _this$analyticsHelper26;
625
- (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
649
+ var _this$analyticsHelper27;
650
+ (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
626
651
  return 0;
627
652
  }
628
653
 
629
654
  // This should not happen in usual, just add error event in case it happens
630
655
  if (collabState.version === undefined) {
631
- var _this$analyticsHelper27;
632
- (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
656
+ var _this$analyticsHelper28;
657
+ (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
633
658
  return 0;
634
659
  }
635
660
  return collabState.version;
@@ -663,8 +688,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
663
688
  logger("Processing data. Version \"".concat(version, "\"."));
664
689
  if (steps !== null && steps !== void 0 && steps.length) {
665
690
  try {
666
- var clientIds = steps.map(function (_ref9) {
667
- var clientId = _ref9.clientId;
691
+ var clientIds = steps.map(function (_ref11) {
692
+ var clientId = _ref11.clientId;
668
693
  return clientId;
669
694
  });
670
695
  this.providerEmitCallback('data', {
@@ -683,19 +708,21 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
683
708
  }, 100);
684
709
  }
685
710
  } catch (error) {
686
- var _this$analyticsHelper28;
711
+ var _this$analyticsHelper29;
712
+ // ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
713
+ var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
687
714
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
688
- (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(error, 'Error while processing steps');
715
+ (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
689
716
  this.throttledCatchupv2(_const.CatchupEventReason.PROCESS_STEPS);
690
717
  }
691
718
  }
692
719
  }
693
720
  }, {
694
721
  key: "setup",
695
- value: function setup(_ref10) {
696
- var getState = _ref10.getState,
697
- onSyncUpError = _ref10.onSyncUpError,
698
- clientId = _ref10.clientId;
722
+ value: function setup(_ref12) {
723
+ var getState = _ref12.getState,
724
+ onSyncUpError = _ref12.onSyncUpError,
725
+ clientId = _ref12.clientId;
699
726
  this.getState = getState;
700
727
  this.onSyncUpError = onSyncUpError || noop;
701
728
  this.clientId = clientId;
@@ -715,8 +742,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
715
742
  var _this$getState7;
716
743
  var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
717
744
  if (!state) {
718
- var _this$analyticsHelper29;
719
- (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
745
+ var _this$analyticsHelper30;
746
+ (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
720
747
  return;
721
748
  }
722
749
  this.send(null, null, state, sendAnalyticsEvent);
@@ -741,8 +768,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
741
768
  // to ensure that analytics events with the number of unconfirmed steps is only
742
769
  // sent once on connection (as opposed to on every step)
743
770
  if (sendAnalyticsEvent) {
744
- var _this$analyticsHelper30;
745
- (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
771
+ var _this$analyticsHelper31;
772
+ (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
746
773
  numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
747
774
  });
748
775
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "9.43.2";
8
+ var version = exports.version = "9.44.0";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -161,12 +161,35 @@ export class DocumentService {
161
161
  throw error; // Reject the promise so the consumer can react to it failing
162
162
  }
163
163
  });
164
+ _defineProperty(this, "isStepsFromNewClientIdForSameUserId", steps => {
165
+ try {
166
+ if (!Array.isArray(steps) || steps.length === 0) {
167
+ return false;
168
+ }
169
+ const clientIds = new Set(steps.map(({
170
+ clientId
171
+ }) => clientId));
172
+ if (!clientIds.has(this.clientId)) {
173
+ const userIds = new Set(steps.map(({
174
+ userId
175
+ }) => userId));
176
+ if (userIds.has(this.getUserId())) {
177
+ return true;
178
+ }
179
+ }
180
+ return false;
181
+ } catch (err) {
182
+ var _this$analyticsHelper8;
183
+ (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
184
+ return false;
185
+ }
186
+ });
164
187
  _defineProperty(this, "getUnconfirmedStepsOrigins", () => {
165
188
  var _this$getState3, _sendableSteps;
166
189
  const state = (_this$getState3 = this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(this);
167
190
  if (!state) {
168
- var _this$analyticsHelper8;
169
- (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
191
+ var _this$analyticsHelper9;
192
+ (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
170
193
  return;
171
194
  }
172
195
  return (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
@@ -175,8 +198,8 @@ export class DocumentService {
175
198
  var _this$getState4, _sendableSteps2;
176
199
  const state = (_this$getState4 = this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(this);
177
200
  if (!state) {
178
- var _this$analyticsHelper9;
179
- (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
201
+ var _this$analyticsHelper10;
202
+ (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
180
203
  return;
181
204
  }
182
205
  return (_sendableSteps2 = sendableSteps(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
@@ -215,8 +238,8 @@ export class DocumentService {
215
238
  userId
216
239
  }) => userId));
217
240
  } catch (stepsAddedError) {
218
- var _this$analyticsHelper10;
219
- (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
241
+ var _this$analyticsHelper11;
242
+ (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
220
243
  this.onErrorHandled({
221
244
  message: 'Error while adding steps in the provider',
222
245
  data: {
@@ -243,7 +266,7 @@ export class DocumentService {
243
266
  const currentState = await this.getCurrentState();
244
267
  const useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && currentState && !targetClientId);
245
268
  try {
246
- var _this$analyticsHelper11;
269
+ var _this$analyticsHelper12;
247
270
  // Reset the editor,
248
271
  // - Replace the document, keep in sync with the server
249
272
  // - Replace the version number, so editor is in sync with NCS server and can commit new changes.
@@ -266,7 +289,7 @@ export class DocumentService {
266
289
  // as this results in all changes made while the client was out of sync being lost
267
290
  this.applyLocalSteps(unconfirmedSteps);
268
291
  }
269
- (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
292
+ (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
270
293
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
271
294
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
272
295
  useReconcile,
@@ -275,15 +298,15 @@ export class DocumentService {
275
298
  triggeredByCatchup: targetClientId ? true : false
276
299
  });
277
300
  } catch (restoreError) {
278
- var _this$analyticsHelper12, _this$analyticsHelper13;
279
- (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
301
+ var _this$analyticsHelper13, _this$analyticsHelper14;
302
+ (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
280
303
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
281
304
  useReconcile,
282
305
  clientId: this.clientId,
283
306
  targetClientId,
284
307
  triggeredByCatchup: targetClientId ? true : false
285
308
  });
286
- (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
309
+ (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
287
310
  this.onErrorHandled({
288
311
  message: 'Caught error while trying to recover the document',
289
312
  data: {
@@ -297,7 +320,7 @@ export class DocumentService {
297
320
  _defineProperty(this, "getFinalAcknowledgedState", async () => {
298
321
  this.aggressiveCatchup = true;
299
322
  try {
300
- var _this$analyticsHelper14;
323
+ var _this$analyticsHelper15;
301
324
  startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
302
325
  let finalAcknowledgedState;
303
326
  try {
@@ -314,19 +337,19 @@ export class DocumentService {
314
337
  };
315
338
  }
316
339
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
317
- (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
340
+ (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
318
341
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
319
342
  });
320
343
  this.aggressiveCatchup = false;
321
344
  return finalAcknowledgedState;
322
345
  } catch (error) {
323
- var _this$analyticsHelper15, _this$analyticsHelper16;
346
+ var _this$analyticsHelper16, _this$analyticsHelper17;
324
347
  this.aggressiveCatchup = false;
325
348
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
326
- (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
349
+ (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
327
350
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
328
351
  });
329
- (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
352
+ (_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
330
353
  throw error; // Reject the promise so the consumer can react to it failing
331
354
  }
332
355
  });
@@ -352,7 +375,7 @@ export class DocumentService {
352
375
  // ESS-5023: only emit error event if updated client version is still behind server version
353
376
  // client version could become higher than server version due to user editing or plugin adding steps
354
377
  if (updatedVersion < version) {
355
- var _doc$content, _this$analyticsHelper17;
378
+ var _doc$content, _this$analyticsHelper18;
356
379
  const error = new UpdateDocumentError('Failed to update the document', {
357
380
  newVersion: version,
358
381
  editorVersion: updatedVersion,
@@ -360,7 +383,7 @@ export class DocumentService {
360
383
  docHasContent: (doc === null || doc === void 0 ? void 0 : (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
361
384
  isDocContentValid
362
385
  });
363
- (_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent(error, 'Failed to update the document in document service');
386
+ (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent(error, 'Failed to update the document in document service');
364
387
  if (this.enableErrorOnFailedDocumentApply) {
365
388
  this.onErrorHandled({
366
389
  message: 'The provider failed to apply changes to the editor',
@@ -377,8 +400,8 @@ export class DocumentService {
377
400
  }
378
401
  // Otherwise just fail silently for now
379
402
  } else {
380
- var _this$analyticsHelper18, _doc$content2;
381
- (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
403
+ var _this$analyticsHelper19, _doc$content2;
404
+ (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
382
405
  newVersion: version,
383
406
  editorVersion: updatedVersion,
384
407
  isDocTruthy: !!doc,
@@ -391,8 +414,8 @@ export class DocumentService {
391
414
  try {
392
415
  var _this$getState5;
393
416
  if (!((_this$getState5 = this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(this))) {
394
- var _this$analyticsHelper19;
395
- (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
417
+ var _this$analyticsHelper20;
418
+ (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
396
419
  }
397
420
  const state = this.getState();
398
421
  const content = (doc.content || []).map(child => state.schema.nodeFromJSON(child));
@@ -416,7 +439,7 @@ export class DocumentService {
416
439
  const unconfirmedSteps = this.getUnconfirmedSteps();
417
440
  try {
418
441
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
419
- var _this$getState6, _this$analyticsHelper21;
442
+ var _this$getState6, _this$analyticsHelper22;
420
443
  startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
421
444
  let count = 0;
422
445
  // We use origins here as steps can be rebased. When steps are rebased a new step is created.
@@ -427,8 +450,8 @@ export class DocumentService {
427
450
  const lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
428
451
  let isLastTrConfirmed = false;
429
452
  if (!((_this$getState6 = this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(this))) {
430
- var _this$analyticsHelper20;
431
- (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
453
+ var _this$analyticsHelper21;
454
+ (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
432
455
  }
433
456
  while (!isLastTrConfirmed) {
434
457
  this.sendStepsFromCurrentState();
@@ -461,35 +484,35 @@ export class DocumentService {
461
484
  }
462
485
  }
463
486
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
464
- (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
487
+ (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
465
488
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
466
489
  // upon success, emit the total number of unconfirmed steps we synced
467
490
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
468
491
  });
469
492
  }
470
493
  } catch (error) {
471
- var _this$analyticsHelper22, _this$analyticsHelper23;
494
+ var _this$analyticsHelper23, _this$analyticsHelper24;
472
495
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
473
- (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
496
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
474
497
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
475
498
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
476
499
  });
477
- (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while committing unconfirmed steps');
500
+ (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while committing unconfirmed steps');
478
501
  throw error;
479
502
  }
480
503
  });
481
504
  _defineProperty(this, "onStepRejectedError", () => {
482
- var _this$analyticsHelper24;
505
+ var _this$analyticsHelper25;
483
506
  this.stepRejectCounter++;
484
507
  logger(`Steps rejected (tries=${this.stepRejectCounter})`);
485
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
508
+ (_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
486
509
  count: this.stepRejectCounter
487
510
  });
488
511
  let maxRetries = this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
489
512
  if (this.stepRejectCounter >= maxRetries) {
490
- var _this$analyticsHelper25;
513
+ var _this$analyticsHelper26;
491
514
  logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
492
- (_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
515
+ (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
493
516
  this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
494
517
  } else {
495
518
  // If committing steps failed try again automatically in 1s
@@ -516,15 +539,15 @@ export class DocumentService {
516
539
  getVersionFromCollabState(state, resource) {
517
540
  const collabState = getCollabState(state);
518
541
  if (!collabState) {
519
- var _this$analyticsHelper26;
520
- (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
542
+ var _this$analyticsHelper27;
543
+ (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
521
544
  return 0;
522
545
  }
523
546
 
524
547
  // This should not happen in usual, just add error event in case it happens
525
548
  if (collabState.version === undefined) {
526
- var _this$analyticsHelper27;
527
- (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
549
+ var _this$analyticsHelper28;
550
+ (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
528
551
  return 0;
529
552
  }
530
553
  return collabState.version;
@@ -572,9 +595,11 @@ export class DocumentService {
572
595
  setTimeout(() => this.sendStepsFromCurrentState(), 100);
573
596
  }
574
597
  } catch (error) {
575
- var _this$analyticsHelper28;
598
+ var _this$analyticsHelper29;
599
+ // ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
600
+ let userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
576
601
  logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
577
- (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(error, 'Error while processing steps');
602
+ (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(error, userIdMatch ? `Error while processing steps with new clientId` : `Error while processing steps`);
578
603
  this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
579
604
  }
580
605
  }
@@ -601,8 +626,8 @@ export class DocumentService {
601
626
  var _this$getState7;
602
627
  const state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
603
628
  if (!state) {
604
- var _this$analyticsHelper29;
605
- (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
629
+ var _this$analyticsHelper30;
630
+ (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
606
631
  return;
607
632
  }
608
633
  this.send(null, null, state, sendAnalyticsEvent);
@@ -624,8 +649,8 @@ export class DocumentService {
624
649
  // to ensure that analytics events with the number of unconfirmed steps is only
625
650
  // sent once on connection (as opposed to on every step)
626
651
  if (sendAnalyticsEvent) {
627
- var _this$analyticsHelper30;
628
- (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
652
+ var _this$analyticsHelper31;
653
+ (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
629
654
  numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
630
655
  });
631
656
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.43.2";
2
+ export const version = "9.44.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -182,12 +182,37 @@ export var DocumentService = /*#__PURE__*/function () {
182
182
  }
183
183
  }, _callee2, null, [[0, 12]]);
184
184
  })));
185
+ _defineProperty(this, "isStepsFromNewClientIdForSameUserId", function (steps) {
186
+ try {
187
+ if (!Array.isArray(steps) || steps.length === 0) {
188
+ return false;
189
+ }
190
+ var clientIds = new Set(steps.map(function (_ref3) {
191
+ var clientId = _ref3.clientId;
192
+ return clientId;
193
+ }));
194
+ if (!clientIds.has(_this.clientId)) {
195
+ var userIds = new Set(steps.map(function (_ref4) {
196
+ var userId = _ref4.userId;
197
+ return userId;
198
+ }));
199
+ if (userIds.has(_this.getUserId())) {
200
+ return true;
201
+ }
202
+ }
203
+ return false;
204
+ } catch (err) {
205
+ var _this$analyticsHelper8;
206
+ (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
207
+ return false;
208
+ }
209
+ });
185
210
  _defineProperty(this, "getUnconfirmedStepsOrigins", function () {
186
211
  var _this$getState3, _sendableSteps;
187
212
  var state = (_this$getState3 = _this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(_this);
188
213
  if (!state) {
189
- var _this$analyticsHelper8;
190
- (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
214
+ var _this$analyticsHelper9;
215
+ (_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
191
216
  return;
192
217
  }
193
218
  return (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
@@ -196,8 +221,8 @@ export var DocumentService = /*#__PURE__*/function () {
196
221
  var _this$getState4, _sendableSteps2;
197
222
  var state = (_this$getState4 = _this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(_this);
198
223
  if (!state) {
199
- var _this$analyticsHelper9;
200
- (_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
224
+ var _this$analyticsHelper10;
225
+ (_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
201
226
  return;
202
227
  }
203
228
  return (_sendableSteps2 = sendableSteps(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
@@ -232,13 +257,13 @@ export var DocumentService = /*#__PURE__*/function () {
232
257
  _this.stepQueue.queueSteps(data);
233
258
  _this.throttledCatchupv2(CatchupEventReason.STEPS_ADDED);
234
259
  }
235
- _this.participantsService.updateLastActive(data.steps.map(function (_ref3) {
236
- var userId = _ref3.userId;
260
+ _this.participantsService.updateLastActive(data.steps.map(function (_ref5) {
261
+ var userId = _ref5.userId;
237
262
  return userId;
238
263
  }));
239
264
  } catch (stepsAddedError) {
240
- var _this$analyticsHelper10;
241
- (_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
265
+ var _this$analyticsHelper11;
266
+ (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
242
267
  _this.onErrorHandled({
243
268
  message: 'Error while adding steps in the provider',
244
269
  data: {
@@ -251,12 +276,12 @@ export var DocumentService = /*#__PURE__*/function () {
251
276
  });
252
277
  // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
253
278
  _defineProperty(this, "onRestore", /*#__PURE__*/function () {
254
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
255
- var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper11, _this$analyticsHelper12, _this$analyticsHelper13;
279
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
280
+ var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper14;
256
281
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
257
282
  while (1) switch (_context3.prev = _context3.next) {
258
283
  case 0:
259
- doc = _ref4.doc, version = _ref4.version, metadata = _ref4.metadata, targetClientId = _ref4.targetClientId;
284
+ doc = _ref6.doc, version = _ref6.version, metadata = _ref6.metadata, targetClientId = _ref6.targetClientId;
260
285
  if (!(targetClientId && _this.clientId !== targetClientId)) {
261
286
  _context3.next = 3;
262
287
  break;
@@ -303,7 +328,7 @@ export var DocumentService = /*#__PURE__*/function () {
303
328
  _this.applyLocalSteps(unconfirmedSteps);
304
329
  }
305
330
  case 17:
306
- (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
331
+ (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
307
332
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
308
333
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
309
334
  useReconcile: useReconcile,
@@ -316,14 +341,14 @@ export var DocumentService = /*#__PURE__*/function () {
316
341
  case 20:
317
342
  _context3.prev = 20;
318
343
  _context3.t0 = _context3["catch"](8);
319
- (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
344
+ (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
320
345
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
321
346
  useReconcile: useReconcile,
322
347
  clientId: _this.clientId,
323
348
  targetClientId: targetClientId,
324
349
  triggeredByCatchup: targetClientId ? true : false
325
350
  });
326
- (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
351
+ (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_context3.t0, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
327
352
  _this.onErrorHandled({
328
353
  message: 'Caught error while trying to recover the document',
329
354
  data: {
@@ -339,11 +364,11 @@ export var DocumentService = /*#__PURE__*/function () {
339
364
  }, _callee3, null, [[8, 20]]);
340
365
  }));
341
366
  return function (_x2) {
342
- return _ref5.apply(this, arguments);
367
+ return _ref7.apply(this, arguments);
343
368
  };
344
369
  }());
345
370
  _defineProperty(this, "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
346
- var _this$analyticsHelper14, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper15, _this$analyticsHelper16, _measure2;
371
+ var _this$analyticsHelper15, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper16, _this$analyticsHelper17, _measure2;
347
372
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
348
373
  while (1) switch (_context4.prev = _context4.next) {
349
374
  case 0:
@@ -378,7 +403,7 @@ export var DocumentService = /*#__PURE__*/function () {
378
403
  };
379
404
  case 20:
380
405
  measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
381
- (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
406
+ (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
382
407
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
383
408
  });
384
409
  _this.aggressiveCatchup = false;
@@ -388,10 +413,10 @@ export var DocumentService = /*#__PURE__*/function () {
388
413
  _context4.t1 = _context4["catch"](1);
389
414
  _this.aggressiveCatchup = false;
390
415
  _measure2 = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
391
- (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
416
+ (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
392
417
  latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
393
418
  });
394
- (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
419
+ (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
395
420
  throw _context4.t1;
396
421
  case 33:
397
422
  case "end":
@@ -399,11 +424,11 @@ export var DocumentService = /*#__PURE__*/function () {
399
424
  }
400
425
  }, _callee4, null, [[1, 26], [3, 11]]);
401
426
  })));
402
- _defineProperty(this, "updateDocument", function (_ref7) {
403
- var doc = _ref7.doc,
404
- version = _ref7.version,
405
- metadata = _ref7.metadata,
406
- reserveCursor = _ref7.reserveCursor;
427
+ _defineProperty(this, "updateDocument", function (_ref9) {
428
+ var doc = _ref9.doc,
429
+ version = _ref9.version,
430
+ metadata = _ref9.metadata,
431
+ reserveCursor = _ref9.reserveCursor;
407
432
  _this.providerEmitCallback('init', _objectSpread({
408
433
  doc: doc,
409
434
  version: version,
@@ -419,7 +444,7 @@ export var DocumentService = /*#__PURE__*/function () {
419
444
  // ESS-5023: only emit error event if updated client version is still behind server version
420
445
  // client version could become higher than server version due to user editing or plugin adding steps
421
446
  if (updatedVersion < version) {
422
- var _doc$content, _this$analyticsHelper17;
447
+ var _doc$content, _this$analyticsHelper18;
423
448
  var error = new UpdateDocumentError('Failed to update the document', {
424
449
  newVersion: version,
425
450
  editorVersion: updatedVersion,
@@ -427,7 +452,7 @@ export var DocumentService = /*#__PURE__*/function () {
427
452
  docHasContent: (doc === null || doc === void 0 || (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
428
453
  isDocContentValid: isDocContentValid
429
454
  });
430
- (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(error, 'Failed to update the document in document service');
455
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendErrorEvent(error, 'Failed to update the document in document service');
431
456
  if (_this.enableErrorOnFailedDocumentApply) {
432
457
  _this.onErrorHandled({
433
458
  message: 'The provider failed to apply changes to the editor',
@@ -444,8 +469,8 @@ export var DocumentService = /*#__PURE__*/function () {
444
469
  }
445
470
  // Otherwise just fail silently for now
446
471
  } else {
447
- var _this$analyticsHelper18, _doc$content2;
448
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
472
+ var _this$analyticsHelper19, _doc$content2;
473
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
449
474
  newVersion: version,
450
475
  editorVersion: updatedVersion,
451
476
  isDocTruthy: !!doc,
@@ -458,8 +483,8 @@ export var DocumentService = /*#__PURE__*/function () {
458
483
  try {
459
484
  var _this$getState5;
460
485
  if (!((_this$getState5 = _this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(_this))) {
461
- var _this$analyticsHelper19;
462
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
486
+ var _this$analyticsHelper20;
487
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
463
488
  }
464
489
  var state = _this.getState();
465
490
  var content = (doc.content || []).map(function (child) {
@@ -482,7 +507,7 @@ export var DocumentService = /*#__PURE__*/function () {
482
507
  * @throws {Error} Couldn't sync the steps after retrying 30 times
483
508
  */
484
509
  _defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
485
- var unconfirmedSteps, _this$getState6, _this$analyticsHelper21, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper20, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper22, _this$analyticsHelper23, _measure3;
510
+ var unconfirmedSteps, _this$getState6, _this$analyticsHelper22, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper21, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper23, _this$analyticsHelper24, _measure3;
486
511
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
487
512
  while (1) switch (_context5.prev = _context5.next) {
488
513
  case 0:
@@ -501,7 +526,7 @@ export var DocumentService = /*#__PURE__*/function () {
501
526
  lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
502
527
  isLastTrConfirmed = false;
503
528
  if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
504
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
529
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
505
530
  }
506
531
  case 9:
507
532
  if (isLastTrConfirmed) {
@@ -548,7 +573,7 @@ export var DocumentService = /*#__PURE__*/function () {
548
573
  break;
549
574
  case 22:
550
575
  measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
551
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
576
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
552
577
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
553
578
  // upon success, emit the total number of unconfirmed steps we synced
554
579
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -560,11 +585,11 @@ export var DocumentService = /*#__PURE__*/function () {
560
585
  _context5.prev = 26;
561
586
  _context5.t0 = _context5["catch"](1);
562
587
  _measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
563
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
588
+ (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
564
589
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
565
590
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
566
591
  });
567
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
592
+ (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
568
593
  throw _context5.t0;
569
594
  case 32:
570
595
  case "end":
@@ -573,17 +598,17 @@ export var DocumentService = /*#__PURE__*/function () {
573
598
  }, _callee5, null, [[1, 26]]);
574
599
  })));
575
600
  _defineProperty(this, "onStepRejectedError", function () {
576
- var _this$analyticsHelper24;
601
+ var _this$analyticsHelper25;
577
602
  _this.stepRejectCounter++;
578
603
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
579
- (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
604
+ (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
580
605
  count: _this.stepRejectCounter
581
606
  });
582
607
  var maxRetries = _this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
583
608
  if (_this.stepRejectCounter >= maxRetries) {
584
- var _this$analyticsHelper25;
609
+ var _this$analyticsHelper26;
585
610
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
586
- (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
611
+ (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
587
612
  _this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
588
613
  } else {
589
614
  // If committing steps failed try again automatically in 1s
@@ -614,15 +639,15 @@ export var DocumentService = /*#__PURE__*/function () {
614
639
  value: function getVersionFromCollabState(state, resource) {
615
640
  var collabState = getCollabState(state);
616
641
  if (!collabState) {
617
- var _this$analyticsHelper26;
618
- (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
642
+ var _this$analyticsHelper27;
643
+ (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
619
644
  return 0;
620
645
  }
621
646
 
622
647
  // This should not happen in usual, just add error event in case it happens
623
648
  if (collabState.version === undefined) {
624
- var _this$analyticsHelper27;
625
- (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
649
+ var _this$analyticsHelper28;
650
+ (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
626
651
  return 0;
627
652
  }
628
653
  return collabState.version;
@@ -656,8 +681,8 @@ export var DocumentService = /*#__PURE__*/function () {
656
681
  logger("Processing data. Version \"".concat(version, "\"."));
657
682
  if (steps !== null && steps !== void 0 && steps.length) {
658
683
  try {
659
- var clientIds = steps.map(function (_ref9) {
660
- var clientId = _ref9.clientId;
684
+ var clientIds = steps.map(function (_ref11) {
685
+ var clientId = _ref11.clientId;
661
686
  return clientId;
662
687
  });
663
688
  this.providerEmitCallback('data', {
@@ -676,19 +701,21 @@ export var DocumentService = /*#__PURE__*/function () {
676
701
  }, 100);
677
702
  }
678
703
  } catch (error) {
679
- var _this$analyticsHelper28;
704
+ var _this$analyticsHelper29;
705
+ // ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
706
+ var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
680
707
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
681
- (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(error, 'Error while processing steps');
708
+ (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
682
709
  this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
683
710
  }
684
711
  }
685
712
  }
686
713
  }, {
687
714
  key: "setup",
688
- value: function setup(_ref10) {
689
- var getState = _ref10.getState,
690
- onSyncUpError = _ref10.onSyncUpError,
691
- clientId = _ref10.clientId;
715
+ value: function setup(_ref12) {
716
+ var getState = _ref12.getState,
717
+ onSyncUpError = _ref12.onSyncUpError,
718
+ clientId = _ref12.clientId;
692
719
  this.getState = getState;
693
720
  this.onSyncUpError = onSyncUpError || noop;
694
721
  this.clientId = clientId;
@@ -708,8 +735,8 @@ export var DocumentService = /*#__PURE__*/function () {
708
735
  var _this$getState7;
709
736
  var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
710
737
  if (!state) {
711
- var _this$analyticsHelper29;
712
- (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
738
+ var _this$analyticsHelper30;
739
+ (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
713
740
  return;
714
741
  }
715
742
  this.send(null, null, state, sendAnalyticsEvent);
@@ -734,8 +761,8 @@ export var DocumentService = /*#__PURE__*/function () {
734
761
  // to ensure that analytics events with the number of unconfirmed steps is only
735
762
  // sent once on connection (as opposed to on every step)
736
763
  if (sendAnalyticsEvent) {
737
- var _this$analyticsHelper30;
738
- (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
764
+ var _this$analyticsHelper31;
765
+ (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
739
766
  numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
740
767
  });
741
768
  }
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "9.43.2";
2
+ export var version = "9.44.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -62,6 +62,7 @@ export declare class DocumentService implements DocumentServiceInterface {
62
62
  getCurrentPmVersion: () => number;
63
63
  private processQueue;
64
64
  getCurrentState: () => Promise<ResolvedEditorState>;
65
+ private isStepsFromNewClientIdForSameUserId;
65
66
  private processSteps;
66
67
  getUnconfirmedStepsOrigins: () => readonly Transaction[] | undefined;
67
68
  getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
@@ -62,6 +62,7 @@ export declare class DocumentService implements DocumentServiceInterface {
62
62
  getCurrentPmVersion: () => number;
63
63
  private processQueue;
64
64
  getCurrentState: () => Promise<ResolvedEditorState>;
65
+ private isStepsFromNewClientIdForSameUserId;
65
66
  private processSteps;
66
67
  getUnconfirmedStepsOrigins: () => readonly Transaction[] | undefined;
67
68
  getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.43.2",
3
+ "version": "9.44.0",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@atlaskit/analytics-gas-types": "^5.1.0",
36
36
  "@atlaskit/analytics-listeners": "^8.11.0",
37
- "@atlaskit/editor-common": "^93.6.0",
37
+ "@atlaskit/editor-common": "^94.8.0",
38
38
  "@atlaskit/editor-json-transformer": "^8.20.0",
39
39
  "@atlaskit/editor-prosemirror": "6.0.0",
40
40
  "@atlaskit/platform-feature-flags": "^0.3.0",
@@ -62,7 +62,7 @@
62
62
  }
63
63
  },
64
64
  "devDependencies": {
65
- "@atlaskit/adf-schema": "^42.0.2",
65
+ "@atlaskit/adf-schema": "^42.3.1",
66
66
  "@atlassian/feature-flags-test-utils": "^0.2.0",
67
67
  "typescript": "~5.4.2"
68
68
  },