@atlaskit/collab-provider 14.0.6 → 14.0.7
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 +6 -0
- package/dist/cjs/document/document-service.js +77 -64
- package/dist/cjs/provider/index.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/document/document-service.js +88 -73
- package/dist/es2019/provider/index.js +2 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/document/document-service.js +77 -64
- package/dist/esm/provider/index.js +2 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/package.json +10 -7
|
@@ -10,6 +10,7 @@ import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform'
|
|
|
10
10
|
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
11
11
|
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
15
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
15
16
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
@@ -91,7 +92,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
91
92
|
*/
|
|
92
93
|
_defineProperty(this, "catchupv2", /*#__PURE__*/function () {
|
|
93
94
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(reason, reconnectionMetadata, sessionId) {
|
|
94
|
-
var start, _this$analyticsHelper2, latency, _this$analyticsHelper3,
|
|
95
|
+
var start, _this$analyticsHelper2, latency, _latency, errorMessage, _this$analyticsHelper3, _this$analyticsHelper4;
|
|
95
96
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
96
97
|
while (1) switch (_context.prev = _context.next) {
|
|
97
98
|
case 0:
|
|
@@ -147,13 +148,25 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
147
148
|
case 16:
|
|
148
149
|
_context.prev = 16;
|
|
149
150
|
_context.t0 = _context["catch"](8);
|
|
150
|
-
_latency = new Date().getTime() - start;
|
|
151
|
-
(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
_latency = new Date().getTime() - start; // Skip client side errors; TypeErrors are client side errors https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch
|
|
152
|
+
if (fg('platform_collab_do_not_client_error_log')) {
|
|
153
|
+
errorMessage = _context.t0 instanceof Error ? _context.t0.message : String(_context.t0);
|
|
154
|
+
if (!errorMessage.includes('TypeError') && !(_context.t0 instanceof TypeError)) {
|
|
155
|
+
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
|
|
156
|
+
latency: _latency,
|
|
157
|
+
reason: reason,
|
|
158
|
+
unconfirmedStepsLength: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.unconfirmedStepsLength,
|
|
159
|
+
disconnectionPeriodSeconds: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.disconnectionPeriodSeconds
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
|
|
164
|
+
latency: _latency,
|
|
165
|
+
reason: reason,
|
|
166
|
+
unconfirmedStepsLength: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.unconfirmedStepsLength,
|
|
167
|
+
disconnectionPeriodSeconds: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.disconnectionPeriodSeconds
|
|
168
|
+
});
|
|
169
|
+
}
|
|
157
170
|
case 20:
|
|
158
171
|
_context.prev = 20;
|
|
159
172
|
_this.stepQueue.resumeQueue();
|
|
@@ -175,8 +188,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
175
188
|
var _this$getState;
|
|
176
189
|
var state = (_this$getState = _this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(_this);
|
|
177
190
|
if (!state) {
|
|
178
|
-
var _this$
|
|
179
|
-
(_this$
|
|
191
|
+
var _this$analyticsHelper5;
|
|
192
|
+
(_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');
|
|
180
193
|
return 0;
|
|
181
194
|
}
|
|
182
195
|
return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
@@ -184,7 +197,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
184
197
|
// Ignored via go/ees005
|
|
185
198
|
// eslint-disable-next-line require-await
|
|
186
199
|
_defineProperty(this, "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
187
|
-
var _this$getState2, _this$
|
|
200
|
+
var _this$getState2, _this$analyticsHelper7, _this$analyticsHelper6, state, adfDocument, version, currentState, measure, _this$analyticsHelper8, _this$analyticsHelper9, _measure;
|
|
188
201
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
189
202
|
while (1) switch (_context2.prev = _context2.next) {
|
|
190
203
|
case 0:
|
|
@@ -193,7 +206,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
193
206
|
|
|
194
207
|
// Convert ProseMirror document in Editor state to ADF document
|
|
195
208
|
if (!((_this$getState2 = _this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(_this))) {
|
|
196
|
-
(_this$
|
|
209
|
+
(_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 || _this$analyticsHelper6.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
|
|
197
210
|
}
|
|
198
211
|
// Ignored via go/ees005
|
|
199
212
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -206,7 +219,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
206
219
|
stepVersion: version
|
|
207
220
|
};
|
|
208
221
|
measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
209
|
-
(_this$
|
|
222
|
+
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
|
|
210
223
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
211
224
|
});
|
|
212
225
|
return _context2.abrupt("return", currentState);
|
|
@@ -214,10 +227,10 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
214
227
|
_context2.prev = 12;
|
|
215
228
|
_context2.t0 = _context2["catch"](0);
|
|
216
229
|
_measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
217
|
-
(_this$
|
|
230
|
+
(_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
|
|
218
231
|
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
|
|
219
232
|
});
|
|
220
|
-
(_this$
|
|
233
|
+
(_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(_context2.t0, 'Error while returning ADF version of current draft document');
|
|
221
234
|
throw _context2.t0;
|
|
222
235
|
case 18:
|
|
223
236
|
case "end":
|
|
@@ -249,8 +262,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
249
262
|
}
|
|
250
263
|
return false;
|
|
251
264
|
} catch (err) {
|
|
252
|
-
var _this$
|
|
253
|
-
(_this$
|
|
265
|
+
var _this$analyticsHelper0;
|
|
266
|
+
(_this$analyticsHelper0 = _this.analyticsHelper) === null || _this$analyticsHelper0 === void 0 || _this$analyticsHelper0.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
|
|
254
267
|
return false;
|
|
255
268
|
}
|
|
256
269
|
});
|
|
@@ -258,8 +271,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
258
271
|
var _this$getState3, _sendableSteps;
|
|
259
272
|
var state = (_this$getState3 = _this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(_this);
|
|
260
273
|
if (!state) {
|
|
261
|
-
var _this$
|
|
262
|
-
(_this$
|
|
274
|
+
var _this$analyticsHelper1;
|
|
275
|
+
(_this$analyticsHelper1 = _this.analyticsHelper) === null || _this$analyticsHelper1 === void 0 || _this$analyticsHelper1.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
|
|
263
276
|
return;
|
|
264
277
|
}
|
|
265
278
|
return (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
|
|
@@ -268,8 +281,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
268
281
|
var _this$getState4, _sendableSteps2;
|
|
269
282
|
var state = (_this$getState4 = _this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(_this);
|
|
270
283
|
if (!state) {
|
|
271
|
-
var _this$
|
|
272
|
-
(_this$
|
|
284
|
+
var _this$analyticsHelper10;
|
|
285
|
+
(_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
|
|
273
286
|
return;
|
|
274
287
|
}
|
|
275
288
|
return (_sendableSteps2 = sendableSteps(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
|
|
@@ -312,8 +325,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
312
325
|
return userId;
|
|
313
326
|
}));
|
|
314
327
|
} catch (stepsAddedError) {
|
|
315
|
-
var _this$
|
|
316
|
-
(_this$
|
|
328
|
+
var _this$analyticsHelper11;
|
|
329
|
+
(_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(stepsAddedError, ADD_STEPS_PROVIDER_ERROR_MSG);
|
|
317
330
|
_this.onErrorHandled({
|
|
318
331
|
message: ADD_STEPS_PROVIDER_ERROR_MSG,
|
|
319
332
|
data: {
|
|
@@ -353,7 +366,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
353
366
|
// Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
354
367
|
_defineProperty(this, "onRestore", /*#__PURE__*/function () {
|
|
355
368
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
|
|
356
|
-
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$obfuscateStepsA, obfuscatedSteps, obfuscatedDoc, _this$
|
|
369
|
+
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$obfuscateStepsA, obfuscatedSteps, obfuscatedDoc, _this$analyticsHelper16, _this$analyticsHelper12, _this$getState5, generatedDiffStepsResponse, generatedSteps, state, stepsToBeApplied, _this$analyticsHelper13, _this$analyticsHelper14, _this$analyticsHelper15, _this$analyticsHelper17, _this$analyticsHelper18;
|
|
357
370
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
358
371
|
while (1) switch (_context3.prev = _context3.next) {
|
|
359
372
|
case 0:
|
|
@@ -392,7 +405,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
392
405
|
});
|
|
393
406
|
_this.metadataService.updateMetadata(metadata);
|
|
394
407
|
_context3.prev = 13;
|
|
395
|
-
(_this$
|
|
408
|
+
(_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
396
409
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
397
410
|
obfuscatedSteps: obfuscatedSteps,
|
|
398
411
|
obfuscatedDoc: obfuscatedDoc,
|
|
@@ -433,12 +446,12 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
433
446
|
return ProseMirrorStep.fromJSON(state.schema, s);
|
|
434
447
|
});
|
|
435
448
|
if (stepsToBeApplied && stepsToBeApplied.length > 0) {
|
|
436
|
-
(_this$
|
|
449
|
+
(_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
437
450
|
stepsCount: stepsToBeApplied.length
|
|
438
451
|
});
|
|
439
452
|
_this.applyLocalSteps(stepsToBeApplied);
|
|
440
453
|
} else {
|
|
441
|
-
(_this$
|
|
454
|
+
(_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
442
455
|
reason: 'fetchGeneratedDiffSteps returned no steps'
|
|
443
456
|
});
|
|
444
457
|
}
|
|
@@ -448,9 +461,9 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
448
461
|
case 31:
|
|
449
462
|
_context3.prev = 31;
|
|
450
463
|
_context3.t1 = _context3["catch"](22);
|
|
451
|
-
(_this$
|
|
464
|
+
(_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendErrorEvent(_context3.t1, "Error fetchGeneratedDiffSteps with steps-only mode");
|
|
452
465
|
case 34:
|
|
453
|
-
(_this$
|
|
466
|
+
(_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
454
467
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
455
468
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
456
469
|
useReconcile: useReconcile,
|
|
@@ -463,14 +476,14 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
463
476
|
case 37:
|
|
464
477
|
_context3.prev = 37;
|
|
465
478
|
_context3.t2 = _context3["catch"](10);
|
|
466
|
-
(_this$
|
|
479
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
|
|
467
480
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
468
481
|
useReconcile: useReconcile,
|
|
469
482
|
clientId: _this.clientId,
|
|
470
483
|
targetClientId: targetClientId,
|
|
471
484
|
triggeredByCatchup: !!targetClientId
|
|
472
485
|
});
|
|
473
|
-
(_this$
|
|
486
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendErrorEvent(_context3.t2, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
|
|
474
487
|
_this.onErrorHandled({
|
|
475
488
|
message: 'Caught error while trying to recover the document',
|
|
476
489
|
data: {
|
|
@@ -491,7 +504,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
491
504
|
}());
|
|
492
505
|
_defineProperty(this, "getFinalAcknowledgedState", /*#__PURE__*/function () {
|
|
493
506
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(reason) {
|
|
494
|
-
var _this$
|
|
507
|
+
var _this$analyticsHelper19, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper20, _this$analyticsHelper21, _measure2;
|
|
495
508
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
496
509
|
while (1) switch (_context4.prev = _context4.next) {
|
|
497
510
|
case 0:
|
|
@@ -526,7 +539,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
526
539
|
};
|
|
527
540
|
case 20:
|
|
528
541
|
measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
529
|
-
(_this$
|
|
542
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
530
543
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
531
544
|
});
|
|
532
545
|
_this.aggressiveCatchup = false;
|
|
@@ -536,10 +549,10 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
536
549
|
_context4.t1 = _context4["catch"](1);
|
|
537
550
|
_this.aggressiveCatchup = false;
|
|
538
551
|
_measure2 = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
539
|
-
(_this$
|
|
552
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
540
553
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
|
|
541
554
|
});
|
|
542
|
-
(_this$
|
|
555
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
|
|
543
556
|
throw _context4.t1;
|
|
544
557
|
case 33:
|
|
545
558
|
case "end":
|
|
@@ -574,7 +587,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
574
587
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
575
588
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
576
589
|
if (updatedVersion < version) {
|
|
577
|
-
var _doc$content, _this$
|
|
590
|
+
var _doc$content, _this$analyticsHelper22;
|
|
578
591
|
var error = new UpdateDocumentError('Failed to update the document', {
|
|
579
592
|
newVersion: version,
|
|
580
593
|
editorVersion: updatedVersion,
|
|
@@ -583,7 +596,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
583
596
|
isDocContentValid: isDocContentValid,
|
|
584
597
|
caller: caller
|
|
585
598
|
});
|
|
586
|
-
(_this$
|
|
599
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
587
600
|
if (_this.enableErrorOnFailedDocumentApply) {
|
|
588
601
|
_this.onErrorHandled({
|
|
589
602
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -600,8 +613,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
600
613
|
}
|
|
601
614
|
// Otherwise just fail silently for now
|
|
602
615
|
} else {
|
|
603
|
-
var _this$
|
|
604
|
-
(_this$
|
|
616
|
+
var _this$analyticsHelper23, _doc$content2;
|
|
617
|
+
(_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
605
618
|
newVersion: version,
|
|
606
619
|
editorVersion: updatedVersion,
|
|
607
620
|
isDocTruthy: !!doc,
|
|
@@ -616,8 +629,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
616
629
|
try {
|
|
617
630
|
var _this$getState6;
|
|
618
631
|
if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
|
|
619
|
-
var _this$
|
|
620
|
-
(_this$
|
|
632
|
+
var _this$analyticsHelper24;
|
|
633
|
+
(_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
621
634
|
}
|
|
622
635
|
// Ignored via go/ees005
|
|
623
636
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -647,7 +660,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
647
660
|
*/
|
|
648
661
|
_defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/function () {
|
|
649
662
|
var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(reason) {
|
|
650
|
-
var unconfirmedSteps, _this$getState7, _this$
|
|
663
|
+
var unconfirmedSteps, _this$getState7, _this$analyticsHelper26, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper25, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper27, _this$analyticsHelper28, _measure3;
|
|
651
664
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
652
665
|
while (1) switch (_context5.prev = _context5.next) {
|
|
653
666
|
case 0:
|
|
@@ -666,7 +679,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
666
679
|
lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
667
680
|
isLastTrConfirmed = false;
|
|
668
681
|
if (!((_this$getState7 = _this.getState) !== null && _this$getState7 !== void 0 && _this$getState7.call(_this))) {
|
|
669
|
-
(_this$
|
|
682
|
+
(_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
670
683
|
}
|
|
671
684
|
case 9:
|
|
672
685
|
if (isLastTrConfirmed) {
|
|
@@ -716,7 +729,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
716
729
|
break;
|
|
717
730
|
case 22:
|
|
718
731
|
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
719
|
-
(_this$
|
|
732
|
+
(_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
720
733
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
721
734
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
722
735
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
@@ -728,11 +741,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
728
741
|
_context5.prev = 26;
|
|
729
742
|
_context5.t0 = _context5["catch"](1);
|
|
730
743
|
_measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
731
|
-
(_this$
|
|
744
|
+
(_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
732
745
|
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
733
746
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
734
747
|
});
|
|
735
|
-
(_this$
|
|
748
|
+
(_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
|
|
736
749
|
throw _context5.t0;
|
|
737
750
|
case 32:
|
|
738
751
|
case "end":
|
|
@@ -745,17 +758,17 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
745
758
|
};
|
|
746
759
|
}());
|
|
747
760
|
_defineProperty(this, "onStepRejectedError", function () {
|
|
748
|
-
var _this$
|
|
761
|
+
var _this$analyticsHelper29;
|
|
749
762
|
_this.stepRejectCounter++;
|
|
750
763
|
logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
|
|
751
|
-
(_this$
|
|
764
|
+
(_this$analyticsHelper29 = _this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
752
765
|
count: _this.stepRejectCounter
|
|
753
766
|
});
|
|
754
767
|
var maxRetries = _this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
|
|
755
768
|
if (_this.stepRejectCounter >= maxRetries) {
|
|
756
|
-
var _this$
|
|
769
|
+
var _this$analyticsHelper30;
|
|
757
770
|
logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
|
|
758
|
-
(_this$
|
|
771
|
+
(_this$analyticsHelper30 = _this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
759
772
|
_this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
|
|
760
773
|
} else {
|
|
761
774
|
// If committing steps failed try again automatically in 1s
|
|
@@ -811,15 +824,15 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
811
824
|
value: function getVersionFromCollabState(state, resource) {
|
|
812
825
|
var collabState = getCollabState(state);
|
|
813
826
|
if (!collabState) {
|
|
814
|
-
var _this$
|
|
815
|
-
(_this$
|
|
827
|
+
var _this$analyticsHelper31;
|
|
828
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
|
|
816
829
|
return 0;
|
|
817
830
|
}
|
|
818
831
|
|
|
819
832
|
// This should not happen in usual, just add error event in case it happens
|
|
820
833
|
if (collabState.version === undefined) {
|
|
821
|
-
var _this$
|
|
822
|
-
(_this$
|
|
834
|
+
var _this$analyticsHelper32;
|
|
835
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
|
|
823
836
|
return 0;
|
|
824
837
|
}
|
|
825
838
|
return collabState.version;
|
|
@@ -895,7 +908,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
895
908
|
logger("Processing data. Version \"".concat(version, "\"."));
|
|
896
909
|
if (steps !== null && steps !== void 0 && steps.length) {
|
|
897
910
|
try {
|
|
898
|
-
var _this$
|
|
911
|
+
var _this$analyticsHelper33;
|
|
899
912
|
var clientIds = steps.map(function (_ref1) {
|
|
900
913
|
var clientId = _ref1.clientId;
|
|
901
914
|
return clientId;
|
|
@@ -917,13 +930,13 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
917
930
|
return _this2.sendStepsFromCurrentState();
|
|
918
931
|
}, 100);
|
|
919
932
|
}
|
|
920
|
-
(_this$
|
|
933
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendActionEvent(EVENT_ACTION.PROCESS_STEPS, EVENT_STATUS.SUCCESS);
|
|
921
934
|
} catch (error) {
|
|
922
|
-
var _this$
|
|
935
|
+
var _this$analyticsHelper34;
|
|
923
936
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
924
937
|
var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
925
938
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
926
|
-
(_this$
|
|
939
|
+
(_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 || _this$analyticsHelper34.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
|
|
927
940
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
928
941
|
}
|
|
929
942
|
}
|
|
@@ -975,8 +988,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
975
988
|
var _this$getState0;
|
|
976
989
|
var state = (_this$getState0 = this.getState) === null || _this$getState0 === void 0 ? void 0 : _this$getState0.call(this);
|
|
977
990
|
if (!state) {
|
|
978
|
-
var _this$
|
|
979
|
-
(_this$
|
|
991
|
+
var _this$analyticsHelper35;
|
|
992
|
+
(_this$analyticsHelper35 = this.analyticsHelper) === null || _this$analyticsHelper35 === void 0 || _this$analyticsHelper35.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
980
993
|
return;
|
|
981
994
|
}
|
|
982
995
|
this.send(null, null, state, sendAnalyticsEvent, reason);
|
|
@@ -1027,8 +1040,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
1027
1040
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
1028
1041
|
// sent once on connection (as opposed to on every step)
|
|
1029
1042
|
if (sendAnalyticsEvent) {
|
|
1030
|
-
var _this$
|
|
1031
|
-
(_this$
|
|
1043
|
+
var _this$analyticsHelper36;
|
|
1044
|
+
(_this$analyticsHelper36 = this.analyticsHelper) === null || _this$analyticsHelper36 === void 0 || _this$analyticsHelper36.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
1032
1045
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
1033
1046
|
});
|
|
1034
1047
|
}
|
|
@@ -1037,12 +1050,12 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
1037
1050
|
}
|
|
1038
1051
|
var rebased = tr === null || tr === void 0 ? void 0 : tr.getMeta('rebasedData');
|
|
1039
1052
|
if (rebased) {
|
|
1040
|
-
var _this$
|
|
1053
|
+
var _this$analyticsHelper37;
|
|
1041
1054
|
var obfuscatedUnconfirmedSteps = this.obfuscateStepsAndState(rebased.unconfirmedSteps).obfuscatedSteps;
|
|
1042
1055
|
var obfuscatedRemoteSteps = this.obfuscateStepsAndState(rebased.remoteSteps);
|
|
1043
1056
|
var obfuscatedRebasedSteps = this.obfuscateStepsAndState(unconfirmedSteps).obfuscatedSteps;
|
|
1044
1057
|
// send analtyics on unconfirmed steps
|
|
1045
|
-
(_this$
|
|
1058
|
+
(_this$analyticsHelper37 = this.analyticsHelper) === null || _this$analyticsHelper37 === void 0 || _this$analyticsHelper37.sendActionEvent(EVENT_ACTION.STEPS_REBASED, EVENT_STATUS.INFO, {
|
|
1046
1059
|
obfuscatedUnconfirmedSteps: obfuscatedUnconfirmedSteps,
|
|
1047
1060
|
obfuscatedRemoteSteps: obfuscatedRemoteSteps,
|
|
1048
1061
|
obfuscatedRebasedSteps: obfuscatedRebasedSteps,
|
|
@@ -12,6 +12,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
12
12
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
15
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
15
16
|
import { v4 as uuidv4 } from 'uuid';
|
|
16
17
|
import { Emitter } from '../emitter';
|
|
17
18
|
import { Channel } from '../channel';
|
|
@@ -457,6 +458,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
457
458
|
// generate a temporary id as clientId when it is undefined
|
|
458
459
|
// prefix temp-cp- indicates collab-provider
|
|
459
460
|
if (!this.clientId) {
|
|
461
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
460
462
|
this.clientId = "temp-cp-".concat(uuidv4());
|
|
461
463
|
}
|
|
462
464
|
this.documentService.setup({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.7",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"@atlaskit/adf-utils": "^19.25.0",
|
|
30
30
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
31
31
|
"@atlaskit/analytics-listeners": "^9.1.0",
|
|
32
|
-
"@atlaskit/anonymous-assets": "^0.0.
|
|
32
|
+
"@atlaskit/anonymous-assets": "^0.0.12",
|
|
33
33
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
34
34
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
35
35
|
"@atlaskit/feature-gate-js-client": "^5.5.0",
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
37
37
|
"@atlaskit/prosemirror-collab": "^0.22.0",
|
|
38
|
-
"@atlaskit/react-ufo": "^4.
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^13.
|
|
38
|
+
"@atlaskit/react-ufo": "^4.14.0",
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^13.32.0",
|
|
40
40
|
"@atlaskit/ufo": "^0.4.0",
|
|
41
41
|
"@atlaskit/util-service-support": "^6.3.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@atlaskit/adf-schema": "^51.3.
|
|
66
|
-
"@atlassian/feature-flags-test-utils": "^0.
|
|
65
|
+
"@atlaskit/adf-schema": "^51.3.2",
|
|
66
|
+
"@atlassian/feature-flags-test-utils": "^1.0.0"
|
|
67
67
|
},
|
|
68
68
|
"platform-feature-flags": {
|
|
69
69
|
"platform_collab_provider_tracingheaders": {
|
|
@@ -74,9 +74,12 @@
|
|
|
74
74
|
},
|
|
75
75
|
"add_session_id_to_catchup_query": {
|
|
76
76
|
"type": "boolean"
|
|
77
|
+
},
|
|
78
|
+
"platform_collab_do_not_client_error_log": {
|
|
79
|
+
"type": "boolean"
|
|
77
80
|
}
|
|
78
81
|
},
|
|
79
82
|
"peerDependencies": {
|
|
80
|
-
"@atlaskit/editor-common": "^110.
|
|
83
|
+
"@atlaskit/editor-common": "^110.24.0"
|
|
81
84
|
}
|
|
82
85
|
}
|