@atlaskit/react-ufo 2.7.0 → 2.8.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 +12 -0
- package/dist/cjs/config/index.js +18 -40
- package/dist/cjs/create-payload/common/utils/index.js +2 -66
- package/dist/cjs/create-payload/index.js +78 -55
- package/dist/cjs/interaction-metrics/common/constants.js +3 -8
- package/dist/cjs/interaction-metrics/index.js +238 -166
- package/dist/cjs/interaction-metrics-init/index.js +9 -31
- package/dist/cjs/load-hold/UFOLoadHold.js +3 -5
- package/dist/cjs/segment/segment.js +8 -9
- package/dist/es2019/config/index.js +0 -22
- package/dist/es2019/create-payload/common/utils/index.js +1 -68
- package/dist/es2019/create-payload/index.js +77 -48
- package/dist/es2019/interaction-metrics/common/constants.js +2 -7
- package/dist/es2019/interaction-metrics/index.js +131 -91
- package/dist/es2019/interaction-metrics-init/index.js +8 -28
- package/dist/es2019/load-hold/UFOLoadHold.js +3 -5
- package/dist/es2019/segment/segment.js +11 -8
- package/dist/esm/config/index.js +18 -39
- package/dist/esm/create-payload/common/utils/index.js +1 -63
- package/dist/esm/create-payload/index.js +78 -53
- package/dist/esm/interaction-metrics/common/constants.js +2 -7
- package/dist/esm/interaction-metrics/index.js +158 -86
- package/dist/esm/interaction-metrics-init/index.js +8 -28
- package/dist/esm/load-hold/UFOLoadHold.js +3 -5
- package/dist/esm/segment/segment.js +8 -9
- package/dist/types/common/common/types.d.ts +4 -6
- package/dist/types/config/index.d.ts +0 -6
- package/dist/types/create-payload/common/utils/index.d.ts +0 -9
- package/dist/types/create-payload/index.d.ts +5660 -13
- package/dist/types/interaction-context/index.d.ts +0 -1
- package/dist/types/interaction-metrics/common/constants.d.ts +3 -32
- package/dist/types/interaction-metrics/index.d.ts +17 -1
- package/dist/types/load-hold/UFOLoadHold.d.ts +2 -1
- package/dist/types-ts4.5/common/common/types.d.ts +4 -6
- package/dist/types-ts4.5/config/index.d.ts +0 -6
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +0 -9
- package/dist/types-ts4.5/create-payload/index.d.ts +5660 -13
- package/dist/types-ts4.5/interaction-context/index.d.ts +0 -1
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -32
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +17 -1
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +2 -1
- package/package.json +2 -3
- package/create-experimental-interaction-metrics-payload/package.json +0 -15
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +0 -100
- package/dist/cjs/interaction-metrics/common/index.js +0 -151
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +0 -71
- package/dist/es2019/interaction-metrics/common/index.js +0 -103
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +0 -90
- package/dist/esm/interaction-metrics/common/index.js +0 -132
- package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +0 -16
- package/dist/types/interaction-metrics/common/index.d.ts +0 -16
- package/dist/types-ts4.5/create-experimental-interaction-metrics-payload/index.d.ts +0 -16
- package/dist/types-ts4.5/interaction-metrics/common/index.d.ts +0 -16
|
@@ -10,8 +10,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _scheduler = require("scheduler");
|
|
11
11
|
var _additionalPayload = require("../additional-payload");
|
|
12
12
|
var _config = require("../config");
|
|
13
|
-
var _createExperimentalInteractionMetricsPayload = require("../create-experimental-interaction-metrics-payload");
|
|
14
|
-
var _utils = require("../create-payload/common/utils");
|
|
15
13
|
var _hiddenTiming = require("../hidden-timing");
|
|
16
14
|
var _interactionMetrics = require("../interaction-metrics");
|
|
17
15
|
var _vc = require("../vc");
|
|
@@ -28,16 +26,6 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
28
26
|
});
|
|
29
27
|
});
|
|
30
28
|
}
|
|
31
|
-
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
32
|
-
(0, _createExperimentalInteractionMetricsPayload.sinkExperimentalHandler)(function (interactionId, interaction) {
|
|
33
|
-
(0, _scheduler.unstable_scheduleCallback)(_scheduler.unstable_IdlePriority, function () {
|
|
34
|
-
var payload = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
35
|
-
if (payload) {
|
|
36
|
-
instance.sendOperationalEvent(payload);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
29
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
42
30
|
(0, _interactionMetrics.sinkPostInteractionLogHandler)(function (logOutput) {
|
|
43
31
|
(0, _scheduler.unstable_scheduleCallback)(_scheduler.unstable_IdlePriority, function () {
|
|
@@ -55,7 +43,6 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
|
|
|
55
43
|
}
|
|
56
44
|
(0, _config.setUFOConfig)(config);
|
|
57
45
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
58
|
-
var _config$experimentalI;
|
|
59
46
|
var vcOptions = {
|
|
60
47
|
heatmapSize: config.vc.heatmapSize,
|
|
61
48
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
@@ -65,23 +52,20 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
|
|
|
65
52
|
(0, _vc.getVCObserver)(vcOptions).start({
|
|
66
53
|
startTime: 0
|
|
67
54
|
});
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
_interactionMetrics.postInteractionLog.initializeVCObserver(vcOptions);
|
|
56
|
+
_interactionMetrics.postInteractionLog.startVCObserver({
|
|
70
57
|
startTime: 0
|
|
71
58
|
});
|
|
72
|
-
if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
73
|
-
_createExperimentalInteractionMetricsPayload.experimentalVC.initialize(vcOptions).start({
|
|
74
|
-
startTime: 0
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
59
|
}
|
|
78
60
|
(0, _hiddenTiming.setupHiddenTimingCapture)();
|
|
79
61
|
(0, _additionalPayload.startLighthouseObserver)();
|
|
80
62
|
initialized = true;
|
|
81
|
-
Promise.all([analyticsWebClientAsync,
|
|
63
|
+
Promise.all([analyticsWebClientAsync, // eslint-disable-next-line import/dynamic-import-chunkname
|
|
64
|
+
Promise.resolve().then(function () {
|
|
82
65
|
return _interopRequireWildcard(require( /* webpackChunkName: "create-payloads" */'../create-payload'));
|
|
83
|
-
}),
|
|
84
|
-
|
|
66
|
+
}), // eslint-disable-next-line import/dynamic-import-chunkname
|
|
67
|
+
Promise.resolve().then(function () {
|
|
68
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "create-post-intreaction-log-payload" */'../create-post-interaction-log-payload'));
|
|
85
69
|
})]).then(function (_ref) {
|
|
86
70
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 3),
|
|
87
71
|
awc = _ref2[0],
|
|
@@ -89,22 +73,16 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
|
|
|
89
73
|
createPostInteractionLogPayloadPackage = _ref2[2];
|
|
90
74
|
if (awc.getAnalyticsWebClientPromise) {
|
|
91
75
|
awc.getAnalyticsWebClientPromise().then(function (client) {
|
|
92
|
-
var _config$
|
|
76
|
+
var _config$postInteracti;
|
|
93
77
|
var instance = client.getInstance();
|
|
94
78
|
sinkInteraction(instance, payloadPackage);
|
|
95
|
-
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
96
|
-
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
97
|
-
}
|
|
98
79
|
if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
|
|
99
80
|
sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
|
|
100
81
|
}
|
|
101
82
|
});
|
|
102
83
|
} else if (awc.sendOperationalEvent) {
|
|
103
|
-
var _config$
|
|
84
|
+
var _config$postInteracti2;
|
|
104
85
|
sinkInteraction(awc, payloadPackage);
|
|
105
|
-
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
106
|
-
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
107
|
-
}
|
|
108
86
|
if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
|
|
109
87
|
sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
|
|
110
88
|
}
|
|
@@ -32,7 +32,8 @@ var useLayoutEffectSAFE = typeof window === 'undefined' ? _react.useEffect : _re
|
|
|
32
32
|
* return (
|
|
33
33
|
* <>
|
|
34
34
|
* <Skeleton />
|
|
35
|
-
* <UFOLoadHold name="card"
|
|
35
|
+
* <UFOLoadHold name="card">
|
|
36
|
+
* </UFOLoadHold>
|
|
36
37
|
* )
|
|
37
38
|
* }
|
|
38
39
|
* ```
|
|
@@ -67,10 +68,7 @@ function UFOLoadHold(_ref) {
|
|
|
67
68
|
// react-18: useId instead
|
|
68
69
|
var context = (0, _react.useContext)(_interactionContext.default);
|
|
69
70
|
useLayoutEffectSAFE(function () {
|
|
70
|
-
if (hold && context != null) {
|
|
71
|
-
if (experimental && context.holdExperimental) {
|
|
72
|
-
return context.holdExperimental(name);
|
|
73
|
-
}
|
|
71
|
+
if (hold && !experimental && context != null) {
|
|
74
72
|
return context.hold(name);
|
|
75
73
|
}
|
|
76
74
|
}, [hold, context, name]);
|
|
@@ -91,14 +91,15 @@ function UFOSegment(_ref) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
function _internalHold(labelStack, name
|
|
95
|
-
|
|
94
|
+
function _internalHold(labelStack, name
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
96
|
+
) {
|
|
96
97
|
if (interactionId.current != null) {
|
|
97
98
|
if (parentContext) {
|
|
98
|
-
return parentContext._internalHold(labelStack, name
|
|
99
|
+
return parentContext._internalHold(labelStack, name);
|
|
99
100
|
} else {
|
|
100
101
|
var capturedInteractionId = interactionId.current;
|
|
101
|
-
var disposeHold = (0, _interactionMetrics.addHold)(interactionId.current, labelStack, name
|
|
102
|
+
var disposeHold = (0, _interactionMetrics.addHold)(interactionId.current, labelStack, name);
|
|
102
103
|
return function () {
|
|
103
104
|
if (capturedInteractionId === interactionId.current) {
|
|
104
105
|
disposeHold();
|
|
@@ -107,7 +108,9 @@ function UFOSegment(_ref) {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
function _internalHoldByID(labelStack, id, name, remove
|
|
111
|
+
function _internalHoldByID(labelStack, id, name, remove
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
113
|
+
) {
|
|
111
114
|
if (interactionId.current != null) {
|
|
112
115
|
if (parentContext) {
|
|
113
116
|
parentContext._internalHoldByID(labelStack, name, id, remove);
|
|
@@ -132,10 +135,6 @@ function UFOSegment(_ref) {
|
|
|
132
135
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
133
136
|
return this._internalHold(this.labelStack, name);
|
|
134
137
|
},
|
|
135
|
-
holdExperimental: function holdExperimental() {
|
|
136
|
-
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
137
|
-
return this._internalHold(this.labelStack, name, true);
|
|
138
|
-
},
|
|
139
138
|
addHoldByID: function addHoldByID(labelStack, id) {
|
|
140
139
|
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unknown';
|
|
141
140
|
this._internalHoldByID(labelStack, id, name, false);
|
|
@@ -67,28 +67,6 @@ export function getInteractionRate(name, interactionKind) {
|
|
|
67
67
|
return 0;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
export function getExperimentalInteractionRate(name, interactionType) {
|
|
71
|
-
try {
|
|
72
|
-
if (!config) {
|
|
73
|
-
return 0;
|
|
74
|
-
}
|
|
75
|
-
const {
|
|
76
|
-
experimentalInteractionMetrics
|
|
77
|
-
} = config;
|
|
78
|
-
if (!(experimentalInteractionMetrics !== null && experimentalInteractionMetrics !== void 0 && experimentalInteractionMetrics.enabled)) {
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
if (experimentalInteractionMetrics.rates && typeof experimentalInteractionMetrics.rates[name] === 'number') {
|
|
82
|
-
return experimentalInteractionMetrics.rates[name];
|
|
83
|
-
}
|
|
84
|
-
if (experimentalInteractionMetrics.kind && typeof experimentalInteractionMetrics.kind[interactionType] === 'number') {
|
|
85
|
-
return experimentalInteractionMetrics.kind[interactionType];
|
|
86
|
-
}
|
|
87
|
-
return 0;
|
|
88
|
-
} catch (e) {
|
|
89
|
-
return 0;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
70
|
export function getPostInteractionRate(name, interactionType) {
|
|
93
71
|
try {
|
|
94
72
|
if (!config) {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
|
2
|
-
|
|
3
2
|
import { REACT_UFO_VERSION } from '../../../common/constants';
|
|
4
|
-
import { getConfig } from '../../../config';
|
|
5
|
-
import { getPageVisibilityState } from '../../../hidden-timing';
|
|
6
|
-
import PostInteractionLog from '../../../interaction-metrics/post-interaction-log';
|
|
7
|
-
import { getSSRDoneTime } from '../../../ssr';
|
|
8
|
-
import { getVCObserver } from '../../../vc';
|
|
9
|
-
export const postInteractionLog = new PostInteractionLog();
|
|
10
3
|
export const sanitizeUfoName = name => {
|
|
11
4
|
return name.replace(/_/g, '-');
|
|
12
5
|
};
|
|
@@ -60,64 +53,4 @@ export function optimizeLabelStack(labelStack) {
|
|
|
60
53
|
s: ls.segmentId
|
|
61
54
|
} : {})
|
|
62
55
|
}));
|
|
63
|
-
}
|
|
64
|
-
export const getPageVisibilityUpToTTAI = interaction => {
|
|
65
|
-
const {
|
|
66
|
-
start,
|
|
67
|
-
end
|
|
68
|
-
} = interaction;
|
|
69
|
-
return getPageVisibilityState(start, end);
|
|
70
|
-
};
|
|
71
|
-
export const calculateVCMetrics = (interaction, prefix, getVCResultFn) => {
|
|
72
|
-
var _interaction$apdex, _interaction$apdex$;
|
|
73
|
-
const result = getVCResultFn({
|
|
74
|
-
start: interaction.start,
|
|
75
|
-
stop: interaction.end,
|
|
76
|
-
tti: (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime,
|
|
77
|
-
prefix,
|
|
78
|
-
vc: interaction.vc
|
|
79
|
-
});
|
|
80
|
-
const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
81
|
-
if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
85
|
-
if (interaction.abortReason || pageVisibilityUpToTTAI !== 'visible') {
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
};
|
|
90
|
-
export function getSSRDoneTimeValue(config) {
|
|
91
|
-
var _config$ssr, _config$ssr2;
|
|
92
|
-
return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : getSSRDoneTime();
|
|
93
|
-
}
|
|
94
|
-
export const getVCMetrics = interaction => {
|
|
95
|
-
var _config$vc, _config$vc$ssrWhiteli, _result$metricsVc;
|
|
96
|
-
const config = getConfig();
|
|
97
|
-
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
98
|
-
return {};
|
|
99
|
-
}
|
|
100
|
-
if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
101
|
-
return {};
|
|
102
|
-
}
|
|
103
|
-
const isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 ? void 0 : (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
|
|
104
|
-
const ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
105
|
-
ssr: getSSRDoneTimeValue(config)
|
|
106
|
-
} : null;
|
|
107
|
-
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
108
|
-
const result = calculateVCMetrics(interaction, 'ufo', getVCObserver().getVCResult);
|
|
109
|
-
getVCObserver().stop();
|
|
110
|
-
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
111
|
-
return {
|
|
112
|
-
...result,
|
|
113
|
-
'metric:vc90': result === null || result === void 0 ? void 0 : (_result$metricsVc = result['metrics:vc']) === null || _result$metricsVc === void 0 ? void 0 : _result$metricsVc['90']
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
export const getTTAI = interaction => {
|
|
117
|
-
const {
|
|
118
|
-
start,
|
|
119
|
-
end
|
|
120
|
-
} = interaction;
|
|
121
|
-
const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
122
|
-
return !interaction.abortReason && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
123
|
-
};
|
|
56
|
+
}
|
|
@@ -2,20 +2,19 @@ import Bowser from 'bowser-ultralight';
|
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
4
4
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
5
|
-
import coinflip from '../coinflip';
|
|
6
5
|
import { REACT_UFO_VERSION } from '../common/constants';
|
|
7
|
-
import { getConfig,
|
|
8
|
-
import { getExperimentalVCMetrics } from '../create-experimental-interaction-metrics-payload';
|
|
6
|
+
import { getConfig, getUfoNameOverrides } from '../config';
|
|
9
7
|
import { getBm3Timings } from '../custom-timings';
|
|
10
8
|
import { getGlobalErrorCount } from '../global-error-handler';
|
|
11
9
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
12
10
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
13
|
-
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
11
|
+
import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
|
|
14
12
|
import * as resourceTiming from '../resource-timing';
|
|
15
13
|
import { roundEpsilon } from '../round-number';
|
|
16
14
|
import * as ssr from '../ssr';
|
|
17
|
-
import {
|
|
18
|
-
|
|
15
|
+
import { getVCObserver } from '../vc';
|
|
16
|
+
import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
17
|
+
function getUfoNameOverride(interaction) {
|
|
19
18
|
const {
|
|
20
19
|
ufoName,
|
|
21
20
|
apdex
|
|
@@ -29,6 +28,7 @@ export function getUfoNameOverride(interaction) {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
return ufoName;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
32
|
} catch (e) {
|
|
33
33
|
return ufoName;
|
|
34
34
|
}
|
|
@@ -63,6 +63,13 @@ const getPageVisibilityUpToTTI = interaction => {
|
|
|
63
63
|
const bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
|
|
64
64
|
return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
|
|
65
65
|
};
|
|
66
|
+
const getPageVisibilityUpToTTAI = interaction => {
|
|
67
|
+
const {
|
|
68
|
+
start,
|
|
69
|
+
end
|
|
70
|
+
} = interaction;
|
|
71
|
+
return getPageVisibilityState(start, end);
|
|
72
|
+
};
|
|
66
73
|
const getVisibilityStateFromPerformance = stop => {
|
|
67
74
|
try {
|
|
68
75
|
const results = performance.getEntriesByType('visibility-state');
|
|
@@ -117,6 +124,15 @@ const getMoreAccuratePageVisibilityUpToTTAI = interaction => {
|
|
|
117
124
|
}
|
|
118
125
|
return old;
|
|
119
126
|
};
|
|
127
|
+
const getInteractionStatus = interaction => {
|
|
128
|
+
const originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
|
|
129
|
+
const hasBm3TTI = interaction.apdex.length > 0;
|
|
130
|
+
const overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
|
|
131
|
+
return {
|
|
132
|
+
originalInteractionStatus,
|
|
133
|
+
overrideStatus
|
|
134
|
+
};
|
|
135
|
+
};
|
|
120
136
|
const getResourceTimings = (start, end) => {
|
|
121
137
|
var _resourceTiming$getRe;
|
|
122
138
|
return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
|
|
@@ -139,6 +155,44 @@ const getPaintMetrics = type => {
|
|
|
139
155
|
});
|
|
140
156
|
return metrics;
|
|
141
157
|
};
|
|
158
|
+
const getVCMetrics = interaction => {
|
|
159
|
+
var _config$vc, _interaction$apdex, _interaction$apdex$;
|
|
160
|
+
const config = getConfig();
|
|
161
|
+
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
165
|
+
return {};
|
|
166
|
+
}
|
|
167
|
+
const ssr = interaction.type === 'page_load' && config !== null && config !== void 0 && config.ssr ? {
|
|
168
|
+
ssr: getSSRDoneTimeValue(config)
|
|
169
|
+
} : null;
|
|
170
|
+
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
171
|
+
const tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime;
|
|
172
|
+
const prefix = 'ufo';
|
|
173
|
+
const result = getVCObserver().getVCResult({
|
|
174
|
+
start: interaction.start,
|
|
175
|
+
stop: interaction.end,
|
|
176
|
+
tti,
|
|
177
|
+
prefix,
|
|
178
|
+
vc: interaction.vc,
|
|
179
|
+
...ssr
|
|
180
|
+
});
|
|
181
|
+
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
182
|
+
const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
183
|
+
if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
const interactionStatus = getInteractionStatus(interaction);
|
|
187
|
+
const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
188
|
+
if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
...result,
|
|
193
|
+
'metric:vc90': VC['90']
|
|
194
|
+
};
|
|
195
|
+
};
|
|
142
196
|
const getNavigationMetrics = type => {
|
|
143
197
|
if (type !== 'page_load') {
|
|
144
198
|
return {};
|
|
@@ -186,15 +240,16 @@ const getNavigationMetrics = type => {
|
|
|
186
240
|
};
|
|
187
241
|
};
|
|
188
242
|
const getPPSMetrics = interaction => {
|
|
189
|
-
var _interaction$
|
|
243
|
+
var _interaction$apdex2, _interaction$apdex2$;
|
|
190
244
|
const {
|
|
191
245
|
start,
|
|
192
246
|
end
|
|
193
247
|
} = interaction;
|
|
194
248
|
const config = getConfig();
|
|
249
|
+
const interactionStatus = getInteractionStatus(interaction);
|
|
195
250
|
const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
196
|
-
const tti = (_interaction$
|
|
197
|
-
const ttai =
|
|
251
|
+
const tti = (_interaction$apdex2 = interaction.apdex) === null || _interaction$apdex2 === void 0 ? void 0 : (_interaction$apdex2$ = _interaction$apdex2[0]) === null || _interaction$apdex2$ === void 0 ? void 0 : _interaction$apdex2$.stopTime;
|
|
252
|
+
const ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
198
253
|
const PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
|
|
199
254
|
start,
|
|
200
255
|
stop: tti
|
|
@@ -539,6 +594,10 @@ function getBm3TrackerTimings(interaction) {
|
|
|
539
594
|
legacyMetrics
|
|
540
595
|
};
|
|
541
596
|
}
|
|
597
|
+
function getSSRDoneTimeValue(config) {
|
|
598
|
+
var _config$ssr, _config$ssr2;
|
|
599
|
+
return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
|
|
600
|
+
}
|
|
542
601
|
function getPayloadSize(payload) {
|
|
543
602
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
544
603
|
}
|
|
@@ -581,15 +640,13 @@ function getStylesheetMetrics() {
|
|
|
581
640
|
return {};
|
|
582
641
|
}
|
|
583
642
|
}
|
|
584
|
-
let regularTTAI;
|
|
585
|
-
let expTTAI;
|
|
586
643
|
function getErrorCounts(interaction) {
|
|
587
644
|
return {
|
|
588
645
|
'ufo:errors:globalCount': getGlobalErrorCount(),
|
|
589
646
|
'ufo:errors:count': interaction.errors.length
|
|
590
647
|
};
|
|
591
648
|
}
|
|
592
|
-
function createInteractionMetricsPayload(interaction, interactionId
|
|
649
|
+
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
593
650
|
var _window$location, _config$additionalPay;
|
|
594
651
|
const interactionPayloadStart = performance.now();
|
|
595
652
|
const config = getConfig();
|
|
@@ -624,7 +681,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
624
681
|
} : {};
|
|
625
682
|
// Page Load
|
|
626
683
|
const getPageLoadInteractionMetrics = () => {
|
|
627
|
-
var _config$
|
|
684
|
+
var _config$ssr3;
|
|
628
685
|
if (!isPageLoad) {
|
|
629
686
|
return {};
|
|
630
687
|
}
|
|
@@ -636,12 +693,12 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
636
693
|
return {
|
|
637
694
|
...SSRDoneTime,
|
|
638
695
|
isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
|
|
639
|
-
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$
|
|
696
|
+
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr3 = config.ssr) !== null && _config$ssr3 !== void 0 && _config$ssr3.getSSRDoneTime)
|
|
640
697
|
};
|
|
641
698
|
};
|
|
642
699
|
// Detailed payload. Page visibility = visible
|
|
643
700
|
const getDetailedInteractionMetrics = () => {
|
|
644
|
-
if (
|
|
701
|
+
if (window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
645
702
|
return {};
|
|
646
703
|
}
|
|
647
704
|
const spans = [...interaction.spans, ...atlaskitInteractionSpans];
|
|
@@ -656,7 +713,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
656
713
|
})),
|
|
657
714
|
holdActive: [...interaction.holdActive.values()],
|
|
658
715
|
redirects: optimizeRedirects(interaction.redirects, start),
|
|
659
|
-
holdInfo: optimizeHoldInfo(
|
|
716
|
+
holdInfo: optimizeHoldInfo(interaction.holdInfo, start),
|
|
660
717
|
spans: optimizeSpans(spans, start),
|
|
661
718
|
requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
|
|
662
719
|
customTimings: optimizeCustomTimings(interaction.customTimings, start),
|
|
@@ -666,21 +723,16 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
666
723
|
};
|
|
667
724
|
// Page load & detailed payload
|
|
668
725
|
const getPageLoadDetailedInteractionMetrics = () => {
|
|
669
|
-
var _config$
|
|
726
|
+
var _config$ssr4;
|
|
670
727
|
if (!isPageLoad || !isDetailedPayload) {
|
|
671
728
|
return {};
|
|
672
729
|
}
|
|
673
730
|
const config = getConfig();
|
|
674
731
|
return {
|
|
675
732
|
initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
|
|
676
|
-
SSRTimings: config !== null && config !== void 0 && (_config$
|
|
733
|
+
SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
|
|
677
734
|
};
|
|
678
735
|
};
|
|
679
|
-
if (experimental) {
|
|
680
|
-
expTTAI = getTTAI(interaction);
|
|
681
|
-
} else {
|
|
682
|
-
regularTTAI = getTTAI(interaction);
|
|
683
|
-
}
|
|
684
736
|
const newUFOName = sanitizeUfoName(ufoName);
|
|
685
737
|
const payload = {
|
|
686
738
|
actionSubject: 'experience',
|
|
@@ -701,7 +753,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
701
753
|
payloadSource: 'platform'
|
|
702
754
|
},
|
|
703
755
|
'event:region': config.region || 'unknown',
|
|
704
|
-
'experience:key':
|
|
756
|
+
'experience:key': 'custom.interaction-metrics',
|
|
705
757
|
'experience:name': newUFOName,
|
|
706
758
|
// root
|
|
707
759
|
...getBrowserMetadata(),
|
|
@@ -710,7 +762,6 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
710
762
|
...getPaintMetrics(type),
|
|
711
763
|
...getNavigationMetrics(type),
|
|
712
764
|
...getVCMetrics(interaction),
|
|
713
|
-
...(experimental ? getExperimentalVCMetrics(interaction) : undefined),
|
|
714
765
|
...((_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)),
|
|
715
766
|
...getTracingContextData(interaction),
|
|
716
767
|
...getStylesheetMetrics(),
|
|
@@ -750,18 +801,12 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
750
801
|
...getPageLoadInteractionMetrics(),
|
|
751
802
|
...getDetailedInteractionMetrics(),
|
|
752
803
|
...getPageLoadDetailedInteractionMetrics(),
|
|
753
|
-
...getBm3TrackerTimings(interaction)
|
|
754
|
-
'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
|
|
755
|
-
'metric:experimental:ttai': expTTAI
|
|
804
|
+
...getBm3TrackerTimings(interaction)
|
|
756
805
|
},
|
|
757
806
|
'ufo:payloadTime': roundEpsilon(performance.now() - interactionPayloadStart)
|
|
758
807
|
}
|
|
759
808
|
}
|
|
760
809
|
};
|
|
761
|
-
if (experimental) {
|
|
762
|
-
regularTTAI = undefined;
|
|
763
|
-
expTTAI = undefined;
|
|
764
|
-
}
|
|
765
810
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
766
811
|
return payload;
|
|
767
812
|
}
|
|
@@ -773,20 +818,4 @@ export function createPayloads(interactionId, interaction) {
|
|
|
773
818
|
};
|
|
774
819
|
const interactionMetricsPayload = createInteractionMetricsPayload(modifiedInteraction, interactionId);
|
|
775
820
|
return [interactionMetricsPayload];
|
|
776
|
-
}
|
|
777
|
-
export function createExperimentalMetricsPayload(interactionId, interaction) {
|
|
778
|
-
const config = getConfig();
|
|
779
|
-
if (!config) {
|
|
780
|
-
throw Error('UFO Configuration not provided');
|
|
781
|
-
}
|
|
782
|
-
const ufoName = sanitizeUfoName(interaction.ufoName);
|
|
783
|
-
const rate = getExperimentalInteractionRate(ufoName, interaction.type);
|
|
784
|
-
if (!coinflip(rate)) {
|
|
785
|
-
return null;
|
|
786
|
-
}
|
|
787
|
-
const pageVisibilityState = getPageVisibilityState(interaction.start, interaction.end);
|
|
788
|
-
if (pageVisibilityState !== 'visible') {
|
|
789
|
-
return null;
|
|
790
|
-
}
|
|
791
|
-
return createInteractionMetricsPayload(interaction, interactionId, true);
|
|
792
821
|
}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export const CLEANUP_TIMEOUT_AFTER_APDEX = 15 * 1000;
|
|
4
|
-
export const interactionQueue = [];
|
|
5
|
-
export const segmentCache = new Map();
|
|
6
|
-
export const segmentObservers = [];
|
|
7
|
-
export const moduleLoadingRequests = {};
|
|
1
|
+
const interactions = new Map();
|
|
2
|
+
export default interactions;
|