@atlaskit/collab-provider 9.6.3 → 9.7.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.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3265cccb965`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3265cccb965) - resolving editor state before updating document/metadata during early provider initialization
8
+
9
+ ## 9.6.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`b7cd15f159b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b7cd15f159b) - ESS-3572 Fix getFinalAcknowledgedState and getCurrentState error handlers not catching errors. Add logs to track the title metadata property
14
+
3
15
  ## 9.6.3
4
16
 
5
17
  ### Patch Changes
@@ -144,19 +144,20 @@ var Channel = /*#__PURE__*/function (_Emitter) {
144
144
  logger('Session ID is', _this.socket.id);
145
145
  if (data.type === 'initial') {
146
146
  if (!_this.initialized) {
147
- var _this$initExperience, _this$analyticsHelper6;
147
+ var _this$initExperience, _this$analyticsHelper6, _data$metadata;
148
+ var doc = data.doc,
149
+ version = data.version,
150
+ userId = data.userId,
151
+ metadata = data.metadata;
148
152
  var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.DOCUMENT_INIT, _this.analyticsHelper);
149
153
  (_this$initExperience = _this.initExperience) === null || _this$initExperience === void 0 ? void 0 : _this$initExperience.success();
150
154
  (_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendActionEvent(_const.EVENT_ACTION.DOCUMENT_INIT,
151
155
  // TODO: detect when document init fails and fire corresponding event for it
152
156
  _const.EVENT_STATUS.SUCCESS, {
153
157
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
154
- resetReason: data === null || data === void 0 ? void 0 : data.resetReason
158
+ resetReason: data.resetReason,
159
+ hasTitle: !!((_data$metadata = data.metadata) !== null && _data$metadata !== void 0 && _data$metadata.title)
155
160
  });
156
- var doc = data.doc,
157
- version = data.version,
158
- userId = data.userId,
159
- metadata = data.metadata;
160
161
  _this.initialized = true;
161
162
  _this.emit('init', {
162
163
  doc: doc,
@@ -263,7 +263,8 @@ var DocumentService = /*#__PURE__*/function () {
263
263
  _this.applyLocalSteps(unconfirmedSteps);
264
264
  }
265
265
  (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
266
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
266
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
267
+ hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title)
267
268
  });
268
269
  } catch (restoreError) {
269
270
  var _this$analyticsHelper12, _this$analyticsHelper13;
@@ -53,24 +53,48 @@ var Provider = /*#__PURE__*/function (_Emitter) {
53
53
  * @param data - Event data to emit to subscribers
54
54
  */
55
55
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "emitCallback", function (evt, data) {
56
- // When the provider is initialized early, we want the editor state promise to resolve before emitting events
56
+ // When the provider is initialized early, we want to ensure the editor state exists after setup is called before emitting events
57
57
  // to ensure that it is ready to listen to the events fired by NCS
58
58
  if (_this.isPreinitializing) {
59
- _this.getStatePromise.then(function () {
59
+ _this.onSetupPromise.then(function () {
60
60
  return _this.emit(evt, data);
61
61
  });
62
62
  } else {
63
63
  _this.emit(evt, data);
64
64
  }
65
65
  });
66
+ /**
67
+ * Wrapper to update document and metadata.
68
+ * Catches and logs any errors thrown by document service's updateDocument and updateMetadata methods and destroys the provider in case of errors.
69
+ * Passing the document, metadata, version (either from the initial draft or from collab service)
70
+ */
71
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDocumentAndMetadata", function (_ref) {
72
+ var doc = _ref.doc,
73
+ version = _ref.version,
74
+ metadata = _ref.metadata;
75
+ try {
76
+ _this.documentService.updateDocument({
77
+ doc: doc,
78
+ version: version,
79
+ metadata: metadata
80
+ });
81
+ _this.metadataService.updateMetadata(metadata);
82
+ _this.isProviderInitialized = true;
83
+ } catch (e) {
84
+ var _this$analyticsHelper;
85
+ (_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendErrorEvent(e, 'Failed to update with the init document, destroying provider');
86
+ // Stop events and connections to step us trying to talk to the backend with an invalid state.
87
+ _this.destroy();
88
+ }
89
+ });
66
90
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initializeChannel", function () {
67
91
  _this.emit('connecting', {
68
92
  initial: true
69
93
  });
70
94
  var shouldInitialize = Boolean(_this.initialDraft) && !_this.isProviderInitialized;
71
- _this.channel.on('connected', function (_ref) {
72
- var sid = _ref.sid,
73
- initialized = _ref.initialized;
95
+ _this.channel.on('connected', function (_ref2) {
96
+ var sid = _ref2.sid,
97
+ initialized = _ref2.initialized;
74
98
  _this.sessionId = sid;
75
99
  _this.emitCallback('connected', {
76
100
  sid: sid,
@@ -89,22 +113,24 @@ var Provider = /*#__PURE__*/function (_Emitter) {
89
113
  document = _this$initialDraft.document,
90
114
  version = _this$initialDraft.version,
91
115
  metadata = _this$initialDraft.metadata;
92
- try {
93
- // Initial document, version, metadata from initial draft
94
- _this.documentService.updateDocument({
116
+ if (_this.isPreinitializing) {
117
+ // When the provider is initialized early, we wait until setup is called with a defined getState before the document is updated to ensure that the editor state exists
118
+ // The `isPreinitializing` check is an extra precaution behind a FF - if the state is already resolved, onSetupPromise will resolve immediately
119
+ _this.onSetupPromise.then(function () {
120
+ _this.updateDocumentAndMetadata({
121
+ doc: document,
122
+ version: version,
123
+ metadata: metadata
124
+ });
125
+ });
126
+ } else {
127
+ _this.updateDocumentAndMetadata({
95
128
  doc: document,
96
129
  version: version,
97
130
  metadata: metadata
98
131
  });
99
- } catch (e) {
100
- var _this$analyticsHelper;
101
- (_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendErrorEvent(e, 'Failed to update the document on reconnect, destroying provider');
102
- // Stop events and connections to step us trying to talk to the backend with an invalid state.
103
- _this.destroy();
104
132
  }
105
- _this.metadataService.updateMetadata(metadata);
106
133
  }
107
- _this.isProviderInitialized = true;
108
134
  }
109
135
  // If already initialized, `connected` means reconnected
110
136
  if (initialized && _this.disconnectedAt &&
@@ -114,25 +140,16 @@ var Provider = /*#__PURE__*/function (_Emitter) {
114
140
  }
115
141
  _this.participantsService.startInactiveRemover(_this.sessionId);
116
142
  _this.disconnectedAt = undefined;
117
- }).on('init', function (_ref2) {
118
- var doc = _ref2.doc,
119
- version = _ref2.version,
120
- metadata = _ref2.metadata;
143
+ }).on('init', function (_ref3) {
144
+ var doc = _ref3.doc,
145
+ version = _ref3.version,
146
+ metadata = _ref3.metadata;
121
147
  // Initial document and version
122
- try {
123
- _this.documentService.updateDocument({
124
- doc: doc,
125
- version: version,
126
- metadata: metadata
127
- });
128
- _this.metadataService.updateMetadata(metadata);
129
- _this.isProviderInitialized = true;
130
- } catch (e) {
131
- var _this$analyticsHelper2;
132
- (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendErrorEvent(e, 'Failed to update with the init document, destroying provider');
133
- // Stop events and connections to step us trying to talk to the backend with an invalid state.
134
- _this.destroy();
135
- }
148
+ _this.updateDocumentAndMetadata({
149
+ doc: doc,
150
+ version: version,
151
+ metadata: metadata
152
+ });
136
153
  }).on('restore', _this.documentService.onRestore).on('steps:added', _this.documentService.onStepsAdded).on('metadata:changed', _this.metadataService.onMetadataChanged).on('participant:telepointer', function (payload) {
137
154
  return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
138
155
  }).on('presence:joined', _this.participantsService.onPresenceJoined).on('presence', _this.participantsService.onPresence).on('participant:left', _this.participantsService.onParticipantLeft).on('participant:updated', _this.participantsService.onParticipantUpdated).on('disconnect', _this.onDisconnected.bind((0, _assertThisInitialized2.default)(_this))).on('error', _this.onErrorHandled).on('status', _this.namespaceService.onNamespaceStatusChanged).connect(shouldInitialize);
@@ -158,20 +175,20 @@ var Provider = /*#__PURE__*/function (_Emitter) {
158
175
  if (((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) === _errorTypes.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || ((_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.code) === _errorTypes.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS) {
159
176
  _this.documentService.onStepRejectedError();
160
177
  } else {
161
- var _this$analyticsHelper3;
162
- (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(error, 'Error handled');
178
+ var _this$analyticsHelper2;
179
+ (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
163
180
  var mappedError = (0, _errorCodeMapper.errorCodeMapper)(error);
164
181
  // Temporarily only emit errors to Confluence very intentionally because they will disconnect the collab provider
165
182
  if (mappedError) {
166
- var _this$analyticsHelper4;
167
- (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(mappedError, 'Error emitted');
183
+ var _this$analyticsHelper3;
184
+ (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(mappedError, 'Error emitted');
168
185
  _this.emitCallback('error', mappedError);
169
186
  }
170
187
  }
171
188
  });
172
189
  // Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
173
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (_ref3) {
174
- var reason = _ref3.reason;
190
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (_ref4) {
191
+ var reason = _ref4.reason;
175
192
  _this.disconnectedAt = Date.now();
176
193
  _this.participantsService.disconnect(reason, _this.sessionId);
177
194
  });
@@ -187,22 +204,25 @@ var Provider = /*#__PURE__*/function (_Emitter) {
187
204
  * @throws {GetCurrentStateError} Something went wrong while returning the current state
188
205
  */
189
206
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
190
- var _this$analyticsHelper5;
207
+ var _this$analyticsHelper4;
191
208
  return _regenerator.default.wrap(function _callee$(_context) {
192
209
  while (1) switch (_context.prev = _context.next) {
193
210
  case 0:
194
211
  _context.prev = 0;
195
- return _context.abrupt("return", _this.documentService.getCurrentState());
196
- case 4:
197
- _context.prev = 4;
212
+ _context.next = 3;
213
+ return _this.documentService.getCurrentState();
214
+ case 3:
215
+ return _context.abrupt("return", _context.sent);
216
+ case 6:
217
+ _context.prev = 6;
198
218
  _context.t0 = _context["catch"](0);
199
- (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(_context.t0, 'Error while returning ADF version of current draft document');
219
+ (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(_context.t0, 'Error while returning ADF version of current draft document');
200
220
  throw new _errorTypes.GetCurrentStateError('Error while returning the current state of the draft document', _context.t0);
201
- case 8:
221
+ case 10:
202
222
  case "end":
203
223
  return _context.stop();
204
224
  }
205
- }, _callee, null, [[0, 4]]);
225
+ }, _callee, null, [[0, 6]]);
206
226
  })));
207
227
  /**
208
228
  * Return the final acknowledged (by NCS) ADF version of the current draft document, together with it's title and the current step version.
@@ -210,7 +230,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
210
230
  * @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
211
231
  */
212
232
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
213
- var _this$analyticsHelper6;
233
+ var _this$analyticsHelper5;
214
234
  return _regenerator.default.wrap(function _callee2$(_context2) {
215
235
  while (1) switch (_context2.prev = _context2.next) {
216
236
  case 0:
@@ -222,7 +242,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
222
242
  case 6:
223
243
  _context2.prev = 6;
224
244
  _context2.t0 = _context2["catch"](0);
225
- (_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
245
+ (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
226
246
  throw new _errorTypes.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
227
247
  case 10:
228
248
  case "end":
@@ -258,8 +278,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
258
278
  _this.documentService = new _documentService.DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.emitCallback, _this.channel.broadcast, function () {
259
279
  return _this.userId;
260
280
  }, _this.onErrorHandled, _this.metadataService, _this.config.failedStepLimitBeforeCatchupOnPublish, _this.config.enableErrorOnFailedDocumentApply);
261
- _this.getStatePromise = new Promise(function (resolve) {
262
- _this.getStatePromiseResolve = resolve;
281
+ _this.onSetupPromise = new Promise(function (resolve) {
282
+ _this.resolveOnSetupPromise = resolve;
263
283
  });
264
284
  _this.namespaceService = new _namespaceService.NamespaceService();
265
285
  return _this;
@@ -293,21 +313,17 @@ var Provider = /*#__PURE__*/function (_Emitter) {
293
313
  */
294
314
  }, {
295
315
  key: "setup",
296
- value: function setup(_ref6) {
297
- var getState = _ref6.getState,
298
- onSyncUpError = _ref6.onSyncUpError;
316
+ value: function setup(_ref7) {
317
+ var getState = _ref7.getState,
318
+ onSyncUpError = _ref7.onSyncUpError;
299
319
  this.checkForCookies();
300
320
  try {
301
- // if setup is called with no state and the initial draft is already provided
321
+ // if setup is called with no getState and the initial draft is already provided
302
322
  // set a flag to mark early provider setup
303
323
  if (!getState && this.initialDraft) {
304
324
  this.isPreinitializing = true;
305
325
  }
306
326
  if (getState) {
307
- // if provider has already been initialized earlier, resolve the state once it is available
308
- if (this.isPreinitializing) {
309
- this.getStatePromiseResolve();
310
- }
311
327
  var collabPlugin = getState().plugins.find(function (p) {
312
328
  return p.key === 'collab$';
313
329
  });
@@ -320,14 +336,20 @@ var Provider = /*#__PURE__*/function (_Emitter) {
320
336
  onSyncUpError: onSyncUpError,
321
337
  clientId: this.clientId
322
338
  });
339
+
340
+ // if provider has already been initialized earlier, resolve the setup promise once setup has been called with
341
+ // a defined getState (ie editor state is ready) AND after documentService sets the editor state
342
+ if (this.isPreinitializing) {
343
+ this.resolveOnSetupPromise();
344
+ }
323
345
  }
324
346
  if (!this.isChannelInitialized) {
325
347
  this.initializeChannel();
326
348
  this.isChannelInitialized = true;
327
349
  }
328
350
  } catch (initError) {
329
- var _this$analyticsHelper7;
330
- (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(initError, 'Error while initialising the provider');
351
+ var _this$analyticsHelper6;
352
+ (_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendErrorEvent(initError, 'Error while initialising the provider');
331
353
  // Throw error so consumers are aware the initialisation failed when initialising themselves
332
354
  throw new _errorTypes.ProviderInitialisationError('Provider initialisation error', initError);
333
355
  }
@@ -337,9 +359,9 @@ var Provider = /*#__PURE__*/function (_Emitter) {
337
359
  key: "checkForCookies",
338
360
  value: function checkForCookies() {
339
361
  if (!global.navigator.cookieEnabled) {
340
- var _this$analyticsHelper8;
362
+ var _this$analyticsHelper7;
341
363
  var initError = new _errorTypes.ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
342
- (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
364
+ (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
343
365
  throw new _errorTypes.ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
344
366
  }
345
367
  }
@@ -377,8 +399,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
377
399
  }
378
400
  this.documentService.send(_tr, _oldState, newState);
379
401
  } catch (error) {
380
- var _this$analyticsHelper9;
381
- (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(error, 'Error while sending steps for a transaction');
402
+ var _this$analyticsHelper8;
403
+ (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(error, 'Error while sending steps for a transaction');
382
404
  throw new _errorTypes.SendTransactionError('Error while sending steps for a transaction', error);
383
405
  }
384
406
  }
@@ -406,9 +428,9 @@ var Provider = /*#__PURE__*/function (_Emitter) {
406
428
  this.channel.broadcast('participant:telepointer', payload, callback);
407
429
  }
408
430
  } catch (error) {
409
- var _this$analyticsHelper10;
431
+ var _this$analyticsHelper9;
410
432
  // We don't want to throw errors for Presence features as they tend to self-restore
411
- (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(error, 'Error while sending message - telepointer');
433
+ (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(error, 'Error while sending message - telepointer');
412
434
  }
413
435
  }
414
436
  }, {
@@ -447,8 +469,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
447
469
  (0, _get2.default)((0, _getPrototypeOf2.default)(Provider.prototype), "unsubscribeAll", this).call(this);
448
470
  this.channel.disconnect();
449
471
  } catch (error) {
450
- var _this$analyticsHelper11;
451
- (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(error, 'Error while shutting down the collab provider');
472
+ var _this$analyticsHelper10;
473
+ (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(error, 'Error while shutting down the collab provider');
452
474
  throw new _errorTypes.DestroyError('Error while shutting down the collab provider', error);
453
475
  }
454
476
  this.clearTimers();
@@ -468,8 +490,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
468
490
  try {
469
491
  this.metadataService.setTitle(title, broadcast);
470
492
  } catch (error) {
471
- var _this$analyticsHelper12;
472
- (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(error, 'Error while setting title');
493
+ var _this$analyticsHelper11;
494
+ (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(error, 'Error while setting title');
473
495
  throw new _errorTypes.SetTitleError('Error while setting title', error);
474
496
  }
475
497
  }
@@ -487,8 +509,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
487
509
  try {
488
510
  this.metadataService.setEditorWidth(editorWidth, broadcast);
489
511
  } catch (error) {
490
- var _this$analyticsHelper13;
491
- (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(error, 'Error while setting editor width');
512
+ var _this$analyticsHelper12;
513
+ (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(error, 'Error while setting editor width');
492
514
  throw new _errorTypes.SetEditorWidthError('Error while setting editor width', error);
493
515
  }
494
516
  }
@@ -504,8 +526,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
504
526
  try {
505
527
  this.metadataService.setMetadata(metadata);
506
528
  } catch (error) {
507
- var _this$analyticsHelper14;
508
- (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting metadata');
529
+ var _this$analyticsHelper13;
530
+ (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(error, 'Error while setting metadata');
509
531
  throw new _errorTypes.SetMetadataError('Error while setting metadata', error);
510
532
  }
511
533
  }
@@ -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.3";
9
+ var version = "9.7.0";
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.3",
3
+ "version": "9.7.0",
4
4
  "sideEffects": false
5
5
  }
@@ -112,21 +112,22 @@ export class Channel extends Emitter {
112
112
  logger('Session ID is', this.socket.id);
113
113
  if (data.type === 'initial') {
114
114
  if (!this.initialized) {
115
- var _this$initExperience, _this$analyticsHelper6;
115
+ var _this$initExperience, _this$analyticsHelper6, _data$metadata;
116
+ const {
117
+ doc,
118
+ version,
119
+ userId,
120
+ metadata
121
+ } = data;
116
122
  const measure = stopMeasure(MEASURE_NAME.DOCUMENT_INIT, this.analyticsHelper);
117
123
  (_this$initExperience = this.initExperience) === null || _this$initExperience === void 0 ? void 0 : _this$initExperience.success();
118
124
  (_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendActionEvent(EVENT_ACTION.DOCUMENT_INIT,
119
125
  // TODO: detect when document init fails and fire corresponding event for it
120
126
  EVENT_STATUS.SUCCESS, {
121
127
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
122
- resetReason: data === null || data === void 0 ? void 0 : data.resetReason
128
+ resetReason: data.resetReason,
129
+ hasTitle: !!((_data$metadata = data.metadata) !== null && _data$metadata !== void 0 && _data$metadata.title)
123
130
  });
124
- const {
125
- doc,
126
- version,
127
- userId,
128
- metadata
129
- } = data;
130
131
  this.initialized = true;
131
132
  this.emit('init', {
132
133
  doc,
@@ -220,7 +220,8 @@ export class DocumentService {
220
220
  this.applyLocalSteps(unconfirmedSteps);
221
221
  }
222
222
  (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
223
- numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
223
+ numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
224
+ hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title)
224
225
  });
225
226
  } catch (restoreError) {
226
227
  var _this$analyticsHelper12, _this$analyticsHelper13;