@atlaskit/collab-provider 9.17.4 → 9.18.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#57982](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/57982) [`858a68983294`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/858a68983294) - removing catchup logic for stale draft
8
+
9
+ ## 9.17.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#57454](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/57454) [`3f18e6719122`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f18e6719122) - Add provider error code logging
14
+
3
15
  ## 9.17.4
4
16
 
5
17
  ### Patch Changes
@@ -96,6 +96,20 @@ var AnalyticsHelper = exports.default = /*#__PURE__*/function () {
96
96
  };
97
97
  this.sendEvent(errorAnalyticsEvent);
98
98
  }
99
+ }, {
100
+ key: "sendProviderErrorEvent",
101
+ value: function sendProviderErrorEvent(error) {
102
+ var errorAnalyticsEvent = {
103
+ eventAction: _const.EVENT_ACTION.ERROR,
104
+ attributes: {
105
+ documentAri: this.documentAri,
106
+ errorMessage: 'Error emitted',
107
+ errorCode: error.code,
108
+ mappedError: error
109
+ }
110
+ };
111
+ this.sendEvent(errorAnalyticsEvent);
112
+ }
99
113
  }, {
100
114
  key: "sendActionEvent",
101
115
  value: function sendActionEvent(action, status, attributes // This breaks discriminated unions, because there is no obvious field to discriminate against any more
@@ -32,7 +32,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
32
32
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
33
  var logger = (0, _utils.createLogger)('Provider', 'black');
34
34
  var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
35
- var PRELOAD_DRAFT_SYNC_PERIOD = 15 * 1000; // 15 seconds
36
35
 
37
36
  var MAX_STEP_REJECTED_ERROR = exports.MAX_STEP_REJECTED_ERROR = 15;
38
37
  var MAX_STEP_REJECTED_ERROR_AGGRESSIVE = exports.MAX_STEP_REJECTED_ERROR_AGGRESSIVE = 2;
@@ -108,22 +107,15 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
108
107
 
109
108
  // Early initialization with initial draft passed via provider
110
109
  if (_this.initialDraft && initialized && !_this.isProviderInitialized) {
111
- // Call catchup if the draft has become stale since being passed to provider
112
- if (_this.isDraftTimestampStale()) {
113
- _this.documentService.throttledCatchup();
114
- }
115
- // If the initial draft is already up to date, update the document with that of the initial draft
116
- else {
117
- var _this$initialDraft = _this.initialDraft,
118
- document = _this$initialDraft.document,
119
- version = _this$initialDraft.version,
120
- metadata = _this$initialDraft.metadata;
121
- _this.updateDocumentAndMetadata({
122
- doc: document,
123
- version: version,
124
- metadata: metadata
125
- });
126
- }
110
+ var _this$initialDraft = _this.initialDraft,
111
+ document = _this$initialDraft.document,
112
+ version = _this$initialDraft.version,
113
+ metadata = _this$initialDraft.metadata;
114
+ _this.updateDocumentAndMetadata({
115
+ doc: document,
116
+ version: version,
117
+ metadata: metadata
118
+ });
127
119
  }
128
120
  // If already initialized, `connected` means reconnected
129
121
  if (initialized && _this.disconnectedAt &&
@@ -173,10 +165,10 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
173
165
  var _this$analyticsHelper2;
174
166
  (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
175
167
  var mappedError = (0, _errorCodeMapper.errorCodeMapper)(error);
176
- // Temporarily only emit errors to Confluence very intentionally because they will disconnect the collab provider
168
+ // Only emit errors to Confluence very intentionally because they will disconnect the collab provider
177
169
  if (mappedError) {
178
170
  var _this$analyticsHelper3;
179
- (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendErrorEvent(mappedError, 'Error emitted');
171
+ (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendProviderErrorEvent(mappedError);
180
172
  _this.emit('error', mappedError);
181
173
  }
182
174
  }
@@ -362,21 +354,6 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
362
354
  }
363
355
  }
364
356
 
365
- /**
366
- * Checks the provider's initial draft timestamp to determine if it is stale.
367
- * Returns true only if the time elapsed since the draft timestamp is greater than or
368
- * equal to a predetermined timeout. Returns false in all other cases.
369
- */
370
- }, {
371
- key: "isDraftTimestampStale",
372
- value: function isDraftTimestampStale() {
373
- var _this$initialDraft3;
374
- if (!((_this$initialDraft3 = this.initialDraft) !== null && _this$initialDraft3 !== void 0 && _this$initialDraft3.timestamp)) {
375
- return false;
376
- }
377
- return Date.now() - this.initialDraft.timestamp >= PRELOAD_DRAFT_SYNC_PERIOD;
378
- }
379
-
380
357
  /**
381
358
  * Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
382
359
  * @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
@@ -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 = "9.17.4";
8
+ var version = exports.version = "9.18.0";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -81,6 +81,18 @@ export default class AnalyticsHelper {
81
81
  };
82
82
  this.sendEvent(errorAnalyticsEvent);
83
83
  }
84
+ sendProviderErrorEvent(error) {
85
+ const errorAnalyticsEvent = {
86
+ eventAction: EVENT_ACTION.ERROR,
87
+ attributes: {
88
+ documentAri: this.documentAri,
89
+ errorMessage: 'Error emitted',
90
+ errorCode: error.code,
91
+ mappedError: error
92
+ }
93
+ };
94
+ this.sendEvent(errorAnalyticsEvent);
95
+ }
84
96
  sendActionEvent(action, status, attributes // This breaks discriminated unions, because there is no obvious field to discriminate against any more
85
97
  ) {
86
98
  const analyticsEvent = {
@@ -14,7 +14,6 @@ import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
14
14
  import { getCollabProviderFeatureFlag } from '../feature-flags';
15
15
  const logger = createLogger('Provider', 'black');
16
16
  const OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
17
- const PRELOAD_DRAFT_SYNC_PERIOD = 15 * 1000; // 15 seconds
18
17
 
19
18
  export const MAX_STEP_REJECTED_ERROR = 15;
20
19
  export const MAX_STEP_REJECTED_ERROR_AGGRESSIVE = 2;
@@ -86,23 +85,16 @@ export class Provider extends Emitter {
86
85
 
87
86
  // Early initialization with initial draft passed via provider
88
87
  if (this.initialDraft && initialized && !this.isProviderInitialized) {
89
- // Call catchup if the draft has become stale since being passed to provider
90
- if (this.isDraftTimestampStale()) {
91
- this.documentService.throttledCatchup();
92
- }
93
- // If the initial draft is already up to date, update the document with that of the initial draft
94
- else {
95
- const {
96
- document,
97
- version,
98
- metadata
99
- } = this.initialDraft;
100
- this.updateDocumentAndMetadata({
101
- doc: document,
102
- version,
103
- metadata
104
- });
105
- }
88
+ const {
89
+ document,
90
+ version,
91
+ metadata
92
+ } = this.initialDraft;
93
+ this.updateDocumentAndMetadata({
94
+ doc: document,
95
+ version,
96
+ metadata
97
+ });
106
98
  }
107
99
  // If already initialized, `connected` means reconnected
108
100
  if (initialized && this.disconnectedAt &&
@@ -151,10 +143,10 @@ export class Provider extends Emitter {
151
143
  var _this$analyticsHelper2;
152
144
  (_this$analyticsHelper2 = this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
153
145
  const mappedError = errorCodeMapper(error);
154
- // Temporarily only emit errors to Confluence very intentionally because they will disconnect the collab provider
146
+ // Only emit errors to Confluence very intentionally because they will disconnect the collab provider
155
147
  if (mappedError) {
156
148
  var _this$analyticsHelper3;
157
- (_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(mappedError, 'Error emitted');
149
+ (_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendProviderErrorEvent(mappedError);
158
150
  this.emit('error', mappedError);
159
151
  }
160
152
  }
@@ -307,19 +299,6 @@ export class Provider extends Emitter {
307
299
  }
308
300
  }
309
301
 
310
- /**
311
- * Checks the provider's initial draft timestamp to determine if it is stale.
312
- * Returns true only if the time elapsed since the draft timestamp is greater than or
313
- * equal to a predetermined timeout. Returns false in all other cases.
314
- */
315
- isDraftTimestampStale() {
316
- var _this$initialDraft;
317
- if (!((_this$initialDraft = this.initialDraft) !== null && _this$initialDraft !== void 0 && _this$initialDraft.timestamp)) {
318
- return false;
319
- }
320
- return Date.now() - this.initialDraft.timestamp >= PRELOAD_DRAFT_SYNC_PERIOD;
321
- }
322
-
323
302
  /**
324
303
  * Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
325
304
  * @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.17.4";
2
+ export const version = "9.18.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -89,6 +89,20 @@ var AnalyticsHelper = /*#__PURE__*/function () {
89
89
  };
90
90
  this.sendEvent(errorAnalyticsEvent);
91
91
  }
92
+ }, {
93
+ key: "sendProviderErrorEvent",
94
+ value: function sendProviderErrorEvent(error) {
95
+ var errorAnalyticsEvent = {
96
+ eventAction: EVENT_ACTION.ERROR,
97
+ attributes: {
98
+ documentAri: this.documentAri,
99
+ errorMessage: 'Error emitted',
100
+ errorCode: error.code,
101
+ mappedError: error
102
+ }
103
+ };
104
+ this.sendEvent(errorAnalyticsEvent);
105
+ }
92
106
  }, {
93
107
  key: "sendActionEvent",
94
108
  value: function sendActionEvent(action, status, attributes // This breaks discriminated unions, because there is no obvious field to discriminate against any more
@@ -25,7 +25,6 @@ import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
25
25
  import { getCollabProviderFeatureFlag } from '../feature-flags';
26
26
  var logger = createLogger('Provider', 'black');
27
27
  var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
28
- var PRELOAD_DRAFT_SYNC_PERIOD = 15 * 1000; // 15 seconds
29
28
 
30
29
  export var MAX_STEP_REJECTED_ERROR = 15;
31
30
  export var MAX_STEP_REJECTED_ERROR_AGGRESSIVE = 2;
@@ -101,22 +100,15 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
101
100
 
102
101
  // Early initialization with initial draft passed via provider
103
102
  if (_this.initialDraft && initialized && !_this.isProviderInitialized) {
104
- // Call catchup if the draft has become stale since being passed to provider
105
- if (_this.isDraftTimestampStale()) {
106
- _this.documentService.throttledCatchup();
107
- }
108
- // If the initial draft is already up to date, update the document with that of the initial draft
109
- else {
110
- var _this$initialDraft = _this.initialDraft,
111
- document = _this$initialDraft.document,
112
- version = _this$initialDraft.version,
113
- metadata = _this$initialDraft.metadata;
114
- _this.updateDocumentAndMetadata({
115
- doc: document,
116
- version: version,
117
- metadata: metadata
118
- });
119
- }
103
+ var _this$initialDraft = _this.initialDraft,
104
+ document = _this$initialDraft.document,
105
+ version = _this$initialDraft.version,
106
+ metadata = _this$initialDraft.metadata;
107
+ _this.updateDocumentAndMetadata({
108
+ doc: document,
109
+ version: version,
110
+ metadata: metadata
111
+ });
120
112
  }
121
113
  // If already initialized, `connected` means reconnected
122
114
  if (initialized && _this.disconnectedAt &&
@@ -166,10 +158,10 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
166
158
  var _this$analyticsHelper2;
167
159
  (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
168
160
  var mappedError = errorCodeMapper(error);
169
- // Temporarily only emit errors to Confluence very intentionally because they will disconnect the collab provider
161
+ // Only emit errors to Confluence very intentionally because they will disconnect the collab provider
170
162
  if (mappedError) {
171
163
  var _this$analyticsHelper3;
172
- (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendErrorEvent(mappedError, 'Error emitted');
164
+ (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendProviderErrorEvent(mappedError);
173
165
  _this.emit('error', mappedError);
174
166
  }
175
167
  }
@@ -355,21 +347,6 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
355
347
  }
356
348
  }
357
349
 
358
- /**
359
- * Checks the provider's initial draft timestamp to determine if it is stale.
360
- * Returns true only if the time elapsed since the draft timestamp is greater than or
361
- * equal to a predetermined timeout. Returns false in all other cases.
362
- */
363
- }, {
364
- key: "isDraftTimestampStale",
365
- value: function isDraftTimestampStale() {
366
- var _this$initialDraft3;
367
- if (!((_this$initialDraft3 = this.initialDraft) !== null && _this$initialDraft3 !== void 0 && _this$initialDraft3.timestamp)) {
368
- return false;
369
- }
370
- return Date.now() - this.initialDraft.timestamp >= PRELOAD_DRAFT_SYNC_PERIOD;
371
- }
372
-
373
350
  /**
374
351
  * Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
375
352
  * @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "9.17.4";
2
+ export var version = "9.18.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,4 +1,5 @@
1
1
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
2
+ import type { ProviderError } from '@atlaskit/editor-common/collab';
2
3
  import type { ActionAnalyticsEvent, EVENT_STATUS } from '../helpers/const';
3
4
  export default class AnalyticsHelper {
4
5
  analyticsClient: AnalyticsWebClient | undefined;
@@ -6,6 +7,7 @@ export default class AnalyticsHelper {
6
7
  documentAri: string;
7
8
  constructor(documentAri: string, analyticsClient?: AnalyticsWebClient, getAnalyticsClient?: Promise<AnalyticsWebClient>);
8
9
  sendErrorEvent(error: unknown, errorMessage: string): void;
10
+ sendProviderErrorEvent(error: ProviderError): void;
9
11
  sendActionEvent(action: ActionAnalyticsEvent['eventAction'], status: EVENT_STATUS, attributes?: Omit<ActionAnalyticsEvent['attributes'], 'documentAri' | 'eventStatus'>): void;
10
12
  private sendEvent;
11
13
  }
@@ -52,7 +52,7 @@ export type ErrorAnalyticsEvent = {
52
52
  documentAri?: string;
53
53
  mappedError?: ProviderError;
54
54
  } & DocumentUpdateErrorAttributes;
55
- nonPrivacySafeAttributes: {
55
+ nonPrivacySafeAttributes?: {
56
56
  error: unknown;
57
57
  };
58
58
  };
@@ -63,12 +63,6 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
63
63
  onSyncUpError?: SyncUpErrorFunction;
64
64
  }): this;
65
65
  private checkForCookies;
66
- /**
67
- * Checks the provider's initial draft timestamp to determine if it is stale.
68
- * Returns true only if the time elapsed since the draft timestamp is greater than or
69
- * equal to a predetermined timeout. Returns false in all other cases.
70
- */
71
- private isDraftTimestampStale;
72
66
  /**
73
67
  * Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
74
68
  * @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
@@ -20,7 +20,6 @@ export interface InitialDraft {
20
20
  document: JSONDocNode;
21
21
  version: number;
22
22
  metadata?: Metadata;
23
- timestamp?: number;
24
23
  }
25
24
  export interface Config {
26
25
  url: string;
@@ -1,4 +1,5 @@
1
1
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
2
+ import type { ProviderError } from '@atlaskit/editor-common/collab';
2
3
  import type { ActionAnalyticsEvent, EVENT_STATUS } from '../helpers/const';
3
4
  export default class AnalyticsHelper {
4
5
  analyticsClient: AnalyticsWebClient | undefined;
@@ -6,6 +7,7 @@ export default class AnalyticsHelper {
6
7
  documentAri: string;
7
8
  constructor(documentAri: string, analyticsClient?: AnalyticsWebClient, getAnalyticsClient?: Promise<AnalyticsWebClient>);
8
9
  sendErrorEvent(error: unknown, errorMessage: string): void;
10
+ sendProviderErrorEvent(error: ProviderError): void;
9
11
  sendActionEvent(action: ActionAnalyticsEvent['eventAction'], status: EVENT_STATUS, attributes?: Omit<ActionAnalyticsEvent['attributes'], 'documentAri' | 'eventStatus'>): void;
10
12
  private sendEvent;
11
13
  }
@@ -52,7 +52,7 @@ export type ErrorAnalyticsEvent = {
52
52
  documentAri?: string;
53
53
  mappedError?: ProviderError;
54
54
  } & DocumentUpdateErrorAttributes;
55
- nonPrivacySafeAttributes: {
55
+ nonPrivacySafeAttributes?: {
56
56
  error: unknown;
57
57
  };
58
58
  };
@@ -63,12 +63,6 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
63
63
  onSyncUpError?: SyncUpErrorFunction;
64
64
  }): this;
65
65
  private checkForCookies;
66
- /**
67
- * Checks the provider's initial draft timestamp to determine if it is stale.
68
- * Returns true only if the time elapsed since the draft timestamp is greater than or
69
- * equal to a predetermined timeout. Returns false in all other cases.
70
- */
71
- private isDraftTimestampStale;
72
66
  /**
73
67
  * Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
74
68
  * @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
@@ -20,7 +20,6 @@ export interface InitialDraft {
20
20
  document: JSONDocNode;
21
21
  version: number;
22
22
  metadata?: Metadata;
23
- timestamp?: number;
24
23
  }
25
24
  export interface Config {
26
25
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.17.4",
3
+ "version": "9.18.0",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"