@atlaskit/collab-provider 14.0.6 → 14.0.8
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 +12 -0
- package/afm-jira/tsconfig.json +1 -1
- package/dist/cjs/api/api.js +11 -20
- 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/api/api.js +1 -10
- 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/api/api.js +11 -20
- 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 +11 -11
|
@@ -4,6 +4,7 @@ import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform'
|
|
|
4
4
|
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
5
5
|
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
@@ -142,14 +143,28 @@ export class DocumentService {
|
|
|
142
143
|
version: this.getCurrentPmVersion()
|
|
143
144
|
});
|
|
144
145
|
} catch (error) {
|
|
145
|
-
var _this$analyticsHelper3;
|
|
146
146
|
const latency = new Date().getTime() - start;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
// Skip client side errors; TypeErrors are client side errors https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch
|
|
148
|
+
if (fg('platform_collab_do_not_client_error_log')) {
|
|
149
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
150
|
+
if (!errorMessage.includes('TypeError') && !(error instanceof TypeError)) {
|
|
151
|
+
var _this$analyticsHelper3;
|
|
152
|
+
(_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
|
|
153
|
+
latency,
|
|
154
|
+
reason,
|
|
155
|
+
unconfirmedStepsLength: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.unconfirmedStepsLength,
|
|
156
|
+
disconnectionPeriodSeconds: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.disconnectionPeriodSeconds
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
var _this$analyticsHelper4;
|
|
161
|
+
(_this$analyticsHelper4 = this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
|
|
162
|
+
latency,
|
|
163
|
+
reason,
|
|
164
|
+
unconfirmedStepsLength: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.unconfirmedStepsLength,
|
|
165
|
+
disconnectionPeriodSeconds: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.disconnectionPeriodSeconds
|
|
166
|
+
});
|
|
167
|
+
}
|
|
153
168
|
} finally {
|
|
154
169
|
this.stepQueue.resumeQueue();
|
|
155
170
|
this.processQueue();
|
|
@@ -161,8 +176,8 @@ export class DocumentService {
|
|
|
161
176
|
var _this$getState;
|
|
162
177
|
const state = (_this$getState = this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(this);
|
|
163
178
|
if (!state) {
|
|
164
|
-
var _this$
|
|
165
|
-
(_this$
|
|
179
|
+
var _this$analyticsHelper5;
|
|
180
|
+
(_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');
|
|
166
181
|
return 0;
|
|
167
182
|
}
|
|
168
183
|
return this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
@@ -171,13 +186,13 @@ export class DocumentService {
|
|
|
171
186
|
// eslint-disable-next-line require-await
|
|
172
187
|
_defineProperty(this, "getCurrentState", async () => {
|
|
173
188
|
try {
|
|
174
|
-
var _this$getState2, _this$
|
|
189
|
+
var _this$getState2, _this$analyticsHelper7;
|
|
175
190
|
startMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
|
|
176
191
|
|
|
177
192
|
// Convert ProseMirror document in Editor state to ADF document
|
|
178
193
|
if (!((_this$getState2 = this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(this))) {
|
|
179
|
-
var _this$
|
|
180
|
-
(_this$
|
|
194
|
+
var _this$analyticsHelper6;
|
|
195
|
+
(_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
|
|
181
196
|
}
|
|
182
197
|
// Ignored via go/ees005
|
|
183
198
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -190,17 +205,17 @@ export class DocumentService {
|
|
|
190
205
|
stepVersion: version
|
|
191
206
|
};
|
|
192
207
|
const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
|
|
193
|
-
(_this$
|
|
208
|
+
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
|
|
194
209
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
195
210
|
});
|
|
196
211
|
return currentState;
|
|
197
212
|
} catch (error) {
|
|
198
|
-
var _this$
|
|
213
|
+
var _this$analyticsHelper8, _this$analyticsHelper9;
|
|
199
214
|
const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
|
|
200
|
-
(_this$
|
|
215
|
+
(_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
|
|
201
216
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
202
217
|
});
|
|
203
|
-
(_this$
|
|
218
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(error, 'Error while returning ADF version of current draft document');
|
|
204
219
|
throw error; // Reject the promise so the consumer can react to it failing
|
|
205
220
|
}
|
|
206
221
|
});
|
|
@@ -226,8 +241,8 @@ export class DocumentService {
|
|
|
226
241
|
}
|
|
227
242
|
return false;
|
|
228
243
|
} catch (err) {
|
|
229
|
-
var _this$
|
|
230
|
-
(_this$
|
|
244
|
+
var _this$analyticsHelper0;
|
|
245
|
+
(_this$analyticsHelper0 = this.analyticsHelper) === null || _this$analyticsHelper0 === void 0 ? void 0 : _this$analyticsHelper0.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
|
|
231
246
|
return false;
|
|
232
247
|
}
|
|
233
248
|
});
|
|
@@ -235,8 +250,8 @@ export class DocumentService {
|
|
|
235
250
|
var _this$getState3, _sendableSteps;
|
|
236
251
|
const state = (_this$getState3 = this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(this);
|
|
237
252
|
if (!state) {
|
|
238
|
-
var _this$
|
|
239
|
-
(_this$
|
|
253
|
+
var _this$analyticsHelper1;
|
|
254
|
+
(_this$analyticsHelper1 = this.analyticsHelper) === null || _this$analyticsHelper1 === void 0 ? void 0 : _this$analyticsHelper1.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
|
|
240
255
|
return;
|
|
241
256
|
}
|
|
242
257
|
return (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
|
|
@@ -245,8 +260,8 @@ export class DocumentService {
|
|
|
245
260
|
var _this$getState4, _sendableSteps2;
|
|
246
261
|
const state = (_this$getState4 = this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(this);
|
|
247
262
|
if (!state) {
|
|
248
|
-
var _this$
|
|
249
|
-
(_this$
|
|
263
|
+
var _this$analyticsHelper10;
|
|
264
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
|
|
250
265
|
return;
|
|
251
266
|
}
|
|
252
267
|
return (_sendableSteps2 = sendableSteps(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
|
|
@@ -288,8 +303,8 @@ export class DocumentService {
|
|
|
288
303
|
userId
|
|
289
304
|
}) => userId));
|
|
290
305
|
} catch (stepsAddedError) {
|
|
291
|
-
var _this$
|
|
292
|
-
(_this$
|
|
306
|
+
var _this$analyticsHelper11;
|
|
307
|
+
(_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(stepsAddedError, ADD_STEPS_PROVIDER_ERROR_MSG);
|
|
293
308
|
this.onErrorHandled({
|
|
294
309
|
message: ADD_STEPS_PROVIDER_ERROR_MSG,
|
|
295
310
|
data: {
|
|
@@ -347,7 +362,7 @@ export class DocumentService {
|
|
|
347
362
|
obfuscatedDoc
|
|
348
363
|
} = this.obfuscateStepsAndState(unconfirmedSteps, currentState);
|
|
349
364
|
try {
|
|
350
|
-
var _this$
|
|
365
|
+
var _this$analyticsHelper16;
|
|
351
366
|
// Reset the editor,
|
|
352
367
|
// - Replace the document, keep in sync with the server
|
|
353
368
|
// - Replace the version number, so editor is in sync with NCS server and can commit new changes.
|
|
@@ -363,8 +378,8 @@ export class DocumentService {
|
|
|
363
378
|
});
|
|
364
379
|
this.metadataService.updateMetadata(metadata);
|
|
365
380
|
try {
|
|
366
|
-
var _this$
|
|
367
|
-
(_this$
|
|
381
|
+
var _this$analyticsHelper12;
|
|
382
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
368
383
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
369
384
|
obfuscatedSteps,
|
|
370
385
|
obfuscatedDoc,
|
|
@@ -399,24 +414,24 @@ export class DocumentService {
|
|
|
399
414
|
if (state !== null && state !== void 0 && state.schema) {
|
|
400
415
|
const stepsToBeApplied = generatedSteps === null || generatedSteps === void 0 ? void 0 : generatedSteps.map(s => ProseMirrorStep.fromJSON(state.schema, s));
|
|
401
416
|
if (stepsToBeApplied && stepsToBeApplied.length > 0) {
|
|
402
|
-
var _this$
|
|
403
|
-
(_this$
|
|
417
|
+
var _this$analyticsHelper13;
|
|
418
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
404
419
|
stepsCount: stepsToBeApplied.length
|
|
405
420
|
});
|
|
406
421
|
this.applyLocalSteps(stepsToBeApplied);
|
|
407
422
|
} else {
|
|
408
|
-
var _this$
|
|
409
|
-
(_this$
|
|
423
|
+
var _this$analyticsHelper14;
|
|
424
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
410
425
|
reason: 'fetchGeneratedDiffSteps returned no steps'
|
|
411
426
|
});
|
|
412
427
|
}
|
|
413
428
|
}
|
|
414
429
|
} catch (reconcileError) {
|
|
415
|
-
var _this$
|
|
416
|
-
(_this$
|
|
430
|
+
var _this$analyticsHelper15;
|
|
431
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendErrorEvent(reconcileError, `Error fetchGeneratedDiffSteps with steps-only mode`);
|
|
417
432
|
}
|
|
418
433
|
}
|
|
419
|
-
(_this$
|
|
434
|
+
(_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
420
435
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
421
436
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
422
437
|
useReconcile,
|
|
@@ -425,15 +440,15 @@ export class DocumentService {
|
|
|
425
440
|
triggeredByCatchup: !!targetClientId
|
|
426
441
|
});
|
|
427
442
|
} catch (restoreError) {
|
|
428
|
-
var _this$
|
|
429
|
-
(_this$
|
|
443
|
+
var _this$analyticsHelper17, _this$analyticsHelper18;
|
|
444
|
+
(_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
|
|
430
445
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
431
446
|
useReconcile,
|
|
432
447
|
clientId: this.clientId,
|
|
433
448
|
targetClientId,
|
|
434
449
|
triggeredByCatchup: !!targetClientId
|
|
435
450
|
});
|
|
436
|
-
(_this$
|
|
451
|
+
(_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
|
|
437
452
|
this.onErrorHandled({
|
|
438
453
|
message: 'Caught error while trying to recover the document',
|
|
439
454
|
data: {
|
|
@@ -447,7 +462,7 @@ export class DocumentService {
|
|
|
447
462
|
_defineProperty(this, "getFinalAcknowledgedState", async reason => {
|
|
448
463
|
this.aggressiveCatchup = true;
|
|
449
464
|
try {
|
|
450
|
-
var _this$
|
|
465
|
+
var _this$analyticsHelper19;
|
|
451
466
|
startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
452
467
|
let finalAcknowledgedState;
|
|
453
468
|
try {
|
|
@@ -464,19 +479,19 @@ export class DocumentService {
|
|
|
464
479
|
};
|
|
465
480
|
}
|
|
466
481
|
const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
467
|
-
(_this$
|
|
482
|
+
(_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
468
483
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
469
484
|
});
|
|
470
485
|
this.aggressiveCatchup = false;
|
|
471
486
|
return finalAcknowledgedState;
|
|
472
487
|
} catch (error) {
|
|
473
|
-
var _this$
|
|
488
|
+
var _this$analyticsHelper20, _this$analyticsHelper21;
|
|
474
489
|
this.aggressiveCatchup = false;
|
|
475
490
|
const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
476
|
-
(_this$
|
|
491
|
+
(_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
477
492
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
478
493
|
});
|
|
479
|
-
(_this$
|
|
494
|
+
(_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
|
|
480
495
|
throw error; // Reject the promise so the consumer can react to it failing
|
|
481
496
|
}
|
|
482
497
|
});
|
|
@@ -505,7 +520,7 @@ export class DocumentService {
|
|
|
505
520
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
506
521
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
507
522
|
if (updatedVersion < version) {
|
|
508
|
-
var _doc$content, _this$
|
|
523
|
+
var _doc$content, _this$analyticsHelper22;
|
|
509
524
|
const error = new UpdateDocumentError('Failed to update the document', {
|
|
510
525
|
newVersion: version,
|
|
511
526
|
editorVersion: updatedVersion,
|
|
@@ -514,7 +529,7 @@ export class DocumentService {
|
|
|
514
529
|
isDocContentValid,
|
|
515
530
|
caller
|
|
516
531
|
});
|
|
517
|
-
(_this$
|
|
532
|
+
(_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
518
533
|
if (this.enableErrorOnFailedDocumentApply) {
|
|
519
534
|
this.onErrorHandled({
|
|
520
535
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -531,8 +546,8 @@ export class DocumentService {
|
|
|
531
546
|
}
|
|
532
547
|
// Otherwise just fail silently for now
|
|
533
548
|
} else {
|
|
534
|
-
var _this$
|
|
535
|
-
(_this$
|
|
549
|
+
var _this$analyticsHelper23, _doc$content2;
|
|
550
|
+
(_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
536
551
|
newVersion: version,
|
|
537
552
|
editorVersion: updatedVersion,
|
|
538
553
|
isDocTruthy: !!doc,
|
|
@@ -547,8 +562,8 @@ export class DocumentService {
|
|
|
547
562
|
try {
|
|
548
563
|
var _this$getState6;
|
|
549
564
|
if (!((_this$getState6 = this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(this))) {
|
|
550
|
-
var _this$
|
|
551
|
-
(_this$
|
|
565
|
+
var _this$analyticsHelper24;
|
|
566
|
+
(_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
552
567
|
}
|
|
553
568
|
// Ignored via go/ees005
|
|
554
569
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -578,7 +593,7 @@ export class DocumentService {
|
|
|
578
593
|
const unconfirmedSteps = this.getUnconfirmedSteps();
|
|
579
594
|
try {
|
|
580
595
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
581
|
-
var _this$getState7, _this$
|
|
596
|
+
var _this$getState7, _this$analyticsHelper26;
|
|
582
597
|
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
583
598
|
let count = 0;
|
|
584
599
|
// We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
@@ -589,8 +604,8 @@ export class DocumentService {
|
|
|
589
604
|
const lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
590
605
|
let isLastTrConfirmed = false;
|
|
591
606
|
if (!((_this$getState7 = this.getState) !== null && _this$getState7 !== void 0 && _this$getState7.call(this))) {
|
|
592
|
-
var _this$
|
|
593
|
-
(_this$
|
|
607
|
+
var _this$analyticsHelper25;
|
|
608
|
+
(_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
594
609
|
}
|
|
595
610
|
while (!isLastTrConfirmed) {
|
|
596
611
|
// this makes all commitUnconfirmedSteps skip the waiting time, which means draft-sync is sped up too.
|
|
@@ -626,35 +641,35 @@ export class DocumentService {
|
|
|
626
641
|
}
|
|
627
642
|
}
|
|
628
643
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
629
|
-
(_this$
|
|
644
|
+
(_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
630
645
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
631
646
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
632
647
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
633
648
|
});
|
|
634
649
|
}
|
|
635
650
|
} catch (error) {
|
|
636
|
-
var _this$
|
|
651
|
+
var _this$analyticsHelper27, _this$analyticsHelper28;
|
|
637
652
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
638
|
-
(_this$
|
|
653
|
+
(_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
639
654
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
640
655
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
641
656
|
});
|
|
642
|
-
(_this$
|
|
657
|
+
(_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(error, 'Error while committing unconfirmed steps');
|
|
643
658
|
throw error;
|
|
644
659
|
}
|
|
645
660
|
});
|
|
646
661
|
_defineProperty(this, "onStepRejectedError", () => {
|
|
647
|
-
var _this$
|
|
662
|
+
var _this$analyticsHelper29;
|
|
648
663
|
this.stepRejectCounter++;
|
|
649
664
|
logger(`Steps rejected (tries=${this.stepRejectCounter})`);
|
|
650
|
-
(_this$
|
|
665
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
651
666
|
count: this.stepRejectCounter
|
|
652
667
|
});
|
|
653
668
|
const maxRetries = this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
|
|
654
669
|
if (this.stepRejectCounter >= maxRetries) {
|
|
655
|
-
var _this$
|
|
670
|
+
var _this$analyticsHelper30;
|
|
656
671
|
logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
|
|
657
|
-
(_this$
|
|
672
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
658
673
|
this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
|
|
659
674
|
} else {
|
|
660
675
|
// If committing steps failed try again automatically in 1s
|
|
@@ -706,15 +721,15 @@ export class DocumentService {
|
|
|
706
721
|
getVersionFromCollabState(state, resource) {
|
|
707
722
|
const collabState = getCollabState(state);
|
|
708
723
|
if (!collabState) {
|
|
709
|
-
var _this$
|
|
710
|
-
(_this$
|
|
724
|
+
var _this$analyticsHelper31;
|
|
725
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
|
|
711
726
|
return 0;
|
|
712
727
|
}
|
|
713
728
|
|
|
714
729
|
// This should not happen in usual, just add error event in case it happens
|
|
715
730
|
if (collabState.version === undefined) {
|
|
716
|
-
var _this$
|
|
717
|
-
(_this$
|
|
731
|
+
var _this$analyticsHelper32;
|
|
732
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
|
|
718
733
|
return 0;
|
|
719
734
|
}
|
|
720
735
|
return collabState.version;
|
|
@@ -785,7 +800,7 @@ export class DocumentService {
|
|
|
785
800
|
logger(`Processing data. Version "${version}".`);
|
|
786
801
|
if (steps !== null && steps !== void 0 && steps.length) {
|
|
787
802
|
try {
|
|
788
|
-
var _this$
|
|
803
|
+
var _this$analyticsHelper33;
|
|
789
804
|
const clientIds = steps.map(({
|
|
790
805
|
clientId
|
|
791
806
|
}) => clientId);
|
|
@@ -804,13 +819,13 @@ export class DocumentService {
|
|
|
804
819
|
if (clientIds.indexOf(this.clientId) === -1) {
|
|
805
820
|
setTimeout(() => this.sendStepsFromCurrentState(), 100);
|
|
806
821
|
}
|
|
807
|
-
(_this$
|
|
822
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 ? void 0 : _this$analyticsHelper33.sendActionEvent(EVENT_ACTION.PROCESS_STEPS, EVENT_STATUS.SUCCESS);
|
|
808
823
|
} catch (error) {
|
|
809
|
-
var _this$
|
|
824
|
+
var _this$analyticsHelper34;
|
|
810
825
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
811
826
|
const userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
812
827
|
logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
|
|
813
|
-
(_this$
|
|
828
|
+
(_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 ? void 0 : _this$analyticsHelper34.sendErrorEvent(error, userIdMatch ? `Error while processing steps with new clientId` : `Error while processing steps`);
|
|
814
829
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
815
830
|
}
|
|
816
831
|
}
|
|
@@ -855,8 +870,8 @@ export class DocumentService {
|
|
|
855
870
|
var _this$getState0;
|
|
856
871
|
const state = (_this$getState0 = this.getState) === null || _this$getState0 === void 0 ? void 0 : _this$getState0.call(this);
|
|
857
872
|
if (!state) {
|
|
858
|
-
var _this$
|
|
859
|
-
(_this$
|
|
873
|
+
var _this$analyticsHelper35;
|
|
874
|
+
(_this$analyticsHelper35 = this.analyticsHelper) === null || _this$analyticsHelper35 === void 0 ? void 0 : _this$analyticsHelper35.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
860
875
|
return;
|
|
861
876
|
}
|
|
862
877
|
this.send(null, null, state, sendAnalyticsEvent, reason);
|
|
@@ -902,8 +917,8 @@ export class DocumentService {
|
|
|
902
917
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
903
918
|
// sent once on connection (as opposed to on every step)
|
|
904
919
|
if (sendAnalyticsEvent) {
|
|
905
|
-
var _this$
|
|
906
|
-
(_this$
|
|
920
|
+
var _this$analyticsHelper36;
|
|
921
|
+
(_this$analyticsHelper36 = this.analyticsHelper) === null || _this$analyticsHelper36 === void 0 ? void 0 : _this$analyticsHelper36.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
907
922
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
908
923
|
});
|
|
909
924
|
}
|
|
@@ -912,12 +927,12 @@ export class DocumentService {
|
|
|
912
927
|
}
|
|
913
928
|
const rebased = tr === null || tr === void 0 ? void 0 : tr.getMeta('rebasedData');
|
|
914
929
|
if (rebased) {
|
|
915
|
-
var _this$
|
|
930
|
+
var _this$analyticsHelper37;
|
|
916
931
|
const obfuscatedUnconfirmedSteps = this.obfuscateStepsAndState(rebased.unconfirmedSteps).obfuscatedSteps;
|
|
917
932
|
const obfuscatedRemoteSteps = this.obfuscateStepsAndState(rebased.remoteSteps);
|
|
918
933
|
const obfuscatedRebasedSteps = this.obfuscateStepsAndState(unconfirmedSteps).obfuscatedSteps;
|
|
919
934
|
// send analtyics on unconfirmed steps
|
|
920
|
-
(_this$
|
|
935
|
+
(_this$analyticsHelper37 = this.analyticsHelper) === null || _this$analyticsHelper37 === void 0 ? void 0 : _this$analyticsHelper37.sendActionEvent(EVENT_ACTION.STEPS_REBASED, EVENT_STATUS.INFO, {
|
|
921
936
|
obfuscatedUnconfirmedSteps,
|
|
922
937
|
obfuscatedRemoteSteps,
|
|
923
938
|
obfuscatedRebasedSteps,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
4
|
import { Emitter } from '../emitter';
|
|
4
5
|
import { Channel } from '../channel';
|
|
@@ -370,6 +371,7 @@ export class Provider extends Emitter {
|
|
|
370
371
|
// generate a temporary id as clientId when it is undefined
|
|
371
372
|
// prefix temp-cp- indicates collab-provider
|
|
372
373
|
if (!this.clientId) {
|
|
374
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
373
375
|
this.clientId = `temp-cp-${uuidv4()}`;
|
|
374
376
|
}
|
|
375
377
|
this.documentService.setup({
|
package/dist/esm/api/api.js
CHANGED
|
@@ -13,8 +13,6 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
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
|
import { getProduct, getSubProduct, createLogger } from '../helpers/utils';
|
|
15
15
|
import { getActiveTraceHttpRequestHeaders } from '@atlaskit/react-ufo/experience-trace-id-context';
|
|
16
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
-
import { addFeatureFlagAccessed } from '@atlaskit/react-ufo/feature-flags-accessed';
|
|
18
16
|
var logger = createLogger('Api', 'blue');
|
|
19
17
|
var AddCommentError = /*#__PURE__*/function (_Error) {
|
|
20
18
|
function AddCommentError(message, status, meta) {
|
|
@@ -42,7 +40,7 @@ export var Api = /*#__PURE__*/function () {
|
|
|
42
40
|
_classCallCheck(this, Api);
|
|
43
41
|
_defineProperty(this, "submitComment", /*#__PURE__*/function () {
|
|
44
42
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(steps, version) {
|
|
45
|
-
var reqBody, url,
|
|
43
|
+
var reqBody, url, tracingHeaders, fetchOptions;
|
|
46
44
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
47
45
|
while (1) switch (_context.prev = _context.next) {
|
|
48
46
|
case 0:
|
|
@@ -53,33 +51,26 @@ export var Api = /*#__PURE__*/function () {
|
|
|
53
51
|
});
|
|
54
52
|
url = "".concat(_this2.config.url, "/document/").concat(encodeURIComponent(_this2.config.documentAri), "/comment");
|
|
55
53
|
logger("Request url: ", url);
|
|
56
|
-
|
|
57
|
-
//Get tracing headers from UFO
|
|
58
|
-
tracingHeaderEnabled = fg('platform_collab_provider_tracingheaders');
|
|
59
|
-
addFeatureFlagAccessed('platform_collab_provider_tracingheaders', tracingHeaderEnabled);
|
|
60
|
-
tracingHeaders = {};
|
|
61
|
-
if (tracingHeaderEnabled) {
|
|
62
|
-
tracingHeaders = getActiveTraceHttpRequestHeaders(url);
|
|
63
|
-
}
|
|
54
|
+
tracingHeaders = getActiveTraceHttpRequestHeaders(url);
|
|
64
55
|
_context.t0 = _objectSpread;
|
|
65
56
|
_context.t1 = _objectSpread;
|
|
66
57
|
_context.t2 = {};
|
|
67
58
|
if (!_this2.config.permissionTokenRefresh) {
|
|
68
|
-
_context.next =
|
|
59
|
+
_context.next = 14;
|
|
69
60
|
break;
|
|
70
61
|
}
|
|
71
|
-
_context.next =
|
|
62
|
+
_context.next = 10;
|
|
72
63
|
return _this2.channel.getChannelToken();
|
|
73
|
-
case
|
|
64
|
+
case 10:
|
|
74
65
|
_context.t4 = _context.sent;
|
|
75
66
|
_context.t3 = {
|
|
76
67
|
'x-token': _context.t4
|
|
77
68
|
};
|
|
78
|
-
_context.next =
|
|
69
|
+
_context.next = 15;
|
|
79
70
|
break;
|
|
80
|
-
case
|
|
71
|
+
case 14:
|
|
81
72
|
_context.t3 = {};
|
|
82
|
-
case
|
|
73
|
+
case 15:
|
|
83
74
|
_context.t5 = _context.t3;
|
|
84
75
|
_context.t6 = (0, _context.t1)(_context.t2, _context.t5);
|
|
85
76
|
_context.t7 = {};
|
|
@@ -97,11 +88,11 @@ export var Api = /*#__PURE__*/function () {
|
|
|
97
88
|
method: 'POST',
|
|
98
89
|
body: _context.t11
|
|
99
90
|
};
|
|
100
|
-
_context.next =
|
|
91
|
+
_context.next = 25;
|
|
101
92
|
return fetch(url, fetchOptions);
|
|
102
|
-
case
|
|
93
|
+
case 25:
|
|
103
94
|
return _context.abrupt("return", _context.sent);
|
|
104
|
-
case
|
|
95
|
+
case 26:
|
|
105
96
|
case "end":
|
|
106
97
|
return _context.stop();
|
|
107
98
|
}
|