@atlaskit/react-ufo 3.11.1 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/create-payload/index.js +6 -2
- package/dist/cjs/interaction-metrics-init/index.js +4 -0
- package/dist/cjs/machine-utilisation/index.js +77 -0
- package/dist/cjs/machine-utilisation/types.js +1 -0
- package/dist/cjs/vc/vc-observer/index.js +6 -5
- package/dist/cjs/vc/vc-observer/observers/index.js +2 -2
- package/dist/es2019/create-payload/index.js +5 -0
- package/dist/es2019/interaction-metrics-init/index.js +4 -0
- package/dist/es2019/machine-utilisation/index.js +62 -0
- package/dist/es2019/machine-utilisation/types.js +0 -0
- package/dist/es2019/vc/vc-observer/index.js +8 -3
- package/dist/es2019/vc/vc-observer/observers/index.js +2 -2
- package/dist/esm/create-payload/index.js +6 -2
- package/dist/esm/interaction-metrics-init/index.js +4 -0
- package/dist/esm/machine-utilisation/index.js +66 -0
- package/dist/esm/machine-utilisation/types.js +0 -0
- package/dist/esm/vc/vc-observer/index.js +6 -5
- package/dist/esm/vc/vc-observer/observers/index.js +2 -2
- package/dist/types/common/react-ufo-payload-schema.d.ts +1 -1
- package/dist/types/create-payload/index.d.ts +449 -1
- package/dist/types/create-post-interaction-log-payload/get-late-mutations.d.ts +3 -3
- package/dist/types/create-post-interaction-log-payload/index.d.ts +1 -1
- package/dist/types/machine-utilisation/index.d.ts +22 -0
- package/dist/types/machine-utilisation/types.d.ts +19 -0
- package/dist/types/vc/no-op-vc-observer.d.ts +1 -1
- package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +2 -2
- package/dist/types/vc/vc-observer-new/index.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/heatmap.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/metric-calculator/types.d.ts +1 -1
- package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +1 -1
- package/dist/types-ts4.5/create-payload/index.d.ts +449 -1
- package/dist/types-ts4.5/create-post-interaction-log-payload/get-late-mutations.d.ts +3 -3
- package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +1 -1
- package/dist/types-ts4.5/machine-utilisation/index.d.ts +22 -0
- package/dist/types-ts4.5/machine-utilisation/types.d.ts +19 -0
- package/dist/types-ts4.5/vc/no-op-vc-observer.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +2 -2
- package/dist/types-ts4.5/vc/vc-observer-new/index.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/heatmap/heatmap.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/types.d.ts +1 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#155304](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/155304)
|
|
8
|
+
[`8208673d5be30`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8208673d5be30) -
|
|
9
|
+
add CPU usage metrics as part of UFO payload
|
|
10
|
+
|
|
11
|
+
## 3.11.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#153697](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/153697)
|
|
16
|
+
[`e513d2cda4042`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e513d2cda4042) -
|
|
17
|
+
AFO-3823 improve VCObserver stop() performance
|
|
18
|
+
|
|
3
19
|
## 3.11.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
16
|
var _bowserUltralight = _interopRequireDefault(require("bowser-ultralight"));
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _additionalPayload = require("../additional-payload");
|
|
18
19
|
var _assets = require("../assets");
|
|
19
20
|
var bundleEvalTiming = _interopRequireWildcard(require("../bundle-eval-timing"));
|
|
@@ -25,6 +26,7 @@ var _globalErrorHandler = require("../global-error-handler");
|
|
|
25
26
|
var _hiddenTiming = require("../hidden-timing");
|
|
26
27
|
var initialPageLoadExtraTiming = _interopRequireWildcard(require("../initial-page-load-extra-timing"));
|
|
27
28
|
var _interactionMetrics = require("../interaction-metrics");
|
|
29
|
+
var _machineUtilisation = require("../machine-utilisation");
|
|
28
30
|
var resourceTiming = _interopRequireWildcard(require("../resource-timing"));
|
|
29
31
|
var _resourceTimingBuffer = require("../resource-timing/common/utils/resource-timing-buffer");
|
|
30
32
|
var _roundNumber = require("../round-number");
|
|
@@ -800,7 +802,7 @@ function _createInteractionMetricsPayload() {
|
|
|
800
802
|
source: 'measured',
|
|
801
803
|
tags: ['observability'],
|
|
802
804
|
attributes: {
|
|
803
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
805
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
804
806
|
// basic
|
|
805
807
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
806
808
|
'event:product': config.product,
|
|
@@ -813,7 +815,9 @@ function _createInteractionMetricsPayload() {
|
|
|
813
815
|
'event:region': config.region || 'unknown',
|
|
814
816
|
'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
|
|
815
817
|
'experience:name': newUFOName
|
|
816
|
-
},
|
|
818
|
+
}, (0, _platformFeatureFlags.fg)('platform_ufo_report_cpu_usage') ? {
|
|
819
|
+
'event:cpu:usage': (0, _machineUtilisation.createPressureStateReport)(interaction.start, interaction.end)
|
|
820
|
+
} : {}), getBrowserMetadata()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), getNavigationMetrics(type)), vcMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
|
|
817
821
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
818
822
|
namePrefix: config.namePrefix || '',
|
|
819
823
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -14,6 +14,7 @@ var _createExperimentalInteractionMetricsPayload = require("../create-experiment
|
|
|
14
14
|
var _hiddenTiming = require("../hidden-timing");
|
|
15
15
|
var _interactionMetrics = require("../interaction-metrics");
|
|
16
16
|
var _interactionsPerformanceObserver = require("../interactions-performance-observer");
|
|
17
|
+
var _machineUtilisation = require("../machine-utilisation");
|
|
17
18
|
var _vc = require("../vc");
|
|
18
19
|
var _scheduleIdleCallback = _interopRequireDefault(require("./schedule-idle-callback"));
|
|
19
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -84,6 +85,9 @@ function init(analyticsWebClientAsync, config) {
|
|
|
84
85
|
if (initialized) {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
88
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_report_cpu_usage')) {
|
|
89
|
+
(0, _machineUtilisation.initialisePressureObserver)();
|
|
90
|
+
}
|
|
87
91
|
(0, _config.setUFOConfig)(config);
|
|
88
92
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
89
93
|
var _config$experimentalI;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createPressureStateReport = createPressureStateReport;
|
|
8
|
+
exports.disconnectPressureObserver = disconnectPressureObserver;
|
|
9
|
+
exports.initialisePressureObserver = initialisePressureObserver;
|
|
10
|
+
exports.removeOldBufferRecords = removeOldBufferRecords;
|
|
11
|
+
exports.resetPressureRecordBuffer = resetPressureRecordBuffer;
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
var BUFFER_MAX_LENGTH = 1000; // ensure we don't blow up this buffer
|
|
14
|
+
var pressureRecordBuffer = [];
|
|
15
|
+
var pressureObserver = null;
|
|
16
|
+
function resetPressureRecordBuffer() {
|
|
17
|
+
pressureRecordBuffer.length = 0;
|
|
18
|
+
}
|
|
19
|
+
function removeOldBufferRecords(filter) {
|
|
20
|
+
pressureRecordBuffer = pressureRecordBuffer.filter(function (_ref) {
|
|
21
|
+
var time = _ref.time;
|
|
22
|
+
return time > filter;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function createPressureStateReport(start, end) {
|
|
26
|
+
// To differentiate between the API not available, vs no PressureRecords added
|
|
27
|
+
if (!('PressureObserver' in globalThis)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
var pressureStateCount = pressureRecordBuffer.reduce(function (pressureReport, _ref2) {
|
|
31
|
+
var time = _ref2.time,
|
|
32
|
+
state = _ref2.state;
|
|
33
|
+
if (time >= start && time <= end) {
|
|
34
|
+
pressureReport[state] += 1;
|
|
35
|
+
}
|
|
36
|
+
return pressureReport;
|
|
37
|
+
}, {
|
|
38
|
+
nominal: 0,
|
|
39
|
+
fair: 0,
|
|
40
|
+
serious: 0,
|
|
41
|
+
critical: 0
|
|
42
|
+
});
|
|
43
|
+
var pressureStateTotal = Object.values(pressureStateCount).reduce(function (total, count) {
|
|
44
|
+
return total + count;
|
|
45
|
+
}) || 1;
|
|
46
|
+
removeOldBufferRecords(end);
|
|
47
|
+
return {
|
|
48
|
+
count: pressureStateCount,
|
|
49
|
+
percentage: {
|
|
50
|
+
nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
|
|
51
|
+
fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
|
|
52
|
+
serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
|
|
53
|
+
critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function initialisePressureObserver() {
|
|
58
|
+
try {
|
|
59
|
+
if ('PressureObserver' in globalThis) {
|
|
60
|
+
pressureObserver = new PressureObserver(function (records) {
|
|
61
|
+
if (pressureRecordBuffer.length + records.length <= BUFFER_MAX_LENGTH) {
|
|
62
|
+
var _pressureRecordBuffer;
|
|
63
|
+
(_pressureRecordBuffer = pressureRecordBuffer).push.apply(_pressureRecordBuffer, (0, _toConsumableArray2.default)(records));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
pressureObserver.observe('cpu', {
|
|
67
|
+
sampleInterval: 100
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
/* do nothing, this is a best efforts metric */
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function disconnectPressureObserver() {
|
|
75
|
+
var _pressureObserver;
|
|
76
|
+
(_pressureObserver = pressureObserver) === null || _pressureObserver === void 0 || _pressureObserver.disconnect();
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -644,11 +644,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
|
|
|
644
644
|
}, {
|
|
645
645
|
key: "detachAbortListeners",
|
|
646
646
|
value: function detachAbortListeners() {
|
|
647
|
-
if (
|
|
648
|
-
this.unbind
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
647
|
+
if (this.unbind) {
|
|
648
|
+
var unbind = this.unbind;
|
|
649
|
+
for (var i = 0; i < unbind.length; i++) {
|
|
650
|
+
unbind[i]();
|
|
651
|
+
}
|
|
652
|
+
this.unbind.length = 0;
|
|
652
653
|
}
|
|
653
654
|
}
|
|
654
655
|
}, {
|
|
@@ -104,8 +104,8 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
|
|
|
104
104
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
105
105
|
(_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.disconnect();
|
|
106
106
|
this.observedMutations = new WeakMap();
|
|
107
|
-
this.elementsInView
|
|
108
|
-
this.callbacks
|
|
107
|
+
this.elementsInView.clear();
|
|
108
|
+
this.callbacks.clear();
|
|
109
109
|
this.ssr.reactRootElement = null;
|
|
110
110
|
this.ssrPlaceholderHandler.clear();
|
|
111
111
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Bowser from 'bowser-ultralight';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
3
4
|
import { CHRReporter } from '../assets';
|
|
4
5
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
@@ -10,6 +11,7 @@ import { getGlobalErrorCount } from '../global-error-handler';
|
|
|
10
11
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
11
12
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
12
13
|
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
14
|
+
import { createPressureStateReport } from '../machine-utilisation';
|
|
13
15
|
import * as resourceTiming from '../resource-timing';
|
|
14
16
|
import { filterResourceTimings } from '../resource-timing/common/utils/resource-timing-buffer';
|
|
15
17
|
import { roundEpsilon } from '../round-number';
|
|
@@ -786,6 +788,9 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
786
788
|
'event:region': config.region || 'unknown',
|
|
787
789
|
'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
|
|
788
790
|
'experience:name': newUFOName,
|
|
791
|
+
...(fg('platform_ufo_report_cpu_usage') ? {
|
|
792
|
+
'event:cpu:usage': createPressureStateReport(interaction.start, interaction.end)
|
|
793
|
+
} : {}),
|
|
789
794
|
// root
|
|
790
795
|
...getBrowserMetadata(),
|
|
791
796
|
...getSSRProperties(type),
|
|
@@ -5,6 +5,7 @@ import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-
|
|
|
5
5
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
6
6
|
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
7
7
|
import { getPerformanceObserver } from '../interactions-performance-observer';
|
|
8
|
+
import { initialisePressureObserver } from '../machine-utilisation';
|
|
8
9
|
import { getVCObserver } from '../vc';
|
|
9
10
|
import scheduleIdleCallback from './schedule-idle-callback';
|
|
10
11
|
let initialized = false;
|
|
@@ -73,6 +74,9 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
73
74
|
if (initialized) {
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
77
|
+
if (fg('platform_ufo_report_cpu_usage')) {
|
|
78
|
+
initialisePressureObserver();
|
|
79
|
+
}
|
|
76
80
|
setUFOConfig(config);
|
|
77
81
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
78
82
|
var _config$experimentalI;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const BUFFER_MAX_LENGTH = 1000; // ensure we don't blow up this buffer
|
|
2
|
+
let pressureRecordBuffer = [];
|
|
3
|
+
let pressureObserver = null;
|
|
4
|
+
export function resetPressureRecordBuffer() {
|
|
5
|
+
pressureRecordBuffer.length = 0;
|
|
6
|
+
}
|
|
7
|
+
export function removeOldBufferRecords(filter) {
|
|
8
|
+
pressureRecordBuffer = pressureRecordBuffer.filter(({
|
|
9
|
+
time
|
|
10
|
+
}) => time > filter);
|
|
11
|
+
}
|
|
12
|
+
export function createPressureStateReport(start, end) {
|
|
13
|
+
// To differentiate between the API not available, vs no PressureRecords added
|
|
14
|
+
if (!('PressureObserver' in globalThis)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const pressureStateCount = pressureRecordBuffer.reduce((pressureReport, {
|
|
18
|
+
time,
|
|
19
|
+
state
|
|
20
|
+
}) => {
|
|
21
|
+
if (time >= start && time <= end) {
|
|
22
|
+
pressureReport[state] += 1;
|
|
23
|
+
}
|
|
24
|
+
return pressureReport;
|
|
25
|
+
}, {
|
|
26
|
+
nominal: 0,
|
|
27
|
+
fair: 0,
|
|
28
|
+
serious: 0,
|
|
29
|
+
critical: 0
|
|
30
|
+
});
|
|
31
|
+
const pressureStateTotal = Object.values(pressureStateCount).reduce((total, count) => total + count) || 1;
|
|
32
|
+
removeOldBufferRecords(end);
|
|
33
|
+
return {
|
|
34
|
+
count: pressureStateCount,
|
|
35
|
+
percentage: {
|
|
36
|
+
nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
|
|
37
|
+
fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
|
|
38
|
+
serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
|
|
39
|
+
critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function initialisePressureObserver() {
|
|
44
|
+
try {
|
|
45
|
+
if ('PressureObserver' in globalThis) {
|
|
46
|
+
pressureObserver = new PressureObserver(records => {
|
|
47
|
+
if (pressureRecordBuffer.length + records.length <= BUFFER_MAX_LENGTH) {
|
|
48
|
+
pressureRecordBuffer.push(...records);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
pressureObserver.observe('cpu', {
|
|
52
|
+
sampleInterval: 100
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
/* do nothing, this is a best efforts metric */
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function disconnectPressureObserver() {
|
|
60
|
+
var _pressureObserver;
|
|
61
|
+
(_pressureObserver = pressureObserver) === null || _pressureObserver === void 0 ? void 0 : _pressureObserver.disconnect();
|
|
62
|
+
}
|
|
File without changes
|
|
@@ -739,9 +739,14 @@ export class VCObserver {
|
|
|
739
739
|
return vc;
|
|
740
740
|
}
|
|
741
741
|
detachAbortListeners() {
|
|
742
|
-
if (
|
|
743
|
-
|
|
744
|
-
|
|
742
|
+
if (this.unbind) {
|
|
743
|
+
const {
|
|
744
|
+
unbind
|
|
745
|
+
} = this;
|
|
746
|
+
for (let i = 0; i < unbind.length; i++) {
|
|
747
|
+
unbind[i]();
|
|
748
|
+
}
|
|
749
|
+
this.unbind.length = 0;
|
|
745
750
|
}
|
|
746
751
|
}
|
|
747
752
|
measureStart() {
|
|
@@ -86,8 +86,8 @@ export class Observers {
|
|
|
86
86
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 ? void 0 : _this$mutationObserve2.disconnect();
|
|
87
87
|
(_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 ? void 0 : _this$intersectionObs2.disconnect();
|
|
88
88
|
this.observedMutations = new WeakMap();
|
|
89
|
-
this.elementsInView
|
|
90
|
-
this.callbacks
|
|
89
|
+
this.elementsInView.clear();
|
|
90
|
+
this.callbacks.clear();
|
|
91
91
|
this.ssr.reactRootElement = null;
|
|
92
92
|
this.ssrPlaceholderHandler.clear();
|
|
93
93
|
}
|
|
@@ -11,6 +11,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
11
11
|
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; }
|
|
12
12
|
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) { _defineProperty(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; }
|
|
13
13
|
import Bowser from 'bowser-ultralight';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
15
16
|
import { CHRReporter } from '../assets';
|
|
16
17
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
@@ -22,6 +23,7 @@ import { getGlobalErrorCount } from '../global-error-handler';
|
|
|
22
23
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
23
24
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
24
25
|
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
26
|
+
import { createPressureStateReport } from '../machine-utilisation';
|
|
25
27
|
import * as resourceTiming from '../resource-timing';
|
|
26
28
|
import { filterResourceTimings } from '../resource-timing/common/utils/resource-timing-buffer';
|
|
27
29
|
import { roundEpsilon } from '../round-number';
|
|
@@ -789,7 +791,7 @@ function _createInteractionMetricsPayload() {
|
|
|
789
791
|
source: 'measured',
|
|
790
792
|
tags: ['observability'],
|
|
791
793
|
attributes: {
|
|
792
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
794
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
793
795
|
// basic
|
|
794
796
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
795
797
|
'event:product': config.product,
|
|
@@ -802,7 +804,9 @@ function _createInteractionMetricsPayload() {
|
|
|
802
804
|
'event:region': config.region || 'unknown',
|
|
803
805
|
'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
|
|
804
806
|
'experience:name': newUFOName
|
|
805
|
-
},
|
|
807
|
+
}, fg('platform_ufo_report_cpu_usage') ? {
|
|
808
|
+
'event:cpu:usage': createPressureStateReport(interaction.start, interaction.end)
|
|
809
|
+
} : {}), getBrowserMetadata()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), getNavigationMetrics(type)), vcMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
|
|
806
810
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
807
811
|
namePrefix: config.namePrefix || '',
|
|
808
812
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -6,6 +6,7 @@ import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-
|
|
|
6
6
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
7
7
|
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
8
8
|
import { getPerformanceObserver } from '../interactions-performance-observer';
|
|
9
|
+
import { initialisePressureObserver } from '../machine-utilisation';
|
|
9
10
|
import { getVCObserver } from '../vc';
|
|
10
11
|
import scheduleIdleCallback from './schedule-idle-callback';
|
|
11
12
|
var initialized = false;
|
|
@@ -74,6 +75,9 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
74
75
|
if (initialized) {
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
78
|
+
if (fg('platform_ufo_report_cpu_usage')) {
|
|
79
|
+
initialisePressureObserver();
|
|
80
|
+
}
|
|
77
81
|
setUFOConfig(config);
|
|
78
82
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
79
83
|
var _config$experimentalI;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
var BUFFER_MAX_LENGTH = 1000; // ensure we don't blow up this buffer
|
|
3
|
+
var pressureRecordBuffer = [];
|
|
4
|
+
var pressureObserver = null;
|
|
5
|
+
export function resetPressureRecordBuffer() {
|
|
6
|
+
pressureRecordBuffer.length = 0;
|
|
7
|
+
}
|
|
8
|
+
export function removeOldBufferRecords(filter) {
|
|
9
|
+
pressureRecordBuffer = pressureRecordBuffer.filter(function (_ref) {
|
|
10
|
+
var time = _ref.time;
|
|
11
|
+
return time > filter;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function createPressureStateReport(start, end) {
|
|
15
|
+
// To differentiate between the API not available, vs no PressureRecords added
|
|
16
|
+
if (!('PressureObserver' in globalThis)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
var pressureStateCount = pressureRecordBuffer.reduce(function (pressureReport, _ref2) {
|
|
20
|
+
var time = _ref2.time,
|
|
21
|
+
state = _ref2.state;
|
|
22
|
+
if (time >= start && time <= end) {
|
|
23
|
+
pressureReport[state] += 1;
|
|
24
|
+
}
|
|
25
|
+
return pressureReport;
|
|
26
|
+
}, {
|
|
27
|
+
nominal: 0,
|
|
28
|
+
fair: 0,
|
|
29
|
+
serious: 0,
|
|
30
|
+
critical: 0
|
|
31
|
+
});
|
|
32
|
+
var pressureStateTotal = Object.values(pressureStateCount).reduce(function (total, count) {
|
|
33
|
+
return total + count;
|
|
34
|
+
}) || 1;
|
|
35
|
+
removeOldBufferRecords(end);
|
|
36
|
+
return {
|
|
37
|
+
count: pressureStateCount,
|
|
38
|
+
percentage: {
|
|
39
|
+
nominal: Math.round(pressureStateCount.nominal / pressureStateTotal * 100),
|
|
40
|
+
fair: Math.round(pressureStateCount.fair / pressureStateTotal * 100),
|
|
41
|
+
serious: Math.round(pressureStateCount.serious / pressureStateTotal * 100),
|
|
42
|
+
critical: Math.round(pressureStateCount.critical / pressureStateTotal * 100)
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function initialisePressureObserver() {
|
|
47
|
+
try {
|
|
48
|
+
if ('PressureObserver' in globalThis) {
|
|
49
|
+
pressureObserver = new PressureObserver(function (records) {
|
|
50
|
+
if (pressureRecordBuffer.length + records.length <= BUFFER_MAX_LENGTH) {
|
|
51
|
+
var _pressureRecordBuffer;
|
|
52
|
+
(_pressureRecordBuffer = pressureRecordBuffer).push.apply(_pressureRecordBuffer, _toConsumableArray(records));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
pressureObserver.observe('cpu', {
|
|
56
|
+
sampleInterval: 100
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
/* do nothing, this is a best efforts metric */
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function disconnectPressureObserver() {
|
|
64
|
+
var _pressureObserver;
|
|
65
|
+
(_pressureObserver = pressureObserver) === null || _pressureObserver === void 0 || _pressureObserver.disconnect();
|
|
66
|
+
}
|
|
File without changes
|
|
@@ -637,11 +637,12 @@ export var VCObserver = /*#__PURE__*/function () {
|
|
|
637
637
|
}, {
|
|
638
638
|
key: "detachAbortListeners",
|
|
639
639
|
value: function detachAbortListeners() {
|
|
640
|
-
if (
|
|
641
|
-
this.unbind
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
640
|
+
if (this.unbind) {
|
|
641
|
+
var unbind = this.unbind;
|
|
642
|
+
for (var i = 0; i < unbind.length; i++) {
|
|
643
|
+
unbind[i]();
|
|
644
|
+
}
|
|
645
|
+
this.unbind.length = 0;
|
|
645
646
|
}
|
|
646
647
|
}
|
|
647
648
|
}, {
|
|
@@ -97,8 +97,8 @@ export var Observers = /*#__PURE__*/function () {
|
|
|
97
97
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
98
98
|
(_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.disconnect();
|
|
99
99
|
this.observedMutations = new WeakMap();
|
|
100
|
-
this.elementsInView
|
|
101
|
-
this.callbacks
|
|
100
|
+
this.elementsInView.clear();
|
|
101
|
+
this.callbacks.clear();
|
|
102
102
|
this.ssr.reactRootElement = null;
|
|
103
103
|
this.ssrPlaceholderHandler.clear();
|
|
104
104
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPayloads } from '../create-payload';
|
|
2
|
-
import { LabelStack } from '../interaction-context';
|
|
2
|
+
import { type LabelStack } from '../interaction-context';
|
|
3
3
|
import { VCObserver } from '../vc/vc-observer';
|
|
4
4
|
import type { AbortReasonType, ApdexType, InteractionError, InteractionType, SegmentInfo } from './common/types';
|
|
5
5
|
import type { RevisionPayload } from './vc/types';
|