@atlaskit/collab-provider 9.6.0 → 9.6.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2e7c3cad470`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e7c3cad470) - Reduce stepsAdded analytics events by only sampling 10%
8
+
9
+ ## 9.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`979e3ad2b67`](https://bitbucket.org/atlassian/atlassian-frontend/commits/979e3ad2b67) - NO-ISSUE: add data portal links and fix a broken analytics error event
14
+
3
15
  ## 9.6.0
4
16
 
5
17
  ### Minor Changes
@@ -382,7 +382,7 @@ var DocumentService = /*#__PURE__*/function () {
382
382
  * @throws {Error} Couldn't sync the steps after retrying 30 times
383
383
  */
384
384
  (0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
385
- var unconfirmedSteps, _this$analyticsHelper19, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, _this$analyticsHelper18, state, unconfirmedStepsInfoUGCRemoved, measure, _this$analyticsHelper20, _this$analyticsHelper21, _measure3;
385
+ var unconfirmedSteps, _this$analyticsHelper18, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, unconfirmedStepsInfoUGCRemoved, _error2, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure3;
386
386
  return _regenerator.default.wrap(function _callee4$(_context4) {
387
387
  while (1) switch (_context4.prev = _context4.next) {
388
388
  case 0:
@@ -435,16 +435,16 @@ var DocumentService = /*#__PURE__*/function () {
435
435
  unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
436
436
  return (0, _utils.getStepUGCFreeDetails)(step);
437
437
  });
438
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent({
439
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
440
- }, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
441
- throw new Error("Can't sync up with Collab Service");
438
+ _error2 = new _errorTypes.CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
439
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
440
+ });
441
+ throw _error2;
442
442
  case 19:
443
443
  _context4.next = 8;
444
444
  break;
445
445
  case 21:
446
446
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
447
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
447
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
448
448
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
449
449
  // upon success, emit the total number of unconfirmed steps we synced
450
450
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -456,11 +456,11 @@ var DocumentService = /*#__PURE__*/function () {
456
456
  _context4.prev = 25;
457
457
  _context4.t0 = _context4["catch"](1);
458
458
  _measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
459
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
459
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
460
460
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
461
461
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
462
462
  });
463
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
463
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
464
464
  throw _context4.t0;
465
465
  case 31:
466
466
  case "end":
@@ -469,17 +469,17 @@ var DocumentService = /*#__PURE__*/function () {
469
469
  }, _callee4, null, [[1, 25]]);
470
470
  })));
471
471
  (0, _defineProperty2.default)(this, "onStepRejectedError", function () {
472
- var _this$analyticsHelper22;
472
+ var _this$analyticsHelper21;
473
473
  _this.stepRejectCounter++;
474
474
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
475
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
475
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
476
476
  count: _this.stepRejectCounter
477
477
  });
478
478
  var maxRetries = _this.aggressiveCatchup ? _this.failedStepsBeforeCatchupOnPublish : _provider.MAX_STEP_REJECTED_ERROR;
479
479
  if (_this.stepRejectCounter >= maxRetries) {
480
- var _this$analyticsHelper23;
480
+ var _this$analyticsHelper22;
481
481
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
482
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
482
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
483
483
  _this.throttledCatchup();
484
484
  } else {
485
485
  // If committing steps failed try again automatically in 1s
@@ -552,9 +552,9 @@ var DocumentService = /*#__PURE__*/function () {
552
552
  }, 100);
553
553
  }
554
554
  } catch (error) {
555
- var _this$analyticsHelper24;
555
+ var _this$analyticsHelper23;
556
556
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
557
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while processing steps');
557
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
558
558
  this.throttledCatchup();
559
559
  }
560
560
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.UpdateDocumentError = exports.SetTitleError = exports.SetMetadataError = exports.SetEditorWidthError = exports.SendTransactionError = exports.ProviderInitialisationError = exports.PROVIDER_ERROR_CODE = exports.NotInitializedError = exports.NotConnectedError = exports.NCS_ERROR_CODE = exports.INTERNAL_ERROR_CODE = exports.GetFinalAcknowledgedStateError = exports.GetCurrentStateError = exports.DestroyError = exports.CustomError = void 0;
7
+ exports.UpdateDocumentError = exports.SetTitleError = exports.SetMetadataError = exports.SetEditorWidthError = exports.SendTransactionError = exports.ProviderInitialisationError = exports.PROVIDER_ERROR_CODE = exports.NotInitializedError = exports.NotConnectedError = exports.NCS_ERROR_CODE = exports.INTERNAL_ERROR_CODE = exports.GetFinalAcknowledgedStateError = exports.GetCurrentStateError = exports.DestroyError = exports.CustomError = exports.CantSyncUpError = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -375,4 +375,17 @@ var UpdateDocumentError = /*#__PURE__*/function (_CustomError11) {
375
375
  }
376
376
  return (0, _createClass2.default)(UpdateDocumentError);
377
377
  }(CustomError);
378
- exports.UpdateDocumentError = UpdateDocumentError;
378
+ exports.UpdateDocumentError = UpdateDocumentError;
379
+ var CantSyncUpError = /*#__PURE__*/function (_CustomError12) {
380
+ (0, _inherits2.default)(CantSyncUpError, _CustomError12);
381
+ var _super13 = _createSuper(CantSyncUpError);
382
+ function CantSyncUpError(message, extraAttributes) {
383
+ var _this13;
384
+ (0, _classCallCheck2.default)(this, CantSyncUpError);
385
+ _this13 = _super13.call(this, message, undefined, extraAttributes);
386
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this13), "name", 'CantSyncUpError');
387
+ return _this13;
388
+ }
389
+ return (0, _createClass2.default)(CantSyncUpError);
390
+ }(CustomError);
391
+ exports.CantSyncUpError = CantSyncUpError;
@@ -20,12 +20,13 @@ var EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
20
20
  EVENT_ACTION["CATCHUP_AFTER_MAX_SEND_STEPS_RETRY"] = "catchupAfterMaxSendStepsRetry";
21
21
  EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
22
22
  return EVENT_ACTION;
23
- }({});
23
+ }({}); // https://data-portal.internal.atlassian.com/analytics/registry/53724
24
24
  exports.EVENT_ACTION = EVENT_ACTION;
25
25
  var EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
26
26
  EVENT_STATUS["SUCCESS"] = "SUCCESS";
27
27
  EVENT_STATUS["FAILURE"] = "FAILURE";
28
28
  EVENT_STATUS["INFO"] = "INFO";
29
+ EVENT_STATUS["SUCCESS_10x_SAMPLED"] = "SUCCESS_10x_SAMPLED";
29
30
  return EVENT_STATUS;
30
31
  }({});
31
32
  exports.EVENT_STATUS = EVENT_STATUS;
@@ -48,13 +48,16 @@ var commitStep = function commitStep(_ref) {
48
48
  steps: stepsWithClientAndUserId,
49
49
  version: response.version
50
50
  });
51
- analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(_const.EVENT_ACTION.ADD_STEPS, _const.EVENT_STATUS.SUCCESS, {
52
- type: _const.ADD_STEPS_TYPE.ACCEPTED,
53
- latency: latency,
54
- stepType: (0, _countBy.default)(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
55
- return stepWithClientAndUserId.stepType;
56
- })
57
- });
51
+ // Sample only 10% of add steps events to avoid overwhelming the analytics
52
+ if (Math.random() < 0.1) {
53
+ analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(_const.EVENT_ACTION.ADD_STEPS, _const.EVENT_STATUS.SUCCESS_10x_SAMPLED, {
54
+ type: _const.ADD_STEPS_TYPE.ACCEPTED,
55
+ latency: latency,
56
+ stepType: (0, _countBy.default)(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
57
+ return stepWithClientAndUserId.stepType;
58
+ })
59
+ });
60
+ }
58
61
  emit('commit-status', {
59
62
  status: 'success',
60
63
  version: response.version
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/collab-provider";
8
8
  exports.name = name;
9
- var version = "9.6.0";
9
+ var version = "9.6.2";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.6.0",
3
+ "version": "9.6.2",
4
4
  "sideEffects": false
5
5
  }
@@ -9,7 +9,7 @@ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
9
9
  import { MAX_STEP_REJECTED_ERROR } from '../provider';
10
10
  import { catchup } from './catchup';
11
11
  import { StepQueueState } from './step-queue-state';
12
- import { INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
12
+ import { CantSyncUpError, INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
13
13
  const CATCHUP_THROTTLE = 1 * 1000; // 1 second
14
14
 
15
15
  const noop = () => {};
@@ -329,7 +329,7 @@ export class DocumentService {
329
329
  const unconfirmedSteps = this.getUnconfirmedSteps();
330
330
  try {
331
331
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
332
- var _this$analyticsHelper19;
332
+ var _this$analyticsHelper18;
333
333
  startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
334
334
  let count = 0;
335
335
  // We use origins here as steps can be rebased. When steps are rebased a new step is created.
@@ -350,7 +350,7 @@ export class DocumentService {
350
350
  isLastTrConfirmed = true;
351
351
  }
352
352
  if (!isLastTrConfirmed && count++ >= ACK_MAX_TRY) {
353
- var _this$getUnconfirmedS, _this$analyticsHelper18;
353
+ var _this$getUnconfirmedS;
354
354
  if (this.onSyncUpError) {
355
355
  const state = this.getState();
356
356
  this.onSyncUpError({
@@ -362,42 +362,42 @@ export class DocumentService {
362
362
  });
363
363
  }
364
364
  const unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(step => getStepUGCFreeDetails(step));
365
- (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent({
366
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
367
- }, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
368
- throw new Error("Can't sync up with Collab Service");
365
+ const error = new CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
366
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
367
+ });
368
+ throw error;
369
369
  }
370
370
  }
371
371
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
372
- (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
372
+ (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
373
373
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
374
374
  // upon success, emit the total number of unconfirmed steps we synced
375
375
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
376
376
  });
377
377
  }
378
378
  } catch (error) {
379
- var _this$analyticsHelper20, _this$analyticsHelper21;
379
+ var _this$analyticsHelper19, _this$analyticsHelper20;
380
380
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
381
- (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
381
+ (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
382
382
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
383
383
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
384
384
  });
385
- (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(error, 'Error while committing unconfirmed steps');
385
+ (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(error, 'Error while committing unconfirmed steps');
386
386
  throw error;
387
387
  }
388
388
  });
389
389
  _defineProperty(this, "onStepRejectedError", () => {
390
- var _this$analyticsHelper22;
390
+ var _this$analyticsHelper21;
391
391
  this.stepRejectCounter++;
392
392
  logger(`Steps rejected (tries=${this.stepRejectCounter})`);
393
- (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
393
+ (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
394
394
  count: this.stepRejectCounter
395
395
  });
396
396
  let maxRetries = this.aggressiveCatchup ? this.failedStepsBeforeCatchupOnPublish : MAX_STEP_REJECTED_ERROR;
397
397
  if (this.stepRejectCounter >= maxRetries) {
398
- var _this$analyticsHelper23;
398
+ var _this$analyticsHelper22;
399
399
  logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
400
- (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
400
+ (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
401
401
  this.throttledCatchup();
402
402
  } else {
403
403
  // If committing steps failed try again automatically in 1s
@@ -462,9 +462,9 @@ export class DocumentService {
462
462
  setTimeout(() => this.sendStepsFromCurrentState(), 100);
463
463
  }
464
464
  } catch (error) {
465
- var _this$analyticsHelper24;
465
+ var _this$analyticsHelper23;
466
466
  logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
467
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while processing steps');
467
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
468
468
  this.throttledCatchup();
469
469
  }
470
470
  }
@@ -245,4 +245,10 @@ export class UpdateDocumentError extends CustomError {
245
245
  super(message, undefined, extraAttributes);
246
246
  _defineProperty(this, "name", 'UpdateDocumentError');
247
247
  }
248
+ }
249
+ export class CantSyncUpError extends CustomError {
250
+ constructor(message, extraAttributes) {
251
+ super(message, undefined, extraAttributes);
252
+ _defineProperty(this, "name", 'CantSyncUpError');
253
+ }
248
254
  }
@@ -14,11 +14,12 @@ export let EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
14
14
  EVENT_ACTION["CATCHUP_AFTER_MAX_SEND_STEPS_RETRY"] = "catchupAfterMaxSendStepsRetry";
15
15
  EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
16
16
  return EVENT_ACTION;
17
- }({});
17
+ }({}); // https://data-portal.internal.atlassian.com/analytics/registry/53724
18
18
  export let EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
19
19
  EVENT_STATUS["SUCCESS"] = "SUCCESS";
20
20
  EVENT_STATUS["FAILURE"] = "FAILURE";
21
21
  EVENT_STATUS["INFO"] = "INFO";
22
+ EVENT_STATUS["SUCCESS_10x_SAMPLED"] = "SUCCESS_10x_SAMPLED";
22
23
  return EVENT_STATUS;
23
24
  }({});
24
25
  export let ADD_STEPS_TYPE = /*#__PURE__*/function (ADD_STEPS_TYPE) {
@@ -38,11 +38,14 @@ export const commitStep = ({
38
38
  steps: stepsWithClientAndUserId,
39
39
  version: response.version
40
40
  });
41
- analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS, {
42
- type: ADD_STEPS_TYPE.ACCEPTED,
43
- latency,
44
- stepType: countBy(stepsWithClientAndUserId, stepWithClientAndUserId => stepWithClientAndUserId.stepType)
45
- });
41
+ // Sample only 10% of add steps events to avoid overwhelming the analytics
42
+ if (Math.random() < 0.1) {
43
+ analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS_10x_SAMPLED, {
44
+ type: ADD_STEPS_TYPE.ACCEPTED,
45
+ latency,
46
+ stepType: countBy(stepsWithClientAndUserId, stepWithClientAndUserId => stepWithClientAndUserId.stepType)
47
+ });
48
+ }
46
49
  emit('commit-status', {
47
50
  status: 'success',
48
51
  version: response.version
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.6.0";
2
+ export const version = "9.6.2";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.6.0",
3
+ "version": "9.6.2",
4
4
  "sideEffects": false
5
5
  }
@@ -15,7 +15,7 @@ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
15
15
  import { MAX_STEP_REJECTED_ERROR } from '../provider';
16
16
  import { catchup } from './catchup';
17
17
  import { StepQueueState } from './step-queue-state';
18
- import { INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
18
+ import { CantSyncUpError, INTERNAL_ERROR_CODE, UpdateDocumentError } from '../errors/error-types';
19
19
  var CATCHUP_THROTTLE = 1 * 1000; // 1 second
20
20
 
21
21
  var noop = function noop() {};
@@ -375,7 +375,7 @@ export var DocumentService = /*#__PURE__*/function () {
375
375
  * @throws {Error} Couldn't sync the steps after retrying 30 times
376
376
  */
377
377
  _defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
378
- var unconfirmedSteps, _this$analyticsHelper19, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, _this$analyticsHelper18, state, unconfirmedStepsInfoUGCRemoved, measure, _this$analyticsHelper20, _this$analyticsHelper21, _measure3;
378
+ var unconfirmedSteps, _this$analyticsHelper18, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, unconfirmedStepsInfoUGCRemoved, _error2, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure3;
379
379
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
380
380
  while (1) switch (_context4.prev = _context4.next) {
381
381
  case 0:
@@ -428,16 +428,16 @@ export var DocumentService = /*#__PURE__*/function () {
428
428
  unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
429
429
  return getStepUGCFreeDetails(step);
430
430
  });
431
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent({
432
- unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
433
- }, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
434
- throw new Error("Can't sync up with Collab Service");
431
+ _error2 = new CantSyncUpError("Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached", {
432
+ unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? unconfirmedStepsInfoUGCRemoved.toString() : 'Unable to generate UGC removed step info'
433
+ });
434
+ throw _error2;
435
435
  case 19:
436
436
  _context4.next = 8;
437
437
  break;
438
438
  case 21:
439
439
  measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
440
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
440
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
441
441
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
442
442
  // upon success, emit the total number of unconfirmed steps we synced
443
443
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -449,11 +449,11 @@ export var DocumentService = /*#__PURE__*/function () {
449
449
  _context4.prev = 25;
450
450
  _context4.t0 = _context4["catch"](1);
451
451
  _measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
452
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
452
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
453
453
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
454
454
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
455
455
  });
456
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
456
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
457
457
  throw _context4.t0;
458
458
  case 31:
459
459
  case "end":
@@ -462,17 +462,17 @@ export var DocumentService = /*#__PURE__*/function () {
462
462
  }, _callee4, null, [[1, 25]]);
463
463
  })));
464
464
  _defineProperty(this, "onStepRejectedError", function () {
465
- var _this$analyticsHelper22;
465
+ var _this$analyticsHelper21;
466
466
  _this.stepRejectCounter++;
467
467
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
468
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
468
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
469
469
  count: _this.stepRejectCounter
470
470
  });
471
471
  var maxRetries = _this.aggressiveCatchup ? _this.failedStepsBeforeCatchupOnPublish : MAX_STEP_REJECTED_ERROR;
472
472
  if (_this.stepRejectCounter >= maxRetries) {
473
- var _this$analyticsHelper23;
473
+ var _this$analyticsHelper22;
474
474
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
475
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
475
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
476
476
  _this.throttledCatchup();
477
477
  } else {
478
478
  // If committing steps failed try again automatically in 1s
@@ -545,9 +545,9 @@ export var DocumentService = /*#__PURE__*/function () {
545
545
  }, 100);
546
546
  }
547
547
  } catch (error) {
548
- var _this$analyticsHelper24;
548
+ var _this$analyticsHelper23;
549
549
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
550
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendErrorEvent(error, 'Error while processing steps');
550
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
551
551
  this.throttledCatchup();
552
552
  }
553
553
  }
@@ -361,4 +361,16 @@ export var UpdateDocumentError = /*#__PURE__*/function (_CustomError11) {
361
361
  return _this12;
362
362
  }
363
363
  return _createClass(UpdateDocumentError);
364
+ }(CustomError);
365
+ export var CantSyncUpError = /*#__PURE__*/function (_CustomError12) {
366
+ _inherits(CantSyncUpError, _CustomError12);
367
+ var _super13 = _createSuper(CantSyncUpError);
368
+ function CantSyncUpError(message, extraAttributes) {
369
+ var _this13;
370
+ _classCallCheck(this, CantSyncUpError);
371
+ _this13 = _super13.call(this, message, undefined, extraAttributes);
372
+ _defineProperty(_assertThisInitialized(_this13), "name", 'CantSyncUpError');
373
+ return _this13;
374
+ }
375
+ return _createClass(CantSyncUpError);
364
376
  }(CustomError);
@@ -14,11 +14,12 @@ export var EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
14
14
  EVENT_ACTION["CATCHUP_AFTER_MAX_SEND_STEPS_RETRY"] = "catchupAfterMaxSendStepsRetry";
15
15
  EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
16
16
  return EVENT_ACTION;
17
- }({});
17
+ }({}); // https://data-portal.internal.atlassian.com/analytics/registry/53724
18
18
  export var EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
19
19
  EVENT_STATUS["SUCCESS"] = "SUCCESS";
20
20
  EVENT_STATUS["FAILURE"] = "FAILURE";
21
21
  EVENT_STATUS["INFO"] = "INFO";
22
+ EVENT_STATUS["SUCCESS_10x_SAMPLED"] = "SUCCESS_10x_SAMPLED";
22
23
  return EVENT_STATUS;
23
24
  }({});
24
25
  export var ADD_STEPS_TYPE = /*#__PURE__*/function (ADD_STEPS_TYPE) {
@@ -41,13 +41,16 @@ export var commitStep = function commitStep(_ref) {
41
41
  steps: stepsWithClientAndUserId,
42
42
  version: response.version
43
43
  });
44
- analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS, {
45
- type: ADD_STEPS_TYPE.ACCEPTED,
46
- latency: latency,
47
- stepType: countBy(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
48
- return stepWithClientAndUserId.stepType;
49
- })
50
- });
44
+ // Sample only 10% of add steps events to avoid overwhelming the analytics
45
+ if (Math.random() < 0.1) {
46
+ analyticsHelper === null || analyticsHelper === void 0 ? void 0 : analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS_10x_SAMPLED, {
47
+ type: ADD_STEPS_TYPE.ACCEPTED,
48
+ latency: latency,
49
+ stepType: countBy(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
50
+ return stepWithClientAndUserId.stepType;
51
+ })
52
+ });
53
+ }
51
54
  emit('commit-status', {
52
55
  status: 'success',
53
56
  version: response.version
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "9.6.0";
2
+ export var version = "9.6.2";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.6.0",
3
+ "version": "9.6.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { DocumentUpdateErrorAttributes } from '../helpers/const';
1
+ import { CantSyncUpErrorAttributes, DocumentUpdateErrorAttributes } from '../helpers/const';
2
2
  export declare enum INTERNAL_ERROR_CODE {
3
3
  TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
4
4
  RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
@@ -480,4 +480,8 @@ export declare class UpdateDocumentError extends CustomError {
480
480
  name: string;
481
481
  constructor(message: string, extraAttributes: DocumentUpdateErrorAttributes);
482
482
  }
483
+ export declare class CantSyncUpError extends CustomError {
484
+ name: string;
485
+ constructor(message: string, extraAttributes: CantSyncUpErrorAttributes);
486
+ }
483
487
  export {};
@@ -18,7 +18,8 @@ export declare enum EVENT_ACTION {
18
18
  export declare enum EVENT_STATUS {
19
19
  SUCCESS = "SUCCESS",
20
20
  FAILURE = "FAILURE",
21
- INFO = "INFO"
21
+ INFO = "INFO",
22
+ SUCCESS_10x_SAMPLED = "SUCCESS_10x_SAMPLED"
22
23
  }
23
24
  export declare enum ADD_STEPS_TYPE {
24
25
  ACCEPTED = "ACCEPTED",
@@ -32,6 +33,9 @@ export type DocumentUpdateErrorAttributes = {
32
33
  docHasContent?: boolean;
33
34
  isDocContentValid?: boolean;
34
35
  };
36
+ export type CantSyncUpErrorAttributes = {
37
+ unconfirmedStepsInfo: string;
38
+ };
35
39
  export type ErrorAnalyticsEvent = {
36
40
  eventAction: EVENT_ACTION.ERROR;
37
41
  attributes: {
@@ -1,4 +1,4 @@
1
- import { DocumentUpdateErrorAttributes } from '../helpers/const';
1
+ import { CantSyncUpErrorAttributes, DocumentUpdateErrorAttributes } from '../helpers/const';
2
2
  export declare enum INTERNAL_ERROR_CODE {
3
3
  TOKEN_PERMISSION_ERROR = "TOKEN_PERMISSION_ERROR",
4
4
  RECONNECTION_NETWORK_ISSUE = "RECONNECTION_NETWORK_ISSUE",
@@ -480,4 +480,8 @@ export declare class UpdateDocumentError extends CustomError {
480
480
  name: string;
481
481
  constructor(message: string, extraAttributes: DocumentUpdateErrorAttributes);
482
482
  }
483
+ export declare class CantSyncUpError extends CustomError {
484
+ name: string;
485
+ constructor(message: string, extraAttributes: CantSyncUpErrorAttributes);
486
+ }
483
487
  export {};
@@ -18,7 +18,8 @@ export declare enum EVENT_ACTION {
18
18
  export declare enum EVENT_STATUS {
19
19
  SUCCESS = "SUCCESS",
20
20
  FAILURE = "FAILURE",
21
- INFO = "INFO"
21
+ INFO = "INFO",
22
+ SUCCESS_10x_SAMPLED = "SUCCESS_10x_SAMPLED"
22
23
  }
23
24
  export declare enum ADD_STEPS_TYPE {
24
25
  ACCEPTED = "ACCEPTED",
@@ -32,6 +33,9 @@ export type DocumentUpdateErrorAttributes = {
32
33
  docHasContent?: boolean;
33
34
  isDocContentValid?: boolean;
34
35
  };
36
+ export type CantSyncUpErrorAttributes = {
37
+ unconfirmedStepsInfo: string;
38
+ };
35
39
  export type ErrorAnalyticsEvent = {
36
40
  eventAction: EVENT_ACTION.ERROR;
37
41
  attributes: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.6.0",
3
+ "version": "9.6.2",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -63,7 +63,7 @@
63
63
  "devDependencies": {
64
64
  "@atlaskit/adf-schema": "^26.1.0",
65
65
  "@atlaskit/analytics-listeners": "^8.7.0",
66
- "@atlaskit/editor-test-helpers": "^18.9.0",
66
+ "@atlaskit/editor-test-helpers": "^18.10.0",
67
67
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
68
68
  "prosemirror-model": "1.16.0",
69
69
  "prosemirror-state": "1.3.4",