@atlaskit/collab-provider 11.1.1 → 11.2.1

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/channel.js +5 -7
  3. package/dist/cjs/document/document-service.js +6 -20
  4. package/dist/cjs/document/null-document-service.js +0 -1
  5. package/dist/cjs/errors/ncs-errors.js +0 -1
  6. package/dist/cjs/helpers/const.js +0 -1
  7. package/dist/cjs/provider/commit-step.js +1 -13
  8. package/dist/cjs/provider/index.js +1 -4
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/channel.js +4 -6
  11. package/dist/es2019/document/document-service.js +6 -20
  12. package/dist/es2019/document/null-document-service.js +0 -1
  13. package/dist/es2019/errors/ncs-errors.js +0 -1
  14. package/dist/es2019/helpers/const.js +0 -1
  15. package/dist/es2019/provider/commit-step.js +1 -13
  16. package/dist/es2019/provider/index.js +1 -4
  17. package/dist/es2019/version-wrapper.js +1 -1
  18. package/dist/esm/channel.js +5 -7
  19. package/dist/esm/document/document-service.js +6 -20
  20. package/dist/esm/document/null-document-service.js +0 -1
  21. package/dist/esm/errors/ncs-errors.js +0 -1
  22. package/dist/esm/helpers/const.js +0 -1
  23. package/dist/esm/provider/commit-step.js +1 -13
  24. package/dist/esm/provider/index.js +1 -4
  25. package/dist/esm/version-wrapper.js +1 -1
  26. package/dist/types/channel.d.ts +3 -3
  27. package/dist/types/document/document-service.d.ts +10 -19
  28. package/dist/types/document/null-document-service.d.ts +0 -1
  29. package/dist/types/errors/ncs-errors.d.ts +2 -11
  30. package/dist/types/helpers/const.d.ts +1 -2
  31. package/dist/types/helpers/utils.d.ts +8 -8
  32. package/dist/types/participants/participants-helper.d.ts +1 -4
  33. package/dist/types/participants/participants-service.d.ts +2 -2
  34. package/dist/types/participants/telepointers-helper.d.ts +1 -1
  35. package/dist/types/provider/commit-step.d.ts +1 -3
  36. package/dist/types/types.d.ts +5 -6
  37. package/dist/types-ts4.5/channel.d.ts +3 -3
  38. package/dist/types-ts4.5/document/document-service.d.ts +10 -19
  39. package/dist/types-ts4.5/document/null-document-service.d.ts +0 -1
  40. package/dist/types-ts4.5/errors/ncs-errors.d.ts +2 -11
  41. package/dist/types-ts4.5/helpers/const.d.ts +1 -2
  42. package/dist/types-ts4.5/helpers/utils.d.ts +8 -8
  43. package/dist/types-ts4.5/participants/participants-helper.d.ts +1 -4
  44. package/dist/types-ts4.5/participants/participants-service.d.ts +2 -2
  45. package/dist/types-ts4.5/participants/telepointers-helper.d.ts +1 -1
  46. package/dist/types-ts4.5/provider/commit-step.d.ts +1 -3
  47. package/dist/types-ts4.5/types.d.ts +5 -6
  48. package/docs/document-service-send-function-analysis.md +3 -7
  49. package/package.json +6 -7
  50. package/socket-io-provider/package.json +1 -1
  51. package/types/package.json +1 -1
  52. package/version-wrapper/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 11.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bc0db0b86820f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bc0db0b86820f) -
8
+ cleanup unused skipValidation experiment code
9
+ - Updated dependencies
10
+
11
+ ## 11.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#197573](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/197573)
16
+ [`2853bc7075415`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2853bc7075415) -
17
+ Clean up platform_editor_connection_auto_disconnect_delay experiment feature gate
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 11.1.1
4
24
 
5
25
  ### Patch Changes
@@ -25,7 +25,6 @@ var _network = _interopRequireDefault(require("./connectivity/network"));
25
25
  var _internalErrors = require("./errors/internal-errors");
26
26
  var _ncsErrors = require("./errors/ncs-errors");
27
27
  var _customErrors = require("./errors/custom-errors");
28
- var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
29
28
  var _bindEventListener = require("bind-event-listener");
30
29
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
31
30
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -884,14 +883,13 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
884
883
  key: "addVisiblityListener",
885
884
  value:
886
885
  /**
887
- * Adds an event listener for visibilitychange events to handle auto-disconnection if tab is in background
886
+ * Adds an event listener for visibilitychange events to automatically close the socket
887
+ * connection if tab is in background for longer than disconnectDelay
888
888
  */
