@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.
@@ -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
- (_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
148
- latency,
149
- reason,
150
- unconfirmedStepsLength: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.unconfirmedStepsLength,
151
- disconnectionPeriodSeconds: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.disconnectionPeriodSeconds
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$analyticsHelper4;
165
- (_this$analyticsHelper4 = this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
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$analyticsHelper6;
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$analyticsHelper5;
180
- (_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
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$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
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$analyticsHelper7, _this$analyticsHelper8;
213
+ var _this$analyticsHelper8, _this$analyticsHelper9;
199
214
  const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
200
- (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
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$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(error, 'Error while returning ADF version of current draft document');
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$analyticsHelper9;
230
- (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
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$analyticsHelper0;
239
- (_this$analyticsHelper0 = this.analyticsHelper) === null || _this$analyticsHelper0 === void 0 ? void 0 : _this$analyticsHelper0.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
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$analyticsHelper1;
249
- (_this$analyticsHelper1 = this.analyticsHelper) === null || _this$analyticsHelper1 === void 0 ? void 0 : _this$analyticsHelper1.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
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$analyticsHelper10;
292
- (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(stepsAddedError, ADD_STEPS_PROVIDER_ERROR_MSG);
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$analyticsHelper15;
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$analyticsHelper11;
367
- (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
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$analyticsHelper12;
403
- (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
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$analyticsHelper13;
409
- (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
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$analyticsHelper14;
416
- (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(reconcileError, `Error fetchGeneratedDiffSteps with steps-only mode`);
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$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
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$analyticsHelper16, _this$analyticsHelper17;
429
- (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
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$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
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$analyticsHelper18;
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$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
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$analyticsHelper19, _this$analyticsHelper20;
488
+ var _this$analyticsHelper20, _this$analyticsHelper21;
474
489
  this.aggressiveCatchup = false;
475
490
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
476
- (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
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$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
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$analyticsHelper21;
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$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(error, 'Failed to update the document in document service');
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$analyticsHelper22, _doc$content2;
535
- (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
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$analyticsHelper23;
551
- (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
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$analyticsHelper25;
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$analyticsHelper24;
593
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
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$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
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$analyticsHelper26, _this$analyticsHelper27;
651
+ var _this$analyticsHelper27, _this$analyticsHelper28;
637
652
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
638
- (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
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$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendErrorEvent(error, 'Error while committing unconfirmed steps');
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$analyticsHelper28;
662
+ var _this$analyticsHelper29;
648
663
  this.stepRejectCounter++;
649
664
  logger(`Steps rejected (tries=${this.stepRejectCounter})`);
650
- (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
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$analyticsHelper29;
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$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
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$analyticsHelper30;
710
- (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
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$analyticsHelper31;
717
- (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
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$analyticsHelper32;
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$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendActionEvent(EVENT_ACTION.PROCESS_STEPS, EVENT_STATUS.SUCCESS);
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$analyticsHelper33;
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$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 ? void 0 : _this$analyticsHelper33.sendErrorEvent(error, userIdMatch ? `Error while processing steps with new clientId` : `Error while processing steps`);
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$analyticsHelper34;
859
- (_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 ? void 0 : _this$analyticsHelper34.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
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$analyticsHelper35;
906
- (_this$analyticsHelper35 = this.analyticsHelper) === null || _this$analyticsHelper35 === void 0 ? void 0 : _this$analyticsHelper35.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
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$analyticsHelper36;
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$analyticsHelper36 = this.analyticsHelper) === null || _this$analyticsHelper36 === void 0 ? void 0 : _this$analyticsHelper36.sendActionEvent(EVENT_ACTION.STEPS_REBASED, EVENT_STATUS.INFO, {
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({
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "14.0.5";
2
+ export const version = "0.0.0-development";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };