@atlaskit/collab-provider 10.3.2 → 10.3.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 +15 -0
- package/dist/cjs/document/catchupv2.js +9 -7
- package/dist/cjs/document/document-service.js +68 -59
- package/dist/cjs/provider/index.js +35 -34
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/document/catchupv2.js +2 -0
- package/dist/es2019/document/document-service.js +77 -67
- package/dist/es2019/provider/index.js +35 -34
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/document/catchupv2.js +9 -7
- package/dist/esm/document/document-service.js +69 -60
- package/dist/esm/provider/index.js +35 -34
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +2 -2
- package/dist/types/types.d.ts +5 -0
- package/dist/types-ts4.5/document/document-service.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +5 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 10.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 10.3.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#99251](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99251)
|
|
14
|
+
[`df1d982fa96ba`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/df1d982fa96ba) -
|
|
15
|
+
Add additional metadata for reconnection analytics to include step length.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 10.3.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ var _utils = require("../helpers/utils");
|
|
|
11
11
|
var logger = (0, _utils.createLogger)('Catchupv2', 'red');
|
|
12
12
|
var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
|
|
13
13
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opt) {
|
|
14
|
-
var steps, metadata, fromVersion, _yield$opt$fetchCatch, _opt$analyticsHelper, version, stepsPayload, _opt$analyticsHelper2;
|
|
14
|
+
var steps, metadata, fromVersion, _yield$opt$fetchCatch, _opt$analyticsHelper, _opt$onCatchupComplet, version, stepsPayload, _opt$analyticsHelper2;
|
|
15
15
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
16
16
|
while (1) switch (_context.prev = _context.next) {
|
|
17
17
|
case 0:
|
|
@@ -37,13 +37,15 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
|
|
|
37
37
|
throw _context.t0;
|
|
38
38
|
case 14:
|
|
39
39
|
_context.prev = 14;
|
|
40
|
+
(_opt$onCatchupComplet = opt.onCatchupComplete) === null || _opt$onCatchupComplet === void 0 || _opt$onCatchupComplet.call(opt, steps);
|
|
41
|
+
// skip onStepsAdded if steps are undefined or empty
|
|
40
42
|
if (!(!steps || steps.length === 0)) {
|
|
41
|
-
_context.next =
|
|
43
|
+
_context.next = 19;
|
|
42
44
|
break;
|
|
43
45
|
}
|
|
44
46
|
opt.updateMetadata(metadata);
|
|
45
47
|
return _context.abrupt("return", false);
|
|
46
|
-
case
|
|
48
|
+
case 19:
|
|
47
49
|
version = fromVersion + steps.length;
|
|
48
50
|
stepsPayload = {
|
|
49
51
|
version: version,
|
|
@@ -52,17 +54,17 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
|
|
|
52
54
|
opt.onStepsAdded(stepsPayload);
|
|
53
55
|
opt.updateMetadata(metadata);
|
|
54
56
|
return _context.abrupt("return", Boolean(opt.clientId && isOutOfSync(fromVersion, opt.getCurrentPmVersion(), steps, opt.clientId)));
|
|
55
|
-
case
|
|
56
|
-
_context.prev =
|
|
57
|
+
case 26:
|
|
58
|
+
_context.prev = 26;
|
|
57
59
|
_context.t1 = _context["catch"](14);
|
|
58
60
|
(_opt$analyticsHelper2 = opt.analyticsHelper) === null || _opt$analyticsHelper2 === void 0 || _opt$analyticsHelper2.sendErrorEvent(_context.t1, 'Failed to apply catchupv2 result in the editor');
|
|
59
61
|
logger("Apply catchupv2 steps failed:", _context.t1.message);
|
|
60
62
|
throw _context.t1;
|
|
61
|
-
case
|
|
63
|
+
case 31:
|
|
62
64
|
case "end":
|
|
63
65
|
return _context.stop();
|
|
64
66
|
}
|
|
65
|
-
}, _callee, null, [[1, 9], [14,
|
|
67
|
+
}, _callee, null, [[1, 9], [14, 26]]);
|
|
66
68
|
}));
|
|
67
69
|
return function catchupv2(_x) {
|
|
68
70
|
return _ref.apply(this, arguments);
|
|
@@ -68,8 +68,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
68
68
|
* To prevent calling catchup to often, use lodash throttle to reduce the frequency
|
|
69
69
|
* @param reason - optional reason to attach.
|
|
70
70
|
*/
|
|
71
|
-
(0, _defineProperty2.default)(this, "throttledCatchupv2", (0, _throttle.default)(function (reason) {
|
|
72
|
-
return _this.catchupv2(reason);
|
|
71
|
+
(0, _defineProperty2.default)(this, "throttledCatchupv2", (0, _throttle.default)(function (reason, reconnectionMetadata) {
|
|
72
|
+
return _this.catchupv2(reason, reconnectionMetadata);
|
|
73
73
|
}, CATCHUP_THROTTLE, {
|
|
74
74
|
leading: false,
|
|
75
75
|
// TODO: why shouldn't this be leading?
|
|
@@ -82,8 +82,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
82
82
|
* @param reason - optional reason to attach.
|
|
83
83
|
*/
|
|
84
84
|
(0, _defineProperty2.default)(this, "catchupv2", /*#__PURE__*/function () {
|
|
85
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reason) {
|
|
86
|
-
var start, _this$
|
|
85
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reason, reconnectionMetadata) {
|
|
86
|
+
var start, _this$analyticsHelper2, latency, _this$analyticsHelper3, _latency;
|
|
87
87
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
88
88
|
while (1) switch (_context.prev = _context.next) {
|
|
89
89
|
case 0:
|
|
@@ -113,12 +113,21 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
113
113
|
clientId: _this.clientId,
|
|
114
114
|
onStepsAdded: _this.onStepsAdded,
|
|
115
115
|
catchUpOutofSync: _this.catchUpOutofSync,
|
|
116
|
-
reason: reason
|
|
116
|
+
reason: reason,
|
|
117
|
+
onCatchupComplete: function onCatchupComplete(steps) {
|
|
118
|
+
// We want to capture the number of steps made while offline vs. online
|
|
119
|
+
if (reason === _const.CatchupEventReason.RECONNECTED) {
|
|
120
|
+
var _this$analyticsHelper, _steps$length;
|
|
121
|
+
(_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 || _this$analyticsHelper.sendActionEvent(_const.EVENT_ACTION.RECONNECTION, _const.EVENT_STATUS.INFO, _objectSpread(_objectSpread({}, reconnectionMetadata), {}, {
|
|
122
|
+
remoteStepsLength: (_steps$length = steps === null || steps === void 0 ? void 0 : steps.length) !== null && _steps$length !== void 0 ? _steps$length : 0
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
117
126
|
});
|
|
118
127
|
case 11:
|
|
119
128
|
_this.catchUpOutofSync = _context.sent;
|
|
120
129
|
latency = new Date().getTime() - start;
|
|
121
|
-
(_this$
|
|
130
|
+
(_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.SUCCESS, {
|
|
122
131
|
latency: latency
|
|
123
132
|
});
|
|
124
133
|
_context.next = 20;
|
|
@@ -127,7 +136,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
127
136
|
_context.prev = 16;
|
|
128
137
|
_context.t0 = _context["catch"](8);
|
|
129
138
|
_latency = new Date().getTime() - start;
|
|
130
|
-
(_this$
|
|
139
|
+
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.FAILURE, {
|
|
131
140
|
latency: _latency
|
|
132
141
|
});
|
|
133
142
|
case 20:
|
|
@@ -143,7 +152,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
143
152
|
}
|
|
144
153
|
}, _callee, null, [[8, 16, 20, 26]]);
|
|
145
154
|
}));
|
|
146
|
-
return function (_x) {
|
|
155
|
+
return function (_x, _x2) {
|
|
147
156
|
return _ref.apply(this, arguments);
|
|
148
157
|
};
|
|
149
158
|
}());
|
|
@@ -151,8 +160,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
151
160
|
var _this$getState;
|
|
152
161
|
var state = (_this$getState = _this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(_this);
|
|
153
162
|
if (!state) {
|
|
154
|
-
var _this$
|
|
155
|
-
(_this$
|
|
163
|
+
var _this$analyticsHelper4;
|
|
164
|
+
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
|
|
156
165
|
return 0;
|
|
157
166
|
}
|
|
158
167
|
return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
@@ -160,7 +169,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
160
169
|
// Ignored via go/ees005
|
|
161
170
|
// eslint-disable-next-line require-await
|
|
162
171
|
(0, _defineProperty2.default)(this, "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
163
|
-
var _this$getState2, _this$
|
|
172
|
+
var _this$getState2, _this$analyticsHelper6, _this$analyticsHelper5, state, adfDocument, version, currentState, measure, _this$analyticsHelper7, _this$analyticsHelper8, _measure;
|
|
164
173
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
165
174
|
while (1) switch (_context2.prev = _context2.next) {
|
|
166
175
|
case 0:
|
|
@@ -169,7 +178,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
169
178
|
|
|
170
179
|
// Convert ProseMirror document in Editor state to ADF document
|
|
171
180
|
if (!((_this$getState2 = _this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(_this))) {
|
|
172
|
-
(_this$
|
|
181
|
+
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
|
|
173
182
|
}
|
|
174
183
|
// Ignored via go/ees005
|
|
175
184
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -182,7 +191,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
182
191
|
stepVersion: version
|
|
183
192
|
};
|
|
184
193
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
185
|
-
(_this$
|
|
194
|
+
(_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 || _this$analyticsHelper6.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.SUCCESS, {
|
|
186
195
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
187
196
|
});
|
|
188
197
|
return _context2.abrupt("return", currentState);
|
|
@@ -190,10 +199,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
190
199
|
_context2.prev = 12;
|
|
191
200
|
_context2.t0 = _context2["catch"](0);
|
|
192
201
|
_measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
193
|
-
(_this$
|
|
202
|
+
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.FAILURE, {
|
|
194
203
|
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
|
|
195
204
|
});
|
|
196
|
-
(_this$
|
|
205
|
+
(_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(_context2.t0, 'Error while returning ADF version of current draft document');
|
|
197
206
|
throw _context2.t0;
|
|
198
207
|
case 18:
|
|
199
208
|
case "end":
|
|
@@ -225,8 +234,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
225
234
|
}
|
|
226
235
|
return false;
|
|
227
236
|
} catch (err) {
|
|
228
|
-
var _this$
|
|
229
|
-
(_this$
|
|
237
|
+
var _this$analyticsHelper9;
|
|
238
|
+
(_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
|
|
230
239
|
return false;
|
|
231
240
|
}
|
|
232
241
|
});
|
|
@@ -234,8 +243,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
234
243
|
var _this$getState3, _sendableSteps;
|
|
235
244
|
var state = (_this$getState3 = _this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(_this);
|
|
236
245
|
if (!state) {
|
|
237
|
-
var _this$
|
|
238
|
-
(_this$
|
|
246
|
+
var _this$analyticsHelper10;
|
|
247
|
+
(_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
|
|
239
248
|
return;
|
|
240
249
|
}
|
|
241
250
|
return (_sendableSteps = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
|
|
@@ -244,8 +253,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
244
253
|
var _this$getState4, _sendableSteps2;
|
|
245
254
|
var state = (_this$getState4 = _this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(_this);
|
|
246
255
|
if (!state) {
|
|
247
|
-
var _this$
|
|
248
|
-
(_this$
|
|
256
|
+
var _this$analyticsHelper11;
|
|
257
|
+
(_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
|
|
249
258
|
return;
|
|
250
259
|
}
|
|
251
260
|
return (_sendableSteps2 = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
|
|
@@ -285,8 +294,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
285
294
|
return userId;
|
|
286
295
|
}));
|
|
287
296
|
} catch (stepsAddedError) {
|
|
288
|
-
var _this$
|
|
289
|
-
(_this$
|
|
297
|
+
var _this$analyticsHelper12;
|
|
298
|
+
(_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
|
|
290
299
|
_this.onErrorHandled({
|
|
291
300
|
message: 'Error while adding steps in the provider',
|
|
292
301
|
data: {
|
|
@@ -300,7 +309,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
300
309
|
// Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
301
310
|
(0, _defineProperty2.default)(this, "onRestore", /*#__PURE__*/function () {
|
|
302
311
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref6) {
|
|
303
|
-
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$
|
|
312
|
+
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper15, _this$analyticsHelper13, _this$analyticsHelper14, _this$analyticsHelper16, _this$analyticsHelper17;
|
|
304
313
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
305
314
|
while (1) switch (_context3.prev = _context3.next) {
|
|
306
315
|
case 0:
|
|
@@ -338,7 +347,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
338
347
|
break;
|
|
339
348
|
}
|
|
340
349
|
_context3.prev = 12;
|
|
341
|
-
(_this$
|
|
350
|
+
(_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.INFO, {
|
|
342
351
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
343
352
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
344
353
|
clientId: _this.clientId,
|
|
@@ -353,7 +362,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
353
362
|
case 17:
|
|
354
363
|
_context3.prev = 17;
|
|
355
364
|
_context3.t0 = _context3["catch"](12);
|
|
356
|
-
(_this$
|
|
365
|
+
(_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_context3.t0, "Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile");
|
|
357
366
|
useReconcile = true;
|
|
358
367
|
_context3.next = 23;
|
|
359
368
|
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
@@ -377,7 +386,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
377
386
|
_this.applyLocalSteps(unconfirmedSteps);
|
|
378
387
|
}
|
|
379
388
|
case 31:
|
|
380
|
-
(_this$
|
|
389
|
+
(_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
|
|
381
390
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
382
391
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
383
392
|
useReconcile: useReconcile,
|
|
@@ -390,14 +399,14 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
390
399
|
case 34:
|
|
391
400
|
_context3.prev = 34;
|
|
392
401
|
_context3.t1 = _context3["catch"](8);
|
|
393
|
-
(_this$
|
|
402
|
+
(_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
|
|
394
403
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
395
404
|
useReconcile: useReconcile,
|
|
396
405
|
clientId: _this.clientId,
|
|
397
406
|
targetClientId: targetClientId,
|
|
398
407
|
triggeredByCatchup: targetClientId ? true : false
|
|
399
408
|
});
|
|
400
|
-
(_this$
|
|
409
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(_context3.t1, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
|
|
401
410
|
_this.onErrorHandled({
|
|
402
411
|
message: 'Caught error while trying to recover the document',
|
|
403
412
|
data: {
|
|
@@ -412,12 +421,12 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
412
421
|
}
|
|
413
422
|
}, _callee3, null, [[8, 34], [12, 17]]);
|
|
414
423
|
}));
|
|
415
|
-
return function (
|
|
424
|
+
return function (_x3) {
|
|
416
425
|
return _ref7.apply(this, arguments);
|
|
417
426
|
};
|
|
418
427
|
}());
|
|
419
428
|
(0, _defineProperty2.default)(this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
420
|
-
var _this$
|
|
429
|
+
var _this$analyticsHelper18, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure2;
|
|
421
430
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
422
431
|
while (1) switch (_context4.prev = _context4.next) {
|
|
423
432
|
case 0:
|
|
@@ -452,7 +461,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
452
461
|
};
|
|
453
462
|
case 20:
|
|
454
463
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
455
|
-
(_this$
|
|
464
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
|
|
456
465
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
457
466
|
});
|
|
458
467
|
_this.aggressiveCatchup = false;
|
|
@@ -462,10 +471,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
462
471
|
_context4.t1 = _context4["catch"](1);
|
|
463
472
|
_this.aggressiveCatchup = false;
|
|
464
473
|
_measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
465
|
-
(_this$
|
|
474
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
|
|
466
475
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
|
|
467
476
|
});
|
|
468
|
-
(_this$
|
|
477
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
|
|
469
478
|
throw _context4.t1;
|
|
470
479
|
case 33:
|
|
471
480
|
case "end":
|
|
@@ -495,7 +504,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
495
504
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
496
505
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
497
506
|
if (updatedVersion < version) {
|
|
498
|
-
var _doc$content, _this$
|
|
507
|
+
var _doc$content, _this$analyticsHelper21;
|
|
499
508
|
var error = new _customErrors.UpdateDocumentError('Failed to update the document', {
|
|
500
509
|
newVersion: version,
|
|
501
510
|
editorVersion: updatedVersion,
|
|
@@ -503,7 +512,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
503
512
|
docHasContent: (doc === null || doc === void 0 || (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
|
|
504
513
|
isDocContentValid: isDocContentValid
|
|
505
514
|
});
|
|
506
|
-
(_this$
|
|
515
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
507
516
|
if (_this.enableErrorOnFailedDocumentApply) {
|
|
508
517
|
_this.onErrorHandled({
|
|
509
518
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -520,8 +529,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
520
529
|
}
|
|
521
530
|
// Otherwise just fail silently for now
|
|
522
531
|
} else {
|
|
523
|
-
var _this$
|
|
524
|
-
(_this$
|
|
532
|
+
var _this$analyticsHelper22, _doc$content2;
|
|
533
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.UPDATE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
|
|
525
534
|
newVersion: version,
|
|
526
535
|
editorVersion: updatedVersion,
|
|
527
536
|
isDocTruthy: !!doc,
|
|
@@ -536,8 +545,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
536
545
|
try {
|
|
537
546
|
var _this$getState5;
|
|
538
547
|
if (!((_this$getState5 = _this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(_this))) {
|
|
539
|
-
var _this$
|
|
540
|
-
(_this$
|
|
548
|
+
var _this$analyticsHelper23;
|
|
549
|
+
(_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
541
550
|
}
|
|
542
551
|
// Ignored via go/ees005
|
|
543
552
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -564,7 +573,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
564
573
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
565
574
|
*/
|
|
566
575
|
(0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
567
|
-
var unconfirmedSteps, _this$getState6, _this$
|
|
576
|
+
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;
|
|
568
577
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
569
578
|
while (1) switch (_context5.prev = _context5.next) {
|
|
570
579
|
case 0:
|
|
@@ -583,7 +592,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
583
592
|
lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
584
593
|
isLastTrConfirmed = false;
|
|
585
594
|
if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
|
|
586
|
-
(_this$
|
|
595
|
+
(_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
587
596
|
}
|
|
588
597
|
case 9:
|
|
589
598
|
if (isLastTrConfirmed) {
|
|
@@ -632,7 +641,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
632
641
|
break;
|
|
633
642
|
case 22:
|
|
634
643
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
635
|
-
(_this$
|
|
644
|
+
(_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
|
|
636
645
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
637
646
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
638
647
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
@@ -644,11 +653,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
644
653
|
_context5.prev = 26;
|
|
645
654
|
_context5.t0 = _context5["catch"](1);
|
|
646
655
|
_measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
647
|
-
(_this$
|
|
656
|
+
(_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
|
|
648
657
|
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
649
658
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
650
659
|
});
|
|
651
|
-
(_this$
|
|
660
|
+
(_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
|
|
652
661
|
throw _context5.t0;
|
|
653
662
|
case 32:
|
|
654
663
|
case "end":
|
|
@@ -657,17 +666,17 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
657
666
|
}, _callee5, null, [[1, 26]]);
|
|
658
667
|
})));
|
|
659
668
|
(0, _defineProperty2.default)(this, "onStepRejectedError", function () {
|
|
660
|
-
var _this$
|
|
669
|
+
var _this$analyticsHelper28;
|
|
661
670
|
_this.stepRejectCounter++;
|
|
662
671
|
logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
|
|
663
|
-
(_this$
|
|
672
|
+
(_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
|
|
664
673
|
count: _this.stepRejectCounter
|
|
665
674
|
});
|
|
666
675
|
var maxRetries = _this.aggressiveCatchup ? _provider.MAX_STEP_REJECTED_ERROR_AGGRESSIVE : _provider.MAX_STEP_REJECTED_ERROR;
|
|
667
676
|
if (_this.stepRejectCounter >= maxRetries) {
|
|
668
|
-
var _this$
|
|
677
|
+
var _this$analyticsHelper29;
|
|
669
678
|
logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
|
|
670
|
-
(_this$
|
|
679
|
+
(_this$analyticsHelper29 = _this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
|
|
671
680
|
_this.throttledCatchupv2(_const.CatchupEventReason.STEPS_REJECTED);
|
|
672
681
|
} else {
|
|
673
682
|
// If committing steps failed try again automatically in 1s
|
|
@@ -699,15 +708,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
699
708
|
value: function getVersionFromCollabState(state, resource) {
|
|
700
709
|
var collabState = (0, _prosemirrorCollab.getCollabState)(state);
|
|
701
710
|
if (!collabState) {
|
|
702
|
-
var _this$
|
|
703
|
-
(_this$
|
|
711
|
+
var _this$analyticsHelper30;
|
|
712
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
|
|
704
713
|
return 0;
|
|
705
714
|
}
|
|
706
715
|
|
|
707
716
|
// This should not happen in usual, just add error event in case it happens
|
|
708
717
|
if (collabState.version === undefined) {
|
|
709
|
-
var _this$
|
|
710
|
-
(_this$
|
|
718
|
+
var _this$analyticsHelper31;
|
|
719
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
|
|
711
720
|
return 0;
|
|
712
721
|
}
|
|
713
722
|
return collabState.version;
|
|
@@ -769,11 +778,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
769
778
|
}, 100);
|
|
770
779
|
}
|
|
771
780
|
} catch (error) {
|
|
772
|
-
var _this$
|
|
781
|
+
var _this$analyticsHelper32;
|
|
773
782
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
774
783
|
var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
775
784
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
776
|
-
(_this$
|
|
785
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
|
|
777
786
|
this.throttledCatchupv2(_const.CatchupEventReason.PROCESS_STEPS);
|
|
778
787
|
}
|
|
779
788
|
}
|
|
@@ -808,8 +817,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
808
817
|
var _this$getState7;
|
|
809
818
|
var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
810
819
|
if (!state) {
|
|
811
|
-
var _this$
|
|
812
|
-
(_this$
|
|
820
|
+
var _this$analyticsHelper33;
|
|
821
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
813
822
|
return;
|
|
814
823
|
}
|
|
815
824
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -842,8 +851,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
842
851
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
843
852
|
// sent once on connection (as opposed to on every step)
|
|
844
853
|
if (sendAnalyticsEvent) {
|
|
845
|
-
var _this$
|
|
846
|
-
(_this$
|
|
854
|
+
var _this$analyticsHelper34;
|
|
855
|
+
(_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 || _this$analyticsHelper34.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
|
|
847
856
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
848
857
|
});
|
|
849
858
|
}
|