@atlaskit/collab-provider 9.37.0 → 9.37.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.37.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#129573](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129573)
8
+ [`9e66ad571558c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9e66ad571558c) -
9
+ To heavily sample the collab-provider.telepointer performance portal SLO
10
+
11
+ ## 9.37.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 9.37.0
4
18
 
5
19
  ### Minor Changes
@@ -3,9 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.measureMap = exports.isPerformanceAPIAvailable = exports.MEASURE_NAME = void 0;
6
+ exports.shouldTelepointerBeSampled = exports.measureMap = exports.isPerformanceAPIAvailable = exports.MEASURE_NAME = void 0;
7
7
  exports.startMeasure = startMeasure;
8
8
  exports.stopMeasure = stopMeasure;
9
+ // Initialize the random sampling rate
10
+ var TELEPOINTER_SAMPLE_RATE = 0.0001;
9
11
  var MEASURE_NAME = exports.MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
10
12
  MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
11
13
  MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
@@ -79,4 +81,13 @@ function clearMeasure(measureName) {
79
81
  performance.clearMarks("".concat(measureName, "::start"));
80
82
  performance.clearMarks("".concat(measureName, "::end"));
81
83
  performance.clearMeasures(measureName);
82
- }
84
+ }
85
+ var shouldTelepointerBeSampled = exports.shouldTelepointerBeSampled = function shouldTelepointerBeSampled() {
86
+ return (
87
+ // At peak usage, telepointer we had 200M events per day. The goal is to sample 1:10000 of the events. (20k per day)
88
+ // Math.random() generates a random floating-point number between 0 (inclusive) and 1 (exclusive).
89
+ // The condition Math.random() < TELEPOINTER_SAMPLE_RATE (0.0001) will be true approximately 0.01% of the time.
90
+ // This means that approximately 1 in 10,000 events will be sampled.
91
+ Math.random() < TELEPOINTER_SAMPLE_RATE
92
+ );
93
+ };
@@ -31,6 +31,7 @@ var _internalErrors = require("../errors/internal-errors");
31
31
  var _const = require("../helpers/const");
32
32
  var _featureFlags = require("../feature-flags");
33
33
  var _api = require("../api/api");
34
+ var _performance = require("../analytics/performance");
34
35
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
36
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
36
37
  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); }; }
@@ -434,7 +435,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
434
435
  if ((data === null || data === void 0 ? void 0 : data.type) === 'telepointer') {
435
436
  this.channel.broadcast('participant:telepointer', _objectSpread(_objectSpread({}, basePayload), {}, {
436
437
  selection: data.selection
437
- }), (0, _telepointersHelper.telepointerCallback)(this.config.documentAri));
438
+ }), (0, _performance.shouldTelepointerBeSampled)() ? (0, _telepointersHelper.telepointerCallback)(this.config.documentAri) : undefined);
438
439
  } else if ((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' || (data === null || data === void 0 ? void 0 : data.type) === 'activity:ack') {
439
440
  this.channel.broadcast((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' ? 'participant:activity-join' : 'participant:activity-ack', _objectSpread(_objectSpread({}, basePayload), {}, {
440
441
  activity: data.activity
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "9.37.0";
8
+ var version = exports.version = "9.37.2";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -1,3 +1,5 @@
1
+ // Initialize the random sampling rate
2
+ const TELEPOINTER_SAMPLE_RATE = 0.0001;
1
3
  export let MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
2
4
  MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
3
5
  MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
@@ -69,4 +71,10 @@ function clearMeasure(measureName) {
69
71
  performance.clearMarks(`${measureName}::start`);
70
72
  performance.clearMarks(`${measureName}::end`);
71
73
  performance.clearMeasures(measureName);
72
- }
74
+ }
75
+ export const shouldTelepointerBeSampled = () =>
76
+ // At peak usage, telepointer we had 200M events per day. The goal is to sample 1:10000 of the events. (20k per day)
77
+ // Math.random() generates a random floating-point number between 0 (inclusive) and 1 (exclusive).
78
+ // The condition Math.random() < TELEPOINTER_SAMPLE_RATE (0.0001) will be true approximately 0.01% of the time.
79
+ // This means that approximately 1 in 10,000 events will be sampled.
80
+ Math.random() < TELEPOINTER_SAMPLE_RATE;
@@ -15,6 +15,7 @@ import { INTERNAL_ERROR_CODE } from '../errors/internal-errors';
15
15
  import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
16
16
  import { getCollabProviderFeatureFlag } from '../feature-flags';
17
17
  import { Api } from '../api/api';
18
+ import { shouldTelepointerBeSampled } from '../analytics/performance';
18
19
  const logger = createLogger('Provider', 'black');
19
20
  const OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
20
21
 
@@ -372,7 +373,7 @@ export class Provider extends Emitter {
372
373
  this.channel.broadcast('participant:telepointer', {
373
374
  ...basePayload,
374
375
  selection: data.selection
375
- }, telepointerCallback(this.config.documentAri));
376
+ }, shouldTelepointerBeSampled() ? telepointerCallback(this.config.documentAri) : undefined);
376
377
  } else if ((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' || (data === null || data === void 0 ? void 0 : data.type) === 'activity:ack') {
377
378
  this.channel.broadcast((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' ? 'participant:activity-join' : 'participant:activity-ack', {
378
379
  ...basePayload,
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.37.0";
2
+ export const version = "9.37.2";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,3 +1,5 @@
1
+ // Initialize the random sampling rate
2
+ var TELEPOINTER_SAMPLE_RATE = 0.0001;
1
3
  export var MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
2
4
  MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
3
5
  MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
@@ -71,4 +73,13 @@ function clearMeasure(measureName) {
71
73
  performance.clearMarks("".concat(measureName, "::start"));
72
74
  performance.clearMarks("".concat(measureName, "::end"));
73
75
  performance.clearMeasures(measureName);
74
- }
76
+ }
77
+ export var shouldTelepointerBeSampled = function shouldTelepointerBeSampled() {
78
+ return (
79
+ // At peak usage, telepointer we had 200M events per day. The goal is to sample 1:10000 of the events. (20k per day)
80
+ // Math.random() generates a random floating-point number between 0 (inclusive) and 1 (exclusive).
81
+ // The condition Math.random() < TELEPOINTER_SAMPLE_RATE (0.0001) will be true approximately 0.01% of the time.
82
+ // This means that approximately 1 in 10,000 events will be sampled.
83
+ Math.random() < TELEPOINTER_SAMPLE_RATE
84
+ );
85
+ };
@@ -28,6 +28,7 @@ import { INTERNAL_ERROR_CODE } from '../errors/internal-errors';
28
28
  import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
29
29
  import { getCollabProviderFeatureFlag } from '../feature-flags';
30
30
  import { Api } from '../api/api';
31
+ import { shouldTelepointerBeSampled } from '../analytics/performance';
31
32
  var logger = createLogger('Provider', 'black');
32
33
  var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
33
34
 
@@ -427,7 +428,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
427
428
  if ((data === null || data === void 0 ? void 0 : data.type) === 'telepointer') {
428
429
  this.channel.broadcast('participant:telepointer', _objectSpread(_objectSpread({}, basePayload), {}, {
429
430
  selection: data.selection
430
- }), telepointerCallback(this.config.documentAri));
431
+ }), shouldTelepointerBeSampled() ? telepointerCallback(this.config.documentAri) : undefined);
431
432
  } else if ((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' || (data === null || data === void 0 ? void 0 : data.type) === 'activity:ack') {
432
433
  this.channel.broadcast((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' ? 'participant:activity-join' : 'participant:activity-ack', _objectSpread(_objectSpread({}, basePayload), {}, {
433
434
  activity: data.activity
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "9.37.0";
2
+ export var version = "9.37.2";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -13,3 +13,4 @@ export declare function stopMeasure(measureName: MEASURE_NAME, analyticsHelper:
13
13
  duration: number;
14
14
  startTime: number;
15
15
  } | undefined;
16
+ export declare const shouldTelepointerBeSampled: () => boolean;
@@ -13,3 +13,4 @@ export declare function stopMeasure(measureName: MEASURE_NAME, analyticsHelper:
13
13
  duration: number;
14
14
  startTime: number;
15
15
  } | undefined;
16
+ export declare const shouldTelepointerBeSampled: () => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "9.37.0",
3
+ "version": "9.37.2",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -38,13 +38,13 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@atlaskit/analytics-gas-types": "^5.1.0",
41
- "@atlaskit/analytics-listeners": "^8.10.0",
42
- "@atlaskit/editor-common": "^87.6.0",
41
+ "@atlaskit/analytics-listeners": "^8.11.0",
42
+ "@atlaskit/editor-common": "^87.10.0",
43
43
  "@atlaskit/editor-json-transformer": "^8.18.0",
44
44
  "@atlaskit/editor-prosemirror": "5.0.1",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/prosemirror-collab": "^0.9.0",
47
- "@atlaskit/ufo": "^0.2.0",
47
+ "@atlaskit/ufo": "^0.3.0",
48
48
  "@atlaskit/util-service-support": "^6.2.0",
49
49
  "@babel/runtime": "^7.0.0",
50
50
  "eventemitter2": "^4.1.0",