@atlaskit/collab-provider 10.9.3 → 10.9.4

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,15 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 10.9.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#124114](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/124114)
8
+ [`a0b9383dc1bf3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a0b9383dc1bf3) -
9
+ CEPS-362: add reason to getResolvedEditorState call chain, to allow collab provider/NCS to
10
+ differentiate between draft sync and publish use cases
11
+ - Updated dependencies
12
+
3
13
  ## 10.9.3
4
14
 
5
15
  ### Patch Changes
@@ -460,63 +460,68 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
460
460
  return _ref7.apply(this, arguments);
461
461
  };
462
462
  }());
463
- (0, _defineProperty2.default)(this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
464
- var _this$analyticsHelper18, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure2;
465
- return _regenerator.default.wrap(function _callee4$(_context4) {
466
- while (1) switch (_context4.prev = _context4.next) {
467
- case 0:
468
- _this.aggressiveCatchup = true;
469
- _context4.prev = 1;
470
- (0, _performance.startMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
471
- _context4.prev = 3;
472
- _context4.next = 6;
473
- return _this.commitUnconfirmedSteps();
474
- case 6:
475
- _context4.next = 8;
476
- return _this.getCurrentState();
477
- case 8:
478
- finalAcknowledgedState = _context4.sent;
479
- _context4.next = 20;
480
- break;
481
- case 11:
482
- _context4.prev = 11;
483
- _context4.t0 = _context4["catch"](3);
484
- _context4.next = 15;
485
- return _this.getCurrentState();
486
- case 15:
487
- currentState = _context4.sent;
488
- _context4.next = 18;
489
- return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-final-ack');
490
- case 18:
491
- reconcileResponse = _context4.sent;
492
- finalAcknowledgedState = {
493
- content: JSON.parse(reconcileResponse.document),
494
- title: currentState.title,
495
- stepVersion: reconcileResponse.version
496
- };
497
- case 20:
498
- measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
499
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
500
- latency: measure === null || measure === void 0 ? void 0 : measure.duration
501
- });
502
- _this.aggressiveCatchup = false;
503
- return _context4.abrupt("return", finalAcknowledgedState);
504
- case 26:
505
- _context4.prev = 26;
506
- _context4.t1 = _context4["catch"](1);
507
- _this.aggressiveCatchup = false;
508
- _measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
509
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
510
- latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
511
- });
512
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
513
- throw _context4.t1;
514
- case 33:
515
- case "end":
516
- return _context4.stop();
517
- }
518
- }, _callee4, null, [[1, 26], [3, 11]]);
519
- })));
463
+ (0, _defineProperty2.default)(this, "getFinalAcknowledgedState", /*#__PURE__*/function () {
464
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(reason) {
465
+ var _this$analyticsHelper18, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure2;
466
+ return _regenerator.default.wrap(function _callee4$(_context4) {
467
+ while (1) switch (_context4.prev = _context4.next) {
468
+ case 0:
469
+ _this.aggressiveCatchup = true;
470
+ _context4.prev = 1;
471
+ (0, _performance.startMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
472
+ _context4.prev = 3;
473
+ _context4.next = 6;
474
+ return _this.commitUnconfirmedSteps(reason);
475
+ case 6:
476
+ _context4.next = 8;
477
+ return _this.getCurrentState();
478
+ case 8:
479
+ finalAcknowledgedState = _context4.sent;
480
+ _context4.next = 20;
481
+ break;
482
+ case 11:
483
+ _context4.prev = 11;
484
+ _context4.t0 = _context4["catch"](3);
485
+ _context4.next = 15;
486
+ return _this.getCurrentState();
487
+ case 15:
488
+ currentState = _context4.sent;
489
+ _context4.next = 18;
490
+ return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-final-ack');
491
+ case 18:
492
+ reconcileResponse = _context4.sent;
493
+ finalAcknowledgedState = {
494
+ content: JSON.parse(reconcileResponse.document),
495
+ title: currentState.title,
496
+ stepVersion: reconcileResponse.version
497
+ };
498
+ case 20:
499
+ measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
500
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
501
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration
502
+ });
503
+ _this.aggressiveCatchup = false;
504
+ return _context4.abrupt("return", finalAcknowledgedState);
505
+ case 26:
506
+ _context4.prev = 26;
507
+ _context4.t1 = _context4["catch"](1);
508
+ _this.aggressiveCatchup = false;
509
+ _measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
510
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
511
+ latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
512
+ });
513
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
514
+ throw _context4.t1;
515
+ case 33:
516
+ case "end":
517
+ return _context4.stop();
518
+ }
519
+ }, _callee4, null, [[1, 26], [3, 11]]);
520
+ }));
521
+ return function (_x4) {
522
+ return _ref8.apply(this, arguments);
523
+ };
524
+ }());
520
525
  (0, _defineProperty2.default)(this, "updateDocument", function (_ref9) {
521
526
  var doc = _ref9.doc,
522
527
  version = _ref9.version,
@@ -607,100 +612,105 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
607
612
  * Commit the unconfirmed local steps to the back-end service
608
613
  * @throws {Error} Couldn't sync the steps after retrying 30 times
609
614
  */
610
- (0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
611
- var unconfirmedSteps, _this$getState6, _this$analyticsHelper25, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper24, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper26, _this$analyticsHelper27, _measure3;
612
- return _regenerator.default.wrap(function _callee5$(_context5) {
613
- while (1) switch (_context5.prev = _context5.next) {
614
- case 0:
615
- unconfirmedSteps = _this.getUnconfirmedSteps();
616
- _context5.prev = 1;
617
- if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
618
- _context5.next = 24;
619
- break;
620
- }
621
- (0, _performance.startMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
622
- count = 0; // We use origins here as steps can be rebased. When steps are rebased a new step is created.
623
- // This means that we can not track if it has been removed from the unconfirmed array or not.
624
- // Origins points to the original transaction that the step was created in. This is never changed
625
- // and gets passed down when a step is rebased.
626
- unconfirmedTrs = _this.getUnconfirmedStepsOrigins();
627
- lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
628
- isLastTrConfirmed = false;
629
- if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
630
- (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
631
- }
632
- case 9:
633
- if (isLastTrConfirmed) {
634
- _context5.next = 22;
615
+ (0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/function () {
616
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(reason) {
617
+ var unconfirmedSteps, _this$getState6, _this$analyticsHelper25, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper24, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper26, _this$analyticsHelper27, _measure3;
618
+ return _regenerator.default.wrap(function _callee5$(_context5) {
619
+ while (1) switch (_context5.prev = _context5.next) {
620
+ case 0:
621
+ unconfirmedSteps = _this.getUnconfirmedSteps();
622
+ _context5.prev = 1;
623
+ if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
624
+ _context5.next = 24;
625
+ break;
626
+ }
627
+ (0, _performance.startMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
628
+ count = 0; // We use origins here as steps can be rebased. When steps are rebased a new step is created.
629
+ // This means that we can not track if it has been removed from the unconfirmed array or not.
630
+ // Origins points to the original transaction that the step was created in. This is never changed
631
+ // and gets passed down when a step is rebased.
632
+ unconfirmedTrs = _this.getUnconfirmedStepsOrigins();
633
+ lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
634
+ isLastTrConfirmed = false;
635
+ if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
636
+ (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
637
+ }
638
+ case 9:
639
+ if (isLastTrConfirmed) {
640
+ _context5.next = 22;
641
+ break;
642
+ }
643
+ // forcePublish = true, this is because commitUnconfirmedSteps is only called when the Editor publishes a document
644
+ _this.sendStepsFromCurrentState(undefined, reason);
645
+ _context5.next = 13;
646
+ return (0, _utils.sleep)(500);
647
+ case 13:
648
+ nextUnconfirmedSteps = _this.getUnconfirmedSteps();
649
+ if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
650
+ nextUnconfirmedTrs = _this.getUnconfirmedStepsOrigins();
651
+ isLastTrConfirmed = !(nextUnconfirmedTrs !== null && nextUnconfirmedTrs !== void 0 && nextUnconfirmedTrs.some(function (tr) {
652
+ return tr === lastTr;
653
+ }));
654
+ } else {
655
+ isLastTrConfirmed = true;
656
+ }
657
+ if (!(!isLastTrConfirmed && count++ >= _const.ACK_MAX_TRY)) {
658
+ _context5.next = 20;
659
+ break;
660
+ }
661
+ if (_this.onSyncUpError) {
662
+ // Ignored via go/ees005
663
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
664
+ state = _this.getState();
665
+ version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
666
+ _this.onSyncUpError({
667
+ lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
668
+ tries: count,
669
+ maxRetries: _const.ACK_MAX_TRY,
670
+ clientId: _this.clientId,
671
+ version: version
672
+ });
673
+ }
674
+ unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
675
+ return (0, _utils.getStepUGCFreeDetails)(step);
676
+ });
677
+ error = new _customErrors.CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
678
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? JSON.stringify(unconfirmedStepsInfoUGCRemoved) : 'Unable to generate UGC removed step info'
679
+ });
680
+ throw error;
681
+ case 20:
682
+ _context5.next = 9;
635
683
  break;
636
- }
637
- // forcePublish = true, this is because commitUnconfirmedSteps is only called when the Editor publishes a document
638
- _this.sendStepsFromCurrentState(undefined, true);
639
- _context5.next = 13;
640
- return (0, _utils.sleep)(500);
641
- case 13:
642
- nextUnconfirmedSteps = _this.getUnconfirmedSteps();
643
- if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
644
- nextUnconfirmedTrs = _this.getUnconfirmedStepsOrigins();
645
- isLastTrConfirmed = !(nextUnconfirmedTrs !== null && nextUnconfirmedTrs !== void 0 && nextUnconfirmedTrs.some(function (tr) {
646
- return tr === lastTr;
647
- }));
648
- } else {
649
- isLastTrConfirmed = true;
650
- }
651
- if (!(!isLastTrConfirmed && count++ >= _const.ACK_MAX_TRY)) {
652
- _context5.next = 20;
684
+ case 22:
685
+ measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
686
+ (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
687
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration,
688
+ // upon success, emit the total number of unconfirmed steps we synced
689
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
690
+ });
691
+ case 24:
692
+ _context5.next = 32;
653
693
  break;
654
- }
655
- if (_this.onSyncUpError) {
656
- // Ignored via go/ees005
657
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
658
- state = _this.getState();
659
- version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
660
- _this.onSyncUpError({
661
- lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
662
- tries: count,
663
- maxRetries: _const.ACK_MAX_TRY,
664
- clientId: _this.clientId,
665
- version: version
694
+ case 26:
695
+ _context5.prev = 26;
696
+ _context5.t0 = _context5["catch"](1);
697
+ _measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
698
+ (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
699
+ latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
700
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
666
701
  });
667
- }
668
- unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
669
- return (0, _utils.getStepUGCFreeDetails)(step);
670
- });
671
- error = new _customErrors.CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
672
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? JSON.stringify(unconfirmedStepsInfoUGCRemoved) : 'Unable to generate UGC removed step info'
673
- });
674
- throw error;
675
- case 20:
676
- _context5.next = 9;
677
- break;
678
- case 22:
679
- measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
680
- (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
681
- latency: measure === null || measure === void 0 ? void 0 : measure.duration,
682
- // upon success, emit the total number of unconfirmed steps we synced
683
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
684
- });
685
- case 24:
686
- _context5.next = 32;
687
- break;
688
- case 26:
689
- _context5.prev = 26;
690
- _context5.t0 = _context5["catch"](1);
691
- _measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
692
- (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
693
- latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
694
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
695
- });
696
- (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
697
- throw _context5.t0;
698
- case 32:
699
- case "end":
700
- return _context5.stop();
701
- }
702
- }, _callee5, null, [[1, 26]]);
703
- })));
702
+ (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
703
+ throw _context5.t0;
704
+ case 32:
705
+ case "end":
706
+ return _context5.stop();
707
+ }
708
+ }, _callee5, null, [[1, 26]]);
709
+ }));
710
+ return function (_x5) {
711
+ return _ref10.apply(this, arguments);
712
+ };
713
+ }());
704
714
  (0, _defineProperty2.default)(this, "onStepRejectedError", function () {
705
715
  var _this$analyticsHelper28;
706
716
  _this.stepRejectCounter++;
@@ -883,7 +893,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
883
893
  */
884
894
  }, {
885
895
  key: "sendStepsFromCurrentState",
886
- value: function sendStepsFromCurrentState(sendAnalyticsEvent, forcePublish) {
896
+ value: function sendStepsFromCurrentState(sendAnalyticsEvent, reason) {
887
897
  var _this$getState8;
888
898
  var state = (_this$getState8 = this.getState) === null || _this$getState8 === void 0 ? void 0 : _this$getState8.call(this);
889
899
  if (!state) {
@@ -891,7 +901,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
891
901
  (_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
892
902
  return;
893
903
  }
894
- this.send(null, null, state, sendAnalyticsEvent, forcePublish);
904
+ this.send(null, null, state, sendAnalyticsEvent, reason);
895
905
  }
896
906
  }, {
897
907
  key: "send",
@@ -900,7 +910,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
900
910
  * Send steps from transaction to other participants
901
911
  * It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
902
912
  */
903
- function send(tr, _oldState, newState, sendAnalyticsEvent, forcePublish) {
913
+ function send(tr, _oldState, newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
914
+ ) {
904
915
  var unconfirmedStepsData = (0, _prosemirrorCollab.sendableSteps)(newState);
905
916
  var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
906
917
 
@@ -983,7 +994,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
983
994
  __livePage: this.options.__livePage,
984
995
  hasRecovered: this.hasRecovered,
985
996
  collabMode: this.participantsService.getCollabMode(),
986
- forcePublish: forcePublish
997
+ reason: reason
987
998
  });
988
999
  }
989
1000
  }]);
@@ -46,7 +46,7 @@ var NullDocumentService = exports.NullDocumentService = /*#__PURE__*/function ()
46
46
  }
47
47
  }, {
48
48
  key: "getFinalAcknowledgedState",
49
- value: function getFinalAcknowledgedState() {
49
+ value: function getFinalAcknowledgedState(reason) {
50
50
  return Promise.resolve({});
51
51
  }
52
52
  }, {
@@ -30,7 +30,7 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
30
30
  __livePage = _ref.__livePage,
31
31
  hasRecovered = _ref.hasRecovered,
32
32
  collabMode = _ref.collabMode,
33
- forcePublish = _ref.forcePublish;
33
+ reason = _ref.reason;
34
34
  if (!readyToCommit) {
35
35
  logger('Not ready to commit, skip');
36
36
  return;
@@ -92,8 +92,7 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
92
92
  collabMode: collabMode,
93
93
  steps: stepsWithClientAndUserId,
94
94
  version: version,
95
- userId: userId,
96
- forcePublish: forcePublish
95
+ userId: userId
97
96
  }, function (response) {
98
97
  var latency = new Date().getTime() - start;
99
98
  if (timer) {
@@ -277,27 +277,32 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
277
277
  * Used when returning the document to Confluence on publish.
278
278
  * @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
279
279
  */
280
- (0, _defineProperty2.default)(_this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
281
- var _this$analyticsHelper5;
282
- return _regenerator.default.wrap(function _callee3$(_context3) {
283
- while (1) switch (_context3.prev = _context3.next) {
284
- case 0:
285
- _context3.prev = 0;
286
- _context3.next = 3;
287
- return _this.documentService.getFinalAcknowledgedState();
288
- case 3:
289
- return _context3.abrupt("return", _context3.sent);
290
- case 6:
291
- _context3.prev = 6;
292
- _context3.t0 = _context3["catch"](0);
293
- (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(_context3.t0, 'Error while returning ADF version of the final draft document');
294
- throw new _customErrors.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context3.t0);
295
- case 10:
296
- case "end":
297
- return _context3.stop();
298
- }
299
- }, _callee3, null, [[0, 6]]);
300
- })));
280
+ (0, _defineProperty2.default)(_this, "getFinalAcknowledgedState", /*#__PURE__*/function () {
281
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(reason) {
282
+ var _this$analyticsHelper5;
283
+ return _regenerator.default.wrap(function _callee3$(_context3) {
284
+ while (1) switch (_context3.prev = _context3.next) {
285
+ case 0:
286
+ _context3.prev = 0;
287
+ _context3.next = 3;
288
+ return _this.documentService.getFinalAcknowledgedState(reason);
289
+ case 3:
290
+ return _context3.abrupt("return", _context3.sent);
291
+ case 6:
292
+ _context3.prev = 6;
293
+ _context3.t0 = _context3["catch"](0);
294
+ (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(_context3.t0, 'Error while returning ADF version of the final draft document');
295
+ throw new _customErrors.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context3.t0);
296
+ case 10:
297
+ case "end":
298
+ return _context3.stop();
299
+ }
300
+ }, _callee3, null, [[0, 6]]);
301
+ }));
302
+ return function (_x2) {
303
+ return _ref7.apply(this, arguments);
304
+ };
305
+ }());
301
306
  (0, _defineProperty2.default)(_this, "getUnconfirmedSteps", function () {
302
307
  return _this.documentService.getUnconfirmedSteps();
303
308
  });
@@ -354,7 +359,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
354
359
  }
355
360
  _this.sendStepsTimer = setInterval(function () {
356
361
  logger('Intervally sendStepsFromCurrentState');
357
- _this.documentService.sendStepsFromCurrentState(true);
362
+ _this.documentService.sendStepsFromCurrentState(true, undefined);
358
363
  }, 5000);
359
364
  return _this;
360
365
  }
@@ -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 = "10.9.3";
8
+ var version = exports.version = "10.9.4";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -398,14 +398,14 @@ export class DocumentService {
398
398
  });
399
399
  }
400
400
  });
401
- _defineProperty(this, "getFinalAcknowledgedState", async () => {
401
+ _defineProperty(this, "getFinalAcknowledgedState", async reason => {
402
402
  this.aggressiveCatchup = true;
403
403
  try {
404
404
  var _this$analyticsHelper18;
405
405
  startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
406
406
  let finalAcknowledgedState;
407
407
  try {
408
- await this.commitUnconfirmedSteps();
408
+ await this.commitUnconfirmedSteps(reason);
409
409
  finalAcknowledgedState = await this.getCurrentState();
410
410
  } catch (error) {
411
411
  // if fails to commit unconfirmed steps, send reconcile request to NCS BE and return the doc to CC
@@ -524,7 +524,7 @@ export class DocumentService {
524
524
  * Commit the unconfirmed local steps to the back-end service
525
525
  * @throws {Error} Couldn't sync the steps after retrying 30 times
526
526
  */
527
- _defineProperty(this, "commitUnconfirmedSteps", async () => {
527
+ _defineProperty(this, "commitUnconfirmedSteps", async reason => {
528
528
  const unconfirmedSteps = this.getUnconfirmedSteps();
529
529
  try {
530
530
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
@@ -544,7 +544,7 @@ export class DocumentService {
544
544
  }
545
545
  while (!isLastTrConfirmed) {
546
546
  // forcePublish = true, this is because commitUnconfirmedSteps is only called when the Editor publishes a document
547
- this.sendStepsFromCurrentState(undefined, true);
547
+ this.sendStepsFromCurrentState(undefined, reason);
548
548
  await sleep(500);
549
549
  const nextUnconfirmedSteps = this.getUnconfirmedSteps();
550
550
  if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
@@ -758,7 +758,7 @@ export class DocumentService {
758
758
  * The getState function will return the current EditorState
759
759
  * from the EditorView.
760
760
  */
761
- sendStepsFromCurrentState(sendAnalyticsEvent, forcePublish) {
761
+ sendStepsFromCurrentState(sendAnalyticsEvent, reason) {
762
762
  var _this$getState8;
763
763
  const state = (_this$getState8 = this.getState) === null || _this$getState8 === void 0 ? void 0 : _this$getState8.call(this);
764
764
  if (!state) {
@@ -766,13 +766,14 @@ export class DocumentService {
766
766
  (_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 ? void 0 : _this$analyticsHelper33.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
767
767
  return;
768
768
  }
769
- this.send(null, null, state, sendAnalyticsEvent, forcePublish);
769
+ this.send(null, null, state, sendAnalyticsEvent, reason);
770
770
  }
771
771
  /**
772
772
  * Send steps from transaction to other participants
773
773
  * It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
774
774
  */
775
- send(tr, _oldState, newState, sendAnalyticsEvent, forcePublish) {
775
+ send(tr, _oldState, newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
776
+ ) {
776
777
  const unconfirmedStepsData = sendableSteps(newState);
777
778
  const version = this.getVersionFromCollabState(newState, 'collab-provider: send');
778
779
 
@@ -855,7 +856,7 @@ export class DocumentService {
855
856
  __livePage: this.options.__livePage,
856
857
  hasRecovered: this.hasRecovered,
857
858
  collabMode: this.participantsService.getCollabMode(),
858
- forcePublish
859
+ reason
859
860
  });
860
861
  }
861
862
  }
@@ -17,7 +17,7 @@ export class NullDocumentService {
17
17
  getCurrentState() {
18
18
  return Promise.resolve({});
19
19
  }
20
- getFinalAcknowledgedState() {
20
+ getFinalAcknowledgedState(reason) {
21
21
  return Promise.resolve({});
22
22
  }
23
23
  getIsNamespaceLocked() {
@@ -20,7 +20,7 @@ export const commitStepQueue = ({
20
20
  __livePage,
21
21
  hasRecovered,
22
22
  collabMode,
23
- forcePublish
23
+ reason
24
24
  }) => {
25
25
  if (!readyToCommit) {
26
26
  logger('Not ready to commit, skip');
@@ -84,8 +84,7 @@ export const commitStepQueue = ({
84
84
  collabMode,
85
85
  steps: stepsWithClientAndUserId,
86
86
  version,
87
- userId,
88
- forcePublish
87
+ userId
89
88
  }, response => {
90
89
  const latency = new Date().getTime() - start;
91
90
  if (timer) {
@@ -228,9 +228,9 @@ export class Provider extends Emitter {
228
228
  * Used when returning the document to Confluence on publish.
229
229
  * @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
230
230
  */
231
- _defineProperty(this, "getFinalAcknowledgedState", async () => {
231
+ _defineProperty(this, "getFinalAcknowledgedState", async reason => {
232
232
  try {
233
- return await this.documentService.getFinalAcknowledgedState();
233
+ return await this.documentService.getFinalAcknowledgedState(reason);
234
234
  } catch (error) {
235
235
  var _this$analyticsHelper5;
236
236
  (_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
@@ -291,7 +291,7 @@ export class Provider extends Emitter {
291
291
  }
292
292
  this.sendStepsTimer = setInterval(() => {
293
293
  logger('Intervally sendStepsFromCurrentState');
294
- this.documentService.sendStepsFromCurrentState(true);
294
+ this.documentService.sendStepsFromCurrentState(true, undefined);
295
295
  }, 5000);
296
296
  }
297
297
  // eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "10.9.3";
2
+ export const version = "10.9.4";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };