@atlaskit/collab-provider 9.2.0 → 9.2.2
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 +12 -0
- package/dist/cjs/document/document-service.js +27 -21
- package/dist/cjs/helpers/utils.js +28 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/document/document-service.js +17 -12
- package/dist/es2019/helpers/utils.js +25 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/document/document-service.js +28 -22
- package/dist/esm/helpers/utils.js +25 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/helpers/const.d.ts +2 -2
- package/dist/types/helpers/utils.d.ts +7 -0
- package/dist/types-ts4.5/helpers/const.d.ts +2 -2
- package/dist/types-ts4.5/helpers/utils.d.ts +7 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 9.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`11ac0368176`](https://bitbucket.org/atlassian/atlassian-frontend/commits/11ac0368176) - Dummy changeset to trigger release
|
|
8
|
+
|
|
9
|
+
## 9.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`65fafdf95fe`](https://bitbucket.org/atlassian/atlassian-frontend/commits/65fafdf95fe) - ESS-3666: add additional analytics events for when the cant sync up with collab service error occurs for better troubleshooting
|
|
14
|
+
|
|
3
15
|
## 9.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -334,14 +334,14 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
334
334
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
335
335
|
*/
|
|
336
336
|
(0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
337
|
-
var unconfirmedSteps, _this$
|
|
337
|
+
var unconfirmedSteps, _this$analyticsHelper18, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, _this$analyticsHelper17, state, unconfirmedStepsInfoUGCRemoved, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure3;
|
|
338
338
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
339
339
|
while (1) switch (_context4.prev = _context4.next) {
|
|
340
340
|
case 0:
|
|
341
341
|
unconfirmedSteps = _this.getUnconfirmedSteps();
|
|
342
342
|
_context4.prev = 1;
|
|
343
343
|
if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
|
|
344
|
-
_context4.next =
|
|
344
|
+
_context4.next = 23;
|
|
345
345
|
break;
|
|
346
346
|
}
|
|
347
347
|
(0, _performance.startMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
@@ -354,7 +354,7 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
354
354
|
isLastTrConfirmed = false;
|
|
355
355
|
case 8:
|
|
356
356
|
if (isLastTrConfirmed) {
|
|
357
|
-
_context4.next =
|
|
357
|
+
_context4.next = 21;
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
_this.sendStepsFromCurrentState();
|
|
@@ -371,7 +371,7 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
371
371
|
isLastTrConfirmed = true;
|
|
372
372
|
}
|
|
373
373
|
if (!(!isLastTrConfirmed && count++ >= _const.ACK_MAX_TRY)) {
|
|
374
|
-
_context4.next =
|
|
374
|
+
_context4.next = 19;
|
|
375
375
|
break;
|
|
376
376
|
}
|
|
377
377
|
if (_this.onSyncUpError) {
|
|
@@ -384,48 +384,54 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
384
384
|
version: (0, _prosemirrorCollab.getVersion)(state)
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
|
+
unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
|
|
388
|
+
return (0, _utils.getStepUGCFreeDetails)(step);
|
|
389
|
+
});
|
|
390
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent({
|
|
391
|
+
unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
|
|
392
|
+
}, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
|
|
387
393
|
throw new Error("Can't sync up with Collab Service");
|
|
388
|
-
case
|
|
394
|
+
case 19:
|
|
389
395
|
_context4.next = 8;
|
|
390
396
|
break;
|
|
391
|
-
case
|
|
397
|
+
case 21:
|
|
392
398
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
393
|
-
(_this$
|
|
399
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
|
|
394
400
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
395
401
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
396
402
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
397
403
|
});
|
|
398
|
-
case 21:
|
|
399
|
-
_context4.next = 29;
|
|
400
|
-
break;
|
|
401
404
|
case 23:
|
|
402
|
-
_context4.
|
|
405
|
+
_context4.next = 31;
|
|
406
|
+
break;
|
|
407
|
+
case 25:
|
|
408
|
+
_context4.prev = 25;
|
|
403
409
|
_context4.t0 = _context4["catch"](1);
|
|
404
410
|
_measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
405
|
-
(_this$
|
|
411
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
|
|
406
412
|
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
407
413
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
408
414
|
});
|
|
409
|
-
(_this$
|
|
415
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
|
|
410
416
|
throw _context4.t0;
|
|
411
|
-
case
|
|
417
|
+
case 31:
|
|
412
418
|
case "end":
|
|
413
419
|
return _context4.stop();
|
|
414
420
|
}
|
|
415
|
-
}, _callee4, null, [[1,
|
|
421
|
+
}, _callee4, null, [[1, 25]]);
|
|
416
422
|
})));
|
|
417
423
|
(0, _defineProperty2.default)(this, "onStepRejectedError", function () {
|
|
418
|
-
var _this$
|
|
424
|
+
var _this$analyticsHelper21;
|
|
419
425
|
_this.stepRejectCounter++;
|
|
420
426
|
logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
|
|
421
|
-
(_this$
|
|
427
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
|
|
422
428
|
count: _this.stepRejectCounter
|
|
423
429
|
});
|
|
424
430
|
var maxRetries = _this.aggressiveCatchup ? _this.failedStepsBeforeCatchupOnPublish : _provider.MAX_STEP_REJECTED_ERROR;
|
|
425
431
|
if (_this.stepRejectCounter >= maxRetries) {
|
|
426
|
-
var _this$
|
|
432
|
+
var _this$analyticsHelper22;
|
|
427
433
|
logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
|
|
428
|
-
(_this$
|
|
434
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
|
|
429
435
|
_this.throttledCatchup();
|
|
430
436
|
} else {
|
|
431
437
|
// If committing steps failed try again automatically in 1s
|
|
@@ -497,9 +503,9 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
497
503
|
}, 100);
|
|
498
504
|
}
|
|
499
505
|
} catch (error) {
|
|
500
|
-
var _this$
|
|
506
|
+
var _this$analyticsHelper23;
|
|
501
507
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
502
|
-
(_this$
|
|
508
|
+
(_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
|
|
503
509
|
this.throttledCatchup();
|
|
504
510
|
}
|
|
505
511
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getSubProduct = exports.getProduct = exports.createLogger = void 0;
|
|
6
|
+
exports.getSubProduct = exports.getStepUGCFreeDetails = exports.getProduct = exports.createLogger = void 0;
|
|
7
7
|
exports.sleep = sleep;
|
|
8
8
|
var createLogger = function createLogger(prefix) {
|
|
9
9
|
var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue';
|
|
@@ -30,4 +30,30 @@ var getSubProduct = function getSubProduct(productInfo) {
|
|
|
30
30
|
var _productInfo$subProdu;
|
|
31
31
|
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';
|
|
32
32
|
};
|
|
33
|
-
exports.getSubProduct = getSubProduct;
|
|
33
|
+
exports.getSubProduct = getSubProduct;
|
|
34
|
+
// Get as step info which is known not to contain user generated content.
|
|
35
|
+
var getStepUGCFreeDetails = function getStepUGCFreeDetails(step) {
|
|
36
|
+
var _stepJson$slice, _stepJson$slice2;
|
|
37
|
+
var stepJson;
|
|
38
|
+
try {
|
|
39
|
+
stepJson = step.toJSON();
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return {
|
|
42
|
+
type: 'unknown',
|
|
43
|
+
contentTypes: '',
|
|
44
|
+
stepSizeInBytes: Buffer.byteLength(JSON.stringify(step))
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var contentTypes = '';
|
|
48
|
+
if ((_stepJson$slice = stepJson.slice) !== null && _stepJson$slice !== void 0 && _stepJson$slice.content && Array.isArray((_stepJson$slice2 = stepJson.slice) === null || _stepJson$slice2 === void 0 ? void 0 : _stepJson$slice2.content)) {
|
|
49
|
+
contentTypes = stepJson.slice.content.map(function (c) {
|
|
50
|
+
return (c === null || c === void 0 ? void 0 : c.type) || 'unknown';
|
|
51
|
+
}).join(', ');
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
type: stepJson.stepType || 'unknown',
|
|
55
|
+
contentTypes: contentTypes,
|
|
56
|
+
stepSizeInBytes: Buffer.byteLength(JSON.stringify(step))
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.getStepUGCFreeDetails = getStepUGCFreeDetails;
|
|
@@ -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.2.
|
|
9
|
+
var version = "9.2.2";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
3
3
|
import { getVersion, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
4
|
-
import { createLogger, sleep } from '../helpers/utils';
|
|
4
|
+
import { createLogger, getStepUGCFreeDetails, sleep } from '../helpers/utils';
|
|
5
5
|
import throttle from 'lodash/throttle';
|
|
6
6
|
import { throttledCommitStep } from '../provider/commit-step';
|
|
7
7
|
import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
|
|
@@ -284,7 +284,7 @@ export class DocumentService {
|
|
|
284
284
|
const unconfirmedSteps = this.getUnconfirmedSteps();
|
|
285
285
|
try {
|
|
286
286
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
287
|
-
var _this$
|
|
287
|
+
var _this$analyticsHelper18;
|
|
288
288
|
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
289
289
|
let count = 0;
|
|
290
290
|
// We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
@@ -305,6 +305,7 @@ export class DocumentService {
|
|
|
305
305
|
isLastTrConfirmed = true;
|
|
306
306
|
}
|
|
307
307
|
if (!isLastTrConfirmed && count++ >= ACK_MAX_TRY) {
|
|
308
|
+
var _this$getUnconfirmedS, _this$analyticsHelper17;
|
|
308
309
|
if (this.onSyncUpError) {
|
|
309
310
|
const state = this.getState();
|
|
310
311
|
this.onSyncUpError({
|
|
@@ -315,39 +316,43 @@ export class DocumentService {
|
|
|
315
316
|
version: getVersion(state)
|
|
316
317
|
});
|
|
317
318
|
}
|
|
319
|
+
const unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(step => getStepUGCFreeDetails(step));
|
|
320
|
+
(_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent({
|
|
321
|
+
unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
|
|
322
|
+
}, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
|
|
318
323
|
throw new Error("Can't sync up with Collab Service");
|
|
319
324
|
}
|
|
320
325
|
}
|
|
321
326
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
322
|
-
(_this$
|
|
327
|
+
(_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
323
328
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
324
329
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
325
330
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
326
331
|
});
|
|
327
332
|
}
|
|
328
333
|
} catch (error) {
|
|
329
|
-
var _this$
|
|
334
|
+
var _this$analyticsHelper19, _this$analyticsHelper20;
|
|
330
335
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
331
|
-
(_this$
|
|
336
|
+
(_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
332
337
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
333
338
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
334
339
|
});
|
|
335
|
-
(_this$
|
|
340
|
+
(_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(error, 'Error while committing unconfirmed steps');
|
|
336
341
|
throw error;
|
|
337
342
|
}
|
|
338
343
|
});
|
|
339
344
|
_defineProperty(this, "onStepRejectedError", () => {
|
|
340
|
-
var _this$
|
|
345
|
+
var _this$analyticsHelper21;
|
|
341
346
|
this.stepRejectCounter++;
|
|
342
347
|
logger(`Steps rejected (tries=${this.stepRejectCounter})`);
|
|
343
|
-
(_this$
|
|
348
|
+
(_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
344
349
|
count: this.stepRejectCounter
|
|
345
350
|
});
|
|
346
351
|
let maxRetries = this.aggressiveCatchup ? this.failedStepsBeforeCatchupOnPublish : MAX_STEP_REJECTED_ERROR;
|
|
347
352
|
if (this.stepRejectCounter >= maxRetries) {
|
|
348
|
-
var _this$
|
|
353
|
+
var _this$analyticsHelper22;
|
|
349
354
|
logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
|
|
350
|
-
(_this$
|
|
355
|
+
(_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
351
356
|
this.throttledCatchup();
|
|
352
357
|
} else {
|
|
353
358
|
// If committing steps failed try again automatically in 1s
|
|
@@ -411,9 +416,9 @@ export class DocumentService {
|
|
|
411
416
|
setTimeout(() => this.sendStepsFromCurrentState(), 100);
|
|
412
417
|
}
|
|
413
418
|
} catch (error) {
|
|
414
|
-
var _this$
|
|
419
|
+
var _this$analyticsHelper23;
|
|
415
420
|
logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
|
|
416
|
-
(_this$
|
|
421
|
+
(_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
|
|
417
422
|
this.throttledCatchup();
|
|
418
423
|
}
|
|
419
424
|
}
|
|
@@ -16,4 +16,29 @@ export const getProduct = productInfo => {
|
|
|
16
16
|
export const getSubProduct = productInfo => {
|
|
17
17
|
var _productInfo$subProdu;
|
|
18
18
|
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';
|
|
19
|
+
};
|
|
20
|
+
// Get as step info which is known not to contain user generated content.
|
|
21
|
+
export const getStepUGCFreeDetails = step => {
|
|
22
|
+
var _stepJson$slice, _stepJson$slice2;
|
|
23
|
+
let stepJson;
|
|
24
|
+
try {
|
|
25
|
+
stepJson = step.toJSON();
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return {
|
|
28
|
+
type: 'unknown',
|
|
29
|
+
contentTypes: '',
|
|
30
|
+
stepSizeInBytes: Buffer.byteLength(JSON.stringify(step))
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
let contentTypes = '';
|
|
34
|
+
if ((_stepJson$slice = stepJson.slice) !== null && _stepJson$slice !== void 0 && _stepJson$slice.content && Array.isArray((_stepJson$slice2 = stepJson.slice) === null || _stepJson$slice2 === void 0 ? void 0 : _stepJson$slice2.content)) {
|
|
35
|
+
contentTypes = stepJson.slice.content.map(c => {
|
|
36
|
+
return (c === null || c === void 0 ? void 0 : c.type) || 'unknown';
|
|
37
|
+
}).join(', ');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
type: stepJson.stepType || 'unknown',
|
|
41
|
+
contentTypes,
|
|
42
|
+
stepSizeInBytes: Buffer.byteLength(JSON.stringify(step))
|
|
43
|
+
};
|
|
19
44
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
9
9
|
import { getVersion, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
10
|
-
import { createLogger, sleep } from '../helpers/utils';
|
|
10
|
+
import { createLogger, getStepUGCFreeDetails, sleep } from '../helpers/utils';
|
|
11
11
|
import throttle from 'lodash/throttle';
|
|
12
12
|
import { throttledCommitStep } from '../provider/commit-step';
|
|
13
13
|
import { MEASURE_NAME, startMeasure, stopMeasure } from '../analytics/performance';
|
|
@@ -327,14 +327,14 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
327
327
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
328
328
|
*/
|
|
329
329
|
_defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
330
|
-
var unconfirmedSteps, _this$
|
|
330
|
+
var unconfirmedSteps, _this$analyticsHelper18, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, _this$analyticsHelper17, state, unconfirmedStepsInfoUGCRemoved, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure3;
|
|
331
331
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
332
332
|
while (1) switch (_context4.prev = _context4.next) {
|
|
333
333
|
case 0:
|
|
334
334
|
unconfirmedSteps = _this.getUnconfirmedSteps();
|
|
335
335
|
_context4.prev = 1;
|
|
336
336
|
if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
|
|
337
|
-
_context4.next =
|
|
337
|
+
_context4.next = 23;
|
|
338
338
|
break;
|
|
339
339
|
}
|
|
340
340
|
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
@@ -347,7 +347,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
347
347
|
isLastTrConfirmed = false;
|
|
348
348
|
case 8:
|
|
349
349
|
if (isLastTrConfirmed) {
|
|
350
|
-
_context4.next =
|
|
350
|
+
_context4.next = 21;
|
|
351
351
|
break;
|
|
352
352
|
}
|
|
353
353
|
_this.sendStepsFromCurrentState();
|
|
@@ -364,7 +364,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
364
364
|
isLastTrConfirmed = true;
|
|
365
365
|
}
|
|
366
366
|
if (!(!isLastTrConfirmed && count++ >= ACK_MAX_TRY)) {
|
|
367
|
-
_context4.next =
|
|
367
|
+
_context4.next = 19;
|
|
368
368
|
break;
|
|
369
369
|
}
|
|
370
370
|
if (_this.onSyncUpError) {
|
|
@@ -377,48 +377,54 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
377
377
|
version: getVersion(state)
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
|
+
unconfirmedStepsInfoUGCRemoved = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.map(function (step) {
|
|
381
|
+
return getStepUGCFreeDetails(step);
|
|
382
|
+
});
|
|
383
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent({
|
|
384
|
+
unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved
|
|
385
|
+
}, "Can't sync up with Collab Service: unable to send unconfirmed steps and max retry reached");
|
|
380
386
|
throw new Error("Can't sync up with Collab Service");
|
|
381
|
-
case
|
|
387
|
+
case 19:
|
|
382
388
|
_context4.next = 8;
|
|
383
389
|
break;
|
|
384
|
-
case
|
|
390
|
+
case 21:
|
|
385
391
|
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
386
|
-
(_this$
|
|
392
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
387
393
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
388
394
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
389
395
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
390
396
|
});
|
|
391
|
-
case 21:
|
|
392
|
-
_context4.next = 29;
|
|
393
|
-
break;
|
|
394
397
|
case 23:
|
|
395
|
-
_context4.
|
|
398
|
+
_context4.next = 31;
|
|
399
|
+
break;
|
|
400
|
+
case 25:
|
|
401
|
+
_context4.prev = 25;
|
|
396
402
|
_context4.t0 = _context4["catch"](1);
|
|
397
403
|
_measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
398
|
-
(_this$
|
|
404
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
399
405
|
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
400
406
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
401
407
|
});
|
|
402
|
-
(_this$
|
|
408
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
|
|
403
409
|
throw _context4.t0;
|
|
404
|
-
case
|
|
410
|
+
case 31:
|
|
405
411
|
case "end":
|
|
406
412
|
return _context4.stop();
|
|
407
413
|
}
|
|
408
|
-
}, _callee4, null, [[1,
|
|
414
|
+
}, _callee4, null, [[1, 25]]);
|
|
409
415
|
})));
|
|
410
416
|
_defineProperty(this, "onStepRejectedError", function () {
|
|
411
|
-
var _this$
|
|
417
|
+
var _this$analyticsHelper21;
|
|
412
418
|
_this.stepRejectCounter++;
|
|
413
419
|
logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
|
|
414
|
-
(_this$
|
|
420
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
415
421
|
count: _this.stepRejectCounter
|
|
416
422
|
});
|
|
417
423
|
var maxRetries = _this.aggressiveCatchup ? _this.failedStepsBeforeCatchupOnPublish : MAX_STEP_REJECTED_ERROR;
|
|
418
424
|
if (_this.stepRejectCounter >= maxRetries) {
|
|
419
|
-
var _this$
|
|
425
|
+
var _this$analyticsHelper22;
|
|
420
426
|
logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
|
|
421
|
-
(_this$
|
|
427
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
422
428
|
_this.throttledCatchup();
|
|
423
429
|
} else {
|
|
424
430
|
// If committing steps failed try again automatically in 1s
|
|
@@ -490,9 +496,9 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
490
496
|
}, 100);
|
|
491
497
|
}
|
|
492
498
|
} catch (error) {
|
|
493
|
-
var _this$
|
|
499
|
+
var _this$analyticsHelper23;
|
|
494
500
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
495
|
-
(_this$
|
|
501
|
+
(_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while processing steps');
|
|
496
502
|
this.throttledCatchup();
|
|
497
503
|
}
|
|
498
504
|
}
|
|
@@ -20,4 +20,29 @@ export var getProduct = function getProduct(productInfo) {
|
|
|
20
20
|
export var getSubProduct = function getSubProduct(productInfo) {
|
|
21
21
|
var _productInfo$subProdu;
|
|
22
22
|
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';
|
|
23
|
+
};
|
|
24
|
+
// Get as step info which is known not to contain user generated content.
|
|
25
|
+
export var getStepUGCFreeDetails = function getStepUGCFreeDetails(step) {
|
|
26
|
+
var _stepJson$slice, _stepJson$slice2;
|
|
27
|
+
var stepJson;
|
|
28
|
+
try {
|
|
29
|
+
stepJson = step.toJSON();
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return {
|
|
32
|
+
type: 'unknown',
|
|
33
|
+
contentTypes: '',
|
|
34
|
+
stepSizeInBytes: Buffer.byteLength(JSON.stringify(step))
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var contentTypes = '';
|
|
38
|
+
if ((_stepJson$slice = stepJson.slice) !== null && _stepJson$slice !== void 0 && _stepJson$slice.content && Array.isArray((_stepJson$slice2 = stepJson.slice) === null || _stepJson$slice2 === void 0 ? void 0 : _stepJson$slice2.content)) {
|
|
39
|
+
contentTypes = stepJson.slice.content.map(function (c) {
|
|
40
|
+
return (c === null || c === void 0 ? void 0 : c.type) || 'unknown';
|
|
41
|
+
}).join(', ');
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
type: stepJson.stepType || 'unknown',
|
|
45
|
+
contentTypes: contentTypes,
|
|
46
|
+
stepSizeInBytes: Buffer.byteLength(JSON.stringify(step))
|
|
47
|
+
};
|
|
23
48
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -192,7 +192,7 @@ type SendStepsRetryAnalyticsEvent = {
|
|
|
192
192
|
eventAction: EVENT_ACTION.SEND_STEPS_RETRY;
|
|
193
193
|
attributes: {
|
|
194
194
|
documentAri: string;
|
|
195
|
-
eventStatus: EVENT_STATUS.
|
|
195
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
196
196
|
count: number;
|
|
197
197
|
};
|
|
198
198
|
};
|
|
@@ -200,7 +200,7 @@ type CatchupAfterMaxSendStepsRetryAnalyticsEvent = {
|
|
|
200
200
|
eventAction: EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY;
|
|
201
201
|
attributes: {
|
|
202
202
|
documentAri: string;
|
|
203
|
-
eventStatus: EVENT_STATUS.
|
|
203
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ProductInformation } from '../types';
|
|
2
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
3
|
export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
|
|
3
4
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
4
5
|
export declare const getProduct: (productInfo?: ProductInformation) => string;
|
|
5
6
|
export declare const getSubProduct: (productInfo?: ProductInformation) => string;
|
|
7
|
+
export type UGCFreeStepDetails = {
|
|
8
|
+
type: string;
|
|
9
|
+
contentTypes: string;
|
|
10
|
+
stepSizeInBytes?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
|
|
@@ -192,7 +192,7 @@ type SendStepsRetryAnalyticsEvent = {
|
|
|
192
192
|
eventAction: EVENT_ACTION.SEND_STEPS_RETRY;
|
|
193
193
|
attributes: {
|
|
194
194
|
documentAri: string;
|
|
195
|
-
eventStatus: EVENT_STATUS.
|
|
195
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
196
196
|
count: number;
|
|
197
197
|
};
|
|
198
198
|
};
|
|
@@ -200,7 +200,7 @@ type CatchupAfterMaxSendStepsRetryAnalyticsEvent = {
|
|
|
200
200
|
eventAction: EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY;
|
|
201
201
|
attributes: {
|
|
202
202
|
documentAri: string;
|
|
203
|
-
eventStatus: EVENT_STATUS.
|
|
203
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ProductInformation } from '../types';
|
|
2
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
3
|
export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
|
|
3
4
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
4
5
|
export declare const getProduct: (productInfo?: ProductInformation) => string;
|
|
5
6
|
export declare const getSubProduct: (productInfo?: ProductInformation) => string;
|
|
7
|
+
export type UGCFreeStepDetails = {
|
|
8
|
+
type: string;
|
|
9
|
+
contentTypes: string;
|
|
10
|
+
stepSizeInBytes?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.2",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@atlaskit/adf-schema": "^25.8.0",
|
|
65
65
|
"@atlaskit/analytics-listeners": "^8.7.0",
|
|
66
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
66
|
+
"@atlaskit/editor-test-helpers": "^18.6.0",
|
|
67
67
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
68
68
|
"@types/prosemirror-model": "^1.11.0",
|
|
69
69
|
"@types/prosemirror-state": "^1.2.0",
|