@atlaskit/react-ufo 2.11.0 → 2.12.1
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 +20 -0
- package/create-experimental-interaction-metrics-payload/package.json +15 -0
- package/dist/cjs/config/index.js +42 -20
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +114 -0
- package/dist/cjs/create-payload/index.js +51 -10
- package/dist/cjs/interaction-metrics/common/constants.js +2 -3
- package/dist/cjs/interaction-metrics/index.js +130 -55
- package/dist/cjs/interaction-metrics/post-interaction-log.js +20 -10
- package/dist/cjs/interaction-metrics-init/index.js +28 -7
- package/dist/cjs/load-hold/UFOLoadHold.js +5 -3
- package/dist/cjs/segment/segment.js +9 -8
- package/dist/cjs/vc/vc-observer/index.js +1 -1
- package/dist/es2019/config/index.js +22 -0
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +85 -0
- package/dist/es2019/create-payload/index.js +50 -8
- package/dist/es2019/interaction-metrics/common/constants.js +1 -2
- package/dist/es2019/interaction-metrics/index.js +109 -28
- package/dist/es2019/interaction-metrics/post-interaction-log.js +21 -11
- package/dist/es2019/interaction-metrics-init/index.js +26 -7
- package/dist/es2019/load-hold/UFOLoadHold.js +5 -3
- package/dist/es2019/segment/segment.js +8 -11
- package/dist/es2019/vc/vc-observer/index.js +1 -0
- package/dist/esm/config/index.js +41 -20
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +104 -0
- package/dist/esm/create-payload/index.js +51 -11
- package/dist/esm/interaction-metrics/common/constants.js +1 -2
- package/dist/esm/interaction-metrics/index.js +102 -27
- package/dist/esm/interaction-metrics/post-interaction-log.js +20 -10
- package/dist/esm/interaction-metrics-init/index.js +26 -7
- package/dist/esm/load-hold/UFOLoadHold.js +5 -3
- package/dist/esm/segment/segment.js +9 -8
- package/dist/esm/vc/vc-observer/index.js +1 -1
- package/dist/types/common/common/types.d.ts +6 -4
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +16 -0
- package/dist/types/create-payload/index.d.ts +5922 -0
- package/dist/types/interaction-context/index.d.ts +1 -0
- package/dist/types/interaction-metrics/common/constants.d.ts +1 -2
- package/dist/types/interaction-metrics/index.d.ts +1 -1
- package/dist/types/load-hold/UFOLoadHold.d.ts +1 -2
- package/dist/types-ts4.5/common/common/types.d.ts +6 -4
- package/dist/types-ts4.5/config/index.d.ts +6 -0
- package/dist/types-ts4.5/create-experimental-interaction-metrics-payload/index.d.ts +16 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +5922 -0
- package/dist/types-ts4.5/interaction-context/index.d.ts +1 -0
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +1 -2
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +1 -1
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +1 -2
- package/package.json +3 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
2
2
|
import { startLighthouseObserver } from '../additional-payload';
|
|
3
3
|
import { setUFOConfig } from '../config';
|
|
4
|
+
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
4
5
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
5
6
|
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
6
7
|
import { getVCObserver } from '../vc';
|
|
@@ -15,6 +16,16 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
15
16
|
});
|
|
16
17
|
});
|
|
17
18
|
}
|
|
19
|
+
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
20
|
+
sinkExperimentalHandler((interactionId, interaction) => {
|
|
21
|
+
scheduleCallback(idlePriority, () => {
|
|
22
|
+
const payload = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
23
|
+
if (payload) {
|
|
24
|
+
instance.sendOperationalEvent(payload);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
18
29
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
19
30
|
sinkPostInteractionLogHandler(logOutput => {
|
|
20
31
|
scheduleCallback(idlePriority, () => {
|
|
@@ -32,6 +43,7 @@ export const init = (analyticsWebClientAsync, config) => {
|
|
|
32
43
|
}
|
|
33
44
|
setUFOConfig(config);
|
|
34
45
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
46
|
+
var _config$experimentalI;
|
|
35
47
|
const vcOptions = {
|
|
36
48
|
heatmapSize: config.vc.heatmapSize,
|
|
37
49
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
@@ -45,27 +57,34 @@ export const init = (analyticsWebClientAsync, config) => {
|
|
|
45
57
|
postInteractionLog.startVCObserver({
|
|
46
58
|
startTime: 0
|
|
47
59
|
});
|
|
60
|
+
if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
61
|
+
experimentalVC.initialize(vcOptions).start({
|
|
62
|
+
startTime: 0
|
|
63
|
+
});
|
|
64
|
+
}
|
|
48
65
|
}
|
|
49
66
|
setupHiddenTimingCapture();
|
|
50
67
|
startLighthouseObserver();
|
|
51
68
|
initialized = true;
|
|
52
|
-
Promise.all([analyticsWebClientAsync,
|
|
53
|
-
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
54
|
-
import( /* webpackChunkName: "create-payloads" */'../create-payload'),
|
|
55
|
-
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
56
|
-
import( /* webpackChunkName: "create-post-intreaction-log-payload" */'../create-post-interaction-log-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage]) => {
|
|
69
|
+
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage]) => {
|
|
57
70
|
if (awc.getAnalyticsWebClientPromise) {
|
|
58
71
|
awc.getAnalyticsWebClientPromise().then(client => {
|
|
59
|
-
var _config$postInteracti;
|
|
72
|
+
var _config$experimentalI2, _config$postInteracti;
|
|
60
73
|
const instance = client.getInstance();
|
|
61
74
|
sinkInteraction(instance, payloadPackage);
|
|
75
|
+
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
76
|
+
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
77
|
+
}
|
|
62
78
|
if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
|
|
63
79
|
sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
|
|
64
80
|
}
|
|
65
81
|
});
|
|
66
82
|
} else if (awc.sendOperationalEvent) {
|
|
67
|
-
var _config$postInteracti2;
|
|
83
|
+
var _config$experimentalI3, _config$postInteracti2;
|
|
68
84
|
sinkInteraction(awc, payloadPackage);
|
|
85
|
+
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
86
|
+
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
87
|
+
}
|
|
69
88
|
if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
|
|
70
89
|
sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
|
|
71
90
|
}
|
|
@@ -22,8 +22,7 @@ const useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayou
|
|
|
22
22
|
* return (
|
|
23
23
|
* <>
|
|
24
24
|
* <Skeleton />
|
|
25
|
-
* <UFOLoadHold name="card"
|
|
26
|
-
* </UFOLoadHold>
|
|
25
|
+
* <UFOLoadHold name="card" />
|
|
27
26
|
* )
|
|
28
27
|
* }
|
|
29
28
|
* ```
|
|
@@ -57,7 +56,10 @@ export default function UFOLoadHold({
|
|
|
57
56
|
// react-18: useId instead
|
|
58
57
|
const context = useContext(UFOInteractionContext);
|
|
59
58
|
useLayoutEffectSAFE(() => {
|
|
60
|
-
if (hold &&
|
|
59
|
+
if (hold && context != null) {
|
|
60
|
+
if (experimental && context.holdExperimental) {
|
|
61
|
+
return context.holdExperimental(name);
|
|
62
|
+
}
|
|
61
63
|
return context.hold(name);
|
|
62
64
|
}
|
|
63
65
|
}, [hold, context, name]);
|
|
@@ -67,15 +67,13 @@ export default function UFOSegment({
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function _internalHold(labelStack, name
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
72
|
-
) {
|
|
70
|
+
function _internalHold(labelStack, name, experimental = false) {
|
|
73
71
|
if (interactionId.current != null) {
|
|
74
72
|
if (parentContext) {
|
|
75
|
-
return parentContext._internalHold(labelStack, name);
|
|
73
|
+
return parentContext._internalHold(labelStack, name, experimental);
|
|
76
74
|
} else {
|
|
77
75
|
const capturedInteractionId = interactionId.current;
|
|
78
|
-
const disposeHold = addHold(interactionId.current, labelStack, name);
|
|
76
|
+
const disposeHold = addHold(interactionId.current, labelStack, name, experimental);
|
|
79
77
|
return () => {
|
|
80
78
|
if (capturedInteractionId === interactionId.current) {
|
|
81
79
|
disposeHold();
|
|
@@ -84,9 +82,7 @@ export default function UFOSegment({
|
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
|
-
function _internalHoldByID(labelStack, id, name, remove
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
89
|
-
) {
|
|
85
|
+
function _internalHoldByID(labelStack, id, name, remove) {
|
|
90
86
|
if (interactionId.current != null) {
|
|
91
87
|
if (parentContext) {
|
|
92
88
|
parentContext._internalHoldByID(labelStack, name, id, remove);
|
|
@@ -108,11 +104,12 @@ export default function UFOSegment({
|
|
|
108
104
|
}
|
|
109
105
|
return {
|
|
110
106
|
labelStack,
|
|
111
|
-
hold(name = 'unknown'
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
113
|
-
) {
|
|
107
|
+
hold(name = 'unknown') {
|
|
114
108
|
return this._internalHold(this.labelStack, name);
|
|
115
109
|
},
|
|
110
|
+
holdExperimental(name = 'unknown') {
|
|
111
|
+
return this._internalHold(this.labelStack, name, true);
|
|
112
|
+
},
|
|
116
113
|
addHoldByID(labelStack, id, name = 'unknown') {
|
|
117
114
|
this._internalHoldByID(labelStack, id, name, false);
|
|
118
115
|
},
|
|
@@ -220,6 +220,7 @@ export class VCObserver {
|
|
|
220
220
|
[`${fullPrefix}vc:ratios`]: ratios,
|
|
221
221
|
...outOfBoundary,
|
|
222
222
|
[`${fullPrefix}vc:next`]: vcNext.VC,
|
|
223
|
+
[`${fullPrefix}vc:next:updates`]: vcNext.VCEntries.rel.slice(0, 50),
|
|
223
224
|
//...oldDomUpdates,
|
|
224
225
|
[`${fullPrefix}vc:ignored`]: this.getIgnoredElements(componentsLog)
|
|
225
226
|
};
|
package/dist/esm/config/index.js
CHANGED
|
@@ -64,13 +64,34 @@ export function getInteractionRate(name, interactionKind) {
|
|
|
64
64
|
return 0;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
export function
|
|
67
|
+
export function getExperimentalInteractionRate(name, interactionType) {
|
|
68
68
|
try {
|
|
69
69
|
if (!config) {
|
|
70
70
|
return 0;
|
|
71
71
|
}
|
|
72
72
|
var _config2 = config,
|
|
73
|
-
|
|
73
|
+
experimentalInteractionMetrics = _config2.experimentalInteractionMetrics;
|
|
74
|
+
if (!(experimentalInteractionMetrics !== null && experimentalInteractionMetrics !== void 0 && experimentalInteractionMetrics.enabled)) {
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
if (experimentalInteractionMetrics.rates && typeof experimentalInteractionMetrics.rates[name] === 'number') {
|
|
78
|
+
return experimentalInteractionMetrics.rates[name];
|
|
79
|
+
}
|
|
80
|
+
if (experimentalInteractionMetrics.kind && typeof experimentalInteractionMetrics.kind[interactionType] === 'number') {
|
|
81
|
+
return experimentalInteractionMetrics.kind[interactionType];
|
|
82
|
+
}
|
|
83
|
+
return 0;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function getPostInteractionRate(name, interactionType) {
|
|
89
|
+
try {
|
|
90
|
+
if (!config) {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
var _config3 = config,
|
|
94
|
+
postInteractionLog = _config3.postInteractionLog;
|
|
74
95
|
if (!(postInteractionLog !== null && postInteractionLog !== void 0 && postInteractionLog.enabled)) {
|
|
75
96
|
return 0;
|
|
76
97
|
}
|
|
@@ -90,8 +111,8 @@ export function getCapabilityRate(capability) {
|
|
|
90
111
|
if (!config) {
|
|
91
112
|
return 0;
|
|
92
113
|
}
|
|
93
|
-
var
|
|
94
|
-
capabilityRate =
|
|
114
|
+
var _config4 = config,
|
|
115
|
+
capabilityRate = _config4.capability;
|
|
95
116
|
if (capabilityRate != null) {
|
|
96
117
|
var rate = capabilityRate[capability];
|
|
97
118
|
if (rate != null) {
|
|
@@ -110,8 +131,8 @@ export function getTypingPerformanceTracingMethod() {
|
|
|
110
131
|
if (!config) {
|
|
111
132
|
return defaultMethod;
|
|
112
133
|
}
|
|
113
|
-
var
|
|
114
|
-
typingMethod =
|
|
134
|
+
var _config5 = config,
|
|
135
|
+
typingMethod = _config5.typingMethod;
|
|
115
136
|
if (typingMethod != null && validTypingMethods.find(function (m) {
|
|
116
137
|
return m === typingMethod;
|
|
117
138
|
})) {
|
|
@@ -130,8 +151,8 @@ export function getAwaitBM3TTIList() {
|
|
|
130
151
|
if (!config) {
|
|
131
152
|
return [];
|
|
132
153
|
}
|
|
133
|
-
var
|
|
134
|
-
awaitBM3TTI =
|
|
154
|
+
var _config6 = config,
|
|
155
|
+
awaitBM3TTI = _config6.awaitBM3TTI;
|
|
135
156
|
if (awaitBM3TTI != null) {
|
|
136
157
|
return awaitBM3TTI;
|
|
137
158
|
} else {
|
|
@@ -148,8 +169,8 @@ export function getRemovePageSegmentsUFOPrefixes() {
|
|
|
148
169
|
if (!config) {
|
|
149
170
|
return false;
|
|
150
171
|
}
|
|
151
|
-
var
|
|
152
|
-
removePageSegmentsUFOPrefixes =
|
|
172
|
+
var _config7 = config,
|
|
173
|
+
removePageSegmentsUFOPrefixes = _config7.removePageSegmentsUFOPrefixes;
|
|
153
174
|
if (removePageSegmentsUFOPrefixes != null) {
|
|
154
175
|
return removePageSegmentsUFOPrefixes;
|
|
155
176
|
} else {
|
|
@@ -166,8 +187,8 @@ export function getRemoveInteractionsUFOPrefixes() {
|
|
|
166
187
|
if (!config) {
|
|
167
188
|
return false;
|
|
168
189
|
}
|
|
169
|
-
var
|
|
170
|
-
removeInteractionsUFOPrefixes =
|
|
190
|
+
var _config8 = config,
|
|
191
|
+
removeInteractionsUFOPrefixes = _config8.removeInteractionsUFOPrefixes;
|
|
171
192
|
if (removeInteractionsUFOPrefixes != null) {
|
|
172
193
|
return removeInteractionsUFOPrefixes;
|
|
173
194
|
} else {
|
|
@@ -187,8 +208,8 @@ export function getUfoNameOverrides() {
|
|
|
187
208
|
if (!config) {
|
|
188
209
|
return undefined;
|
|
189
210
|
}
|
|
190
|
-
var
|
|
191
|
-
ufoNameOverrides =
|
|
211
|
+
var _config9 = config,
|
|
212
|
+
ufoNameOverrides = _config9.ufoNameOverrides;
|
|
192
213
|
if (ufoNameOverrides != null) {
|
|
193
214
|
return ufoNameOverrides;
|
|
194
215
|
}
|
|
@@ -204,8 +225,8 @@ export function getDoNotAbortActivePressInteraction() {
|
|
|
204
225
|
if (!config) {
|
|
205
226
|
return undefined;
|
|
206
227
|
}
|
|
207
|
-
var
|
|
208
|
-
doNotAbortActivePressInteraction =
|
|
228
|
+
var _config10 = config,
|
|
229
|
+
doNotAbortActivePressInteraction = _config10.doNotAbortActivePressInteraction;
|
|
209
230
|
return doNotAbortActivePressInteraction;
|
|
210
231
|
} catch (e) {
|
|
211
232
|
return undefined;
|
|
@@ -218,8 +239,8 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
|
|
|
218
239
|
if (!config) {
|
|
219
240
|
return undefined;
|
|
220
241
|
}
|
|
221
|
-
var
|
|
222
|
-
doNotAbortActivePressInteractionOnTransition =
|
|
242
|
+
var _config11 = config,
|
|
243
|
+
doNotAbortActivePressInteractionOnTransition = _config11.doNotAbortActivePressInteractionOnTransition;
|
|
223
244
|
return doNotAbortActivePressInteractionOnTransition;
|
|
224
245
|
} catch (e) {
|
|
225
246
|
return undefined;
|
|
@@ -227,8 +248,8 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
|
|
|
227
248
|
}
|
|
228
249
|
export function shouldHandleEditorLnv() {
|
|
229
250
|
try {
|
|
230
|
-
var _config$enableEditorL,
|
|
231
|
-
return (_config$enableEditorL = (
|
|
251
|
+
var _config$enableEditorL, _config12;
|
|
252
|
+
return (_config$enableEditorL = (_config12 = config) === null || _config12 === void 0 ? void 0 : _config12.enableEditorLnvHandler) !== null && _config$enableEditorL !== void 0 ? _config$enableEditorL : false;
|
|
232
253
|
} catch (e) {
|
|
233
254
|
return false;
|
|
234
255
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
|
+
import { getPageVisibilityState } from '../hidden-timing';
|
|
10
|
+
import { VCObserver } from '../vc/vc-observer';
|
|
11
|
+
var interactionBuffer = [];
|
|
12
|
+
var bufferInteractionData = function bufferInteractionData(interactionId, data) {
|
|
13
|
+
interactionBuffer.push({
|
|
14
|
+
interactionId: interactionId,
|
|
15
|
+
data: data
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
function clearInteractionBuffer() {
|
|
19
|
+
interactionBuffer.length = 0;
|
|
20
|
+
}
|
|
21
|
+
function appendInteractionData(interactionId, data) {
|
|
22
|
+
bufferInteractionData(interactionId, data);
|
|
23
|
+
}
|
|
24
|
+
export function installInteractionSink(handler) {
|
|
25
|
+
var _iterator = _createForOfIteratorHelper(interactionBuffer),
|
|
26
|
+
_step;
|
|
27
|
+
try {
|
|
28
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
29
|
+
var _step$value = _step.value,
|
|
30
|
+
_interactionId = _step$value.interactionId,
|
|
31
|
+
data = _step$value.data;
|
|
32
|
+
handler(_interactionId, data);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_iterator.e(err);
|
|
36
|
+
} finally {
|
|
37
|
+
_iterator.f();
|
|
38
|
+
}
|
|
39
|
+
clearInteractionBuffer();
|
|
40
|
+
bufferInteractionData = handler;
|
|
41
|
+
}
|
|
42
|
+
export function sinkExperimentalHandler(sinkFn) {
|
|
43
|
+
installInteractionSink(sinkFn);
|
|
44
|
+
}
|
|
45
|
+
export function onExperimentalInteractionComplete(interactionId, data) {
|
|
46
|
+
var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
|
|
47
|
+
if (data.ufoName) {
|
|
48
|
+
data.end = endTime;
|
|
49
|
+
appendInteractionData(interactionId, data);
|
|
50
|
+
clearInteractionBuffer();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export var ExperimentalVCMetrics = /*#__PURE__*/function () {
|
|
54
|
+
function ExperimentalVCMetrics() {
|
|
55
|
+
_classCallCheck(this, ExperimentalVCMetrics);
|
|
56
|
+
_defineProperty(this, "vcObserver", null);
|
|
57
|
+
}
|
|
58
|
+
return _createClass(ExperimentalVCMetrics, [{
|
|
59
|
+
key: "initialize",
|
|
60
|
+
value: function initialize(options) {
|
|
61
|
+
if (this.vcObserver === null) {
|
|
62
|
+
this.vcObserver = new VCObserver(_objectSpread(_objectSpread({}, options), {}, {
|
|
63
|
+
isPostInteraction: true
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "start",
|
|
70
|
+
value: function start(_ref) {
|
|
71
|
+
var _this$vcObserver;
|
|
72
|
+
var startTime = _ref.startTime;
|
|
73
|
+
(_this$vcObserver = this.vcObserver) === null || _this$vcObserver === void 0 || _this$vcObserver.start({
|
|
74
|
+
startTime: startTime
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}]);
|
|
78
|
+
}();
|
|
79
|
+
export var experimentalVC = new ExperimentalVCMetrics();
|
|
80
|
+
export var getExperimentalVCMetrics = function getExperimentalVCMetrics(interaction) {
|
|
81
|
+
if (experimentalVC.vcObserver) {
|
|
82
|
+
var _interaction$apdex;
|
|
83
|
+
var prefix = 'ufo-experimental';
|
|
84
|
+
var result = experimentalVC.vcObserver.getVCResult({
|
|
85
|
+
start: interaction.start,
|
|
86
|
+
stop: interaction.end,
|
|
87
|
+
tti: (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime,
|
|
88
|
+
prefix: prefix,
|
|
89
|
+
vc: interaction.vc
|
|
90
|
+
});
|
|
91
|
+
var VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
92
|
+
if (!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")])) {
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
var pageVisibilityUpToTTAI = getPageVisibilityState(interaction.start, interaction.end);
|
|
96
|
+
if (interaction.abortReason || pageVisibilityUpToTTAI !== 'visible') {
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
100
|
+
'metric:experimental:vc90': VC['90']
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
@@ -12,8 +12,10 @@ import Bowser from 'bowser-ultralight';
|
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
14
14
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
15
|
+
import coinflip from '../coinflip';
|
|
15
16
|
import { REACT_UFO_VERSION } from '../common/constants';
|
|
16
|
-
import { getConfig, getUfoNameOverrides } from '../config';
|
|
17
|
+
import { getConfig, getExperimentalInteractionRate, getUfoNameOverrides } from '../config';
|
|
18
|
+
import { getExperimentalVCMetrics } from '../create-experimental-interaction-metrics-payload';
|
|
17
19
|
import { getBm3Timings } from '../custom-timings';
|
|
18
20
|
import { getGlobalErrorCount } from '../global-error-handler';
|
|
19
21
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
@@ -36,7 +38,6 @@ function getUfoNameOverride(interaction) {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
return ufoName;
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
41
|
} catch (e) {
|
|
41
42
|
return ufoName;
|
|
42
43
|
}
|
|
@@ -168,8 +169,14 @@ var getPaintMetrics = function getPaintMetrics(type) {
|
|
|
168
169
|
});
|
|
169
170
|
return metrics;
|
|
170
171
|
};
|
|
172
|
+
var getTTAI = function getTTAI(interaction) {
|
|
173
|
+
var start = interaction.start,
|
|
174
|
+
end = interaction.end;
|
|
175
|
+
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
176
|
+
return !interaction.abortReason && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
177
|
+
};
|
|
171
178
|
var getVCMetrics = function getVCMetrics(interaction) {
|
|
172
|
-
var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex;
|
|
179
|
+
var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI;
|
|
173
180
|
var config = getConfig();
|
|
174
181
|
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
175
182
|
return {};
|
|
@@ -191,6 +198,9 @@ var getVCMetrics = function getVCMetrics(interaction) {
|
|
|
191
198
|
prefix: prefix,
|
|
192
199
|
vc: interaction.vc
|
|
193
200
|
}, ssr));
|
|
201
|
+
if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
202
|
+
getVCObserver().stop();
|
|
203
|
+
}
|
|
194
204
|
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
195
205
|
var VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
196
206
|
if (!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")])) {
|
|
@@ -639,13 +649,15 @@ function getStylesheetMetrics() {
|
|
|
639
649
|
return {};
|
|
640
650
|
}
|
|
641
651
|
}
|
|
652
|
+
var regularTTAI;
|
|
653
|
+
var expTTAI;
|
|
642
654
|
function getErrorCounts(interaction) {
|
|
643
655
|
return {
|
|
644
656
|
'ufo:errors:globalCount': getGlobalErrorCount(),
|
|
645
657
|
'ufo:errors:count': interaction.errors.length
|
|
646
658
|
};
|
|
647
659
|
}
|
|
648
|
-
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
660
|
+
function createInteractionMetricsPayload(interaction, interactionId, experimental) {
|
|
649
661
|
var _window$location, _config$additionalPay;
|
|
650
662
|
var interactionPayloadStart = performance.now();
|
|
651
663
|
var config = getConfig();
|
|
@@ -696,7 +708,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
696
708
|
};
|
|
697
709
|
// Detailed payload. Page visibility = visible
|
|
698
710
|
var getDetailedInteractionMetrics = function getDetailedInteractionMetrics() {
|
|
699
|
-
if (window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
711
|
+
if (experimental || window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
700
712
|
return {};
|
|
701
713
|
}
|
|
702
714
|
var spans = [].concat(_toConsumableArray(interaction.spans), _toConsumableArray(atlaskitInteractionSpans));
|
|
@@ -711,7 +723,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
711
723
|
}),
|
|
712
724
|
holdActive: _toConsumableArray(interaction.holdActive.values()),
|
|
713
725
|
redirects: optimizeRedirects(interaction.redirects, start),
|
|
714
|
-
holdInfo: optimizeHoldInfo(interaction.holdInfo, start),
|
|
726
|
+
holdInfo: optimizeHoldInfo(experimental ? interaction.holdExpInfo : interaction.holdInfo, start),
|
|
715
727
|
spans: optimizeSpans(spans, start),
|
|
716
728
|
requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
|
|
717
729
|
customTimings: optimizeCustomTimings(interaction.customTimings, start),
|
|
@@ -731,6 +743,11 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
731
743
|
SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
|
|
732
744
|
};
|
|
733
745
|
};
|
|
746
|
+
if (experimental) {
|
|
747
|
+
expTTAI = getTTAI(interaction);
|
|
748
|
+
} else {
|
|
749
|
+
regularTTAI = getTTAI(interaction);
|
|
750
|
+
}
|
|
734
751
|
var newUFOName = sanitizeUfoName(ufoName);
|
|
735
752
|
var payload = {
|
|
736
753
|
actionSubject: 'experience',
|
|
@@ -739,7 +756,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
739
756
|
source: 'measured',
|
|
740
757
|
tags: ['observability'],
|
|
741
758
|
attributes: {
|
|
742
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
759
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
743
760
|
// basic
|
|
744
761
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
745
762
|
'event:product': config.product,
|
|
@@ -751,10 +768,10 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
751
768
|
payloadSource: 'platform'
|
|
752
769
|
},
|
|
753
770
|
'event:region': config.region || 'unknown',
|
|
754
|
-
'experience:key': 'custom.interaction-metrics',
|
|
771
|
+
'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
|
|
755
772
|
'experience:name': newUFOName
|
|
756
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
|
|
757
|
-
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
773
|
+
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), experimental ? getExperimentalVCMetrics(interaction) : undefined), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
|
|
774
|
+
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
758
775
|
namePrefix: config.namePrefix || '',
|
|
759
776
|
segmentPrefix: config.segmentPrefix || '',
|
|
760
777
|
interactionId: interactionId,
|
|
@@ -785,11 +802,18 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
785
802
|
marks: optimizeMarks(interaction.marks),
|
|
786
803
|
customData: optimizeCustomData(interaction),
|
|
787
804
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
|
|
788
|
-
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
805
|
+
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)), {}, {
|
|
806
|
+
'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
|
|
807
|
+
'metric:experimental:ttai': expTTAI
|
|
808
|
+
}),
|
|
789
809
|
'ufo:payloadTime': roundEpsilon(performance.now() - interactionPayloadStart)
|
|
790
810
|
})
|
|
791
811
|
}
|
|
792
812
|
};
|
|
813
|
+
if (experimental) {
|
|
814
|
+
regularTTAI = undefined;
|
|
815
|
+
expTTAI = undefined;
|
|
816
|
+
}
|
|
793
817
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
794
818
|
return payload;
|
|
795
819
|
}
|
|
@@ -800,4 +824,20 @@ export function createPayloads(interactionId, interaction) {
|
|
|
800
824
|
});
|
|
801
825
|
var interactionMetricsPayload = createInteractionMetricsPayload(modifiedInteraction, interactionId);
|
|
802
826
|
return [interactionMetricsPayload];
|
|
827
|
+
}
|
|
828
|
+
export function createExperimentalMetricsPayload(interactionId, interaction) {
|
|
829
|
+
var config = getConfig();
|
|
830
|
+
if (!config) {
|
|
831
|
+
throw Error('UFO Configuration not provided');
|
|
832
|
+
}
|
|
833
|
+
var ufoName = sanitizeUfoName(interaction.ufoName);
|
|
834
|
+
var rate = getExperimentalInteractionRate(ufoName, interaction.type);
|
|
835
|
+
if (!coinflip(rate)) {
|
|
836
|
+
return null;
|
|
837
|
+
}
|
|
838
|
+
var pageVisibilityState = getPageVisibilityState(interaction.start, interaction.end);
|
|
839
|
+
if (pageVisibilityState !== 'visible') {
|
|
840
|
+
return null;
|
|
841
|
+
}
|
|
842
|
+
return createInteractionMetricsPayload(interaction, interactionId, true);
|
|
803
843
|
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var interactions = new Map();
|
|
2
|
-
export default interactions;
|
|
1
|
+
export var interactions = new Map();
|