@atlaskit/collab-provider 7.4.1 → 7.4.4

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,23 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 7.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 7.4.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`ec2f2d0b804`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ec2f2d0b804) - ED-14734: Add analytics to track time to connect to collab service, as well as tracking document initial load time.
14
+
15
+ ## 7.4.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 7.4.1
4
22
 
5
23
  ### Patch 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.triggerAnalyticsForStepsRejected = exports.triggerAnalyticsForStepsAddedSuccessfully = exports.triggerAnalyticsForCatchupSuccessfulWithLatency = exports.triggerAnalyticsForCatchupFailed = exports.fireAnalyticsEvent = exports.buildAnalyticsPayload = void 0;
8
+ exports.triggerCollabAnalyticsEvent = exports.fireAnalyticsEvent = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
@@ -15,22 +15,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
15
15
 
16
16
  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; }
17
17
 
18
- var buildAnalyticsPayload = function buildAnalyticsPayload(subject, payload) {
19
- return {
20
- action: 'collab',
21
- actionSubject: subject,
22
- source: 'unknown',
23
- attributes: {
24
- packageName: _const.ATTRIBUTES_PACKAGE,
25
- payload: payload
26
- }
27
- };
28
- };
29
-
30
- exports.buildAnalyticsPayload = buildAnalyticsPayload;
31
-
32
- var fireAnalyticsEvent = function fireAnalyticsEvent(analyticsClient, analyticsEvent) {
33
- if (!analyticsClient || !analyticsEvent) {
18
+ var fireAnalyticsEvent = function fireAnalyticsEvent(analyticsClient, payload) {
19
+ if (!analyticsClient || !payload) {
34
20
  return;
35
21
  }
36
22
 
@@ -42,38 +28,25 @@ var fireAnalyticsEvent = function fireAnalyticsEvent(analyticsClient, analyticsE
42
28
  runItLater(function () {
43
29
  client.sendOperationalEvent(_objectSpread(_objectSpread({
44
30
  action: 'collab'
45
- }, analyticsEvent), {}, {
46
- source: analyticsEvent.source || 'unknown'
31
+ }, payload), {}, {
32
+ source: payload.source || 'unknown',
33
+ tags: ['editor']
47
34
  }));
48
35
  });
49
36
  };
50
37
 
51
38
  exports.fireAnalyticsEvent = fireAnalyticsEvent;
52
39
 
53
- var triggerAnalyticsForStepsAddedSuccessfully = function triggerAnalyticsForStepsAddedSuccessfully(analyticsClient) {
54
- var stepAddedEvent = buildAnalyticsPayload(_const.STEPS_ADDED);
55
- fireAnalyticsEvent(analyticsClient, stepAddedEvent);
56
- };
57
-
58
- exports.triggerAnalyticsForStepsAddedSuccessfully = triggerAnalyticsForStepsAddedSuccessfully;
59
-
60
- var triggerAnalyticsForStepsRejected = function triggerAnalyticsForStepsRejected(analyticsClient, error) {
61
- var stepRejectedEvent = buildAnalyticsPayload(_const.STEPS_REJECTED, error);
62
- fireAnalyticsEvent(analyticsClient, stepRejectedEvent);
63
- };
64
-
65
- exports.triggerAnalyticsForStepsRejected = triggerAnalyticsForStepsRejected;
66
-
67
- var triggerAnalyticsForCatchupFailed = function triggerAnalyticsForCatchupFailed(analyticsClient, error) {
68
- var catchupFailedEvent = buildAnalyticsPayload(_const.CATCHUP_FAILURE, error);
69
- fireAnalyticsEvent(analyticsClient, catchupFailedEvent);
70
- };
71
-
72
- exports.triggerAnalyticsForCatchupFailed = triggerAnalyticsForCatchupFailed;
73
-
74
- var triggerAnalyticsForCatchupSuccessfulWithLatency = function triggerAnalyticsForCatchupSuccessfulWithLatency(analyticsClient, latency) {
75
- var callCatchupLatency = buildAnalyticsPayload(_const.CATCHUP_SUCCESS, latency);
76
- fireAnalyticsEvent(analyticsClient, callCatchupLatency);
40
+ var triggerCollabAnalyticsEvent = function triggerCollabAnalyticsEvent(analyticsEvent, analyticsClient) {
41
+ var payload = {
42
+ action: analyticsEvent.eventAction,
43
+ actionSubject: _const.EVENT_SUBJECT,
44
+ source: 'unknown',
45
+ attributes: _objectSpread({
46
+ packageName: _const.ATTRIBUTES_PACKAGE
47
+ }, analyticsEvent.attributes)
48
+ };
49
+ fireAnalyticsEvent(analyticsClient, payload);
77
50
  };
78
51
 
79
- exports.triggerAnalyticsForCatchupSuccessfulWithLatency = triggerAnalyticsForCatchupSuccessfulWithLatency;
52
+ exports.triggerCollabAnalyticsEvent = triggerCollabAnalyticsEvent;
@@ -40,19 +40,29 @@ function stopMeasure(measureName, onMeasureComplete) {
40
40
 
41
41
  try {
42
42
  performance.measure(measureName, "".concat(measureName, "::start"), "".concat(measureName, "::end"));
43
- } catch (error) {} finally {
44
- if (onMeasureComplete) {
45
- var entry = performance.getEntriesByName(measureName).pop();
46
-
47
- if (entry) {
48
- onMeasureComplete(entry.duration, entry.startTime);
49
- } else if (start) {
50
- onMeasureComplete(performance.now() - start, start);
51
- }
52
- }
53
-
54
- clearMeasure(measureName);
43
+ } catch (e) {}
44
+
45
+ var entry = performance.getEntriesByName(measureName).pop();
46
+ clearMeasure(measureName);
47
+ var measure;
48
+
49
+ if (entry) {
50
+ measure = {
51
+ duration: entry.duration,
52
+ startTime: entry.startTime
53
+ };
54
+ } else if (start) {
55
+ measure = {
56
+ duration: performance.now() - start,
57
+ startTime: start
58
+ };
55
59
  }
60
+
61
+ if (measure && onMeasureComplete) {
62
+ onMeasureComplete(measure.duration, measure.startTime);
63
+ }
64
+
65
+ return measure;
56
66
  }
57
67
 
58
68
  function clearMeasure(measureName) {
@@ -37,6 +37,8 @@ var _performance = require("./analytics/performance");
37
37
 
38
38
  var _analytics = require("./analytics");
39
39
 
40
+ var _const = require("./helpers/const");
41
+
40
42
  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; }
41
43
 
42
44
  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; }
@@ -72,6 +74,14 @@ var Channel = /*#__PURE__*/function (_Emitter) {
72
74
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onConnect", function () {
73
75
  _this.connected = true;
74
76
  logger('Connected.', _this.socket.id);
77
+ var measure = (0, _performance.stopMeasure)('socketConnect');
78
+ (0, _analytics.triggerCollabAnalyticsEvent)({
79
+ eventAction: _const.EVENT_ACTION.CONNECTION,
80
+ attributes: {
81
+ eventStatus: _const.EVENT_STATUS.SUCCESS,
82
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration
83
+ }
84
+ }, _this.analyticsClient);
75
85
 
76
86
  _this.emit('connected', {
77
87
  sid: _this.socket.id,
@@ -84,6 +94,15 @@ var Channel = /*#__PURE__*/function (_Emitter) {
84
94
 
85
95
  if (data.type === 'initial') {
86
96
  if (!_this.initialized) {
97
+ var measure = (0, _performance.stopMeasure)('documentInit');
98
+ (0, _analytics.triggerCollabAnalyticsEvent)({
99
+ eventAction: _const.EVENT_ACTION.DOCUMENT_INIT,
100
+ attributes: {
101
+ eventStatus: _const.EVENT_STATUS.SUCCESS,
102
+ // TODO: detect when document init fails and fire corresponding event for it
103
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration
104
+ }
105
+ }, _this.analyticsClient);
87
106
  var doc = data.doc,
88
107
  version = data.version,
89
108
  userId = data.userId,
@@ -120,6 +139,12 @@ var Channel = /*#__PURE__*/function (_Emitter) {
120
139
  function connect() {
121
140
  var _this2 = this;
122
141
 
142
+ (0, _performance.startMeasure)('socketConnect');
143
+
144
+ if (!this.initialized) {
145
+ (0, _performance.startMeasure)('documentInit');
146
+ }
147
+
123
148
  var _this$config = this.config,
124
149
  documentAri = _this$config.documentAri,
125
150
  url = _this$config.url;
@@ -228,10 +253,19 @@ var Channel = /*#__PURE__*/function (_Emitter) {
228
253
  // Ensure the error emit to the provider has the same structure, so we can handle them unified.
229
254
 
230
255
  this.socket.on('connect_error', function (error) {
231
- // If error received with `data`, it means the connection is rejected
256
+ var measure = (0, _performance.stopMeasure)('socketConnect');
257
+ (0, _analytics.triggerCollabAnalyticsEvent)({
258
+ eventAction: _const.EVENT_ACTION.CONNECTION,
259
+ attributes: {
260
+ eventStatus: _const.EVENT_STATUS.FAILURE,
261
+ error: error,
262
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration
263
+ }
264
+ }, _this2.analyticsClient); // If error received with `data`, it means the connection is rejected
232
265
  // by the server on purpose for example no permission, so no need to
233
266
  // keep the underneath connection, need to close. But some error like
234
267
  // `xhr polling error` needs to retry.
268
+
235
269
  if (!!error.data) {
236
270
  var _this2$socket;
237
271
 
@@ -248,8 +282,6 @@ var Channel = /*#__PURE__*/function (_Emitter) {
248
282
  key: "fetchCatchup",
249
283
  value: function () {
250
284
  var _fetchCatchup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(fromVersion) {
251
- var _this3 = this;
252
-
253
285
  var _yield$utils$requestS, doc, version, stepMaps, metadata, errorCatchup;
254
286
 
255
287
  return _regenerator.default.wrap(function _callee2$(_context2) {
@@ -257,7 +289,6 @@ var Channel = /*#__PURE__*/function (_Emitter) {
257
289
  switch (_context2.prev = _context2.next) {
258
290
  case 0:
259
291
  _context2.prev = 0;
260
- (0, _performance.startMeasure)('callingCatchupApi');
261
292
  _context2.t0 = _utilServiceSupport.utils;
262
293
  _context2.t1 = this.config;
263
294
  _context2.t2 = _objectSpread;
@@ -269,14 +300,14 @@ var Channel = /*#__PURE__*/function (_Emitter) {
269
300
  };
270
301
 
271
302
  if (!this.config.permissionTokenRefresh) {
272
- _context2.next = 15;
303
+ _context2.next = 14;
273
304
  break;
274
305
  }
275
306
 
276
- _context2.next = 9;
307
+ _context2.next = 8;
277
308
  return this.config.permissionTokenRefresh();
278
309
 
279
- case 9:
310
+ case 8:
280
311
  _context2.t5 = _context2.sent;
281
312
  _context2.t6 = {
282
313
  'x-token': _context2.t5
@@ -287,19 +318,19 @@ var Channel = /*#__PURE__*/function (_Emitter) {
287
318
  _context2.t4 = {
288
319
  requestInit: _context2.t7
289
320
  };
290
- _context2.next = 16;
321
+ _context2.next = 15;
291
322
  break;
292
323
 
293
- case 15:
324
+ case 14:
294
325
  _context2.t4 = {};
295
326
 
296
- case 16:
327
+ case 15:
297
328
  _context2.t8 = _context2.t4;
298
329
  _context2.t9 = (0, _context2.t2)(_context2.t3, _context2.t8);
299
- _context2.next = 20;
330
+ _context2.next = 19;
300
331
  return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t9);
301
332
 
302
- case 20:
333
+ case 19:
303
334
  _yield$utils$requestS = _context2.sent;
304
335
  doc = _yield$utils$requestS.doc;
305
336
  version = _yield$utils$requestS.version;
@@ -312,8 +343,8 @@ var Channel = /*#__PURE__*/function (_Emitter) {
312
343
  metadata: metadata
313
344
  });
314
345
 
315
- case 28:
316
- _context2.prev = 28;
346
+ case 27:
347
+ _context2.prev = 27;
317
348
  _context2.t10 = _context2["catch"](0);
318
349
  logger("Can't fetch the catchup", _context2.t10.message);
319
350
  errorCatchup = {
@@ -326,19 +357,12 @@ var Channel = /*#__PURE__*/function (_Emitter) {
326
357
  this.emit('error', errorCatchup);
327
358
  return _context2.abrupt("return", {});
328
359
 
329
- case 34:
330
- _context2.prev = 34;
331
- (0, _performance.stopMeasure)('callingCatchupApi', function (duration, _) {
332
- (0, _analytics.triggerAnalyticsForCatchupSuccessfulWithLatency)(_this3.analyticsClient, duration);
333
- });
334
- return _context2.finish(34);
335
-
336
- case 37:
360
+ case 33:
337
361
  case "end":
338
362
  return _context2.stop();
339
363
  }
340
364
  }
341
- }, _callee2, this, [[0, 28, 34, 37]]);
365
+ }, _callee2, this, [[0, 27]]);
342
366
  }));
343
367
 
344
368
  function fetchCatchup(_x2) {
@@ -3,16 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.STEPS_REJECTED = exports.STEPS_ADDED = exports.CATCHUP_SUCCESS = exports.CATCHUP_FAILURE = exports.ATTRIBUTES_PACKAGE = exports.ACK_MAX_TRY = void 0;
7
- var STEPS_ADDED = 'collabStepsAddedSuccess';
8
- exports.STEPS_ADDED = STEPS_ADDED;
9
- var STEPS_REJECTED = 'collabStepsAddedRejected';
10
- exports.STEPS_REJECTED = STEPS_REJECTED;
6
+ exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.ATTRIBUTES_PACKAGE = exports.ACK_MAX_TRY = void 0;
11
7
  var ATTRIBUTES_PACKAGE = 'collabProvider';
12
8
  exports.ATTRIBUTES_PACKAGE = ATTRIBUTES_PACKAGE;
13
- var CATCHUP_SUCCESS = 'collabCatchupSuccess';
14
- exports.CATCHUP_SUCCESS = CATCHUP_SUCCESS;
15
- var CATCHUP_FAILURE = 'collabCatchupFailure';
16
- exports.CATCHUP_FAILURE = CATCHUP_FAILURE;
9
+ var EVENT_SUBJECT = 'collab';
10
+ exports.EVENT_SUBJECT = EVENT_SUBJECT;
11
+ var EVENT_ACTION;
12
+ exports.EVENT_ACTION = EVENT_ACTION;
13
+
14
+ (function (EVENT_ACTION) {
15
+ EVENT_ACTION["CONNECTION"] = "connection";
16
+ EVENT_ACTION["CATCHUP"] = "catchup";
17
+ EVENT_ACTION["DOCUMENT_INIT"] = "documentInit";
18
+ EVENT_ACTION["ADD_STEPS"] = "addSteps";
19
+ })(EVENT_ACTION || (exports.EVENT_ACTION = EVENT_ACTION = {}));
20
+
21
+ var EVENT_STATUS;
22
+ exports.EVENT_STATUS = EVENT_STATUS;
23
+
24
+ (function (EVENT_STATUS) {
25
+ EVENT_STATUS["SUCCESS"] = "SUCCESS";
26
+ EVENT_STATUS["FAILURE"] = "FAILURE";
27
+ })(EVENT_STATUS || (exports.EVENT_STATUS = EVENT_STATUS = {}));
28
+
17
29
  var ACK_MAX_TRY = 10;
18
30
  exports.ACK_MAX_TRY = ACK_MAX_TRY;
@@ -11,10 +11,10 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
 
12
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
13
 
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
14
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
17
15
 
16
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
18
18
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
19
 
20
20
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -55,6 +55,8 @@ var _errorCodeMapper = require("../error-code-mapper");
55
55
 
56
56
  var _disconnectedReasonMapper = require("../disconnected-reason-mapper");
57
57
 
58
+ var _performance = require("../analytics/performance");
59
+
58
60
  var _excluded = ["type"];
59
61
 
60
62
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -224,22 +226,26 @@ var Provider = /*#__PURE__*/function (_Emitter) {
224
226
  return (0, _prosemirrorCollab.sendableSteps)(_this.getState());
225
227
  });
226
228
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "catchup", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
229
+ var measure, _measure;
230
+
227
231
  return _regenerator.default.wrap(function _callee$(_context) {
228
232
  while (1) {
229
233
  switch (_context.prev = _context.next) {
230
234
  case 0:
235
+ (0, _performance.startMeasure)('callingCatchupApi'); // if the queue is already paused, we are busy with something else, so don't proceed.
236
+
231
237
  if (!_this.pauseQueue) {
232
- _context.next = 3;
238
+ _context.next = 4;
233
239
  break;
234
240
  }
235
241
 
236
242
  logger("Queue is paused. Aborting.");
237
243
  return _context.abrupt("return");
238
244
 
239
- case 3:
245
+ case 4:
240
246
  _this.pauseQueue = true;
241
- _context.prev = 4;
242
- _context.next = 7;
247
+ _context.prev = 5;
248
+ _context.next = 8;
243
249
  return (0, _catchup.catchup)({
244
250
  getCurrentPmVersion: _this.getCurrentPmVersion,
245
251
  fetchCatchup: _this.channel.fetchCatchup.bind(_this.channel),
@@ -249,18 +255,34 @@ var Provider = /*#__PURE__*/function (_Emitter) {
249
255
  applyLocalsteps: _this.applyLocalsteps
250
256
  });
251
257
 
252
- case 7:
253
- _context.next = 13;
258
+ case 8:
259
+ measure = (0, _performance.stopMeasure)('callingCatchupApi');
260
+ (0, _analytics.triggerCollabAnalyticsEvent)({
261
+ eventAction: _const.EVENT_ACTION.CATCHUP,
262
+ attributes: {
263
+ eventStatus: _const.EVENT_STATUS.SUCCESS,
264
+ latency: measure === null || measure === void 0 ? void 0 : measure.duration
265
+ }
266
+ }, _this.analyticsClient);
267
+ _context.next = 17;
254
268
  break;
255
269
 
256
- case 9:
257
- _context.prev = 9;
258
- _context.t0 = _context["catch"](4);
259
- (0, _analytics.triggerAnalyticsForCatchupFailed)(_this.analyticsClient, _context.t0);
270
+ case 12:
271
+ _context.prev = 12;
272
+ _context.t0 = _context["catch"](5);
273
+ _measure = (0, _performance.stopMeasure)('callingCatchupApi');
274
+ (0, _analytics.triggerCollabAnalyticsEvent)({
275
+ eventAction: _const.EVENT_ACTION.CATCHUP,
276
+ attributes: {
277
+ eventStatus: _const.EVENT_STATUS.FAILURE,
278
+ error: _context.t0,
279
+ latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
280
+ }
281
+ }, _this.analyticsClient);
260
282
  logger("Catch-Up Failed:", _context.t0.message);
261
283
 
262
- case 13:
263
- _context.prev = 13;
284
+ case 17:
285
+ _context.prev = 17;
264
286
  _this.pauseQueue = false;
265
287
 
266
288
  _this.processQueue();
@@ -268,19 +290,25 @@ var Provider = /*#__PURE__*/function (_Emitter) {
268
290
  _this.sendStepsFromCurrentState();
269
291
 
270
292
  _this.stepRejectCounter = 0;
271
- return _context.finish(13);
293
+ return _context.finish(17);
272
294
 
273
- case 19:
295
+ case 23:
274
296
  case "end":
275
297
  return _context.stop();
276
298
  }
277
299
  }
278
- }, _callee, null, [[4, 9, 13, 19]]);
300
+ }, _callee, null, [[5, 12, 17, 23]]);
279
301
  })));
280
302
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onErrorHandled", function (error) {
281
303
  if (error && error.data) {
282
304
  if (error.data.code === 'HEAD_VERSION_UPDATE_FAILED' || error.data.code === 'VERSION_NUMBER_ALREADY_EXISTS') {
283
- (0, _analytics.triggerAnalyticsForStepsRejected)(_this.analyticsClient, error);
305
+ (0, _analytics.triggerCollabAnalyticsEvent)({
306
+ eventAction: _const.EVENT_ACTION.ADD_STEPS,
307
+ attributes: {
308
+ eventStatus: _const.EVENT_STATUS.FAILURE,
309
+ error: error
310
+ }
311
+ }, _this.analyticsClient);
284
312
  _this.stepRejectCounter++;
285
313
  }
286
314
 
@@ -784,7 +812,12 @@ var Provider = /*#__PURE__*/function (_Emitter) {
784
812
  }); // If steps can apply to local editor sucessfully, no need to accumulate the error counter.
785
813
 
786
814
  this.stepRejectCounter = 0;
787
- (0, _analytics.triggerAnalyticsForStepsAddedSuccessfully)(this.analyticsClient);
815
+ (0, _analytics.triggerCollabAnalyticsEvent)({
816
+ eventAction: _const.EVENT_ACTION.ADD_STEPS,
817
+ attributes: {
818
+ eventStatus: _const.EVENT_STATUS.SUCCESS
819
+ }
820
+ }, this.analyticsClient);
788
821
  this.emitTelepointersFromSteps(steps); // Resend local steps if none of the received steps originated with us!
789
822
 
790
823
  if (clientIds.indexOf(this.clientId) === -1) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.4.1",
3
+ "version": "7.4.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,17 +1,6 @@
1
- import { ATTRIBUTES_PACKAGE, CATCHUP_FAILURE, CATCHUP_SUCCESS, STEPS_ADDED, STEPS_REJECTED } from '../helpers/const';
2
- export const buildAnalyticsPayload = (subject, payload) => {
3
- return {
4
- action: 'collab',
5
- actionSubject: subject,
6
- source: 'unknown',
7
- attributes: {
8
- packageName: ATTRIBUTES_PACKAGE,
9
- payload
10
- }
11
- };
12
- };
13
- export const fireAnalyticsEvent = (analyticsClient, analyticsEvent) => {
14
- if (!analyticsClient || !analyticsEvent) {
1
+ import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT } from '../helpers/const';
2
+ export const fireAnalyticsEvent = (analyticsClient, payload) => {
3
+ if (!analyticsClient || !payload) {
15
4
  return;
16
5
  }
17
6
 
@@ -23,24 +12,21 @@ export const fireAnalyticsEvent = (analyticsClient, analyticsEvent) => {
23
12
  runItLater(() => {
24
13
  client.sendOperationalEvent({
25
14
  action: 'collab',
26
- ...analyticsEvent,
27
- source: analyticsEvent.source || 'unknown'
15
+ ...payload,
16
+ source: payload.source || 'unknown',
17
+ tags: ['editor']
28
18
  });
29
19
  });
30
20
  };
31
- export const triggerAnalyticsForStepsAddedSuccessfully = analyticsClient => {
32
- const stepAddedEvent = buildAnalyticsPayload(STEPS_ADDED);
33
- fireAnalyticsEvent(analyticsClient, stepAddedEvent);
34
- };
35
- export const triggerAnalyticsForStepsRejected = (analyticsClient, error) => {
36
- const stepRejectedEvent = buildAnalyticsPayload(STEPS_REJECTED, error);
37
- fireAnalyticsEvent(analyticsClient, stepRejectedEvent);
38
- };
39
- export const triggerAnalyticsForCatchupFailed = (analyticsClient, error) => {
40
- const catchupFailedEvent = buildAnalyticsPayload(CATCHUP_FAILURE, error);
41
- fireAnalyticsEvent(analyticsClient, catchupFailedEvent);
42
- };
43
- export const triggerAnalyticsForCatchupSuccessfulWithLatency = (analyticsClient, latency) => {
44
- const callCatchupLatency = buildAnalyticsPayload(CATCHUP_SUCCESS, latency);
45
- fireAnalyticsEvent(analyticsClient, callCatchupLatency);
21
+ export const triggerCollabAnalyticsEvent = (analyticsEvent, analyticsClient) => {
22
+ const payload = {
23
+ action: analyticsEvent.eventAction,
24
+ actionSubject: EVENT_SUBJECT,
25
+ source: 'unknown',
26
+ attributes: {
27
+ packageName: ATTRIBUTES_PACKAGE,
28
+ ...analyticsEvent.attributes
29
+ }
30
+ };
31
+ fireAnalyticsEvent(analyticsClient, payload);
46
32
  };
@@ -27,19 +27,29 @@ export function stopMeasure(measureName, onMeasureComplete) {
27
27
 
28
28
  try {
29
29
  performance.measure(measureName, `${measureName}::start`, `${measureName}::end`);
30
- } catch (error) {} finally {
31
- if (onMeasureComplete) {
32
- const entry = performance.getEntriesByName(measureName).pop();
33
-
34
- if (entry) {
35
- onMeasureComplete(entry.duration, entry.startTime);
36
- } else if (start) {
37
- onMeasureComplete(performance.now() - start, start);
38
- }
39
- }
40
-
41
- clearMeasure(measureName);
30
+ } catch (e) {}
31
+
32
+ const entry = performance.getEntriesByName(measureName).pop();
33
+ clearMeasure(measureName);
34
+ let measure;
35
+
36
+ if (entry) {
37
+ measure = {
38
+ duration: entry.duration,
39
+ startTime: entry.startTime
40
+ };
41
+ } else if (start) {
42
+ measure = {
43
+ duration: performance.now() - start,
44
+ startTime: start
45
+ };
42
46
  }
47
+
48
+ if (measure && onMeasureComplete) {
49
+ onMeasureComplete(measure.duration, measure.startTime);
50
+ }
51
+
52
+ return measure;
43
53
  }
44
54
  export function clearMeasure(measureName) {
45
55
  if (!hasPerformanceAPIAvailable) {