@atlaskit/collab-provider 7.4.4 → 7.6.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/config/package.json +8 -0
  3. package/dist/cjs/analytics/index.js +2 -1
  4. package/dist/cjs/analytics/performance.js +10 -0
  5. package/dist/cjs/channel.js +56 -47
  6. package/dist/cjs/config.js +12 -0
  7. package/dist/cjs/error-code-mapper.js +39 -31
  8. package/dist/cjs/helpers/const.js +11 -1
  9. package/dist/cjs/helpers/utils.js +18 -2
  10. package/dist/cjs/provider/index.js +55 -11
  11. package/dist/cjs/socket-io-provider.js +15 -3
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/es2019/analytics/index.js +2 -1
  14. package/dist/es2019/analytics/performance.js +9 -0
  15. package/dist/es2019/channel.js +26 -23
  16. package/dist/es2019/config.js +5 -0
  17. package/dist/es2019/error-code-mapper.js +34 -31
  18. package/dist/es2019/helpers/const.js +9 -0
  19. package/dist/es2019/helpers/utils.js +11 -1
  20. package/dist/es2019/provider/index.js +53 -10
  21. package/dist/es2019/socket-io-provider.js +13 -3
  22. package/dist/es2019/version.json +1 -1
  23. package/dist/esm/analytics/index.js +3 -2
  24. package/dist/esm/analytics/performance.js +9 -0
  25. package/dist/esm/channel.js +60 -50
  26. package/dist/esm/config.js +5 -0
  27. package/dist/esm/error-code-mapper.js +35 -31
  28. package/dist/esm/helpers/const.js +9 -0
  29. package/dist/esm/helpers/utils.js +11 -1
  30. package/dist/esm/provider/index.js +55 -12
  31. package/dist/esm/socket-io-provider.js +13 -3
  32. package/dist/esm/version.json +1 -1
  33. package/dist/types/analytics/performance.d.ts +8 -4
  34. package/dist/types/config.d.ts +5 -0
  35. package/dist/types/helpers/const.d.ts +10 -2
  36. package/dist/types/helpers/utils.d.ts +3 -0
  37. package/dist/types/socket-io-provider.d.ts +2 -2
  38. package/dist/types/types.d.ts +11 -2
  39. package/package.json +6 -5
  40. package/tsconfig.json +1 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 7.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5bd58e91664`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5bd58e91664) - [ESS-2513] Add tracking for number of participants in analytics
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 7.5.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
18
+ - Updated dependencies
19
+
20
+ ## 7.5.0
21
+
22
+ ### Minor Changes
23
+
24
+ - [`1c555e79e56`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1c555e79e56) - Added the capability to pass product information (product & sub-product) to the collab service
25
+ - [`247420a48f7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/247420a48f7) - [ESS-1050] Return ADF document from getFinalAcknowledgedState
26
+ - [`17f1b0b87cc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/17f1b0b87cc) - ESS-1019 changes the reconnectionDelayMax to 128s to reduce the reconnection storm.
27
+
28
+ ### Patch Changes
29
+
30
+ - [`bf848f39cb1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bf848f39cb1) - ESS-2419 Emit the reason of permission errors to the consumers of collab-provider
31
+ - [`680dc155ebc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/680dc155ebc) - Raise errors in the collab provider when the server fails loading initilisation data
32
+ - Updated dependencies
33
+
3
34
  ## 7.4.4
4
35
 
5
36
  ### Patch Changes
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@atlaskit/collab-provider/config",
3
+ "main": "../dist/cjs/config.js",
4
+ "module": "../dist/esm/config.js",
5
+ "module:es2019": "../dist/es2019/config.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/config.d.ts"
8
+ }
@@ -43,7 +43,8 @@ var triggerCollabAnalyticsEvent = function triggerCollabAnalyticsEvent(analytics
43
43
  actionSubject: _const.EVENT_SUBJECT,
44
44
  source: 'unknown',
45
45
  attributes: _objectSpread({
46
- packageName: _const.ATTRIBUTES_PACKAGE
46
+ packageName: _const.ATTRIBUTES_PACKAGE,
47
+ collabService: _const.COLLAB_SERVICE.NCS
47
48
  }, analyticsEvent.attributes)
48
49
  };
49
50
  fireAnalyticsEvent(analyticsClient, payload);
@@ -3,9 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.MEASURE_NAME = void 0;
6
7
  exports.clearMeasure = clearMeasure;
7
8
  exports.startMeasure = startMeasure;
8
9
  exports.stopMeasure = stopMeasure;
10
+ var MEASURE_NAME;
11
+ exports.MEASURE_NAME = MEASURE_NAME;
12
+
13
+ (function (MEASURE_NAME) {
14
+ MEASURE_NAME["CALLING_CATCHUP_API"] = "callingCatchupApi";
15
+ MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
16
+ MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
17
+ MEASURE_NAME["CONVERT_PM_TO_ADF"] = "convertPMToADF";
18
+ })(MEASURE_NAME || (exports.MEASURE_NAME = MEASURE_NAME = {}));
9
19
 
10
20
  var isPerformanceAPIAvailable = function isPerformanceAPIAvailable() {
11
21
  return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(function (api) {
@@ -74,12 +74,13 @@ var Channel = /*#__PURE__*/function (_Emitter) {
74
74
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onConnect", function () {
75
75
  _this.connected = true;
76
76
  logger('Connected.', _this.socket.id);
77
- var measure = (0, _performance.stopMeasure)('socketConnect');
77
+ var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.SOCKET_CONNECT);
78
78
  (0, _analytics.triggerCollabAnalyticsEvent)({
79
79
  eventAction: _const.EVENT_ACTION.CONNECTION,
80
80
  attributes: {
81
81
  eventStatus: _const.EVENT_STATUS.SUCCESS,
82
- latency: measure === null || measure === void 0 ? void 0 : measure.duration
82
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration,
83
+ documentAri: _this.config.documentAri
83
84
  }
84
85
  }, _this.analyticsClient);
85
86
 
@@ -94,13 +95,14 @@ var Channel = /*#__PURE__*/function (_Emitter) {
94
95
 
95
96
  if (data.type === 'initial') {
96
97
  if (!_this.initialized) {
97
- var measure = (0, _performance.stopMeasure)('documentInit');
98
+ var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.DOCUMENT_INIT);
98
99
  (0, _analytics.triggerCollabAnalyticsEvent)({
99
100
  eventAction: _const.EVENT_ACTION.DOCUMENT_INIT,
100
101
  attributes: {
101
102
  eventStatus: _const.EVENT_STATUS.SUCCESS,
102
103
  // TODO: detect when document init fails and fire corresponding event for it
103
- latency: measure === null || measure === void 0 ? void 0 : measure.duration
104
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration,
105
+ documentAri: _this.config.documentAri
104
106
  }
105
107
  }, _this.analyticsClient);
106
108
  var doc = data.doc,
@@ -139,10 +141,10 @@ var Channel = /*#__PURE__*/function (_Emitter) {
139
141
  function connect() {
140
142
  var _this2 = this;
141
143
 
142
- (0, _performance.startMeasure)('socketConnect');
144
+ (0, _performance.startMeasure)(_performance.MEASURE_NAME.SOCKET_CONNECT);
143
145
 
144
146
  if (!this.initialized) {
145
- (0, _performance.startMeasure)('documentInit');
147
+ (0, _performance.startMeasure)(_performance.MEASURE_NAME.DOCUMENT_INIT);
146
148
  }
147
149
 
148
150
  var _this$config = this.config,
@@ -150,9 +152,10 @@ var Channel = /*#__PURE__*/function (_Emitter) {
150
152
  url = _this$config.url;
151
153
  var createSocket = this.config.createSocket;
152
154
  var permissionTokenRefresh = this.config.permissionTokenRefresh;
155
+ var authCb = null;
153
156
 
154
157
  if (permissionTokenRefresh) {
155
- var authCb = function authCb(cb) {
158
+ authCb = function authCb(cb) {
156
159
  permissionTokenRefresh().then(function (token) {
157
160
  cb({
158
161
  // The permission token.
@@ -166,10 +169,8 @@ var Channel = /*#__PURE__*/function (_Emitter) {
166
169
  _this2.emit('error', err);
167
170
  });
168
171
  };
169
-
170
- this.socket = createSocket("".concat(url, "/session/").concat(documentAri), authCb);
171
172
  } else {
172
- var _authCb = function _authCb(cb) {
173
+ authCb = function authCb(cb) {
173
174
  cb({
174
175
  // The initialized status. If false, BE will send document, otherwise not.
175
176
  initialized: _this2.initialized,
@@ -177,13 +178,12 @@ var Channel = /*#__PURE__*/function (_Emitter) {
177
178
  need404: _this2.config.need404
178
179
  });
179
180
  };
181
+ }
180
182
 
181
- this.socket = createSocket("".concat(url, "/session/").concat(documentAri), _authCb);
182
- } // Due to https://github.com/socketio/socket.io-client/issues/1473,
183
+ this.socket = createSocket("".concat(url, "/session/").concat(documentAri), authCb, this.config.productInfo); // Due to https://github.com/socketio/socket.io-client/issues/1473,
183
184
  // reconnect no longer fired on the socket.
184
185
  // We should use `connect` for better cross platform compatibility(Mobile/Web).
185
186
 
186
-
187
187
  this.socket.on('connect', this.onConnect);
188
188
  this.socket.on('data', this.onReceiveData);
189
189
  this.socket.on('steps:added', function (data) {
@@ -253,13 +253,14 @@ var Channel = /*#__PURE__*/function (_Emitter) {
253
253
  // Ensure the error emit to the provider has the same structure, so we can handle them unified.
254
254
 
255
255
  this.socket.on('connect_error', function (error) {
256
- var measure = (0, _performance.stopMeasure)('socketConnect');
256
+ var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.SOCKET_CONNECT);
257
257
  (0, _analytics.triggerCollabAnalyticsEvent)({
258
258
  eventAction: _const.EVENT_ACTION.CONNECTION,
259
259
  attributes: {
260
260
  eventStatus: _const.EVENT_STATUS.FAILURE,
261
261
  error: error,
262
- latency: measure === null || measure === void 0 ? void 0 : measure.duration
262
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration,
263
+ documentAri: _this2.config.documentAri
263
264
  }
264
265
  }, _this2.analyticsClient); // If error received with `data`, it means the connection is rejected
265
266
  // by the server on purpose for example no permission, so no need to
@@ -291,46 +292,54 @@ var Channel = /*#__PURE__*/function (_Emitter) {
291
292
  _context2.prev = 0;
292
293
  _context2.t0 = _utilServiceSupport.utils;
293
294
  _context2.t1 = this.config;
294
- _context2.t2 = _objectSpread;
295
+ _context2.t2 = "document/".concat(encodeURIComponent(this.config.documentAri), "/catchup");
295
296
  _context2.t3 = {
296
- path: "document/".concat(encodeURIComponent(this.config.documentAri), "/catchup"),
297
- queryParams: {
298
- version: fromVersion
299
- }
297
+ version: fromVersion
300
298
  };
299
+ _context2.t4 = _objectSpread;
300
+ _context2.t5 = _objectSpread;
301
+ _context2.t6 = {};
301
302
 
302
303
  if (!this.config.permissionTokenRefresh) {
303
- _context2.next = 14;
304
+ _context2.next = 15;
304
305
  break;
305
306
  }
306
307
 
307
- _context2.next = 8;
308
+ _context2.next = 11;
308
309
  return this.config.permissionTokenRefresh();
309
310
 
310
- case 8:
311
- _context2.t5 = _context2.sent;
312
- _context2.t6 = {
313
- 'x-token': _context2.t5
314
- };
311
+ case 11:
312
+ _context2.t8 = _context2.sent;
315
313
  _context2.t7 = {
316
- headers: _context2.t6
317
- };
318
- _context2.t4 = {
319
- requestInit: _context2.t7
314
+ 'x-token': _context2.t8
320
315
  };
321
- _context2.next = 15;
316
+ _context2.next = 16;
322
317
  break;
323
318
 
324
- case 14:
325
- _context2.t4 = {};
326
-
327
319
  case 15:
328
- _context2.t8 = _context2.t4;
329
- _context2.t9 = (0, _context2.t2)(_context2.t3, _context2.t8);
330
- _context2.next = 19;
331
- return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t9);
320
+ _context2.t7 = {};
321
+
322
+ case 16:
323
+ _context2.t9 = _context2.t7;
324
+ _context2.t10 = (0, _context2.t5)(_context2.t6, _context2.t9);
325
+ _context2.t11 = {};
326
+ _context2.t12 = {
327
+ 'x-product': (0, _utils.getProduct)(this.config.productInfo),
328
+ 'x-subproduct': (0, _utils.getSubProduct)(this.config.productInfo)
329
+ };
330
+ _context2.t13 = (0, _context2.t4)(_context2.t10, _context2.t11, _context2.t12);
331
+ _context2.t14 = {
332
+ headers: _context2.t13
333
+ };
334
+ _context2.t15 = {
335
+ path: _context2.t2,
336
+ queryParams: _context2.t3,
337
+ requestInit: _context2.t14
338
+ };
339
+ _context2.next = 25;
340
+ return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t15);
332
341
 
333
- case 19:
342
+ case 25:
334
343
  _yield$utils$requestS = _context2.sent;
335
344
  doc = _yield$utils$requestS.doc;
336
345
  version = _yield$utils$requestS.version;
@@ -343,26 +352,26 @@ var Channel = /*#__PURE__*/function (_Emitter) {
343
352
  metadata: metadata
344
353
  });
345
354
 
346
- case 27:
347
- _context2.prev = 27;
348
- _context2.t10 = _context2["catch"](0);
349
- logger("Can't fetch the catchup", _context2.t10.message);
355
+ case 33:
356
+ _context2.prev = 33;
357
+ _context2.t16 = _context2["catch"](0);
358
+ logger("Can't fetch the catchup", _context2.t16.message);
350
359
  errorCatchup = {
351
360
  message: _errorCodeMapper.ErrorCodeMapper.catchupFail.message,
352
361
  data: {
353
- status: _context2.t10.status,
362
+ status: _context2.t16.status,
354
363
  code: _errorCodeMapper.ErrorCodeMapper.catchupFail.code
355
364
  }
356
365
  };
357
366
  this.emit('error', errorCatchup);
358
367
  return _context2.abrupt("return", {});
359
368
 
360
- case 33:
369
+ case 39:
361
370
  case "end":
362
371
  return _context2.stop();
363
372
  }
364
373
  }
365
- }, _callee2, this, [[0, 27]]);
374
+ }, _callee2, this, [[0, 33]]);
366
375
  }));
367
376
 
368
377
  function fetchCatchup(_x2) {
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SOCKET_IO_OPTIONS = void 0;
7
+ var SOCKET_IO_OPTIONS = {
8
+ RECONNECTION_DELAY_MAX: 128 * 1000,
9
+ RECONNECTION_DELAY: 1000,
10
+ RANDOMIZATION_FACTOR: 0.1
11
+ };
12
+ exports.SOCKET_IO_OPTIONS = SOCKET_IO_OPTIONS;
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.errorCodeMapper = exports.ErrorCodeMapper = void 0;
9
+
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
7
12
  var ErrorCodeMapper = {
8
13
  noPermissionError: {
9
14
  code: 'NO_PERMISSION_ERROR',
@@ -37,41 +42,44 @@ var ErrorCodeMapper = {
37
42
  exports.ErrorCodeMapper = ErrorCodeMapper;
38
43
 
39
44
  var errorCodeMapper = function errorCodeMapper(error) {
40
- if (error.data) {
41
- switch (error.data.code) {
42
- case 'INSUFFICIENT_EDITING_PERMISSION':
43
- return {
44
- status: 403,
45
- code: ErrorCodeMapper.noPermissionError.code,
46
- message: ErrorCodeMapper.noPermissionError.message
47
- };
45
+ var _error$data;
46
+
47
+ switch ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) {
48
+ case 'INSUFFICIENT_EDITING_PERMISSION':
49
+ return {
50
+ status: 403,
51
+ code: ErrorCodeMapper.noPermissionError.code,
52
+ message: ErrorCodeMapper.noPermissionError.message,
53
+ reason: // Typescript magic so it detects the union type
54
+ (0, _typeof2.default)(error.data.meta) === 'object' ? error.data.meta.reason : undefined
55
+ };
48
56
 
49
- case 'DOCUMENT_NOT_FOUND':
50
- return {
51
- status: 404,
52
- code: ErrorCodeMapper.documentNotFound.code,
53
- message: ErrorCodeMapper.documentNotFound.message
54
- };
57
+ case 'DOCUMENT_NOT_FOUND':
58
+ return {
59
+ status: 404,
60
+ code: ErrorCodeMapper.documentNotFound.code,
61
+ message: ErrorCodeMapper.documentNotFound.message
62
+ };
55
63
 
56
- case 'FAILED_ON_S3':
57
- case 'DYNAMO_ERROR':
58
- return {
59
- status: 500,
60
- code: ErrorCodeMapper.failToSave.code,
61
- message: ErrorCodeMapper.failToSave.message
62
- };
64
+ case 'FAILED_ON_S3':
65
+ case 'DYNAMO_ERROR':
66
+ return {
67
+ status: 500,
68
+ code: ErrorCodeMapper.failToSave.code,
69
+ message: ErrorCodeMapper.failToSave.message
70
+ };
63
71
 
64
- case 'CATCHUP_FAILED':
65
- case 'GET_QUERY_TIME_OUT':
66
- return {
67
- status: 500,
68
- code: ErrorCodeMapper.internalError.code,
69
- message: ErrorCodeMapper.internalError.message
70
- };
72
+ case 'CATCHUP_FAILED':
73
+ case 'GET_QUERY_TIME_OUT':
74
+ case 'INIT_DATA_LOAD_FAILED':
75
+ return {
76
+ status: 500,
77
+ code: ErrorCodeMapper.internalError.code,
78
+ message: ErrorCodeMapper.internalError.message
79
+ };
71
80
 
72
- default:
73
- break;
74
- }
81
+ default:
82
+ break;
75
83
  }
76
84
  };
77
85
 
@@ -3,11 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.ATTRIBUTES_PACKAGE = exports.ACK_MAX_TRY = void 0;
6
+ exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.COLLAB_SERVICE = exports.ATTRIBUTES_PACKAGE = exports.ACK_MAX_TRY = void 0;
7
7
  var ATTRIBUTES_PACKAGE = 'collabProvider';
8
8
  exports.ATTRIBUTES_PACKAGE = ATTRIBUTES_PACKAGE;
9
9
  var EVENT_SUBJECT = 'collab';
10
10
  exports.EVENT_SUBJECT = EVENT_SUBJECT;
11
+ var COLLAB_SERVICE;
12
+ exports.COLLAB_SERVICE = COLLAB_SERVICE;
13
+
14
+ (function (COLLAB_SERVICE) {
15
+ COLLAB_SERVICE["NCS"] = "ncs";
16
+ COLLAB_SERVICE["SYNCHRONY"] = "synchrony";
17
+ })(COLLAB_SERVICE || (exports.COLLAB_SERVICE = COLLAB_SERVICE = {}));
18
+
11
19
  var EVENT_ACTION;
12
20
  exports.EVENT_ACTION = EVENT_ACTION;
13
21
 
@@ -16,6 +24,8 @@ exports.EVENT_ACTION = EVENT_ACTION;
16
24
  EVENT_ACTION["CATCHUP"] = "catchup";
17
25
  EVENT_ACTION["DOCUMENT_INIT"] = "documentInit";
18
26
  EVENT_ACTION["ADD_STEPS"] = "addSteps";
27
+ EVENT_ACTION["CONVERT_PM_TO_ADF"] = "convertPMToADF";
28
+ EVENT_ACTION["UPDATE_PARTICIPANTS"] = "updateParticipants";
19
29
  })(EVENT_ACTION || (exports.EVENT_ACTION = EVENT_ACTION = {}));
20
30
 
21
31
  var EVENT_STATUS;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getParticipant = exports.createLogger = void 0;
6
+ exports.getSubProduct = exports.getProduct = exports.getParticipant = exports.createLogger = void 0;
7
7
  exports.sleep = sleep;
8
8
 
9
9
  var createLogger = function createLogger(prefix) {
@@ -37,4 +37,20 @@ function sleep(ms) {
37
37
  return new Promise(function (resolve) {
38
38
  setTimeout(resolve, ms);
39
39
  });
40
- }
40
+ }
41
+
42
+ var getProduct = function getProduct(productInfo) {
43
+ var _productInfo$product;
44
+
45
+ return (_productInfo$product = productInfo === null || productInfo === void 0 ? void 0 : productInfo.product) !== null && _productInfo$product !== void 0 ? _productInfo$product : 'unknown';
46
+ };
47
+
48
+ exports.getProduct = getProduct;
49
+
50
+ var getSubProduct = function getSubProduct(productInfo) {
51
+ var _productInfo$subProdu;
52
+
53
+ return (_productInfo$subProdu = productInfo === null || productInfo === void 0 ? void 0 : productInfo.subProduct) !== null && _productInfo$subProdu !== void 0 ? _productInfo$subProdu : !!(productInfo !== null && productInfo !== void 0 && productInfo.product) ? 'none' : 'unknown';
54
+ };
55
+
56
+ exports.getSubProduct = getSubProduct;
@@ -39,6 +39,8 @@ var _throttle = _interopRequireDefault(require("lodash/throttle"));
39
39
 
40
40
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
41
41
 
42
+ var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
43
+
42
44
  var _emitter = require("../emitter");
43
45
 
44
46
  var _channel = require("../channel");
@@ -232,7 +234,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
232
234
  while (1) {
233
235
  switch (_context.prev = _context.next) {
234
236
  case 0:
235
- (0, _performance.startMeasure)('callingCatchupApi'); // if the queue is already paused, we are busy with something else, so don't proceed.
237
+ (0, _performance.startMeasure)(_performance.MEASURE_NAME.CALLING_CATCHUP_API); // if the queue is already paused, we are busy with something else, so don't proceed.
236
238
 
237
239
  if (!_this.pauseQueue) {
238
240
  _context.next = 4;
@@ -256,12 +258,13 @@ var Provider = /*#__PURE__*/function (_Emitter) {
256
258
  });
257
259
 
258
260
  case 8:
259
- measure = (0, _performance.stopMeasure)('callingCatchupApi');
261
+ measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.CALLING_CATCHUP_API);
260
262
  (0, _analytics.triggerCollabAnalyticsEvent)({
261
263
  eventAction: _const.EVENT_ACTION.CATCHUP,
262
264
  attributes: {
263
265
  eventStatus: _const.EVENT_STATUS.SUCCESS,
264
- latency: measure === null || measure === void 0 ? void 0 : measure.duration
266
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration,
267
+ documentAri: _this.config.documentAri
265
268
  }
266
269
  }, _this.analyticsClient);
267
270
  _context.next = 17;
@@ -270,13 +273,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
270
273
  case 12:
271
274
  _context.prev = 12;
272
275
  _context.t0 = _context["catch"](5);
273
- _measure = (0, _performance.stopMeasure)('callingCatchupApi');
276
+ _measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.CALLING_CATCHUP_API);
274
277
  (0, _analytics.triggerCollabAnalyticsEvent)({
275
278
  eventAction: _const.EVENT_ACTION.CATCHUP,
276
279
  attributes: {
277
280
  eventStatus: _const.EVENT_STATUS.FAILURE,
278
281
  error: _context.t0,
279
- latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
282
+ latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration,
283
+ documentAri: _this.config.documentAri
280
284
  }
281
285
  }, _this.analyticsClient);
282
286
  logger("Catch-Up Failed:", _context.t0.message);
@@ -306,7 +310,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
306
310
  eventAction: _const.EVENT_ACTION.ADD_STEPS,
307
311
  attributes: {
308
312
  eventStatus: _const.EVENT_STATUS.FAILURE,
309
- error: error
313
+ error: error,
314
+ documentAri: _this.config.documentAri
310
315
  }
311
316
  }, _this.analyticsClient);
312
317
  _this.stepRejectCounter++;
@@ -513,6 +518,16 @@ var Provider = /*#__PURE__*/function (_Emitter) {
513
518
  });
514
519
 
515
520
  if (joined.length || left.length) {
521
+ var _this$participants$si;
522
+
523
+ (0, _analytics.triggerCollabAnalyticsEvent)({
524
+ eventAction: _const.EVENT_ACTION.UPDATE_PARTICIPANTS,
525
+ attributes: {
526
+ participants: (_this$participants$si = _this.participants.size) !== null && _this$participants$si !== void 0 ? _this$participants$si : 1,
527
+ documentAri: _this.config.documentAri
528
+ }
529
+ }, _this.analyticsClient);
530
+
516
531
  _this.emit('presence', _objectSpread(_objectSpread({}, joined.length ? {
517
532
  joined: joined
518
533
  } : {}), left.length ? {
@@ -566,7 +581,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
566
581
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
567
582
  var _this$metadata$title;
568
583
 
569
- var maxAttemptsToSync, count, unconfirmedState, state;
584
+ var maxAttemptsToSync, count, unconfirmedState, state, adfDocument, measure, _measure2;
585
+
570
586
  return _regenerator.default.wrap(function _callee4$(_context4) {
571
587
  while (1) {
572
588
  switch (_context4.prev = _context4.next) {
@@ -650,14 +666,41 @@ var Provider = /*#__PURE__*/function (_Emitter) {
650
666
  })(), "t0", 5);
651
667
 
652
668
  case 5:
653
- state = _this.getState();
669
+ state = _this.getState(); // Convert ProseMirror document in Editor state to ADF document
670
+
671
+ try {
672
+ (0, _performance.startMeasure)(_performance.MEASURE_NAME.CONVERT_PM_TO_ADF);
673
+ adfDocument = new _editorJsonTransformer.JSONTransformer().encode(state.doc);
674
+ measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.CONVERT_PM_TO_ADF);
675
+ (0, _analytics.triggerCollabAnalyticsEvent)({
676
+ eventAction: _const.EVENT_ACTION.CONVERT_PM_TO_ADF,
677
+ attributes: {
678
+ eventStatus: _const.EVENT_STATUS.SUCCESS,
679
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration,
680
+ documentAri: _this.config.documentAri
681
+ }
682
+ }, _this.analyticsClient);
683
+ } catch (error) {
684
+ _measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.CONVERT_PM_TO_ADF);
685
+ (0, _analytics.triggerCollabAnalyticsEvent)({
686
+ eventAction: _const.EVENT_ACTION.CONVERT_PM_TO_ADF,
687
+ attributes: {
688
+ eventStatus: _const.EVENT_STATUS.FAILURE,
689
+ latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration,
690
+ error: error,
691
+ documentAri: _this.config.documentAri
692
+ }
693
+ }, _this.analyticsClient);
694
+ logger("Error when converting PM document to ADF: ", error);
695
+ }
696
+
654
697
  return _context4.abrupt("return", {
655
- content: state.doc.toJSON(),
698
+ content: adfDocument,
656
699
  title: (_this$metadata$title = _this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
657
700
  stepVersion: (0, _prosemirrorCollab.getVersion)(state)
658
701
  });
659
702
 
660
- case 7:
703
+ case 8:
661
704
  case "end":
662
705
  return _context4.stop();
663
706
  }
@@ -815,7 +858,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
815
858
  (0, _analytics.triggerCollabAnalyticsEvent)({
816
859
  eventAction: _const.EVENT_ACTION.ADD_STEPS,
817
860
  attributes: {
818
- eventStatus: _const.EVENT_STATUS.SUCCESS
861
+ eventStatus: _const.EVENT_STATUS.SUCCESS,
862
+ documentAri: this.config.documentAri
819
863
  }
820
864
  }, this.analyticsClient);
821
865
  this.emitTelepointersFromSteps(steps); // Resend local steps if none of the received steps originated with us!
@@ -14,19 +14,31 @@ var _provider = require("./provider");
14
14
 
15
15
  var _socket = require("socket.io-client");
16
16
 
17
+ var _utils = require("./helpers/utils");
18
+
19
+ var _config = require("./config");
20
+
17
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
22
 
19
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
24
 
21
- function createSocketIOSocket(url, auth) {
25
+ function createSocketIOSocket(url, auth, productInfo) {
22
26
  var _URL = new URL(url),
23
- pathname = _URL.pathname;
27
+ pathname = _URL.pathname; // to limit the reconnection flooding towards collab service, here we set the reconnectionDelayMax to 128s.
28
+
24
29
 
25
30
  return (0, _socket.io)(url, {
31
+ reconnectionDelayMax: _config.SOCKET_IO_OPTIONS.RECONNECTION_DELAY_MAX,
32
+ reconnectionDelay: _config.SOCKET_IO_OPTIONS.RECONNECTION_DELAY,
33
+ randomizationFactor: _config.SOCKET_IO_OPTIONS.RANDOMIZATION_FACTOR,
26
34
  withCredentials: true,
27
35
  transports: ['polling', 'websocket'],
28
36
  path: "/".concat(pathname.split('/')[1], "/socket.io"),
29
- auth: auth
37
+ auth: auth,
38
+ extraHeaders: {
39
+ 'x-product': (0, _utils.getProduct)(productInfo),
40
+ 'x-subproduct': (0, _utils.getSubProduct)(productInfo)
41
+ }
30
42
  });
31
43
  }
32
44
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.4.4",
3
+ "version": "7.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT } from '../helpers/const';
1
+ import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT, COLLAB_SERVICE } from '../helpers/const';
2
2
  export const fireAnalyticsEvent = (analyticsClient, payload) => {
3
3
  if (!analyticsClient || !payload) {
4
4
  return;
@@ -25,6 +25,7 @@ export const triggerCollabAnalyticsEvent = (analyticsEvent, analyticsClient) =>
25
25
  source: 'unknown',
26
26
  attributes: {
27
27
  packageName: ATTRIBUTES_PACKAGE,
28
+ collabService: COLLAB_SERVICE.NCS,
28
29
  ...analyticsEvent.attributes
29
30
  }
30
31
  };