@atlaskit/collab-provider 7.7.0 → 8.0.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 (36) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/analytics/index.js +17 -27
  3. package/dist/cjs/analytics/performance.js +0 -2
  4. package/dist/cjs/channel.js +74 -35
  5. package/dist/cjs/helpers/const.js +10 -1
  6. package/dist/cjs/provider/catchup.js +2 -2
  7. package/dist/cjs/provider/index.js +174 -65
  8. package/dist/cjs/types.js +10 -1
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/analytics/index.js +15 -22
  12. package/dist/es2019/analytics/performance.js +0 -2
  13. package/dist/es2019/channel.js +28 -10
  14. package/dist/es2019/helpers/const.js +8 -0
  15. package/dist/es2019/provider/catchup.js +2 -2
  16. package/dist/es2019/provider/index.js +165 -65
  17. package/dist/es2019/types.js +7 -1
  18. package/dist/es2019/version-wrapper.js +1 -1
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/analytics/index.js +15 -22
  21. package/dist/esm/analytics/performance.js +0 -2
  22. package/dist/esm/channel.js +75 -36
  23. package/dist/esm/helpers/const.js +8 -0
  24. package/dist/esm/provider/catchup.js +2 -2
  25. package/dist/esm/provider/index.js +175 -69
  26. package/dist/esm/types.js +7 -1
  27. package/dist/esm/version-wrapper.js +1 -1
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/analytics/index.d.ts +1 -3
  30. package/dist/types/analytics/performance.d.ts +0 -2
  31. package/dist/types/channel.d.ts +2 -1
  32. package/dist/types/helpers/const.d.ts +30 -2
  33. package/dist/types/provider/index.d.ts +10 -6
  34. package/dist/types/types.d.ts +32 -12
  35. package/package.json +9 -6
  36. package/report.api.md +13 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 8.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`618b64f0d8c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/618b64f0d8c) - Introduce ufo and measure document init latency with histogram
8
+
9
+ ### Minor Changes
10
+
11
+ - [`83060253868`](https://bitbucket.org/atlassian/atlassian-frontend/commits/83060253868) - [ESS-2752] Introduced the capability to distinguish step commit failures due to errors and step rejections in collab provider analytics
12
+ - [`cc8b81f8fd8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cc8b81f8fd8) - Use socket.io acknowledgements to improve add-step performance tracking
13
+ - [`50d8749c3fa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/50d8749c3fa) - Track telepointer latency
14
+
15
+ ### Patch Changes
16
+
17
+ - [`0a482422f75`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0a482422f75) - Update add-steps analytic
18
+ - [`9f1f34a71ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9f1f34a71ea) - [ESS-3020] Turned all type dependencies in dev dependencies
19
+ - [`de027d19a65`](https://bitbucket.org/atlassian/atlassian-frontend/commits/de027d19a65) - Handle null for permission token refresh callback response
20
+ - [`62332c99254`](https://bitbucket.org/atlassian/atlassian-frontend/commits/62332c99254) - ESS-2964 - add numSteps and stepType to ADD-STEPS analytic events
21
+ - Updated dependencies
22
+
3
23
  ## 7.7.0
4
24
 
5
25
  ### Minor Changes
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.triggerCollabAnalyticsEvent = exports.fireAnalyticsEvent = void 0;
8
+ exports.triggerAnalyticsEvent = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
@@ -17,40 +17,30 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
17
17
 
18
18
  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; }
19
19
 
20
- var fireAnalyticsEvent = function fireAnalyticsEvent(analyticsClient, payload) {
21
- if (!analyticsClient || !payload) {
20
+ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analyticsClient) {
21
+ if (!analyticsClient) {
22
22
  return;
23
23
  }
24
24
 
25
- var client = analyticsClient;
26
- var requestIdleCallbackFunction = window.requestIdleCallback;
27
- var runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame; // Let the browser figure out
28
- // when it should send those events
29
-
30
- runItLater(function () {
31
- client.sendOperationalEvent(_objectSpread(_objectSpread({
32
- action: 'collab'
33
- }, payload), {}, {
34
- source: payload.source || 'unknown',
35
- tags: ['editor']
36
- }));
37
- });
38
- };
39
-
40
- exports.fireAnalyticsEvent = fireAnalyticsEvent;
41
-
42
- var triggerCollabAnalyticsEvent = function triggerCollabAnalyticsEvent(analyticsEvent, analyticsClient) {
43
25
  var payload = {
44
- action: analyticsEvent.eventAction,
45
26
  actionSubject: _const.EVENT_SUBJECT,
46
- source: 'unknown',
47
27
  attributes: _objectSpread({
48
28
  packageName: _versionWrapper.name,
49
29
  packageVersion: _versionWrapper.version,
50
30
  collabService: _const.COLLAB_SERVICE.NCS
51
- }, analyticsEvent.attributes)
52
- };
53
- fireAnalyticsEvent(analyticsClient, payload);
31
+ }, analyticsEvent.attributes),
32
+ tags: ['editor'],
33
+ action: analyticsEvent.eventAction,
34
+ source: 'unknown' // Adds zero analytics value, but event validation throws an error if you don't add it :-(
35
+
36
+ }; // Let the browser figure out
37
+ // when it should send those events
38
+
39
+ var requestIdleCallbackFunction = window.requestIdleCallback;
40
+ var runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame;
41
+ runItLater(function () {
42
+ analyticsClient.sendOperationalEvent(payload);
43
+ });
54
44
  };
