@atlaskit/collab-provider 9.40.3 → 9.40.5
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 +16 -0
- package/dist/cjs/document/document-service.js +36 -16
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/document/document-service.js +29 -11
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/document/document-service.js +37 -17
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +1 -0
- package/dist/types-ts4.5/document/document-service.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 9.40.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#143146](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/143146)
|
|
8
|
+
[`5df86b2c5407e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5df86b2c5407e) -
|
|
9
|
+
Retire getVersion using getCollabState from prosemirror-collab, and adding error events on
|
|
10
|
+
checking undefined collab state in all collab-provider usages
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 9.40.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 9.40.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -218,10 +218,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
218
218
|
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
|
|
219
219
|
return 0;
|
|
220
220
|
}
|
|
221
|
-
return (
|
|
221
|
+
return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
222
222
|
});
|
|
223
223
|
(0, _defineProperty2.default)(this, "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
224
|
-
var _this$getState2, _this$analyticsHelper7, _this$analyticsHelper6, state, adfDocument, currentState, measure, _this$analyticsHelper8, _this$analyticsHelper9, _measure;
|
|
224
|
+
var _this$getState2, _this$analyticsHelper7, _this$analyticsHelper6, state, adfDocument, version, currentState, measure, _this$analyticsHelper8, _this$analyticsHelper9, _measure;
|
|
225
225
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
226
226
|
while (1) switch (_context3.prev = _context3.next) {
|
|
227
227
|
case 0:
|
|
@@ -234,18 +234,19 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
234
234
|
}
|
|
235
235
|
state = _this.getState();
|
|
236
236
|
adfDocument = new _editorJsonTransformer.JSONTransformer().encode(state.doc);
|
|
237
|
+
version = _this.getVersionFromCollabState(state, 'collab-provider: getCurrentState');
|
|
237
238
|
currentState = {
|
|
238
239
|
content: adfDocument,
|
|
239
240
|
title: _this.metadataService.getTitle(),
|
|
240
|
-
stepVersion:
|
|
241
|
+
stepVersion: version
|
|
241
242
|
};
|
|
242
243
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
243
244
|
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.SUCCESS, {
|
|
244
245
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
245
246
|
});
|
|
246
247
|
return _context3.abrupt("return", currentState);
|
|
247
|
-
case
|
|
248
|
-
_context3.prev =
|
|
248
|
+
case 12:
|
|
249
|
+
_context3.prev = 12;
|
|
249
250
|
_context3.t0 = _context3["catch"](0);
|
|
250
251
|
_measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
251
252
|
(_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.FAILURE, {
|
|
@@ -253,11 +254,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
253
254
|
});
|
|
254
255
|
(_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(_context3.t0, 'Error while returning ADF version of current draft document');
|
|
255
256
|
throw _context3.t0;
|
|
256
|
-
case
|
|
257
|
+
case 18:
|
|
257
258
|
case "end":
|
|
258
259
|
return _context3.stop();
|
|
259
260
|
}
|
|
260
|
-
}, _callee3, null, [[0,
|
|
261
|
+
}, _callee3, null, [[0, 12]]);
|
|
261
262
|
})));
|
|
262
263
|
(0, _defineProperty2.default)(this, "getUnconfirmedStepsOrigins", function () {
|
|
263
264
|
var _this$getState3, _sendableSteps;
|
|
@@ -557,7 +558,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
557
558
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
558
559
|
*/
|
|
559
560
|
(0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
560
|
-
var unconfirmedSteps, _this$getState6, _this$analyticsHelper23, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper22, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper24, _this$analyticsHelper25, _measure3;
|
|
561
|
+
var unconfirmedSteps, _this$getState6, _this$analyticsHelper23, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper22, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper24, _this$analyticsHelper25, _measure3;
|
|
561
562
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
562
563
|
while (1) switch (_context6.prev = _context6.next) {
|
|
563
564
|
case 0:
|
|
@@ -602,12 +603,13 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
602
603
|
}
|
|
603
604
|
if (_this.onSyncUpError) {
|
|
604
605
|
state = _this.getState();
|
|
606
|
+
version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
|
|
605
607
|
_this.onSyncUpError({
|
|
606
608
|
lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
|
|
607
609
|
tries: count,
|
|
608
610
|
maxRetries: _const.ACK_MAX_TRY,
|
|
609
611
|
clientId: _this.clientId,
|
|
610
|
-
version:
|
|
612
|
+
version: version
|
|
611
613
|
});
|
|
612
614
|
}
|
|
613
615
|
unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
|
|
@@ -685,6 +687,24 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
685
687
|
this.onErrorHandled = onErrorHandled;
|
|
686
688
|
}
|
|
687
689
|
(0, _createClass2.default)(DocumentService, [{
|
|
690
|
+
key: "getVersionFromCollabState",
|
|
691
|
+
value: function getVersionFromCollabState(state, resource) {
|
|
692
|
+
var collabState = (0, _prosemirrorCollab.getCollabState)(state);
|
|
693
|
+
if (!collabState) {
|
|
694
|
+
var _this$analyticsHelper28;
|
|
695
|
+
(_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
|
|
696
|
+
return 0;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// This should not happen in usual, just add error event in case it happens
|
|
700
|
+
if (collabState.version === undefined) {
|
|
701
|
+
var _this$analyticsHelper29;
|
|
702
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
|
|
703
|
+
return 0;
|
|
704
|
+
}
|
|
705
|
+
return collabState.version;
|
|
706
|
+
}
|
|
707
|
+
}, {
|
|
688
708
|
key: "processQueue",
|
|
689
709
|
value: function processQueue() {
|
|
690
710
|
if (this.stepQueue.isPaused()) {
|
|
@@ -733,9 +753,9 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
733
753
|
}, 100);
|
|
734
754
|
}
|
|
735
755
|
} catch (error) {
|
|
736
|
-
var _this$
|
|
756
|
+
var _this$analyticsHelper30;
|
|
737
757
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
738
|
-
(_this$
|
|
758
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(error, 'Error while processing steps');
|
|
739
759
|
this.throttledCatchupv2(_const.CatchupEventReason.PROCESS_STEPS);
|
|
740
760
|
}
|
|
741
761
|
}
|
|
@@ -765,8 +785,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
765
785
|
var _this$getState7;
|
|
766
786
|
var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
767
787
|
if (!state) {
|
|
768
|
-
var _this$
|
|
769
|
-
(_this$
|
|
788
|
+
var _this$analyticsHelper31;
|
|
789
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
770
790
|
return;
|
|
771
791
|
}
|
|
772
792
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -780,7 +800,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
780
800
|
*/
|
|
781
801
|
function send(_tr, _oldState, newState, sendAnalyticsEvent) {
|
|
782
802
|
var unconfirmedStepsData = (0, _prosemirrorCollab.sendableSteps)(newState);
|
|
783
|
-
var version =
|
|
803
|
+
var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
|
|
784
804
|
|
|
785
805
|
// Don't send any steps before we're ready.
|
|
786
806
|
if (!unconfirmedStepsData) {
|
|
@@ -791,8 +811,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
791
811
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
792
812
|
// sent once on connection (as opposed to on every step)
|
|
793
813
|
if (sendAnalyticsEvent) {
|
|
794
|
-
var _this$
|
|
795
|
-
(_this$
|
|
814
|
+
var _this$analyticsHelper32;
|
|
815
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
|
|
796
816
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
797
817
|
});
|
|
798
818
|
}
|
|
@@ -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.40.
|
|
8
|
+
var version = exports.version = "9.40.5";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
3
|
-
import {
|
|
3
|
+
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
4
4
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
5
5
|
import throttle from 'lodash/throttle';
|
|
6
6
|
import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
|
|
@@ -179,7 +179,7 @@ export class DocumentService {
|
|
|
179
179
|
(_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
|
|
180
180
|
return 0;
|
|
181
181
|
}
|
|
182
|
-
return
|
|
182
|
+
return this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
183
183
|
});
|
|
184
184
|
_defineProperty(this, "getCurrentState", async () => {
|
|
185
185
|
try {
|
|
@@ -193,10 +193,11 @@ export class DocumentService {
|
|
|
193
193
|
}
|
|
194
194
|
const state = this.getState();
|
|
195
195
|
const adfDocument = new JSONTransformer().encode(state.doc);
|
|
196
|
+
const version = this.getVersionFromCollabState(state, 'collab-provider: getCurrentState');
|
|
196
197
|
const currentState = {
|
|
197
198
|
content: adfDocument,
|
|
198
199
|
title: this.metadataService.getTitle(),
|
|
199
|
-
stepVersion:
|
|
200
|
+
stepVersion: version
|
|
200
201
|
};
|
|
201
202
|
const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
|
|
202
203
|
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
|
|
@@ -494,12 +495,13 @@ export class DocumentService {
|
|
|
494
495
|
var _this$getUnconfirmedS;
|
|
495
496
|
if (this.onSyncUpError) {
|
|
496
497
|
const state = this.getState();
|
|
498
|
+
const version = this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
|
|
497
499
|
this.onSyncUpError({
|
|
498
500
|
lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
|
|
499
501
|
tries: count,
|
|
500
502
|
maxRetries: ACK_MAX_TRY,
|
|
501
503
|
clientId: this.clientId,
|
|
502
|
-
version
|
|
504
|
+
version
|
|
503
505
|
});
|
|
504
506
|
}
|
|
505
507
|
const unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(step => getStepUGCFreeDetails(step));
|
|
@@ -563,6 +565,22 @@ export class DocumentService {
|
|
|
563
565
|
this.stepQueue = new StepQueueState();
|
|
564
566
|
this.onErrorHandled = onErrorHandled;
|
|
565
567
|
}
|
|
568
|
+
getVersionFromCollabState(state, resource) {
|
|
569
|
+
const collabState = getCollabState(state);
|
|
570
|
+
if (!collabState) {
|
|
571
|
+
var _this$analyticsHelper28;
|
|
572
|
+
(_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
|
|
573
|
+
return 0;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// This should not happen in usual, just add error event in case it happens
|
|
577
|
+
if (collabState.version === undefined) {
|
|
578
|
+
var _this$analyticsHelper29;
|
|
579
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
|
|
580
|
+
return 0;
|
|
581
|
+
}
|
|
582
|
+
return collabState.version;
|
|
583
|
+
}
|
|
566
584
|
processQueue() {
|
|
567
585
|
if (this.stepQueue.isPaused()) {
|
|
568
586
|
logger(`Queue is paused. Aborting.`);
|
|
@@ -606,9 +624,9 @@ export class DocumentService {
|
|
|
606
624
|
setTimeout(() => this.sendStepsFromCurrentState(), 100);
|
|
607
625
|
}
|
|
608
626
|
} catch (error) {
|
|
609
|
-
var _this$
|
|
627
|
+
var _this$analyticsHelper30;
|
|
610
628
|
logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
|
|
611
|
-
(_this$
|
|
629
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(error, 'Error while processing steps');
|
|
612
630
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
613
631
|
}
|
|
614
632
|
}
|
|
@@ -635,8 +653,8 @@ export class DocumentService {
|
|
|
635
653
|
var _this$getState7;
|
|
636
654
|
const state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
637
655
|
if (!state) {
|
|
638
|
-
var _this$
|
|
639
|
-
(_this$
|
|
656
|
+
var _this$analyticsHelper31;
|
|
657
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
640
658
|
return;
|
|
641
659
|
}
|
|
642
660
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -647,7 +665,7 @@ export class DocumentService {
|
|
|
647
665
|
*/
|
|
648
666
|
send(_tr, _oldState, newState, sendAnalyticsEvent) {
|
|
649
667
|
const unconfirmedStepsData = sendableSteps(newState);
|
|
650
|
-
const version =
|
|
668
|
+
const version = this.getVersionFromCollabState(newState, 'collab-provider: send');
|
|
651
669
|
|
|
652
670
|
// Don't send any steps before we're ready.
|
|
653
671
|
if (!unconfirmedStepsData) {
|
|
@@ -658,8 +676,8 @@ export class DocumentService {
|
|
|
658
676
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
659
677
|
// sent once on connection (as opposed to on every step)
|
|
660
678
|
if (sendAnalyticsEvent) {
|
|
661
|
-
var _this$
|
|
662
|
-
(_this$
|
|
679
|
+
var _this$analyticsHelper32;
|
|
680
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
663
681
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
664
682
|
});
|
|
665
683
|
}
|
|
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
9
|
-
import {
|
|
9
|
+
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
10
10
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
11
11
|
import throttle from 'lodash/throttle';
|
|
12
12
|
import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
|
|
@@ -211,10 +211,10 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
211
211
|
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
|
|
212
212
|
return 0;
|
|
213
213
|
}
|
|
214
|
-
return
|
|
214
|
+
return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
215
215
|
});
|
|
216
216
|
_defineProperty(this, "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
217
|
-
var _this$getState2, _this$analyticsHelper7, _this$analyticsHelper6, state, adfDocument, currentState, measure, _this$analyticsHelper8, _this$analyticsHelper9, _measure;
|
|
217
|
+
var _this$getState2, _this$analyticsHelper7, _this$analyticsHelper6, state, adfDocument, version, currentState, measure, _this$analyticsHelper8, _this$analyticsHelper9, _measure;
|
|
218
218
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
219
219
|
while (1) switch (_context3.prev = _context3.next) {
|
|
220
220
|
case 0:
|
|
@@ -227,18 +227,19 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
227
227
|
}
|
|
228
228
|
state = _this.getState();
|
|
229
229
|
adfDocument = new JSONTransformer().encode(state.doc);
|
|
230
|
+
version = _this.getVersionFromCollabState(state, 'collab-provider: getCurrentState');
|
|
230
231
|
currentState = {
|
|
231
232
|
content: adfDocument,
|
|
232
233
|
title: _this.metadataService.getTitle(),
|
|
233
|
-
stepVersion:
|
|
234
|
+
stepVersion: version
|
|
234
235
|
};
|
|
235
236
|
measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
236
237
|
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
|
|
237
238
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
238
239
|
});
|
|
239
240
|
return _context3.abrupt("return", currentState);
|
|
240
|
-
case
|
|
241
|
-
_context3.prev =
|
|
241
|
+
case 12:
|
|
242
|
+
_context3.prev = 12;
|
|
242
243
|
_context3.t0 = _context3["catch"](0);
|
|
243
244
|
_measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
244
245
|
(_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
|
|
@@ -246,11 +247,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
246
247
|
});
|
|
247
248
|
(_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(_context3.t0, 'Error while returning ADF version of current draft document');
|
|
248
249
|
throw _context3.t0;
|
|
249
|
-
case
|
|
250
|
+
case 18:
|
|
250
251
|
case "end":
|
|
251
252
|
return _context3.stop();
|
|
252
253
|
}
|
|
253
|
-
}, _callee3, null, [[0,
|
|
254
|
+
}, _callee3, null, [[0, 12]]);
|
|
254
255
|
})));
|
|
255
256
|
_defineProperty(this, "getUnconfirmedStepsOrigins", function () {
|
|
256
257
|
var _this$getState3, _sendableSteps;
|
|
@@ -550,7 +551,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
550
551
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
551
552
|
*/
|
|
552
553
|
_defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
553
|
-
var unconfirmedSteps, _this$getState6, _this$analyticsHelper23, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper22, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper24, _this$analyticsHelper25, _measure3;
|
|
554
|
+
var unconfirmedSteps, _this$getState6, _this$analyticsHelper23, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper22, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper24, _this$analyticsHelper25, _measure3;
|
|
554
555
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
555
556
|
while (1) switch (_context6.prev = _context6.next) {
|
|
556
557
|
case 0:
|
|
@@ -595,12 +596,13 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
595
596
|
}
|
|
596
597
|
if (_this.onSyncUpError) {
|
|
597
598
|
state = _this.getState();
|
|
599
|
+
version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
|
|
598
600
|
_this.onSyncUpError({
|
|
599
601
|
lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
|
|
600
602
|
tries: count,
|
|
601
603
|
maxRetries: ACK_MAX_TRY,
|
|
602
604
|
clientId: _this.clientId,
|
|
603
|
-
version:
|
|
605
|
+
version: version
|
|
604
606
|
});
|
|
605
607
|
}
|
|
606
608
|
unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
|
|
@@ -678,6 +680,24 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
678
680
|
this.onErrorHandled = onErrorHandled;
|
|
679
681
|
}
|
|
680
682
|
_createClass(DocumentService, [{
|
|
683
|
+
key: "getVersionFromCollabState",
|
|
684
|
+
value: function getVersionFromCollabState(state, resource) {
|
|
685
|
+
var collabState = getCollabState(state);
|
|
686
|
+
if (!collabState) {
|
|
687
|
+
var _this$analyticsHelper28;
|
|
688
|
+
(_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
|
|
689
|
+
return 0;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// This should not happen in usual, just add error event in case it happens
|
|
693
|
+
if (collabState.version === undefined) {
|
|
694
|
+
var _this$analyticsHelper29;
|
|
695
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
|
|
696
|
+
return 0;
|
|
697
|
+
}
|
|
698
|
+
return collabState.version;
|
|
699
|
+
}
|
|
700
|
+
}, {
|
|
681
701
|
key: "processQueue",
|
|
682
702
|
value: function processQueue() {
|
|
683
703
|
if (this.stepQueue.isPaused()) {
|
|
@@ -726,9 +746,9 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
726
746
|
}, 100);
|
|
727
747
|
}
|
|
728
748
|
} catch (error) {
|
|
729
|
-
var _this$
|
|
749
|
+
var _this$analyticsHelper30;
|
|
730
750
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
731
|
-
(_this$
|
|
751
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(error, 'Error while processing steps');
|
|
732
752
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
733
753
|
}
|
|
734
754
|
}
|
|
@@ -758,8 +778,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
758
778
|
var _this$getState7;
|
|
759
779
|
var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
760
780
|
if (!state) {
|
|
761
|
-
var _this$
|
|
762
|
-
(_this$
|
|
781
|
+
var _this$analyticsHelper31;
|
|
782
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
763
783
|
return;
|
|
764
784
|
}
|
|
765
785
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -773,7 +793,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
773
793
|
*/
|
|
774
794
|
function send(_tr, _oldState, newState, sendAnalyticsEvent) {
|
|
775
795
|
var unconfirmedStepsData = sendableSteps(newState);
|
|
776
|
-
var version =
|
|
796
|
+
var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
|
|
777
797
|
|
|
778
798
|
// Don't send any steps before we're ready.
|
|
779
799
|
if (!unconfirmedStepsData) {
|
|
@@ -784,8 +804,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
784
804
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
785
805
|
// sent once on connection (as opposed to on every step)
|
|
786
806
|
if (sendAnalyticsEvent) {
|
|
787
|
-
var _this$
|
|
788
|
-
(_this$
|
|
807
|
+
var _this$analyticsHelper32;
|
|
808
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
789
809
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
790
810
|
});
|
|
791
811
|
}
|
|
@@ -70,6 +70,7 @@ export declare class DocumentService implements DocumentServiceInterface {
|
|
|
70
70
|
* @param reason - optional reason to attach.
|
|
71
71
|
*/
|
|
72
72
|
private catchupv2;
|
|
73
|
+
private getVersionFromCollabState;
|
|
73
74
|
getCurrentPmVersion: () => number;
|
|
74
75
|
private processQueue;
|
|
75
76
|
getCurrentState: () => Promise<ResolvedEditorState>;
|
|
@@ -70,6 +70,7 @@ export declare class DocumentService implements DocumentServiceInterface {
|
|
|
70
70
|
* @param reason - optional reason to attach.
|
|
71
71
|
*/
|
|
72
72
|
private catchupv2;
|
|
73
|
+
private getVersionFromCollabState;
|
|
73
74
|
getCurrentPmVersion: () => number;
|
|
74
75
|
private processQueue;
|
|
75
76
|
getCurrentState: () => Promise<ResolvedEditorState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "9.40.
|
|
3
|
+
"version": "9.40.5",
|
|
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": "^
|
|
37
|
+
"@atlaskit/editor-common": "^90.2.0",
|
|
38
38
|
"@atlaskit/editor-json-transformer": "^8.18.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|