@atlaskit/react-ufo 4.4.2 → 4.4.4
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 +18 -0
- package/dist/cjs/create-interaction-extra-metrics-payload/index.js +116 -0
- package/dist/cjs/create-payload/index.js +3 -2
- package/dist/cjs/create-payload/utils/get-vc-metrics.js +37 -21
- package/dist/cjs/interaction-metrics/index.js +306 -232
- package/dist/cjs/interaction-metrics/interaction-extra-metrics.js +89 -0
- package/dist/cjs/interaction-metrics-init/index.js +51 -7
- package/dist/cjs/segment/third-party-segment.js +3 -1
- package/dist/cjs/ssr/index.js +3 -2
- package/dist/cjs/trace-interaction/internal/trace-ufo-interaction.js +3 -8
- package/dist/cjs/vc/index.js +4 -3
- package/dist/cjs/vc/vc-observer/index.js +3 -46
- package/dist/cjs/vc/vc-observer-new/index.js +4 -3
- package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +3 -3
- package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +4 -4
- package/dist/es2019/create-interaction-extra-metrics-payload/index.js +93 -0
- package/dist/es2019/create-payload/index.js +3 -3
- package/dist/es2019/create-payload/utils/get-vc-metrics.js +3 -2
- package/dist/es2019/interaction-metrics/index.js +310 -233
- package/dist/es2019/interaction-metrics/interaction-extra-metrics.js +63 -0
- package/dist/es2019/interaction-metrics-init/index.js +29 -2
- package/dist/es2019/segment/third-party-segment.js +3 -1
- package/dist/es2019/ssr/index.js +3 -2
- package/dist/es2019/trace-interaction/internal/trace-ufo-interaction.js +3 -8
- package/dist/es2019/vc/index.js +4 -2
- package/dist/es2019/vc/vc-observer/index.js +0 -43
- package/dist/es2019/vc/vc-observer-new/index.js +4 -2
- package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +3 -2
- package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +4 -4
- package/dist/esm/create-interaction-extra-metrics-payload/index.js +109 -0
- package/dist/esm/create-payload/index.js +3 -3
- package/dist/esm/create-payload/utils/get-vc-metrics.js +37 -21
- package/dist/esm/interaction-metrics/index.js +305 -231
- package/dist/esm/interaction-metrics/interaction-extra-metrics.js +83 -0
- package/dist/esm/interaction-metrics-init/index.js +48 -6
- package/dist/esm/segment/third-party-segment.js +3 -1
- package/dist/esm/ssr/index.js +3 -2
- package/dist/esm/trace-interaction/internal/trace-ufo-interaction.js +3 -8
- package/dist/esm/vc/index.js +4 -3
- package/dist/esm/vc/vc-observer/index.js +3 -46
- package/dist/esm/vc/vc-observer-new/index.js +4 -3
- package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +3 -3
- package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +4 -4
- package/dist/types/common/common/types.d.ts +2 -0
- package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +45 -0
- package/dist/types/create-payload/index.d.ts +1 -0
- package/dist/types/create-payload/utils/get-vc-metrics.d.ts +1 -1
- package/dist/types/interaction-metrics/index.d.ts +2 -0
- package/dist/types/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
- package/dist/types/vc/types.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +2 -2
- package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/types.d.ts +1 -0
- package/dist/types-ts4.5/common/common/types.d.ts +2 -0
- package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +45 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +1 -0
- package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +1 -1
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +2 -0
- package/dist/types-ts4.5/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
- package/dist/types-ts4.5/vc/types.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +2 -2
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +1 -0
- package/package.json +4 -10
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { VCObserverWrapper } from '../vc';
|
|
3
|
+
import { interactions } from './common/constants';
|
|
4
|
+
import { remove } from './index';
|
|
5
|
+
export default class InteractionExtraMetrics {
|
|
6
|
+
constructor() {
|
|
7
|
+
// Store the finished interaction ID (as non-3p interaction)
|
|
8
|
+
_defineProperty(this, "finishedInteractionId", null);
|
|
9
|
+
// independent VC observer, that observes until `custom.post-interaction-logs` event is sent
|
|
10
|
+
_defineProperty(this, "vcObserver", null);
|
|
11
|
+
_defineProperty(this, "sinkHandlerFn", () => {});
|
|
12
|
+
}
|
|
13
|
+
initializeVCObserver(options) {
|
|
14
|
+
this.vcObserver = new VCObserverWrapper({
|
|
15
|
+
...options,
|
|
16
|
+
isPostInteraction: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
startVCObserver({
|
|
20
|
+
startTime
|
|
21
|
+
}, interactionId) {
|
|
22
|
+
if (this.eligibleToMeasure(interactionId)) {
|
|
23
|
+
var _this$vcObserver;
|
|
24
|
+
(_this$vcObserver = this.vcObserver) === null || _this$vcObserver === void 0 ? void 0 : _this$vcObserver.start({
|
|
25
|
+
startTime
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
stopVCObserver() {
|
|
30
|
+
var _this$vcObserver2;
|
|
31
|
+
(_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 ? void 0 : _this$vcObserver2.stop();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Check if the current interaction is eligible for measurement
|
|
35
|
+
eligibleToMeasure(interactionId) {
|
|
36
|
+
const interaction = interactions.get(interactionId);
|
|
37
|
+
return (interaction === null || interaction === void 0 ? void 0 : interaction.type) === 'page_load' || (interaction === null || interaction === void 0 ? void 0 : interaction.type) === 'transition';
|
|
38
|
+
}
|
|
39
|
+
updateFinishedInteractionId(interactionId) {
|
|
40
|
+
if (this.eligibleToMeasure(interactionId)) {
|
|
41
|
+
this.finishedInteractionId = interactionId;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
sinkHandler(fn) {
|
|
45
|
+
this.sinkHandlerFn = fn;
|
|
46
|
+
}
|
|
47
|
+
onInteractionComplete(id, data) {
|
|
48
|
+
if (data.ufoName) {
|
|
49
|
+
var _this$vcObserver3;
|
|
50
|
+
const updatedData = {
|
|
51
|
+
...data,
|
|
52
|
+
vcObserver: (_this$vcObserver3 = this.vcObserver) !== null && _this$vcObserver3 !== void 0 ? _this$vcObserver3 : undefined
|
|
53
|
+
};
|
|
54
|
+
this.sinkHandlerFn(id, updatedData);
|
|
55
|
+
}
|
|
56
|
+
this.stopVCObserver();
|
|
57
|
+
remove(id);
|
|
58
|
+
this.reset();
|
|
59
|
+
}
|
|
60
|
+
reset() {
|
|
61
|
+
this.finishedInteractionId = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -3,7 +3,7 @@ import { startLighthouseObserver } from '../additional-payload';
|
|
|
3
3
|
import { setUFOConfig } from '../config';
|
|
4
4
|
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
5
5
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
6
|
-
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
6
|
+
import { interactionExtraMetrics, postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
7
7
|
import { getPerformanceObserver } from '../interactions-performance-observer';
|
|
8
8
|
import { initialiseMemoryObserver, initialisePressureObserver } from '../machine-utilisation';
|
|
9
9
|
import scheduleIdleCallback from './schedule-idle-callback';
|
|
@@ -68,6 +68,24 @@ function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
function sinkInteractionExtraMetrics(instance, createInteractionExtraLogPayload) {
|
|
72
|
+
interactionExtraMetrics.sinkHandler((interactionId, interaction) => {
|
|
73
|
+
scheduleIdleCallback(async () => {
|
|
74
|
+
const payload = await createInteractionExtraLogPayload(interactionId, interaction);
|
|
75
|
+
if (payload) {
|
|
76
|
+
// NOTE: This API is used by the UFO DevTool Chrome Extension and also by Criterion
|
|
77
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
78
|
+
if (fg('enable_ufo_devtools_api_for_extra_events')) {
|
|
79
|
+
const devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
80
|
+
if (typeof devToolObserver === 'function') {
|
|
81
|
+
devToolObserver === null || devToolObserver === void 0 ? void 0 : devToolObserver(payload);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
instance.sendOperationalEvent(payload);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
71
89
|
export function init(analyticsWebClientAsync, config) {
|
|
72
90
|
var _config$vc;
|
|
73
91
|
if (initialized) {
|
|
@@ -93,6 +111,9 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
93
111
|
startTime: 0
|
|
94
112
|
});
|
|
95
113
|
}
|
|
114
|
+
if (fg('platform_ufo_enable_ttai_with_3p')) {
|
|
115
|
+
interactionExtraMetrics.initializeVCObserver(vcOptions);
|
|
116
|
+
}
|
|
96
117
|
}
|
|
97
118
|
setupHiddenTimingCapture();
|
|
98
119
|
startLighthouseObserver();
|
|
@@ -105,7 +126,7 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
105
126
|
durationThreshold: 16
|
|
106
127
|
});
|
|
107
128
|
}
|
|
108
|
-
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]) => {
|
|
129
|
+
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'), import( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage, createInteractionExtraMetricsPayloadPackage]) => {
|
|
109
130
|
if (awc.getAnalyticsWebClientPromise) {
|
|
110
131
|
awc.getAnalyticsWebClientPromise().then(client => {
|
|
111
132
|
var _config$experimentalI2, _config$postInteracti;
|
|
@@ -117,6 +138,9 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
117
138
|
if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
|
|
118
139
|
sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
|
|
119
140
|
}
|
|
141
|
+
if (fg('platform_ufo_enable_ttai_with_3p')) {
|
|
142
|
+
sinkInteractionExtraMetrics(instance, createInteractionExtraMetricsPayloadPackage.default);
|
|
143
|
+
}
|
|
120
144
|
});
|
|
121
145
|
} else if (awc.sendOperationalEvent) {
|
|
122
146
|
var _config$experimentalI3, _config$postInteracti2;
|
|
@@ -127,6 +151,9 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
127
151
|
if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
|
|
128
152
|
sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
|
|
129
153
|
}
|
|
154
|
+
if (fg('platform_ufo_enable_ttai_with_3p')) {
|
|
155
|
+
sinkInteractionExtraMetrics(awc, createInteractionExtraMetricsPayloadPackage.default);
|
|
156
|
+
}
|
|
130
157
|
}
|
|
131
158
|
});
|
|
132
159
|
}
|
|
@@ -8,7 +8,9 @@ export function UFOThirdPartySegment(props) {
|
|
|
8
8
|
children,
|
|
9
9
|
...otherProps
|
|
10
10
|
} = props;
|
|
11
|
-
return /*#__PURE__*/React.createElement(UFOSegment, _extends({
|
|
11
|
+
return fg('platform_ufo_enable_ttai_with_3p') ? /*#__PURE__*/React.createElement(UFOSegment, _extends({
|
|
12
|
+
type: "third-party"
|
|
13
|
+
}, otherProps), children) : /*#__PURE__*/React.createElement(UFOSegment, _extends({
|
|
12
14
|
type: "third-party"
|
|
13
15
|
}, otherProps), /*#__PURE__*/React.createElement(UFOIgnoreHolds, {
|
|
14
16
|
ignore: fg('platform_ufo_exclude_3p_elements_from_ttai'),
|
package/dist/es2019/ssr/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
//
|
|
2
|
+
|
|
2
3
|
const NESTED_METRIC_SEPARATOR = '/';
|
|
3
4
|
function filterEntry(entry) {
|
|
4
5
|
return !(!entry || typeof entry !== 'object' || entry.startTime < 0 || entry.duration < 0);
|
|
@@ -7,7 +8,7 @@ function mapEntry(entry) {
|
|
|
7
8
|
return {
|
|
8
9
|
startTime: Math.round(entry.startTime),
|
|
9
10
|
duration: Math.round(entry.duration),
|
|
10
|
-
...(entry.size
|
|
11
|
+
...(entry.size ? {
|
|
11
12
|
size: Math.round(entry.size)
|
|
12
13
|
} : {})
|
|
13
14
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { v4 as createUUID } from 'uuid';
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import coinflip from '../../coinflip';
|
|
4
3
|
import { getDoNotAbortActivePressInteraction, getInteractionRate } from '../../config';
|
|
5
4
|
import { getActiveTrace, setInteractionActiveTrace } from '../../experience-trace-id-context';
|
|
@@ -15,15 +14,11 @@ function traceUFOInteraction(name, interactionType, startTime) {
|
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
17
16
|
} else {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
17
|
+
// Abort any existing interaction regardless of the coinflip outcome
|
|
18
|
+
// Ensures measurements are not carried over between distinct interactions
|
|
19
|
+
abortAll('new_interaction', name);
|
|
22
20
|
}
|
|
23
21
|
if (coinflip(rate)) {
|
|
24
|
-
if (!fg('platform_ufo_abort_measurement_fix')) {
|
|
25
|
-
abortAll('new_interaction', name);
|
|
26
|
-
}
|
|
27
22
|
const startTimestamp = startTime !== null && startTime !== void 0 ? startTime : performance.now();
|
|
28
23
|
const newId = createUUID();
|
|
29
24
|
DefaultInteractionID.current = newId;
|
package/dist/es2019/vc/index.js
CHANGED
|
@@ -94,14 +94,16 @@ export class VCObserverWrapper {
|
|
|
94
94
|
async getVCResult(param) {
|
|
95
95
|
var _this$oldVCObserver4, _this$newVCObserver3, _ref;
|
|
96
96
|
const {
|
|
97
|
-
experienceKey
|
|
97
|
+
experienceKey,
|
|
98
|
+
include3p
|
|
98
99
|
} = param;
|
|
99
100
|
const v1v2Result = isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey) ? await ((_this$oldVCObserver4 = this.oldVCObserver) === null || _this$oldVCObserver4 === void 0 ? void 0 : _this$oldVCObserver4.getVCResult(param)) : {};
|
|
100
101
|
const v3Result = isVCRevisionEnabled('fy25.03', experienceKey) ? await ((_this$newVCObserver3 = this.newVCObserver) === null || _this$newVCObserver3 === void 0 ? void 0 : _this$newVCObserver3.getVCResult({
|
|
101
102
|
start: param.start,
|
|
102
103
|
stop: param.stop,
|
|
103
104
|
interactionId: param.interactionId,
|
|
104
|
-
ssr: param.includeSSRInV3 ? param.ssr : undefined
|
|
105
|
+
ssr: param.includeSSRInV3 ? param.ssr : undefined,
|
|
106
|
+
include3p
|
|
105
107
|
})) : [];
|
|
106
108
|
if (!v3Result) {
|
|
107
109
|
return v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { isVCRevisionEnabled } from '../../config';
|
|
4
3
|
import { getActiveInteraction } from '../../interaction-metrics';
|
|
5
4
|
import { attachAbortListeners } from './attachAbortListeners';
|
|
@@ -183,48 +182,6 @@ export class VCObserver {
|
|
|
183
182
|
viewport,
|
|
184
183
|
fixSSRAttribution: includeSSRRatio
|
|
185
184
|
});
|
|
186
|
-
try {
|
|
187
|
-
if (!this.isPostInteraction) {
|
|
188
|
-
VCObserver.VCParts.forEach(key => {
|
|
189
|
-
if (isTTVCv1Disabled) {
|
|
190
|
-
const duration = vcNext.VC[key];
|
|
191
|
-
if (duration !== null && duration !== undefined) {
|
|
192
|
-
if (!fg('ufo_chrome_devtools_uplift')) {
|
|
193
|
-
performance.measure(`VC${key}`, {
|
|
194
|
-
start,
|
|
195
|
-
duration
|
|
196
|
-
});
|
|
197
|
-
performance.measure(`VC_Next${key}`, {
|
|
198
|
-
start,
|
|
199
|
-
duration
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
const ttvcV1duration = VC[key];
|
|
205
|
-
if (ttvcV1duration !== null && ttvcV1duration !== undefined) {
|
|
206
|
-
if (!fg('ufo_chrome_devtools_uplift')) {
|
|
207
|
-
performance.measure(`VC${key}`, {
|
|
208
|
-
start,
|
|
209
|
-
duration: ttvcV1duration
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const ttvcV2duration = vcNext.VC[key];
|
|
214
|
-
if (ttvcV2duration !== null && ttvcV2duration !== undefined) {
|
|
215
|
-
if (!fg('ufo_chrome_devtools_uplift')) {
|
|
216
|
-
performance.measure(`VC_Next${key}`, {
|
|
217
|
-
start,
|
|
218
|
-
duration: ttvcV2duration
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
} catch (e) {
|
|
226
|
-
/* empty */
|
|
227
|
-
}
|
|
228
185
|
const outOfBoundary = outOfBoundaryInfo ? {
|
|
229
186
|
[`${fullPrefix}vc:oob`]: outOfBoundaryInfo
|
|
230
187
|
} : {};
|
|
@@ -184,7 +184,8 @@ export default class VCObserverNew {
|
|
|
184
184
|
const {
|
|
185
185
|
start,
|
|
186
186
|
stop,
|
|
187
|
-
interactionId
|
|
187
|
+
interactionId,
|
|
188
|
+
include3p
|
|
188
189
|
} = param;
|
|
189
190
|
const results = [];
|
|
190
191
|
this.addStartEntry(start);
|
|
@@ -201,7 +202,8 @@ export default class VCObserverNew {
|
|
|
201
202
|
startTime: start,
|
|
202
203
|
stopTime: stop,
|
|
203
204
|
interactionId,
|
|
204
|
-
isPostInteraction: this.isPostInteraction
|
|
205
|
+
isPostInteraction: this.isPostInteraction,
|
|
206
|
+
include3p
|
|
205
207
|
});
|
|
206
208
|
if (fy25_03) {
|
|
207
209
|
results.push(fy25_03);
|
|
@@ -219,11 +219,12 @@ export default class AbstractVCCalculatorBase {
|
|
|
219
219
|
stopTime,
|
|
220
220
|
orderedEntries,
|
|
221
221
|
interactionId,
|
|
222
|
-
isPostInteraction
|
|
222
|
+
isPostInteraction,
|
|
223
|
+
include3p
|
|
223
224
|
}) {
|
|
224
225
|
var _vcDetails$90$t, _vcDetails$;
|
|
225
226
|
const filteredEntries = orderedEntries.filter(entry => {
|
|
226
|
-
return this.isEntryIncluded(entry);
|
|
227
|
+
return this.isEntryIncluded(entry, include3p);
|
|
227
228
|
});
|
|
228
229
|
let isVCClean;
|
|
229
230
|
let dirtyReason;
|
|
@@ -3,12 +3,12 @@ import AbstractVCCalculatorBase from '../abstract-base-vc-calculator';
|
|
|
3
3
|
import isViewportEntryData from '../utils/is-viewport-entry-data';
|
|
4
4
|
const ABORTING_WINDOW_EVENT = ['wheel', 'scroll', 'keydown', 'resize'];
|
|
5
5
|
const REVISION_NO = 'fy25.03';
|
|
6
|
-
const getConsideredEntryTypes =
|
|
6
|
+
const getConsideredEntryTypes = include3p => {
|
|
7
7
|
const entryTypes = ['mutation:child-element', 'mutation:element', 'mutation:attribute', 'layout-shift', 'window:event'];
|
|
8
8
|
|
|
9
9
|
// If not exclude 3p elements from ttvc,
|
|
10
10
|
// including the tags into the ConsideredEntryTypes so that it won't be ignored for TTVC calculation
|
|
11
|
-
if (!fg('platform_ufo_exclude_3p_elements_from_ttvc')) {
|
|
11
|
+
if (!fg('platform_ufo_exclude_3p_elements_from_ttvc') || include3p) {
|
|
12
12
|
entryTypes.push('mutation:third-party-element');
|
|
13
13
|
}
|
|
14
14
|
if (fg('platform_ufo_enable_media_for_ttvc_v3')) {
|
|
@@ -28,8 +28,8 @@ export default class VCCalculator_FY25_03 extends AbstractVCCalculatorBase {
|
|
|
28
28
|
constructor() {
|
|
29
29
|
super(REVISION_NO);
|
|
30
30
|
}
|
|
31
|
-
isEntryIncluded(entry) {
|
|
32
|
-
if (!getConsideredEntryTypes().includes(entry.data.type)) {
|
|
31
|
+
isEntryIncluded(entry, include3p) {
|
|
32
|
+
if (!getConsideredEntryTypes(include3p).includes(entry.data.type)) {
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
if (entry.data.type === 'mutation:attribute') {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { getConfig } from '../config';
|
|
4
|
+
import { getMoreAccuratePageVisibilityUpToTTAI } from '../create-payload';
|
|
5
|
+
import { sanitizeUfoName } from '../create-payload/common/utils';
|
|
6
|
+
import getPageVisibilityUpToTTAI from '../create-payload/utils/get-page-visibility-up-to-ttai';
|
|
7
|
+
import getPayloadSize from '../create-payload/utils/get-payload-size';
|
|
8
|
+
import { getReactUFOPayloadVersion } from '../create-payload/utils/get-react-ufo-payload-version';
|
|
9
|
+
import getTTAI from '../create-payload/utils/get-ttai';
|
|
10
|
+
import getVCMetrics from '../create-payload/utils/get-vc-metrics';
|
|
11
|
+
function createInteractionExtraLogPayload(_x, _x2) {
|
|
12
|
+
return _createInteractionExtraLogPayload.apply(this, arguments);
|
|
13
|
+
}
|
|
14
|
+
function _createInteractionExtraLogPayload() {
|
|
15
|
+
_createInteractionExtraLogPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interactionId, interaction) {
|
|
16
|
+
var _getTTAI, _finalVCMetrics$ufoV, _window$location;
|
|
17
|
+
var config, end, start, ufoName, rate, type, abortReason, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, pageVisibilityAtTTAI, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTAI, extraTTAI, newUFOName, finalVCMetrics, ttvc, payload;
|
|
18
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
+
while (1) switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
config = getConfig();
|
|
22
|
+
if (config) {
|
|
23
|
+
_context.next = 3;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
throw Error('UFO Configuration not provided');
|
|
27
|
+
case 3:
|
|
28
|
+
end = interaction.end, start = interaction.start, ufoName = interaction.ufoName, rate = interaction.rate, type = interaction.type, abortReason = interaction.abortReason, routeName = interaction.routeName, previousInteractionName = interaction.previousInteractionName, isPreviousInteractionAborted = interaction.isPreviousInteractionAborted, abortedByInteractionName = interaction.abortedByInteractionName;
|
|
29
|
+
pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
30
|
+
isPageLoad = type === 'page_load' || type === 'transition';
|
|
31
|
+
if (isPageLoad) {
|
|
32
|
+
_context.next = 8;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return _context.abrupt("return", null);
|
|
36
|
+
case 8:
|
|
37
|
+
calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
|
|
38
|
+
moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTAI(interaction) : null;
|
|
39
|
+
extraTTAI = (_getTTAI = getTTAI(interaction)) !== null && _getTTAI !== void 0 ? _getTTAI : undefined;
|
|
40
|
+
newUFOName = sanitizeUfoName(ufoName);
|
|
41
|
+
_context.next = 14;
|
|
42
|
+
return getVCMetrics(interaction, true);
|
|
43
|
+
case 14:
|
|
44
|
+
finalVCMetrics = _context.sent;
|
|
45
|
+
ttvc = (_finalVCMetrics$ufoV = finalVCMetrics['ufo:vc:rev']) === null || _finalVCMetrics$ufoV === void 0 ? void 0 : _finalVCMetrics$ufoV.map(function (revision) {
|
|
46
|
+
if (revision['metric:vc90'] === null || revision.clean !== true) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
revision: revision.revision,
|
|
51
|
+
vc90: revision['metric:vc90']
|
|
52
|
+
};
|
|
53
|
+
}).filter(function (revision) {
|
|
54
|
+
return revision != null;
|
|
55
|
+
});
|
|
56
|
+
payload = {
|
|
57
|
+
actionSubject: 'experience',
|
|
58
|
+
action: 'measured',
|
|
59
|
+
eventType: 'operational',
|
|
60
|
+
source: 'measured',
|
|
61
|
+
tags: ['observability'],
|
|
62
|
+
attributes: {
|
|
63
|
+
properties: {
|
|
64
|
+
// basic
|
|
65
|
+
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
66
|
+
'event:product': config.product,
|
|
67
|
+
'event:schema': '1.0.0',
|
|
68
|
+
'event:sizeInKb': 0,
|
|
69
|
+
'event:source': {
|
|
70
|
+
name: 'react-ufo/web',
|
|
71
|
+
version: getReactUFOPayloadVersion(interaction.type)
|
|
72
|
+
},
|
|
73
|
+
'event:region': config.region || 'unknown',
|
|
74
|
+
'experience:key': 'custom.interaction-extra-metrics',
|
|
75
|
+
'experience:name': newUFOName,
|
|
76
|
+
interactionMetrics: {
|
|
77
|
+
namePrefix: config.namePrefix || '',
|
|
78
|
+
segmentPrefix: config.segmentPrefix || '',
|
|
79
|
+
interactionId: interactionId,
|
|
80
|
+
pageVisibilityAtTTAI: pageVisibilityAtTTAI,
|
|
81
|
+
experimental__pageVisibilityAtTTAI: moreAccuratePageVisibilityAtTTAI,
|
|
82
|
+
// raw interaction metrics
|
|
83
|
+
rate: rate,
|
|
84
|
+
routeName: routeName,
|
|
85
|
+
type: type,
|
|
86
|
+
abortReason: abortReason,
|
|
87
|
+
previousInteractionName: previousInteractionName,
|
|
88
|
+
isPreviousInteractionAborted: isPreviousInteractionAborted,
|
|
89
|
+
abortedByInteractionName: abortedByInteractionName,
|
|
90
|
+
// performance
|
|
91
|
+
end: Math.round(end),
|
|
92
|
+
start: Math.round(start),
|
|
93
|
+
'metric:ttai:3p': extraTTAI,
|
|
94
|
+
ttvc: ttvc !== null && ttvc !== void 0 ? ttvc : undefined
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
100
|
+
return _context.abrupt("return", payload);
|
|
101
|
+
case 19:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee);
|
|
106
|
+
}));
|
|
107
|
+
return _createInteractionExtraLogPayload.apply(this, arguments);
|
|
108
|
+
}
|
|
109
|
+
export default createInteractionExtraLogPayload;
|
|
@@ -134,7 +134,7 @@ function getMoreAccuratePageVisibilityUpToTTI(interaction) {
|
|
|
134
134
|
}
|
|
135
135
|
return old;
|
|
136
136
|
}
|
|
137
|
-
function getMoreAccuratePageVisibilityUpToTTAI(interaction) {
|
|
137
|
+
export function getMoreAccuratePageVisibilityUpToTTAI(interaction) {
|
|
138
138
|
var old = getPageVisibilityUpToTTAI(interaction);
|
|
139
139
|
var buffered = getVisibilityStateFromPerformance(interaction.end);
|
|
140
140
|
if (!buffered) {
|
|
@@ -618,7 +618,7 @@ function _createInteractionMetricsPayload() {
|
|
|
618
618
|
} : {};
|
|
619
619
|
var isBM3ConfigSSRDoneAsFmp = interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp;
|
|
620
620
|
var isUFOConfigSSRDoneAsFmp = interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime);
|
|
621
|
-
if (!experimental && (isBM3ConfigSSRDoneAsFmp || isUFOConfigSSRDoneAsFmp) && SSRDoneTimeValue !== undefined
|
|
621
|
+
if (!experimental && (isBM3ConfigSSRDoneAsFmp || isUFOConfigSSRDoneAsFmp) && SSRDoneTimeValue !== undefined) {
|
|
622
622
|
try {
|
|
623
623
|
performance.mark("FMP", {
|
|
624
624
|
startTime: SSRDoneTimeValue,
|
|
@@ -702,7 +702,7 @@ function _createInteractionMetricsPayload() {
|
|
|
702
702
|
experimentalMetrics = _yield$Promise$all2[1];
|
|
703
703
|
paintMetrics = _yield$Promise$all2[2];
|
|
704
704
|
if (!experimental) {
|
|
705
|
-
|
|
705
|
+
addPerformanceMeasures(interaction.start, _toConsumableArray((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || []));
|
|
706
706
|
}
|
|
707
707
|
getReactHydrationStats = function getReactHydrationStats() {
|
|
708
708
|
if (!isPageLoad || !hydration) {
|
|
@@ -15,53 +15,67 @@ function getVCMetrics(_x) {
|
|
|
15
15
|
function _getVCMetrics() {
|
|
16
16
|
_getVCMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
|
|
17
17
|
var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$vc2, _config$vc3, _result$ufoVcRev;
|
|
18
|
-
var
|
|
18
|
+
var include3p,
|
|
19
|
+
config,
|
|
20
|
+
interactionStatus,
|
|
21
|
+
pageVisibilityUpToTTAI,
|
|
22
|
+
shouldReportVCMetrics,
|
|
23
|
+
observer,
|
|
24
|
+
isSSREnabled,
|
|
25
|
+
ssr,
|
|
26
|
+
tti,
|
|
27
|
+
prefix,
|
|
28
|
+
result,
|
|
29
|
+
mostRecentVCRevision,
|
|
30
|
+
mostRecentVCRevisionPayload,
|
|
31
|
+
_args = arguments;
|
|
19
32
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20
33
|
while (1) switch (_context.prev = _context.next) {
|
|
21
34
|
case 0:
|
|
35
|
+
include3p = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
22
36
|
config = getConfig();
|
|
23
37
|
if (config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
24
|
-
_context.next =
|
|
38
|
+
_context.next = 4;
|
|
25
39
|
break;
|
|
26
40
|
}
|
|
27
41
|
return _context.abrupt("return", {});
|
|
28
|
-
case
|
|
42
|
+
case 4:
|
|
29
43
|
if (!fg('platform_ufo_enable_vc_press_interactions')) {
|
|
30
|
-
_context.next =
|
|
44
|
+
_context.next = 9;
|
|
31
45
|
break;
|
|
32
46
|
}
|
|
33
47
|
if (!(interaction.type !== 'page_load' && interaction.type !== 'transition' && interaction.type !== 'press')) {
|
|
34
|
-
_context.next =
|
|
48
|
+
_context.next = 7;
|
|
35
49
|
break;
|
|
36
50
|
}
|
|
37
51
|
return _context.abrupt("return", {});
|
|
38
|
-
case
|
|
39
|
-
_context.next =
|
|
52
|
+
case 7:
|
|
53
|
+
_context.next = 11;
|
|
40
54
|
break;
|
|
41
|
-
case
|
|
55
|
+
case 9:
|
|
42
56
|
if (!(interaction.type !== 'page_load' && interaction.type !== 'transition')) {
|
|
43
|
-
_context.next =
|
|
57
|
+
_context.next = 11;
|
|
44
58
|
break;
|
|
45
59
|
}
|
|
46
60
|
return _context.abrupt("return", {});
|
|
47
|
-
case
|
|
61
|
+
case 11:
|
|
48
62
|
interactionStatus = getInteractionStatus(interaction);
|
|
49
63
|
pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
50
64
|
shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible'; // Use per-interaction VC observer if available, otherwise fall back to global
|
|
51
65
|
observer = interaction.vcObserver;
|
|
52
66
|
if (observer) {
|
|
53
|
-
_context.next =
|
|
67
|
+
_context.next = 17;
|
|
54
68
|
break;
|
|
55
69
|
}
|
|
56
70
|
return _context.abrupt("return", {});
|
|
57
|
-
case
|
|
71
|
+
case 17:
|
|
58
72
|
if (!(!shouldReportVCMetrics && fg('platform_ufo_no_vc_on_aborted'))) {
|
|
59
|
-
_context.next =
|
|
73
|
+
_context.next = 20;
|
|
60
74
|
break;
|
|
61
75
|
}
|
|
62
76
|
observer.stop(interaction.ufoName);
|
|
63
77
|
return _context.abrupt("return", {});
|
|
64
|
-
case
|
|
78
|
+
case 20:
|
|
65
79
|
isSSREnabled = interaction.type === 'page_load' && ((config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName)));
|
|
66
80
|
ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
67
81
|
ssr: getSSRDoneTimeValue(config)
|
|
@@ -69,8 +83,8 @@ function _getVCMetrics() {
|
|
|
69
83
|
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
70
84
|
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;
|
|
71
85
|
prefix = 'ufo';
|
|
72
|
-
_context.next =
|
|
73
|
-
return observer.getVCResult(_objectSpread({
|
|
86
|
+
_context.next = 27;
|
|
87
|
+
return observer.getVCResult(_objectSpread(_objectSpread({
|
|
74
88
|
start: interaction.start,
|
|
75
89
|
stop: interaction.end,
|
|
76
90
|
tti: tti,
|
|
@@ -81,8 +95,10 @@ function _getVCMetrics() {
|
|
|
81
95
|
experienceKey: interaction.ufoName,
|
|
82
96
|
interactionId: interaction.id,
|
|
83
97
|
includeSSRRatio: (_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.includeSSRRatio
|
|
84
|
-
}, ssr)
|
|
85
|
-
|
|
98
|
+
}, ssr), {}, {
|
|
99
|
+
include3p: include3p
|
|
100
|
+
}));
|
|
101
|
+
case 27:
|
|
86
102
|
result = _context.sent;
|
|
87
103
|
observer.stop(interaction.ufoName);
|
|
88
104
|
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
@@ -92,15 +108,15 @@ function _getVCMetrics() {
|
|
|
92
108
|
return revision === mostRecentVCRevision;
|
|
93
109
|
});
|
|
94
110
|
if (!(!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean))) {
|
|
95
|
-
_context.next =
|
|
111
|
+
_context.next = 34;
|
|
96
112
|
break;
|
|
97
113
|
}
|
|
98
114
|
return _context.abrupt("return", result);
|
|
99
|
-
case
|
|
115
|
+
case 34:
|
|
100
116
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
101
117
|
'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
|
|
102
118
|
}));
|
|
103
|
-
case
|
|
119
|
+
case 35:
|
|
104
120
|
case "end":
|
|
105
121
|
return _context.stop();
|
|
106
122
|
}
|