@atlaskit/editor-core 234.3.1 → 234.3.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/version-wrapper.js +1 -1
  3. package/dist/es2019/version-wrapper.js +1 -1
  4. package/dist/esm/version-wrapper.js +1 -1
  5. package/package.json +3 -3
  6. package/dist/cjs/utils/performance/outlier.js +0 -16
  7. package/dist/cjs/utils/performance/percentile.js +0 -22
  8. package/dist/cjs/utils/performance/plugin-performance-observer.js +0 -131
  9. package/dist/cjs/utils/performance/plugin-performance-report.js +0 -190
  10. package/dist/cjs/utils/performance/simple-measure-to-entries.js +0 -101
  11. package/dist/es2019/utils/performance/outlier.js +0 -10
  12. package/dist/es2019/utils/performance/percentile.js +0 -14
  13. package/dist/es2019/utils/performance/plugin-performance-observer.js +0 -88
  14. package/dist/es2019/utils/performance/plugin-performance-report.js +0 -133
  15. package/dist/es2019/utils/performance/simple-measure-to-entries.js +0 -83
  16. package/dist/esm/utils/performance/outlier.js +0 -10
  17. package/dist/esm/utils/performance/percentile.js +0 -16
  18. package/dist/esm/utils/performance/plugin-performance-observer.js +0 -124
  19. package/dist/esm/utils/performance/plugin-performance-report.js +0 -183
  20. package/dist/esm/utils/performance/simple-measure-to-entries.js +0 -94
  21. package/dist/types/utils/performance/outlier.d.ts +0 -1
  22. package/dist/types/utils/performance/percentile.d.ts +0 -1
  23. package/dist/types/utils/performance/plugin-performance-observer.d.ts +0 -23
  24. package/dist/types/utils/performance/plugin-performance-report.d.ts +0 -47
  25. package/dist/types/utils/performance/simple-measure-to-entries.d.ts +0 -28
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 234.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`be603fee7766f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/be603fee7766f) -
8
+ Remove unused internal performance analytics code (plugin performance report/observer and the
9
+ renderedSampled payload type)
10
+ - Updated dependencies
11
+
3
12
  ## 234.3.1
4
13
 
5
14
  ### Patch Changes
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
8
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
9
- var version = exports.version = "234.3.0";
9
+ var version = exports.version = "234.3.1";
@@ -1,3 +1,3 @@
1
1
  export const name = "@atlaskit/editor-core";
2
2
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
- export const version = "234.3.0";
3
+ export const version = "234.3.1";
@@ -1,3 +1,3 @@
1
1
  export var name = "@atlaskit/editor-core";
2
2
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
- export var version = "234.3.0";
3
+ export var version = "234.3.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "234.3.1",
3
+ "version": "234.3.2",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -96,7 +96,7 @@
96
96
  "uuid": "^11.1.1"
97
97
  },
98
98
  "peerDependencies": {
99
- "@atlaskit/editor-common": "^128.3.0",
99
+ "@atlaskit/editor-common": "^128.4.0",
100
100
  "@atlaskit/link-provider": "^6.0.0",
101
101
  "@atlaskit/media-core": "^39.0.0",
102
102
  "react": "^18.2.0 || ^19.2.0",
@@ -116,7 +116,7 @@
116
116
  "@atlaskit/docs": "^12.3.0",
117
117
  "@atlaskit/drawer": "^14.3.0",
118
118
  "@atlaskit/editor-plugin-alignment": "^25.0.0",
119
- "@atlaskit/editor-plugin-annotation": "^24.0.0",
119
+ "@atlaskit/editor-plugin-annotation": "^24.1.0",
120
120
  "@atlaskit/editor-plugin-base": "^25.1.0",
121
121
  "@atlaskit/editor-plugin-card": "^30.0.0",
122
122
  "@atlaskit/editor-plugin-code-block-advanced": "^24.0.0",
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.outlier = void 0;
7
- var _percentile = require("./percentile");
8
- var outlier = exports.outlier = function outlier(input, factor) {
9
- var q1 = (0, _percentile.percentile)(input, 0.25);
10
- var q3 = (0, _percentile.percentile)(input, 0.75);
11
- if (typeof q1 === 'undefined' || typeof q3 === 'undefined') {
12
- return;
13
- }
14
- var iqr = q3 - q1;
15
- return q3 + iqr * factor;
16
- };
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.percentile = void 0;
7
- var percentile = exports.percentile = function percentile(input, fraction) {
8
- var sorted = input.sort(function (a, b) {
9
- return a - b;
10
- });
11
- var position = sorted.length * fraction;
12
- var base = Math.floor(position);
13
- var rest = position - base;
14
- if (rest > 0) {
15
- return sorted[base];
16
- }
17
- var item = sorted[base - 1];
18
- var next = sorted[base];
19
- if (typeof item !== 'undefined' && typeof next !== 'undefined') {
20
- return (item + next) / 2;
21
- }
22
- };
@@ -1,131 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.PluginPerformanceObserver = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- var _pluginPerformanceReport = require("./plugin-performance-report");
13
- var _simpleMeasureToEntries = require("./simple-measure-to-entries");
14
- var _trackTransactions = require("./track-transactions");
15
- var PluginPerformanceObserver = exports.PluginPerformanceObserver = /*#__PURE__*/function () {
16
- function PluginPerformanceObserver(callback) {
17
- var _this = this;
18
- (0, _classCallCheck2.default)(this, PluginPerformanceObserver);
19
- (0, _defineProperty2.default)(this, "getNodeCounts", function () {
20
- return [{
21
- nodeCount: {},
22
- extensionNodeCount: {}
23
- }, 0];
24
- });
25
- (0, _defineProperty2.default)(this, "getPlugins", function () {
26
- return [];
27
- });
28
- (0, _defineProperty2.default)(this, "getOptions", function () {
29
- return {};
30
- });
31
- (0, _defineProperty2.default)(this, "reportCount", 0);
32
- (0, _defineProperty2.default)(this, "simpleObserver", new _simpleMeasureToEntries.SimpleMeasurementLogger());
33
- (0, _defineProperty2.default)(this, "onObserveration", function (entries) {
34
- var reports = entries.getEntriesByName(_trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION).map(function (entry) {
35
- var _PluginPerformanceRep;
36
- return (_PluginPerformanceRep = _pluginPerformanceReport.PluginPerformanceReport.fromEntry(entry).withCount(++_this.reportCount).withEntryList(entries)).withNodes.apply(_PluginPerformanceRep, (0, _toConsumableArray2.default)(_this.getNodeCounts())).withPlugins(_this.getPlugins()).withOptions(_this.getOptions()).toJSON();
37
- });
38
- reports.filter(function (report) {
39
- return report.trigger !== 'none';
40
- }).forEach(function (report) {
41
- return _this.callback(report);
42
- });
43
- });
44
- this.callback = callback;
45
- this.observer = window.PerformanceObserver ? new PerformanceObserver(this.onObserveration) : {
46
- observe: function observe() {},
47
- disconnect: function disconnect() {},
48
- takeRecords: function takeRecords() {
49
- return [];
50
- }
51
- };
52
- }
53
- return (0, _createClass2.default)(PluginPerformanceObserver, [{
54
- key: "isSimpleTracking",
55
- get: function get() {
56
- var _this$getOptions = this.getOptions(),
57
- _this$getOptions$useP = _this$getOptions.usePerformanceMarks,
58
- usePerformanceMarks = _this$getOptions$useP === void 0 ? _trackTransactions.DEFAULT_USE_PERFORMANCE_MARK : _this$getOptions$useP;
59
- return !usePerformanceMarks;
60
- }
61
- }, {
62
- key: "withNodeCounts",
63
- value: function withNodeCounts(getNodeCounts) {
64
- this.getNodeCounts = function () {
65
- var start = performance.now();
66
- var result = getNodeCounts();
67
- return [result, performance.now() - start];
68
- };
69
- return this;
70
- }
71
- }, {
72
- key: "withPlugins",
73
- value: function withPlugins(getPlugins) {
74
- this.getPlugins = getPlugins;
75
- return this;
76
- }
77
- }, {
78
- key: "withOptions",
79
- value: function withOptions(getOptions) {
80
- this.getOptions = getOptions;
81
- return this;
82
- }
83
- }, {
84
- key: "withTransactionTracker",
85
- value: function withTransactionTracker(getTransactionTracker) {
86
- this.getTransactionTracker = getTransactionTracker;
87
- return this;
88
- }
89
- }, {
90
- key: "observe",
91
- value: function observe() {
92
- var _this2 = this;
93
- if (this.isSimpleTracking) {
94
- this.simpleObserver.setPluginNames(this.getPlugins());
95
- this.simpleObserver.setOnObservation(function (entries) {
96
- _this2.onObserveration(entries, _this2.observer);
97
- });
98
-
99
- // can trigger a callback when stopMeasure() measures something.
100
- // use that to trigger this.onObservation()
101
- this.getTransactionTracker && this.getTransactionTracker().addMeasureListener(this.simpleObserver.observed);
102
- } else {
103
- try {
104
- this.observer.observe({
105
- buffered: false,
106
- type: 'measure'
107
- });
108
- } catch (err) {
109
- // Older API implementations do not support the simpler type init
110
- this.observer.observe({
111
- entryTypes: ['measure']
112
- });
113
- }
114
- }
115
- }
116
- }, {
117
- key: "disconnect",
118
- value: function disconnect() {
119
- if (this.isSimpleTracking) {
120
- this.getTransactionTracker && this.getTransactionTracker().removeMeasureListener(this.simpleObserver.observed);
121
- } else {
122
- this.observer.disconnect();
123
- }
124
- }
125
- }, {
126
- key: "takeRecords",
127
- value: function takeRecords() {
128
- return this.observer.takeRecords();
129
- }
130
- }]);
131
- }();
@@ -1,190 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.PluginPerformanceReport = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- var _outlier = require("./outlier");
13
- var _trackTransactions = require("./track-transactions");
14
- 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; }
15
- 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; }
16
- var PluginPerformanceReport = exports.PluginPerformanceReport = /*#__PURE__*/function () {
17
- function PluginPerformanceReport(entry) {
18
- var _this = this;
19
- (0, _classCallCheck2.default)(this, PluginPerformanceReport);
20
- (0, _defineProperty2.default)(this, "count", 0);
21
- (0, _defineProperty2.default)(this, "pluginNames", []);
22
- (0, _defineProperty2.default)(this, "nodes", {});
23
- (0, _defineProperty2.default)(this, "extensionNodes", {});
24
- (0, _defineProperty2.default)(this, "nodesDuration", 0);
25
- (0, _defineProperty2.default)(this, "plugins", {});
26
- (0, _defineProperty2.default)(this, "slowPlugins", {});
27
- (0, _defineProperty2.default)(this, "options", {
28
- samplingRate: 100,
29
- slowThreshold: 300,
30
- outlierThreshold: 30,
31
- outlierFactor: 3
32
- });
33
- (0, _defineProperty2.default)(this, "isChild", function (child) {
34
- return child.startTime >= _this.entry.startTime && child.startTime + child.duration <= _this.entry.startTime + _this.entry.duration;
35
- });
36
- this.entry = entry;
37
- }
38
- return (0, _createClass2.default)(PluginPerformanceReport, [{
39
- key: "getEntryByName",
40
- value: function getEntryByName(entryList, name) {
41
- return entryList.getEntriesByName(name).find(this.isChild);
42
- }
43
- }, {
44
- key: "getMethodSum",
45
- value: function getMethodSum(methods) {
46
- return Object.values(methods).reduce(function (a, b) {
47
- return a + b;
48
- }, 0);
49
- }
50
- }, {
51
- key: "greaterEquals",
52
- value: function greaterEquals(a, b) {
53
- return typeof b === 'number' ? a >= b : false;
54
- }
55
- }, {
56
- key: "hasOutlierMethods",
57
- value: function hasOutlierMethods(methods, outliers) {
58
- return this.greaterEquals(methods.stateApply, outliers.stateApplyOutlier) || this.greaterEquals(methods.viewUpdate, outliers.viewUpdateOutlier);
59
- }
60
- }, {
61
- key: "trigger",
62
- get: function get() {
63
- if (this.entry.duration > this.options.slowThreshold) {
64
- return 'slow';
65
- } else if (this.hasSlowPlugins && this.entry.duration > this.options.outlierThreshold) {
66
- return 'distribution';
67
- } else if (this.count > 0 && this.count % this.options.samplingRate === 0) {
68
- return 'sample';
69
- } else {
70
- return 'none';
71
- }
72
- }
73
- }, {
74
- key: "hasSlowPlugins",
75
- get: function get() {
76
- return Object.keys(this.slowPlugins).length > 0;
77
- }
78
- }, {
79
- key: "withEntryList",
80
- value: function withEntryList(entryList) {
81
- this.entryList = entryList;
82
- this.stateApplied = this.getEntryByName(entryList, _trackTransactions.EVENT_NAME_STATE_APPLY);
83
- this.viewUpdated = this.getEntryByName(entryList, _trackTransactions.EVENT_NAME_UPDATE_STATE);
84
- this.onChangeCalled = this.getEntryByName(entryList, _trackTransactions.EVENT_NAME_ON_CHANGE);
85
- this.onEditorViewStateUpdatedCalled = this.getEntryByName(entryList, _trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED);
86
- this.withPlugins(this.pluginNames);
87
- return this;
88
- }
89
- }, {
90
- key: "withPlugins",
91
- value: function withPlugins(pluginNames) {
92
- var _this2 = this;
93
- var emptyEntry = {
94
- duration: 0
95
- };
96
- this.pluginNames = pluginNames;
97
- this.plugins = pluginNames.reduce(function (acc, name) {
98
- var pluginApplied = _this2.entryList ? _this2.getEntryByName(_this2.entryList, "\uD83E\uDD89".concat(name, "::apply")) || emptyEntry : emptyEntry;
99
- var pluginViewUpdated = _this2.entryList ? _this2.getEntryByName(_this2.entryList, "\uD83E\uDD89".concat(name, "::view::update")) || emptyEntry : emptyEntry;
100
- var pluginOnEditorViewStateUpdated = _this2.entryList ? _this2.getEntryByName(_this2.entryList, "\uD83E\uDD89".concat(name, "::onEditorViewStateUpdated")) || emptyEntry : emptyEntry;
101
- acc[name] = {
102
- stateApply: pluginApplied.duration,
103
- viewUpdate: pluginViewUpdated.duration,
104
- onEditorViewStateUpdated: pluginOnEditorViewStateUpdated.duration
105
- };
106
- return acc;
107
- }, {});
108
- if (this.stateApplied && pluginNames.length > 0) {
109
- var pluginEntries = Object.entries(this.plugins);
110
- var stateApplyOutlier = (0, _outlier.outlier)(pluginEntries.map(function (_ref) {
111
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
112
- stateApply = _ref2[1].stateApply;
113
- return stateApply;
114
- }), this.options.outlierFactor);
115
- var viewUpdateOutlier = (0, _outlier.outlier)(pluginEntries.map(function (_ref3) {
116
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
117
- viewUpdate = _ref4[1].viewUpdate;
118
- return viewUpdate;
119
- }), this.options.outlierFactor);
120
- var budget = this.options.outlierThreshold / pluginEntries.length;
121
-
122
- /**
123
- * Consider plugin methods slow that are
124
- * statistically significantly slower than peers
125
- * AND where the sum of methods for a plugin is slower than 16.7ms / plugins.length
126
- */
127
- var pluginIsOutlier = function pluginIsOutlier(_ref5) {
128
- var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
129
- methods = _ref6[1];
130
- return _this2.getMethodSum(methods) > budget && _this2.hasOutlierMethods(methods, {
131
- stateApplyOutlier: stateApplyOutlier,
132
- viewUpdateOutlier: viewUpdateOutlier
133
- });
134
- };
135
- this.slowPlugins = pluginEntries.filter(pluginIsOutlier).reduce(function (acc, _ref7) {
136
- var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
137
- n = _ref8[0],
138
- d = _ref8[1];
139
- return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, n, d));
140
- }, {});
141
- }
142
- return this;
143
- }
144
- }, {
145
- key: "withNodes",
146
- value: function withNodes(nodesCount) {
147
- var nodesDuration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
148
- this.nodes = nodesCount.nodeCount;
149
- this.extensionNodes = nodesCount.extensionNodeCount;
150
- this.nodesDuration = nodesDuration;
151
- return this;
152
- }
153
- }, {
154
- key: "withCount",
155
- value: function withCount(count) {
156
- this.count = count;
157
- return this;
158
- }
159
- }, {
160
- key: "withOptions",
161
- value: function withOptions(options) {
162
- Object.assign(this.options, options);
163
- return this;
164
- }
165
- }, {
166
- key: "toJSON",
167
- value: function toJSON() {
168
- return {
169
- trigger: this.trigger,
170
- duration: this.entry.duration,
171
- nodes: this.nodes,
172
- extensionNodes: this.extensionNodes,
173
- plugins: this.plugins,
174
- slowPlugins: this.slowPlugins,
175
- stepDurations: {
176
- stateApply: this.stateApplied ? this.stateApplied.duration : 0,
177
- viewUpdate: this.viewUpdated ? this.viewUpdated.duration : 0,
178
- onChange: this.onChangeCalled ? this.onChangeCalled.duration : 0,
179
- onEditorViewStateUpdated: this.onEditorViewStateUpdatedCalled ? this.onEditorViewStateUpdatedCalled.duration : 0,
180
- countNodes: this.nodesDuration
181
- }
182
- };
183
- }
184
- }], [{
185
- key: "fromEntry",
186
- value: function fromEntry(entry) {
187
- return new PluginPerformanceReport(entry);
188
- }
189
- }]);
190
- }();
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.SimpleMeasurementLogger = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- var _trackTransactions = require("./track-transactions");
13
- var EVENT_NAMES = [_trackTransactions.EVENT_NAME_STATE_APPLY, _trackTransactions.EVENT_NAME_UPDATE_STATE, _trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED, _trackTransactions.EVENT_NAME_ON_CHANGE, _trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION];
14
-
15
- /**
16
- * A class that logs and collates measurement entries until
17
- * EVENT_NAME_DISPATCHTRANSACTION is detected.
18
- *
19
- * At that point, it will group together all the entries
20
- * logged and fire a callback with all entries packaged
21
- * into a PerformanceObserverEntryList.
22
- *
23
- * We are able to make use of this method as the measurements
24
- * which occur during dispatchTransactions are synchronous.
25
- */
26
- var SimpleMeasurementLogger = exports.SimpleMeasurementLogger = /*#__PURE__*/(0, _createClass2.default)(function SimpleMeasurementLogger() {
27
- var _this = this;
28
- (0, _classCallCheck2.default)(this, SimpleMeasurementLogger);
29
- (0, _defineProperty2.default)(this, "currentBatch", []);
30
- (0, _defineProperty2.default)(this, "pluginNameCache", new Set());
31
- (0, _defineProperty2.default)(this, "setPluginNames", function (names) {
32
- _this.pluginNameCache = new Set(names);
33
- });
34
- (0, _defineProperty2.default)(this, "setOnObservation", function (callback) {
35
- _this.observationCallback = callback;
36
- });
37
- (0, _defineProperty2.default)(this, "createPerformanceEntry", function (reading) {
38
- return {
39
- entryType: 'mark',
40
- name: reading.name,
41
- startTime: reading.startTime,
42
- duration: reading.duration,
43
- toJSON: function toJSON() {
44
- return JSON.stringify({
45
- entryType: 'mark',
46
- name: reading.name,
47
- startTime: reading.startTime,
48
- duration: reading.duration
49
- });
50
- }
51
- };
52
- });
53
- (0, _defineProperty2.default)(this, "convertToEntryList", function (batch) {
54
- return {
55
- getEntries: function getEntries() {
56
- return batch;
57
- },
58
- // We ignore type because we only store type of mark in batch
59
- getEntriesByName: function getEntriesByName(name, type) {
60
- return batch.filter(function (entry) {
61
- return entry.name === name;
62
- });
63
- },
64
- getEntriesByType: function getEntriesByType(type) {
65
- return batch;
66
- }
67
- };
68
- });
69
- (0, _defineProperty2.default)(this, "observed", function (reading) {
70
- // Given that this is only used for tracking transactions and
71
- // transactions are synchronous, we can assume that anything measured
72
- // between EVENT_NAME_DISPATCHTRANSACTION is encapsulated.
73
- var name = reading.name;
74
-
75
- // Transaction tracking event are prefixed with Owl emoji
76
- if (name.startsWith('🦉')) {
77
- var _name$split$;
78
- // check if its logging InstrumentedPlugin.state.apply()
79
- var pluginName = ((_name$split$ = name.split(':')[0]) === null || _name$split$ === void 0 ? void 0 : _name$split$.split('🦉')[1]) || '';
80
- var isPluginApply = _this.pluginNameCache.has(pluginName);
81
- var isTransactionMeasurement = EVENT_NAMES.includes(name);
82
- if (!isTransactionMeasurement && process.env.NODE_ENV === 'development') {
83
- // eslint-disable-next-line no-console
84
- console.warn("SimpleMeasurementLogger: unknown transaction event name '".concat(name, "'"));
85
- }
86
- if (isPluginApply || isTransactionMeasurement) {
87
- _this.currentBatch.push(_this.createPerformanceEntry(reading));
88
- }
89
- }
90
-
91
- // Trigger a report
92
- if (name === _trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION) {
93
- // convert the batch into a bunch of entries
94
- if (_this.observationCallback) {
95
- var _entries = _this.convertToEntryList((0, _toConsumableArray2.default)(_this.currentBatch));
96
- _this.observationCallback(_entries);
97
- }
98
- _this.currentBatch = [];
99
- }
100
- });
101
- });
@@ -1,10 +0,0 @@
1
- import { percentile } from './percentile';
2
- export const outlier = (input, factor) => {
3
- const q1 = percentile(input, 0.25);
4
- const q3 = percentile(input, 0.75);
5
- if (typeof q1 === 'undefined' || typeof q3 === 'undefined') {
6
- return;
7
- }
8
- const iqr = q3 - q1;
9
- return q3 + iqr * factor;
10
- };
@@ -1,14 +0,0 @@
1
- export const percentile = (input, fraction) => {
2
- const sorted = input.sort((a, b) => a - b);
3
- const position = sorted.length * fraction;
4
- const base = Math.floor(position);
5
- const rest = position - base;
6
- if (rest > 0) {
7
- return sorted[base];
8
- }
9
- const item = sorted[base - 1];
10
- const next = sorted[base];
11
- if (typeof item !== 'undefined' && typeof next !== 'undefined') {
12
- return (item + next) / 2;
13
- }
14
- };
@@ -1,88 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { PluginPerformanceReport } from './plugin-performance-report';
3
- import { SimpleMeasurementLogger } from './simple-measure-to-entries';
4
- import { DEFAULT_USE_PERFORMANCE_MARK, EVENT_NAME_DISPATCH_TRANSACTION } from './track-transactions';
5
- export class PluginPerformanceObserver {
6
- constructor(callback) {
7
- _defineProperty(this, "getNodeCounts", () => [{
8
- nodeCount: {},
9
- extensionNodeCount: {}
10
- }, 0]);
11
- _defineProperty(this, "getPlugins", () => []);
12
- _defineProperty(this, "getOptions", () => ({}));
13
- _defineProperty(this, "reportCount", 0);
14
- _defineProperty(this, "simpleObserver", new SimpleMeasurementLogger());
15
- _defineProperty(this, "onObserveration", entries => {
16
- const reports = entries.getEntriesByName(EVENT_NAME_DISPATCH_TRANSACTION).map(entry => PluginPerformanceReport.fromEntry(entry).withCount(++this.reportCount).withEntryList(entries).withNodes(...this.getNodeCounts()).withPlugins(this.getPlugins()).withOptions(this.getOptions()).toJSON());
17
- reports.filter(report => report.trigger !== 'none').forEach(report => this.callback(report));
18
- });
19
- this.callback = callback;
20
- this.observer = window.PerformanceObserver ? new PerformanceObserver(this.onObserveration) : {
21
- observe() {},
22
- disconnect() {},
23
- takeRecords() {
24
- return [];
25
- }
26
- };
27
- }
28
- get isSimpleTracking() {
29
- const {
30
- usePerformanceMarks = DEFAULT_USE_PERFORMANCE_MARK
31
- } = this.getOptions();
32
- return !usePerformanceMarks;
33
- }
34
- withNodeCounts(getNodeCounts) {
35
- this.getNodeCounts = () => {
36
- const start = performance.now();
37
- const result = getNodeCounts();
38
- return [result, performance.now() - start];
39
- };
40
- return this;
41
- }
42
- withPlugins(getPlugins) {
43
- this.getPlugins = getPlugins;
44
- return this;
45
- }
46
- withOptions(getOptions) {
47
- this.getOptions = getOptions;
48
- return this;
49
- }
50
- withTransactionTracker(getTransactionTracker) {
51
- this.getTransactionTracker = getTransactionTracker;
52
- return this;
53
- }
54
- observe() {
55
- if (this.isSimpleTracking) {
56
- this.simpleObserver.setPluginNames(this.getPlugins());
57
- this.simpleObserver.setOnObservation(entries => {
58
- this.onObserveration(entries, this.observer);
59
- });
60
-
61
- // can trigger a callback when stopMeasure() measures something.
62
- // use that to trigger this.onObservation()
63
- this.getTransactionTracker && this.getTransactionTracker().addMeasureListener(this.simpleObserver.observed);
64
- } else {
65
- try {
66
- this.observer.observe({
67
- buffered: false,
68
- type: 'measure'
69
- });
70
- } catch (err) {
71
- // Older API implementations do not support the simpler type init
72
- this.observer.observe({
73
- entryTypes: ['measure']
74
- });
75
- }
76
- }
77
- }
78
- disconnect() {
79
- if (this.isSimpleTracking) {
80
- this.getTransactionTracker && this.getTransactionTracker().removeMeasureListener(this.simpleObserver.observed);
81
- } else {
82
- this.observer.disconnect();
83
- }
84
- }
85
- takeRecords() {
86
- return this.observer.takeRecords();
87
- }
88
- }