55
45
 
56
- exports.triggerCollabAnalyticsEvent = triggerCollabAnalyticsEvent;
46
+ exports.triggerAnalyticsEvent = triggerAnalyticsEvent;
@@ -11,11 +11,9 @@ var MEASURE_NAME;
11
11
  exports.MEASURE_NAME = MEASURE_NAME;
12
12
 
13
13
  (function (MEASURE_NAME) {
14
- MEASURE_NAME["CALLING_CATCHUP_API"] = "callingCatchupApi";
15
14
  MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
16
15
  MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
17
16
  MEASURE_NAME["CONVERT_PM_TO_ADF"] = "convertPMToADF";
18
- MEASURE_NAME["ADD_STEPS"] = "addSteps";
19
17
  MEASURE_NAME["COMMIT_UNCONFIRMED_STEPS"] = "commitUnconfirmedSteps";
20
18
  })(MEASURE_NAME || (exports.MEASURE_NAME = MEASURE_NAME = {}));
21
19
 
@@ -39,6 +39,8 @@ var _analytics = require("./analytics");
39
39
 
40
40
  var _const = require("./helpers/const");
41
41
 
42
+ var _ufo = require("@atlaskit/ufo");
43
+
42
44
  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; }
43
45
 
44
46
  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; }
@@ -62,6 +64,15 @@ var Channel = /*#__PURE__*/function (_Emitter) {
62
64
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "connected", false);
63
65
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "socket", null);
64
66
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initialized", false);
67
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initExperience", new _ufo.UFOExperience('collab-provider.document-init', {
68
+ type: _ufo.ExperienceTypes.Load,
69
+ performanceType: _ufo.ExperiencePerformanceTypes.Custom,
70
+ performanceConfig: {
71
+ histogram: (0, _defineProperty2.default)({}, _ufo.ExperiencePerformanceTypes.Custom, {
72
+ duration: '250_500_1000_1500_2000_3000_4000'
73
+ })
74
+ }
75
+ }));
65
76
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getInitialized", function () {
66
77
  return _this.initialized;
67
78
  });
@@ -75,7 +86,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
75
86
  _this.connected = true;
76
87
  logger('Connected.', _this.socket.id);
77
88
  var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.SOCKET_CONNECT);