889
889
  function addVisiblityListener() {
890
- var _FeatureGates$getExpe,
891
- _this3 = this;
892
- var disconnectDelay = (_FeatureGates$getExpe = _featureGateJsClient.default.getExperimentValue('platform_editor_connection_auto_disconnect_delay', 'delay', -1)) !== null && _FeatureGates$getExpe !== void 0 ? _FeatureGates$getExpe : -1;
893
- var isAutoDisconnectEnabled = disconnectDelay >= 0;
894
- if (isAutoDisconnectEnabled && this.config.isPresenceOnly) {
890
+ var _this3 = this;
891
+ var disconnectDelay = 60;
892
+ if (this.config.isPresenceOnly) {
895
893
  this.unbindVisibilityListener = (0, _bindEventListener.bind)(document, {
896
894
  type: 'visibilitychange',
897
895
  listener: function listener() {
@@ -21,7 +21,6 @@ var _const = require("../helpers/const");
21
21
  var _performance = require("../analytics/performance");
22
22
  var _internalErrors = require("../errors/internal-errors");
23
23
  var _utils = require("../helpers/utils");
24
- var _participantsService = require("../participants/participants-service");
25
24
  var _provider = require("../provider");
26
25
  var _commitStep = require("../provider/commit-step");
27
26
  var _customErrors = require("../errors/custom-errors");
@@ -78,7 +77,6 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
78
77
  (0, _defineProperty2.default)(this, "aggressiveCatchup", false);
79
78
  (0, _defineProperty2.default)(this, "catchUpOutofSync", false);
80
79
  (0, _defineProperty2.default)(this, "hasRecovered", false);
81
- (0, _defineProperty2.default)(this, "numberOfStepCommitsSent", 0);
82
80
  (0, _defineProperty2.default)(this, "timeoutExceeded", false);
83
81
  /**
84
82
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
@@ -91,16 +89,6 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
91
89
  // TODO: ED-26957 - why shouldn't this be leading?
92
90
  trailing: true
93
91
  }));
94
- /**
95
- * Updates the number of commits sent since connect/reconnect
96
- * This is used to track the number of commits sent to the server.
97
- * currently we are validating the first steps from a user after connect/reconnect - CEPS-710
98
- * @param steps
99
- * @example
100
- */
101
- (0, _defineProperty2.default)(this, "setNumberOfCommitsSent", function (steps) {
102
- _this.numberOfStepCommitsSent = steps;
103
- });
104
92
  /**
105
93
  * Called when:
106
94
  * * session established(offline -> online)
@@ -140,7 +128,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
140
128
  analyticsHelper: _this.analyticsHelper,
141
129
  clientId: _this.clientId,
142
130
  onStepsAdded: _this.onStepsAdded,
143
- catchUpOutofSync: reason === _const.CatchupEventReason.CORRUPT_STEP ? true : _this.catchUpOutofSync,
131
+ catchUpOutofSync: _this.catchUpOutofSync,
144
132
  reason: reason,
145
133
  sessionId: sessionId,
146
134
  onCatchupComplete: function onCatchupComplete(steps) {
@@ -1026,12 +1014,12 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
1026
1014
  ) {
1027
1015
  var _this3 = this;
1028
1016
  var offlineEditingEnabled = (0, _experiments.editorExperiment)('platform_editor_offline_editing_web', true);
1029
- var singlePlayerStepMergingEnabled = (0, _expValEquals.expValEquals)('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
1017
+ var onlineStepMergingEnabled = (0, _expValEquals.expValEquals)('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
1030
1018
 
1031
1019
  // Don't send any steps before we're ready.
1032
- if (offlineEditingEnabled || singlePlayerStepMergingEnabled) {
1033
- var enableStepsMergingForSinglePlayer = singlePlayerStepMergingEnabled && !this.commitStepService.getReadyToCommitStatus() && this.participantsService.getCollabMode() === _participantsService.SINGLE_COLLAB_MODE;
1034
- if (!this.getConnected() || enableStepsMergingForSinglePlayer) {
1020
+ if (offlineEditingEnabled || onlineStepMergingEnabled) {
1021
+ var enableOnlineStepMerging = onlineStepMergingEnabled && !this.commitStepService.getReadyToCommitStatus();
1022
+ if (!this.getConnected() || enableOnlineStepMerging) {
1035
1023
  return;
1036
1024
  }
1037
1025
  }
@@ -1040,7 +1028,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
1040
1028
  if (!unconfirmedStepsData) {
1041
1029
  return;
1042
1030
  }
1043
- if (offlineEditingEnabled || singlePlayerStepMergingEnabled) {
1031
+ if (offlineEditingEnabled || onlineStepMergingEnabled) {
1044
1032
  this.lockStepOrigins(unconfirmedStepsData.origins);
1045
1033
  }
1046
1034
  var unconfirmedSteps = unconfirmedStepsData.steps;
@@ -1124,8 +1112,6 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
1124
1112
  hasRecovered: this.hasRecovered,
1125
1113
  collabMode: this.participantsService.getCollabMode(),
1126
1114
  reason: reason,
1127
- numberOfStepCommitsSent: this.numberOfStepCommitsSent,
1128
- setNumberOfCommitsSent: this.setNumberOfCommitsSent,
1129
1115
  lockSteps: this.lockSteps
1130
1116
  });
1131
1117
  }
@@ -17,7 +17,6 @@ var NullDocumentService = exports.NullDocumentService = /*#__PURE__*/function ()
17
17
  return _this;
18
18
  });
19
19
  (0, _defineProperty2.default)(this, "onErrorHandled", function () {});
20
- (0, _defineProperty2.default)(this, "setNumberOfCommitsSent", function () {});
21
20
  }
22
21
  return (0, _createClass2.default)(NullDocumentService, [{
23
22
  key: "updateDocument",
@@ -24,7 +24,6 @@ var NCS_ERROR_CODE = exports.NCS_ERROR_CODE = /*#__PURE__*/function (NCS_ERROR_C
24
24
  NCS_ERROR_CODE["INVALID_CLOUD_ID"] = "INVALID_CLOUD_ID";
25
25
  NCS_ERROR_CODE["RATE_LIMIT_ERROR"] = "RATE_LIMIT_ERROR";
26
26
  NCS_ERROR_CODE["PROSEMIRROR_SCHEMA_VALIDATION_ERROR"] = "PROSEMIRROR_SCHEMA_VALIDATION_ERROR";
27
- NCS_ERROR_CODE["CORRUPT_STEP_FAILED_TO_SAVE"] = "CORRUPT_STEP_FAILED_TO_SAVE";
28
27
  return NCS_ERROR_CODE;
29
28
  }({}); // TODO: ED-26957 - Import emitted error codes from NCS
30
29
  // NCS Errors
@@ -75,6 +75,5 @@ var CatchupEventReason = exports.CatchupEventReason = /*#__PURE__*/function (Cat
75
75
  CatchupEventReason["STEPS_REJECTED"] = "onStepsRejected";
76
76
  CatchupEventReason["PROCESS_STEPS"] = "processSteps";
77
77
  CatchupEventReason["RECONNECTED"] = "reconnected";
78
- CatchupEventReason["CORRUPT_STEP"] = "corruptStep";
79
78
  return CatchupEventReason;
80
79
  }({});
@@ -9,7 +9,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
11
  var _countBy = _interopRequireDefault(require("lodash/countBy"));
12
- var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
13
12
  var _const = require("../helpers/const");
14
13
  var _types = require("../types");
15
14
  var _ncsErrors = require("../errors/ncs-errors");
@@ -50,8 +49,6 @@ var CommitStepService = exports.CommitStepService = /*#__PURE__*/function () {
50
49
  hasRecovered = _ref.hasRecovered,
51
50
  collabMode = _ref.collabMode,
52
51
  reason = _ref.reason,
53
- numberOfStepCommitsSent = _ref.numberOfStepCommitsSent,
54
- setNumberOfCommitsSent = _ref.setNumberOfCommitsSent,
55
52
  lockSteps = _ref.lockSteps;
56
53
  // this timer is for waiting to send the next batch in between acks from the BE
57
54
  var commitWaitTimer;
@@ -124,17 +121,11 @@ var CommitStepService = exports.CommitStepService = /*#__PURE__*/function () {
124
121
  version: version
125
122
  });
126
123
  try {
127
- var _FeatureGates$getExpe;
128
- var n = (_FeatureGates$getExpe = _featureGateJsClient.default.getExperimentValue('platform_editor_step_validation_on_connect', 'steps', 0)) !== null && _FeatureGates$getExpe !== void 0 ? _FeatureGates$getExpe : 0;
129
- var isExperimentEnabled = n > 0;
130
- // skip validation if FG is on and we have already sent n steps, or if FG is off
131
- var skipValidation = isExperimentEnabled ? numberOfStepCommitsSent >= n : true;
132
124
  this.broadcast('steps:commit', {
133
125
  collabMode: collabMode,
134
126
  steps: stepsWithClientAndUserId,
135
127
  version: version,
136
- userId: userId,
137
- skipValidation: skipValidation
128
+ userId: userId
138
129
  }, function (response) {
139
130
  _this.lastBroadcastRequestAcked = true;
140
131
  var latency = new Date().getTime() - start;
@@ -185,9 +176,6 @@ var CommitStepService = exports.CommitStepService = /*#__PURE__*/function () {
185
176
  console.error(ADD_STEPS_ACKNOWLEDGEMENT_ERROR_MSG);
186
177
  }
187
178
  });
188
- if (isExperimentEnabled && numberOfStepCommitsSent < n) {
189
- setNumberOfCommitsSent(numberOfStepCommitsSent + 1);
190
- }
191
179
  } catch (error) {
192
180
  var _this$analyticsHelper2;
193
181
  // if the broadcast failed for any reason, we shouldn't keep the queue locked as the BE has not recieved any message
@@ -117,7 +117,6 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
117
117
  initial: !initialized
118
118
  });
119
119
  var unconfirmedStepsLength = (_this$documentService = _this.documentService.getUnconfirmedSteps()) === null || _this$documentService === void 0 ? void 0 : _this$documentService.length;
120
- _this.documentService.setNumberOfCommitsSent(0);
121
120
 
122
121
  // if buffering is enabled and the provider is initialized before connection,
123
122
  // send any unconfirmed steps
@@ -220,14 +219,12 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
220
219
  * @param {InternalError} error The error to handle
221
220
  */
222
221
  (0, _defineProperty2.default)(_this, "onErrorHandled", function (error) {
223
- var _error$data, _error$data2, _error$data3;
222
+ var _error$data, _error$data2;
224
223
  // User tried committing steps but they were rejected because:
225
224
  // HEAD_VERSION_UPDATE_FAILED: the collab service's latest stored step tail version didn't correspond to the head version of the first step submitted
226
225
  // VERSION_NUMBER_ALREADY_EXISTS: while storing the steps there was a conflict meaning someone else wrote steps into the database more quickly
227
226
  if (((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) === _ncsErrors.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || ((_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.code) === _ncsErrors.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS) {
228
227
  _this.documentService.onStepRejectedError();
229
- } else if (((_error$data3 = error.data) === null || _error$data3 === void 0 ? void 0 : _error$data3.code) === _ncsErrors.NCS_ERROR_CODE.CORRUPT_STEP_FAILED_TO_SAVE) {
230
- _this.documentService.throttledCatchupv2(_const.CatchupEventReason.CORRUPT_STEP, undefined, (0, _platformFeatureFlags.fg)('add_session_id_to_catchup_query') ? _this.sessionId : undefined);
231
228
  } else {
232
229
  var _this$analyticsHelper2;
233
230
  (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendErrorEvent(error, error.message);
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "11.1.0";
8
+ var version = exports.version = "11.2.0";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -11,7 +11,6 @@ import Network from './connectivity/network';
11
11
  import { INTERNAL_ERROR_CODE } from './errors/internal-errors';
12
12
  import { NCS_ERROR_CODE } from './errors/ncs-errors';
13
13
  import { NotConnectedError, NotInitializedError } from './errors/custom-errors';
14
- import FeatureGates from '@atlaskit/feature-gate-js-client';
15
14
  import { bind } from 'bind-event-listener';
16
15
  const logger = createLogger('Channel', 'green');
17
16
  export class Channel extends Emitter {
@@ -621,13 +620,12 @@ export class Channel extends Emitter {
621
620
  return stepLimit > 0 && this.stepCounter > stepLimit || stepSizeLimit > 0 && this.stepSizeCounter > stepSizeLimit || maxStepSizeLimit > 0 && this.maxStepSize > maxStepSizeLimit;
622
621
  }
623
622
  /**
624
- * Adds an event listener for visibilitychange events to handle auto-disconnection if tab is in background
623
+ * Adds an event listener for visibilitychange events to automatically close the socket
624
+ * connection if tab is in background for longer than disconnectDelay
625
625
  */
626
626
  addVisiblityListener() {
627
- var _FeatureGates$getExpe;
628
- const disconnectDelay = (_FeatureGates$getExpe = FeatureGates.getExperimentValue('platform_editor_connection_auto_disconnect_delay', 'delay', -1)) !== null && _FeatureGates$getExpe !== void 0 ? _FeatureGates$getExpe : -1;
629
- const isAutoDisconnectEnabled = disconnectDelay >= 0;
630
- if (isAutoDisconnectEnabled && this.config.isPresenceOnly) {
627
+ const disconnectDelay = 60;
628
+ if (this.config.isPresenceOnly) {
631
629
  this.unbindVisibilityListener = bind(document, {
632
630
  type: 'visibilitychange',
633
631
  listener: () => {
@@ -10,7 +10,6 @@ import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../
10
10
  import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
11
11
  import { INTERNAL_ERROR_CODE } from '../errors/internal-errors';
12
12
  import { createLogger, getDocAdfWithObfuscationFromJSON, getObfuscatedSteps, getStepUGCFreeDetails, sleep } from '../helpers/utils';
13
- import { SINGLE_COLLAB_MODE } from '../participants/participants-service';
14
13
  import { MAX_STEP_REJECTED_ERROR, MAX_STEP_REJECTED_ERROR_AGGRESSIVE } from '../provider';
15
14
  import { CommitStepService } from '../provider/commit-step';
16
15
  import { CantSyncUpError, UpdateDocumentError } from '../errors/custom-errors';
@@ -60,7 +59,6 @@ export class DocumentService {
60
59
  _defineProperty(this, "aggressiveCatchup", false);
61
60
  _defineProperty(this, "catchUpOutofSync", false);
62
61
  _defineProperty(this, "hasRecovered", false);
63
- _defineProperty(this, "numberOfStepCommitsSent", 0);
64
62
  _defineProperty(this, "timeoutExceeded", false);
65
63
  /**
66
64
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
@@ -71,16 +69,6 @@ export class DocumentService {
71
69
  // TODO: ED-26957 - why shouldn't this be leading?
72
70
  trailing: true
73
71
  }));
74
- /**
75
- * Updates the number of commits sent since connect/reconnect
76
- * This is used to track the number of commits sent to the server.
77
- * currently we are validating the first steps from a user after connect/reconnect - CEPS-710
78
- * @param steps
79
- * @example
80
- */
81
- _defineProperty(this, "setNumberOfCommitsSent", steps => {
82
- this.numberOfStepCommitsSent = steps;
83
- });
84
72
  /**
85
73
  * Called when:
86
74
  * * session established(offline -> online)
@@ -133,7 +121,7 @@ export class DocumentService {
133
121
  analyticsHelper: this.analyticsHelper,
134
122
  clientId: this.clientId,
135
123
  onStepsAdded: this.onStepsAdded,
136
- catchUpOutofSync: reason === CatchupEventReason.CORRUPT_STEP ? true : this.catchUpOutofSync,
124
+ catchUpOutofSync: this.catchUpOutofSync,
137
125
  reason,
138
126
  sessionId,
139
127
  onCatchupComplete: steps => {
@@ -892,12 +880,12 @@ export class DocumentService {
892
880
  send(tr, _oldState, newState, sendAnalyticsEvent, reason // only used for publish and draft-sync events - when called through getFinalAcknowledgedState
893
881
  ) {
894
882
  const offlineEditingEnabled = editorExperiment('platform_editor_offline_editing_web', true);
895
- const singlePlayerStepMergingEnabled = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
883
+ const onlineStepMergingEnabled = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
896
884
 
897
885
  // Don't send any steps before we're ready.
898
- if (offlineEditingEnabled || singlePlayerStepMergingEnabled) {
899
- const enableStepsMergingForSinglePlayer = singlePlayerStepMergingEnabled && !this.commitStepService.getReadyToCommitStatus() && this.participantsService.getCollabMode() === SINGLE_COLLAB_MODE;
900
- if (!this.getConnected() || enableStepsMergingForSinglePlayer) {
886
+ if (offlineEditingEnabled || onlineStepMergingEnabled) {
887
+ const enableOnlineStepMerging = onlineStepMergingEnabled && !this.commitStepService.getReadyToCommitStatus();
888
+ if (!this.getConnected() || enableOnlineStepMerging) {
901
889
  return;
902
890
  }
903
891
  }
@@ -906,7 +894,7 @@ export class DocumentService {
906
894
  if (!unconfirmedStepsData) {
907
895
  return;
908
896
  }
909
- if (offlineEditingEnabled || singlePlayerStepMergingEnabled) {
897
+ if (offlineEditingEnabled || onlineStepMergingEnabled) {
910
898
  this.lockStepOrigins(unconfirmedStepsData.origins);
911
899
  }
912
900
  const unconfirmedSteps = unconfirmedStepsData.steps;
@@ -990,8 +978,6 @@ export class DocumentService {
990
978
  hasRecovered: this.hasRecovered,
991
979
  collabMode: this.participantsService.getCollabMode(),
992
980
  reason,
993
- numberOfStepCommitsSent: this.numberOfStepCommitsSent,
994
- setNumberOfCommitsSent: this.setNumberOfCommitsSent,
995
981
  lockSteps: this.lockSteps
996
982
  });
997
983
  }
@@ -6,7 +6,6 @@ export class NullDocumentService {
6
6
  return this;
7
7
  });
8
8
  _defineProperty(this, "onErrorHandled", () => {});
9
- _defineProperty(this, "setNumberOfCommitsSent", () => {});
10
9
  }
11
10
  updateDocument() {}
12
11
  onRestore() {}
@@ -18,7 +18,6 @@ export let NCS_ERROR_CODE = /*#__PURE__*/function (NCS_ERROR_CODE) {
18
18
  NCS_ERROR_CODE["INVALID_CLOUD_ID"] = "INVALID_CLOUD_ID";
19
19
  NCS_ERROR_CODE["RATE_LIMIT_ERROR"] = "RATE_LIMIT_ERROR";
20
20
  NCS_ERROR_CODE["PROSEMIRROR_SCHEMA_VALIDATION_ERROR"] = "PROSEMIRROR_SCHEMA_VALIDATION_ERROR";
21
- NCS_ERROR_CODE["CORRUPT_STEP_FAILED_TO_SAVE"] = "CORRUPT_STEP_FAILED_TO_SAVE";
22
21
  return NCS_ERROR_CODE;
23
22
  }({});
24
23
 
@@ -69,6 +69,5 @@ export let CatchupEventReason = /*#__PURE__*/function (CatchupEventReason) {
69
69
  CatchupEventReason["STEPS_REJECTED"] = "onStepsRejected";
70
70
  CatchupEventReason["PROCESS_STEPS"] = "processSteps";
71
71
  CatchupEventReason["RECONNECTED"] = "reconnected";
72
- CatchupEventReason["CORRUPT_STEP"] = "corruptStep";
73
72
  return CatchupEventReason;
74
73
  }({});
@@ -1,5 +1,4 @@
1
1
  import countBy from 'lodash/countBy';
2
- import FeatureGates from '@atlaskit/feature-gate-js-client';
3
2
  import { ADD_STEPS_TYPE, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
4
3
  import { AcknowledgementResponseTypes } from '../types';
5
4
  import { NCS_ERROR_CODE } from '../errors/ncs-errors';
@@ -34,8 +33,6 @@ export class CommitStepService {
34
33
  hasRecovered,
35
34
  collabMode,
36
35
  reason,
37
- numberOfStepCommitsSent,
38
- setNumberOfCommitsSent,
39
36
  lockSteps
40
37
  }) {
41
38
  // this timer is for waiting to send the next batch in between acks from the BE
@@ -110,17 +107,11 @@ export class CommitStepService {
110
107
  version
111
108
  });
112
109
  try {
113
- var _FeatureGates$getExpe;
114
- const n = (_FeatureGates$getExpe = FeatureGates.getExperimentValue('platform_editor_step_validation_on_connect', 'steps', 0)) !== null && _FeatureGates$getExpe !== void 0 ? _FeatureGates$getExpe : 0;
115
- const isExperimentEnabled = n > 0;
116
- // skip validation if FG is on and we have already sent n steps, or if FG is off
117
- const skipValidation = isExperimentEnabled ? numberOfStepCommitsSent >= n : true;
118
110
  this.broadcast('steps:commit', {
119
111
  collabMode,
120
112
  steps: stepsWithClientAndUserId,
121
113
  version,
122
- userId,
123
- skipValidation
114
+ userId
124
115
  }, response => {
125
116
  this.lastBroadcastRequestAcked = true;
126
117
  const latency = new Date().getTime() - start;
@@ -171,9 +162,6 @@ export class CommitStepService {
171
162
  console.error(ADD_STEPS_ACKNOWLEDGEMENT_ERROR_MSG);
172
163
  }
173
164
  });
174
- if (isExperimentEnabled && numberOfStepCommitsSent < n) {
175
- setNumberOfCommitsSent(numberOfStepCommitsSent + 1);
176
- }
177
165
  } catch (error) {
178
166
  var _this$analyticsHelper2;
179
167
  // if the broadcast failed for any reason, we shouldn't keep the queue locked as the BE has not recieved any message
@@ -95,7 +95,6 @@ export class Provider extends Emitter {
95
95
  initial: !initialized
96
96
  });
97
97
  const unconfirmedStepsLength = (_this$documentService = this.documentService.getUnconfirmedSteps()) === null || _this$documentService === void 0 ? void 0 : _this$documentService.length;
98
- this.documentService.setNumberOfCommitsSent(0);
99
98
 
100
99
  // if buffering is enabled and the provider is initialized before connection,
101
100
  // send any unconfirmed steps
@@ -182,14 +181,12 @@ export class Provider extends Emitter {
182
181
  * @param {InternalError} error The error to handle
183
182
  */
184
183
  _defineProperty(this, "onErrorHandled", error => {
185
- var _error$data, _error$data2, _error$data3;
184
+ var _error$data, _error$data2;
186
185
  // User tried committing steps but they were rejected because:
187
186
  // HEAD_VERSION_UPDATE_FAILED: the collab service's latest stored step tail version didn't correspond to the head version of the first step submitted
188
187
  // VERSION_NUMBER_ALREADY_EXISTS: while storing the steps there was a conflict meaning someone else wrote steps into the database more quickly
189
188
  if (((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) === NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || ((_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.code) === NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS) {
190
189
  this.documentService.onStepRejectedError();
191
- } else if (((_error$data3 = error.data) === null || _error$data3 === void 0 ? void 0 : _error$data3.code) === NCS_ERROR_CODE.CORRUPT_STEP_FAILED_TO_SAVE) {
192
- this.documentService.throttledCatchupv2(CatchupEventReason.CORRUPT_STEP, undefined, fg('add_session_id_to_catchup_query') ? this.sessionId : undefined);
193
190
  } else {
194
191
  var _this$analyticsHelper2;
195
192
  (_this$analyticsHelper2 = this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendErrorEvent(error, error.message);
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "11.1.0";
2
+ export const version = "11.2.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -25,7 +25,6 @@ import Network from './connectivity/network';
25
25
  import { INTERNAL_ERROR_CODE } from './errors/internal-errors';
26
26
  import { NCS_ERROR_CODE } from './errors/ncs-errors';
27
27
  import { NotConnectedError, NotInitializedError } from './errors/custom-errors';
28
- import FeatureGates from '@atlaskit/feature-gate-js-client';
29
28
  import { bind } from 'bind-event-listener';
30
29
  var logger = createLogger('Channel', 'green');
31
30
  export var Channel = /*#__PURE__*/function (_Emitter) {
@@ -877,14 +876,13 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
877
876
  key: "addVisiblityListener",
878
877
  value:
879
878
  /**
880
- * Adds an event listener for visibilitychange events to handle auto-disconnection if tab is in background
879
+ * Adds an event listener for visibilitychange events to automatically close the socket
880
+ * connection if tab is in background for longer than disconnectDelay
881
881
  */
882
882
  function addVisiblityListener() {
883
- var _FeatureGates$getExpe,
884
- _this3 = this;
885
- var disconnectDelay = (_FeatureGates$getExpe = FeatureGates.getExperimentValue('platform_editor_connection_auto_disconnect_delay', 'delay', -1)) !== null && _FeatureGates$getExpe !== void 0 ? _FeatureGates$getExpe : -1;
886
- var isAutoDisconnectEnabled = disconnectDelay >= 0;
887
- if (isAutoDisconnectEnabled && this.config.isPresenceOnly) {
883
+ var _this3 = this;
884
+ var disconnectDelay = 60;
885
+ if (this.config.isPresenceOnly) {
888
886
  this.unbindVisibilityListener = bind(document, {
889
887
  type: 'visibilitychange',
890
888
  listener: function listener() {
@@ -16,7 +16,6 @@ import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../
16
16
  import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
17
17
  import { INTERNAL_ERROR_CODE } from '../errors/internal-errors';
18
18
  import { createLogger, getDocAdfWithObfuscationFromJSON, getObfuscatedSteps, getStepUGCFreeDetails, sleep } from '../helpers/utils';
19
- import { SINGLE_COLLAB_MODE } from '../participants/participants-service';
20
19
  import { MAX_STEP_REJECTED_ERROR, MAX_STEP_REJECTED_ERROR_AGGRESSIVE } from '../provider';
21
20
  import { CommitStepService } from '../provider/commit-step';
22
21
  import { CantSyncUpError, UpdateDocumentError } from '../errors/custom-errors';
@@ -71,7 +70,6 @@ export var DocumentService = /*#__PURE__*/function () {
71
70
  _defineProperty(this, "aggressiveCatchup", false);
72
71
  _defineProperty(this, "catchUpOutofSync", false);
73
72
  _defineProperty(this, "hasRecovered", false);
74
- _defineProperty(this, "numberOfStepCommitsSent", 0);
75
73
  _defineProperty(this, "timeoutExceeded", false);
76
74
  /**
77
75
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
@@ -84,16 +82,6 @@ export var DocumentService = /*#__PURE__*/function () {
84
82
  // TODO: ED-26957 - why shouldn't this be leading?
85
83
  trailing: true
86
84
  }));
87
- /**
88
- * Updates the number of commits sent since connect/reconnect
89
- * This is used to track the number of commits sent to the server.
90
- * currently we are validating the first steps from a user after connect/reconnect - CEPS-710
91
- * @param steps
92
- * @example
93
- */
94
- _defineProperty(this, "setNumberOfCommitsSent", function (steps) {
95
- _this.numberOfStepCommitsSent = steps;
96
- });
97
85
  /**
98
86
  * Called when:
99
87
  * * session established(offline -> online)
@@ -133,7 +121,7 @@ export var DocumentService = /*#__PURE__*/function () {
133
121
  analyticsHelper: _this.analyticsHelper,
134
122
  clientId: _this.clientId,
135
123
  onStepsAdded: _this.onStepsAdded,
136
- catchUpOutofSync: reason === CatchupEventReason.CORRUPT_STEP ? true : _this.catchUpOutofSync,
124
+ catchUpOutofSync: _this.catchUpOutofSync,
137
125
  reason: reason,
138
126
  sessionId: sessionId,
139
127
  onCatchupComplete: function onCatchupComplete(steps) {
@@ -1019,12 +1007,12 @@ export var DocumentService = /*#__PURE__*/function () {
1019
1007
  ) {
1020
1008
  var _this3 = this;
1021
1009
  var offlineEditingEnabled = editorExperiment('platform_editor_offline_editing_web', true);
1022
- var singlePlayerStepMergingEnabled = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
1010
+ var onlineStepMergingEnabled = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true);
1023
1011
 
1024
1012
  // Don't send any steps before we're ready.
1025
- if (offlineEditingEnabled || singlePlayerStepMergingEnabled) {
1026
- var enableStepsMergingForSinglePlayer = singlePlayerStepMergingEnabled && !this.commitStepService.getReadyToCommitStatus() && this.participantsService.getCollabMode() === SINGLE_COLLAB_MODE;
1027
- if (!this.getConnected() || enableStepsMergingForSinglePlayer) {
1013
+ if (offlineEditingEnabled || onlineStepMergingEnabled) {
1014
+ var enableOnlineStepMerging = onlineStepMergingEnabled && !this.commitStepService.getReadyToCommitStatus();
1015
+ if (!this.getConnected() || enableOnlineStepMerging) {
1028
1016
  return;
1029
1017
  }
1030
1018
  }
@@ -1033,7 +1021,7 @@ export var DocumentService = /*#__PURE__*/function () {
1033
1021
  if (!unconfirmedStepsData) {
1034
1022
  return;
1035
1023
  }
1036
- if (offlineEditingEnabled || singlePlayerStepMergingEnabled) {
1024
+ if (offlineEditingEnabled || onlineStepMergingEnabled) {
1037
1025
  this.lockStepOrigins(unconfirmedStepsData.origins);
1038
1026
  }
1039
1027
  var unconfirmedSteps = unconfirmedStepsData.steps;
@@ -1117,8 +1105,6 @@ export var DocumentService = /*#__PURE__*/function () {
1117
1105
  hasRecovered: this.hasRecovered,
1118
1106
  collabMode: this.participantsService.getCollabMode(),
1119
1107
  reason: reason,
1120
- numberOfStepCommitsSent: this.numberOfStepCommitsSent,
1121
- setNumberOfCommitsSent: this.setNumberOfCommitsSent,
1122
1108
  lockSteps: this.lockSteps
1123
1109
  });
1124
1110
  }
@@ -10,7 +10,6 @@ export var NullDocumentService = /*#__PURE__*/function () {
10
10
  return _this;
11
11
  });
12
12
  _defineProperty(this, "onErrorHandled", function () {});
13
- _defineProperty(this, "setNumberOfCommitsSent", function () {});
14
13
  }
15
14
  return _createClass(NullDocumentService, [{
16
15
  key: "updateDocument",
@@ -18,7 +18,6 @@ export var NCS_ERROR_CODE = /*#__PURE__*/function (NCS_ERROR_CODE) {
18
18
  NCS_ERROR_CODE["INVALID_CLOUD_ID"] = "INVALID_CLOUD_ID";
19
19
  NCS_ERROR_CODE["RATE_LIMIT_ERROR"] = "RATE_LIMIT_ERROR";
20
20
  NCS_ERROR_CODE["PROSEMIRROR_SCHEMA_VALIDATION_ERROR"] = "PROSEMIRROR_SCHEMA_VALIDATION_ERROR";
21
- NCS_ERROR_CODE["CORRUPT_STEP_FAILED_TO_SAVE"] = "CORRUPT_STEP_FAILED_TO_SAVE";
22
21
  return NCS_ERROR_CODE;
23
22
  }({});
24
23
 
@@ -69,6 +69,5 @@ export var CatchupEventReason = /*#__PURE__*/function (CatchupEventReason) {
69
69
  CatchupEventReason["STEPS_REJECTED"] = "onStepsRejected";
70
70
  CatchupEventReason["PROCESS_STEPS"] = "processSteps";
71
71
  CatchupEventReason["RECONNECTED"] = "reconnected";
72
- CatchupEventReason["CORRUPT_STEP"] = "corruptStep";
73
72
  return CatchupEventReason;
74
73
  }({});
@@ -4,7 +4,6 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import countBy from 'lodash/countBy';
7
- import FeatureGates from '@atlaskit/feature-gate-js-client';
8
7
  import { ADD_STEPS_TYPE, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
9
8
  import { AcknowledgementResponseTypes } from '../types';
10
9
  import { NCS_ERROR_CODE } from '../errors/ncs-errors';
@@ -43,8 +42,6 @@ export var CommitStepService = /*#__PURE__*/function () {
43
42
  hasRecovered = _ref.hasRecovered,
44
43
  collabMode = _ref.collabMode,
45
44
  reason = _ref.reason,
46
- numberOfStepCommitsSent = _ref.numberOfStepCommitsSent,
47
- setNumberOfCommitsSent = _ref.setNumberOfCommitsSent,
48
45
  lockSteps = _ref.lockSteps;
49
46
  // this timer is for waiting to send the next batch in between acks from the BE
50
47
  var commitWaitTimer;
@@ -117,17 +114,11 @@ export var CommitStepService = /*#__PURE__*/function () {
117
114
  version: version
118
115
  });
119
116
  try {
120
- var _FeatureGates$getExpe;
121
- var n = (_FeatureGates$getExpe = FeatureGates.getExperimentValue('platform_editor_step_validation_on_connect', 'steps', 0)) !== null && _FeatureGates$getExpe !== void 0 ? _FeatureGates$getExpe : 0;
122
- var isExperimentEnabled = n > 0;
123
- // skip validation if FG is on and we have already sent n steps, or if FG is off
124
- var skipValidation = isExperimentEnabled ? numberOfStepCommitsSent >= n : true;
125
117
  this.broadcast('steps:commit', {
126
118
  collabMode: collabMode,
127
119
  steps: stepsWithClientAndUserId,
128
120
  version: version,
129
- userId: userId,
130
- skipValidation: skipValidation
121
+ userId: userId
131
122
  }, function (response) {
132
123
  _this.lastBroadcastRequestAcked = true;
133
124
  var latency = new Date().getTime() - start;
@@ -178,9 +169,6 @@ export var CommitStepService = /*#__PURE__*/function () {
178
169
  console.error(ADD_STEPS_ACKNOWLEDGEMENT_ERROR_MSG);
179
170
  }
180
171
  });
181
- if (isExperimentEnabled && numberOfStepCommitsSent < n) {
182
- setNumberOfCommitsSent(numberOfStepCommitsSent + 1);
183
- }
184
172
  } catch (error) {
185
173
  var _this$analyticsHelper2;
186
174
  // if the broadcast failed for any reason, we shouldn't keep the queue locked as the BE has not recieved any message