@atlaskit/collab-provider 14.0.9 → 14.1.0

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,7 +4,6 @@ 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';
8
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
9
  import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
@@ -145,20 +144,10 @@ export class DocumentService {
145
144
  } catch (error) {
146
145
  const latency = new Date().getTime() - start;
147
146
  // 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, {
147
+ const errorMessage = error instanceof Error ? error.message : String(error);
148
+ if (!errorMessage.includes('TypeError') && !(error instanceof TypeError)) {
149
+ var _this$analyticsHelper3;
150
+ (_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
162
151
  latency,
163
152
  reason,
164
153
  unconfirmedStepsLength: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.unconfirmedStepsLength,
@@ -176,8 +165,8 @@ export class DocumentService {
176
165
  var _this$getState;
177
166
  const state = (_this$getState = this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(this);
178
167
  if (!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');
168
+ var _this$analyticsHelper4;
169
+ (_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');
181
170
  return 0;
182
171
  }
183
172
  return this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
@@ -186,13 +175,13 @@ export class DocumentService {
186
175
  // eslint-disable-next-line require-await
187
176
  _defineProperty(this, "getCurrentState", async () => {
188
177
  try {
189
- var _this$getState2, _this$analyticsHelper7;
178
+ var _this$getState2, _this$analyticsHelper6;
190
179
  startMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
191
180
 
192
181
  // Convert ProseMirror document in Editor state to ADF document
193
182
  if (!((_this$getState2 = this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(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');
183
+ var _this$analyticsHelper5;
184
+ (_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
196
185
  }
197
186
  // Ignored via go/ees005
198
187
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -205,17 +194,17 @@ export class DocumentService {
205
194
  stepVersion: version
206
195
  };
207
196
  const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
208
- (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
197
+ (_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
209
198
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
210
199
  });
211
200
  return currentState;
212
201
  } catch (error) {
213
- var _this$analyticsHelper8, _this$analyticsHelper9;
202
+ var _this$analyticsHelper7, _this$analyticsHelper8;
214
203
  const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
215
- (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
204
+ (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
216
205
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
217
206
  });
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');
207
+ (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(error, 'Error while returning ADF version of current draft document');
219
208
  throw error; // Reject the promise so the consumer can react to it failing
220
209
  }
221
210
  });
@@ -241,8 +230,8 @@ export class DocumentService {
241
230
  }
242
231
  return false;
243
232
  } catch (err) {
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');
233
+ var _this$analyticsHelper9;
234
+ (_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');
246
235
  return false;
247
236
  }
248
237
  });
@@ -250,8 +239,8 @@ export class DocumentService {
250
239
  var _this$getState3, _sendableSteps;
251
240
  const state = (_this$getState3 = this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(this);
252
241
  if (!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');
242
+ var _this$analyticsHelper0;
243
+ (_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');
255
244
  return;
256
245
  }
257
246
  return (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
@@ -260,8 +249,8 @@ export class DocumentService {
260
249
  var _this$getState4, _sendableSteps2;
261
250
  const state = (_this$getState4 = this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(this);
262
251
  if (!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');
252
+ var _this$analyticsHelper1;
253
+ (_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');
265
254
  return;
266
255
  }
267
256
  return (_sendableSteps2 = sendableSteps(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
@@ -303,8 +292,8 @@ export class DocumentService {
303
292
  userId
304
293
  }) => userId));
305
294
  } catch (stepsAddedError) {
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);
295
+ var _this$analyticsHelper10;
296
+ (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(stepsAddedError, ADD_STEPS_PROVIDER_ERROR_MSG);
308
297
  this.onErrorHandled({
309
298
  message: ADD_STEPS_PROVIDER_ERROR_MSG,
310
299
  data: {
@@ -362,7 +351,7 @@ export class DocumentService {
362
351
  obfuscatedDoc
363
352
  } = this.obfuscateStepsAndState(unconfirmedSteps, currentState);
364
353
  try {
365
- var _this$analyticsHelper16;
354
+ var _this$analyticsHelper15;
366
355
  // Reset the editor,
367
356
  // - Replace the document, keep in sync with the server
368
357
  // - Replace the version number, so editor is in sync with NCS server and can commit new changes.
@@ -378,8 +367,8 @@ export class DocumentService {
378
367
  });
379
368
  this.metadataService.updateMetadata(metadata);
380
369
  try {
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, {
370
+ var _this$analyticsHelper11;
371
+ (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
383
372
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
384
373
  obfuscatedSteps,
385
374
  obfuscatedDoc,
@@ -414,24 +403,24 @@ export class DocumentService {
414
403
  if (state !== null && state !== void 0 && state.schema) {
415
404
  const stepsToBeApplied = generatedSteps === null || generatedSteps === void 0 ? void 0 : generatedSteps.map(s => ProseMirrorStep.fromJSON(state.schema, s));
416
405
  if (stepsToBeApplied && stepsToBeApplied.length > 0) {
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, {
406
+ var _this$analyticsHelper12;
407
+ (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
419
408
  stepsCount: stepsToBeApplied.length
420
409
  });
421
410
  this.applyLocalSteps(stepsToBeApplied);
422
411
  } else {
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, {
412
+ var _this$analyticsHelper13;
413
+ (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
425
414
  reason: 'fetchGeneratedDiffSteps returned no steps'
426
415
  });
427
416
  }
428
417
  }
429
418
  } catch (reconcileError) {
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`);
419
+ var _this$analyticsHelper14;
420
+ (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(reconcileError, `Error fetchGeneratedDiffSteps with steps-only mode`);
432
421
  }
433
422
  }
434
- (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
423
+ (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
435
424
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
436
425
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
437
426
  useReconcile,
@@ -440,15 +429,15 @@ export class DocumentService {
440
429
  triggeredByCatchup: !!targetClientId
441
430
  });
442
431
  } catch (restoreError) {
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, {
432
+ var _this$analyticsHelper16, _this$analyticsHelper17;
433
+ (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
445
434
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
446
435
  useReconcile,
447
436
  clientId: this.clientId,
448
437
  targetClientId,
449
438
  triggeredByCatchup: !!targetClientId
450
439
  });
451
- (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
440
+ (_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
452
441
  this.onErrorHandled({
453
442
  message: 'Caught error while trying to recover the document',
454
443
  data: {
@@ -462,7 +451,7 @@ export class DocumentService {
462
451
  _defineProperty(this, "getFinalAcknowledgedState", async reason => {
463
452
  this.aggressiveCatchup = true;
464
453
  try {
465
- var _this$analyticsHelper19;
454
+ var _this$analyticsHelper18;
466
455
  startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
467
456
  let finalAcknowledgedState;
468
457
  try {
@@ -479,19 +468,19 @@ export class DocumentService {
479
468
  };
480
469
  }
481
470
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
482
- (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
471
+ (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
483
472
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
484
473
  });
485
474
  this.aggressiveCatchup = false;
486
475
  return finalAcknowledgedState;
487
476
  } catch (error) {
488
- var _this$analyticsHelper20, _this$analyticsHelper21;
477
+ var _this$analyticsHelper19, _this$analyticsHelper20;
489
478
  this.aggressiveCatchup = false;
490
479
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
491
- (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
480
+ (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
492
481
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
493
482
  });
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');
483
+ (_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');
495
484
  throw error; // Reject the promise so the consumer can react to it failing
496
485
  }
497
486
  });
@@ -520,7 +509,7 @@ export class DocumentService {
520
509
  // ESS-5023: only emit error event if updated client version is still behind server version
521
510
  // client version could become higher than server version due to user editing or plugin adding steps
522
511
  if (updatedVersion < version) {
523
- var _doc$content, _this$analyticsHelper22;
512
+ var _doc$content, _this$analyticsHelper21;
524
513
  const error = new UpdateDocumentError('Failed to update the document', {
525
514
  newVersion: version,
526
515
  editorVersion: updatedVersion,
@@ -529,7 +518,7 @@ export class DocumentService {
529
518
  isDocContentValid,
530
519
  caller
531
520
  });
532
- (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendErrorEvent(error, 'Failed to update the document in document service');
521
+ (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(error, 'Failed to update the document in document service');
533
522
  if (this.enableErrorOnFailedDocumentApply) {
534
523
  this.onErrorHandled({
535
524
  message: 'The provider failed to apply changes to the editor',
@@ -546,8 +535,8 @@ export class DocumentService {
546
535
  }
547
536
  // Otherwise just fail silently for now
548
537
  } else {
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, {
538
+ var _this$analyticsHelper22, _doc$content2;
539
+ (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
551
540
  newVersion: version,
552
541
  editorVersion: updatedVersion,
553
542
  isDocTruthy: !!doc,
@@ -562,8 +551,8 @@ export class DocumentService {
562
551
  try {
563
552
  var _this$getState6;
564
553
  if (!((_this$getState6 = this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(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');
554
+ var _this$analyticsHelper23;
555
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
567
556
  }
568
557
  // Ignored via go/ees005
569
558
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -593,7 +582,7 @@ export class DocumentService {
593
582
  const unconfirmedSteps = this.getUnconfirmedSteps();
594
583
  try {
595
584
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
596
- var _this$getState7, _this$analyticsHelper26;
585
+ var _this$getState7, _this$analyticsHelper25;
597
586
  startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
598
587
  let count = 0;
599
588
  // We use origins here as steps can be rebased. When steps are rebased a new step is created.
@@ -604,8 +593,8 @@ export class DocumentService {
604
593
  const lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
605
594
  let isLastTrConfirmed = false;
606
595
  if (!((_this$getState7 = this.getState) !== null && _this$getState7 !== void 0 && _this$getState7.call(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');
596
+ var _this$analyticsHelper24;
597
+ (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
609
598
  }
610
599
  while (!isLastTrConfirmed) {
611
600
  // this makes all commitUnconfirmedSteps skip the waiting time, which means draft-sync is sped up too.
@@ -641,35 +630,35 @@ export class DocumentService {
641
630
  }
642
631
  }
643
632
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
644
- (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
633
+ (_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
645
634
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
646
635
  // upon success, emit the total number of unconfirmed steps we synced
647
636
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
648
637
  });
649
638
  }
650
639
  } catch (error) {
651
- var _this$analyticsHelper27, _this$analyticsHelper28;
640
+ var _this$analyticsHelper26, _this$analyticsHelper27;
652
641
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
653
- (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
642
+ (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
654
643
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
655
644
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
656
645
  });
657
- (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(error, 'Error while committing unconfirmed steps');
646
+ (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendErrorEvent(error, 'Error while committing unconfirmed steps');
658
647
  throw error;
659
648
  }
660
649
  });
661
650
  _defineProperty(this, "onStepRejectedError", () => {
662
- var _this$analyticsHelper29;
651
+ var _this$analyticsHelper28;
663
652
  this.stepRejectCounter++;
664
653
  logger(`Steps rejected (tries=${this.stepRejectCounter})`);
665
- (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
654
+ (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
666
655
  count: this.stepRejectCounter
667
656
  });
668
657
  const maxRetries = this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
669
658
  if (this.stepRejectCounter >= maxRetries) {
670
- var _this$analyticsHelper30;
659
+ var _this$analyticsHelper29;
671
660
  logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
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);
661
+ (_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);
673
662
  this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
674
663
  } else {
675
664
  // If committing steps failed try again automatically in 1s
@@ -721,15 +710,15 @@ export class DocumentService {
721
710
  getVersionFromCollabState(state, resource) {
722
711
  const collabState = getCollabState(state);
723
712
  if (!collabState) {
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`);
713
+ var _this$analyticsHelper30;
714
+ (_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`);
726
715
  return 0;
727
716
  }
728
717
 
729
718
  // This should not happen in usual, just add error event in case it happens
730
719
  if (collabState.version === undefined) {
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`);
720
+ var _this$analyticsHelper31;
721
+ (_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`);
733
722
  return 0;
734
723
  }
735
724
  return collabState.version;
@@ -800,7 +789,7 @@ export class DocumentService {
800
789
  logger(`Processing data. Version "${version}".`);
801
790
  if (steps !== null && steps !== void 0 && steps.length) {
802
791
  try {
803
- var _this$analyticsHelper33;
792
+ var _this$analyticsHelper32;
804
793
  const clientIds = steps.map(({
805
794
  clientId
806
795
  }) => clientId);
@@ -819,13 +808,13 @@ export class DocumentService {
819
808
  if (clientIds.indexOf(this.clientId) === -1) {
820
809
  setTimeout(() => this.sendStepsFromCurrentState(), 100);
821
810
  }
822
- (_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 ? void 0 : _this$analyticsHelper33.sendActionEvent(EVENT_ACTION.PROCESS_STEPS, EVENT_STATUS.SUCCESS);
811
+ (_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendActionEvent(EVENT_ACTION.PROCESS_STEPS, EVENT_STATUS.SUCCESS);
823
812
  } catch (error) {
824
- var _this$analyticsHelper34;
813
+ var _this$analyticsHelper33;
825
814
  // ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
826
815
  const userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
827
816
  logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
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`);
817
+ (_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`);
829
818
  this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
830
819
  }
831
820
  }
@@ -870,8 +859,8 @@ export class DocumentService {
870
859
  var _this$getState0;
871
860
  const state = (_this$getState0 = this.getState) === null || _this$getState0 === void 0 ? void 0 : _this$getState0.call(this);
872
861
  if (!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');
862
+ var _this$analyticsHelper34;
863
+ (_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 ? void 0 : _this$analyticsHelper34.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
875
864
  return;
876
865
  }
877
866
  this.send(null, null, state, sendAnalyticsEvent, reason);
@@ -917,8 +906,8 @@ export class DocumentService {
917
906
  // to ensure that analytics events with the number of unconfirmed steps is only
918
907
  // sent once on connection (as opposed to on every step)
919
908
  if (sendAnalyticsEvent) {
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, {
909
+ var _this$analyticsHelper35;
910
+ (_this$analyticsHelper35 = this.analyticsHelper) === null || _this$analyticsHelper35 === void 0 ? void 0 : _this$analyticsHelper35.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
922
911
  numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
923
912
  });
924
913
  }
@@ -927,12 +916,12 @@ export class DocumentService {
927
916
  }
928
917
  const rebased = tr === null || tr === void 0 ? void 0 : tr.getMeta('rebasedData');
929
918
  if (rebased) {
930
- var _this$analyticsHelper37;
919
+ var _this$analyticsHelper36;
931
920
  const obfuscatedUnconfirmedSteps = this.obfuscateStepsAndState(rebased.unconfirmedSteps).obfuscatedSteps;
932
921
  const obfuscatedRemoteSteps = this.obfuscateStepsAndState(rebased.remoteSteps);
933
922
  const obfuscatedRebasedSteps = this.obfuscateStepsAndState(unconfirmedSteps).obfuscatedSteps;
934
923
  // send analtyics on unconfirmed steps
935
- (_this$analyticsHelper37 = this.analyticsHelper) === null || _this$analyticsHelper37 === void 0 ? void 0 : _this$analyticsHelper37.sendActionEvent(EVENT_ACTION.STEPS_REBASED, EVENT_STATUS.INFO, {
924
+ (_this$analyticsHelper36 = this.analyticsHelper) === null || _this$analyticsHelper36 === void 0 ? void 0 : _this$analyticsHelper36.sendActionEvent(EVENT_ACTION.STEPS_REBASED, EVENT_STATUS.INFO, {
936
925
  obfuscatedUnconfirmedSteps,
937
926
  obfuscatedRemoteSteps,
938
927
  obfuscatedRebasedSteps,
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "14.0.8";
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
  };