78
- (0, _analytics.triggerCollabAnalyticsEvent)({
89
+ (0, _analytics.triggerAnalyticsEvent)({
79
90
  eventAction: _const.EVENT_ACTION.CONNECTION,
80
91
  attributes: {
81
92
  eventStatus: _const.EVENT_STATUS.SUCCESS,
@@ -96,7 +107,10 @@ var Channel = /*#__PURE__*/function (_Emitter) {
96
107
  if (data.type === 'initial') {
97
108
  if (!_this.initialized) {
98
109
  var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.DOCUMENT_INIT);
99
- (0, _analytics.triggerCollabAnalyticsEvent)({
110
+
111
+ _this.initExperience.success();
112
+
113
+ (0, _analytics.triggerAnalyticsEvent)({
100
114
  eventAction: _const.EVENT_ACTION.DOCUMENT_INIT,
101
115
  attributes: {
102
116
  eventStatus: _const.EVENT_STATUS.SUCCESS,
@@ -158,6 +172,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
158
172
 
159
173
  if (!this.initialized) {
160
174
  (0, _performance.startMeasure)(_performance.MEASURE_NAME.DOCUMENT_INIT);
175
+ this.initExperience.start();
161
176
  }
162
177
 
163
178
  var _this$config = this.config,
@@ -170,14 +185,14 @@ var Channel = /*#__PURE__*/function (_Emitter) {
170
185
  if (permissionTokenRefresh) {
171
186
  authCb = function authCb(cb) {
172
187
  permissionTokenRefresh().then(function (token) {
173
- cb({
174
- // The permission token.
175
- token: token,
188
+ cb(_objectSpread(_objectSpread({}, token ? {
189
+ token: token
190
+ } : {}), {}, {
176
191
  // The initialized status. If false, BE will send document, otherwise not.
177
192
  initialized: _this2.initialized,
178
193
  // ESS-1009 Allow to opt-in into 404 response
179
194
  need404: _this2.config.need404
180
- });
195
+ }));
181
196
  }).catch(function (err) {
182
197
  _this2.emit('error', err);
183
198
  });
@@ -271,7 +286,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
271
286
 
272
287
  this.socket.on('connect_error', function (error) {
273
288
  var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.SOCKET_CONNECT);
274
- (0, _analytics.triggerCollabAnalyticsEvent)({
289
+ (0, _analytics.triggerAnalyticsEvent)({
275
290
  eventAction: _const.EVENT_ACTION.CONNECTION,
276
291
  attributes: {
277
292
  eventStatus: _const.EVENT_STATUS.FAILURE,
@@ -300,7 +315,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
300
315
  key: "fetchCatchup",
301
316
  value: function () {
302
317
  var _fetchCatchup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(fromVersion) {
303
- var _yield$utils$requestS, doc, version, stepMaps, metadata, errorCatchup;
318
+ var _yield$this$config$pe, _yield$utils$requestS, doc, version, stepMaps, metadata, errorCatchup;
304
319
 
305
320
  return _regenerator.default.wrap(function _callee2$(_context2) {
306
321
  while (1) {
@@ -318,7 +333,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
318
333
  _context2.t6 = {};
319
334
 
320
335
  if (!this.config.permissionTokenRefresh) {
321
- _context2.next = 15;
336
+ _context2.next = 24;
322
337
  break;
323
338
  }
324
339
 
@@ -326,37 +341,61 @@ var Channel = /*#__PURE__*/function (_Emitter) {
326
341
  return this.config.permissionTokenRefresh();
327
342
 
328
343
  case 11:
329
- _context2.t8 = _context2.sent;
344
+ _context2.t9 = _yield$this$config$pe = _context2.sent;
345
+ _context2.t8 = _context2.t9 !== null;
346
+
347
+ if (!_context2.t8) {
348
+ _context2.next = 15;
349
+ break;
350
+ }
351
+
352
+ _context2.t8 = _yield$this$config$pe !== void 0;
353
+
354
+ case 15:
355
+ if (!_context2.t8) {
356
+ _context2.next = 19;
357
+ break;
358
+ }
359
+
360
+ _context2.t10 = _yield$this$config$pe;
361
+ _context2.next = 20;
362
+ break;
363
+
364
+ case 19:
365
+ _context2.t10 = undefined;
366
+
367
+ case 20:
368
+ _context2.t11 = _context2.t10;
330
369
  _context2.t7 = {
331
- 'x-token': _context2.t8
370
+ 'x-token': _context2.t11
332
371
  };
333
- _context2.next = 16;
372
+ _context2.next = 25;
334
373
  break;
335
374
 
336
- case 15:
375
+ case 24:
337
376
  _context2.t7 = {};
338
377
 
339
- case 16:
340
- _context2.t9 = _context2.t7;
341
- _context2.t10 = (0, _context2.t5)(_context2.t6, _context2.t9);
342
- _context2.t11 = {};
343
- _context2.t12 = {
378
+ case 25:
379
+ _context2.t12 = _context2.t7;
380
+ _context2.t13 = (0, _context2.t5)(_context2.t6, _context2.t12);
381
+ _context2.t14 = {};
382
+ _context2.t15 = {
344
383
  'x-product': (0, _utils.getProduct)(this.config.productInfo),
345
384
  'x-subproduct': (0, _utils.getSubProduct)(this.config.productInfo)
346
385
  };
347
- _context2.t13 = (0, _context2.t4)(_context2.t10, _context2.t11, _context2.t12);
348
- _context2.t14 = {
349
- headers: _context2.t13
386
+ _context2.t16 = (0, _context2.t4)(_context2.t13, _context2.t14, _context2.t15);
387
+ _context2.t17 = {
388
+ headers: _context2.t16
350
389
  };
351
- _context2.t15 = {
390
+ _context2.t18 = {
352
391
  path: _context2.t2,
353
392
  queryParams: _context2.t3,
354
- requestInit: _context2.t14
393
+ requestInit: _context2.t17
355
394
  };
356
- _context2.next = 25;
357
- return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t15);
395
+ _context2.next = 34;
396
+ return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t18);
358
397
 
359
- case 25:
398
+ case 34:
360
399
  _yield$utils$requestS = _context2.sent;
361
400
  doc = _yield$utils$requestS.doc;
362
401
  version = _yield$utils$requestS.version;
@@ -369,26 +408,26 @@ var Channel = /*#__PURE__*/function (_Emitter) {
369
408
  metadata: metadata
370
409
  });
371
410
 
372
- case 33:
373
- _context2.prev = 33;
374
- _context2.t16 = _context2["catch"](0);
375
- logger("Can't fetch the catchup", _context2.t16.message);
411
+ case 42:
412
+ _context2.prev = 42;
413
+ _context2.t19 = _context2["catch"](0);
414
+ logger("Can't fetch the catchup", _context2.t19.message);
376
415
  errorCatchup = {
377
416
  message: _errorCodeMapper.ErrorCodeMapper.catchupFail.message,
378
417
  data: {
379
- status: _context2.t16.status,
418
+ status: _context2.t19.status,
380
419
  code: _errorCodeMapper.ErrorCodeMapper.catchupFail.code
381
420
  }
382
421
  };
383
422
  this.emit('error', errorCatchup);
384
423
  return _context2.abrupt("return", {});
385
424
 
386
- case 39:
425
+ case 48:
387
426
  case "end":
388
427
  return _context2.stop();
389
428
  }
390
429
  }
391
- }, _callee2, this, [[0, 33]]);
430
+ }, _callee2, this, [[0, 42]]);
392
431
  }));
393
432
 
394
433
  function fetchCatchup(_x2) {
@@ -403,14 +442,14 @@ var Channel = /*#__PURE__*/function (_Emitter) {
403
442
 
404
443
  }, {
405
444
  key: "broadcast",
406
- value: function broadcast(type, data) {
445
+ value: function broadcast(type, data, callback) {
407
446
  if (!this.connected || !this.socket) {
408
447
  return;
409
448
  }
410
449
 
411
450
  this.socket.emit('broadcast', _objectSpread({
412
451
  type: type
413
- }, data));
452
+ }, data), callback);
414
453
  }
415
454
  }, {
416
455
  key: "sendMetadata",
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.COLLAB_SERVICE = exports.ACK_MAX_TRY = void 0;
6
+ exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.COLLAB_SERVICE = exports.ADD_STEPS_TYPE = exports.ACK_MAX_TRY = void 0;
7
7
  var EVENT_SUBJECT = 'collab';
8
8
  exports.EVENT_SUBJECT = EVENT_SUBJECT;
9
9
  var COLLAB_SERVICE;
@@ -36,5 +36,14 @@ exports.EVENT_STATUS = EVENT_STATUS;
36
36
  EVENT_STATUS["FAILURE"] = "FAILURE";
37
37
  })(EVENT_STATUS || (exports.EVENT_STATUS = EVENT_STATUS = {}));
38
38
 
39
+ var ADD_STEPS_TYPE;
40
+ exports.ADD_STEPS_TYPE = ADD_STEPS_TYPE;
41
+
42
+ (function (ADD_STEPS_TYPE) {
43
+ ADD_STEPS_TYPE["ACCEPTED"] = "ACCEPTED";
44
+ ADD_STEPS_TYPE["REJECTED"] = "REJECTED";
45
+ ADD_STEPS_TYPE["ERROR"] = "ERROR";
46
+ })(ADD_STEPS_TYPE || (exports.ADD_STEPS_TYPE = ADD_STEPS_TYPE = {}));
47
+
39
48
  var ACK_MAX_TRY = 30;
40
49
  exports.ACK_MAX_TRY = ACK_MAX_TRY;
@@ -91,7 +91,7 @@ var catchup = /*#__PURE__*/function () {
91
91
  * newer.
92
92
  */
93
93
 
94
- opt.fitlerQueue(function (data) {
94
+ opt.filterQueue(function (data) {
95
95
  return data.version > serverVersion;
96
96
  }); // We are too far behind - replace the entire document
97
97
 
@@ -126,7 +126,7 @@ var catchup = /*#__PURE__*/function () {
126
126
  newUnconfirmedSteps = rebaseSteps(unconfirmedSteps, mapping);
127
127
  logger("Re-aply ".concat(newUnconfirmedSteps.length, " mapped unconfirmed steps: ").concat(JSON.stringify(newUnconfirmedSteps))); // Re-aply local steps
128
128
 
129
- opt.applyLocalsteps(newUnconfirmedSteps);
129
+ opt.applyLocalSteps(newUnconfirmedSteps);
130
130
  }
131
131
  }
132
132
  }