@atlaskit/react-ufo 4.10.2 → 4.11.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 +14 -0
- package/dist/cjs/create-post-interaction-log-payload/index.js +12 -3
- package/dist/cjs/interaction-metrics/index.js +10 -4
- package/dist/cjs/interaction-metrics/post-interaction-log.js +13 -1
- package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +5 -0
- package/dist/cjs/vc/vc-observer-new/metric-calculator/vcnext/index.js +4 -1
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +26 -40
- package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/is-element-visible.js +23 -0
- package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/is-same-rect-dimensions.js +13 -0
- package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/is-same-rect-size.js +13 -0
- package/dist/es2019/create-post-interaction-log-payload/index.js +9 -2
- package/dist/es2019/interaction-metrics/index.js +10 -4
- package/dist/es2019/interaction-metrics/post-interaction-log.js +11 -1
- package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +5 -0
- package/dist/es2019/vc/vc-observer-new/metric-calculator/vcnext/index.js +4 -1
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +25 -39
- package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/is-element-visible.js +17 -0
- package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/is-same-rect-dimensions.js +7 -0
- package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/is-same-rect-size.js +7 -0
- package/dist/esm/create-post-interaction-log-payload/index.js +12 -3
- package/dist/esm/interaction-metrics/index.js +10 -4
- package/dist/esm/interaction-metrics/post-interaction-log.js +13 -1
- package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +5 -0
- package/dist/esm/vc/vc-observer-new/metric-calculator/vcnext/index.js +4 -1
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +25 -39
- package/dist/esm/vc/vc-observer-new/viewport-observer/utils/is-element-visible.js +17 -0
- package/dist/esm/vc/vc-observer-new/viewport-observer/utils/is-same-rect-dimensions.js +7 -0
- package/dist/esm/vc/vc-observer-new/viewport-observer/utils/is-same-rect-size.js +7 -0
- package/dist/types/common/common/types.d.ts +2 -0
- package/dist/types/common/react-ufo-payload-schema.d.ts +1 -0
- package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +1 -0
- package/dist/types/create-payload/index.d.ts +384 -0
- package/dist/types/create-post-interaction-log-payload/index.d.ts +7 -1
- package/dist/types/interaction-metrics/index.d.ts +2 -2
- package/dist/types/interaction-metrics/post-interaction-log.d.ts +3 -1
- package/dist/types/vc/vc-observer-new/types.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/viewport-observer/utils/is-element-visible.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/viewport-observer/utils/is-same-rect-dimensions.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/viewport-observer/utils/is-same-rect-size.d.ts +1 -0
- package/dist/types-ts4.5/common/common/types.d.ts +2 -0
- package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +1 -0
- package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +1 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +384 -0
- package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +7 -1
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +2 -2
- package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +3 -1
- package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/is-element-visible.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/is-same-rect-dimensions.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/is-same-rect-size.d.ts +1 -0
- package/package.json +7 -1
|
@@ -339,6 +339,10 @@ function removeHoldCriterion(id) {
|
|
|
339
339
|
export function addHold(interactionId, labelStack, name, experimental) {
|
|
340
340
|
var interaction = interactions.get(interactionId);
|
|
341
341
|
var id = createUUID();
|
|
342
|
+
if (!interaction && fg('platform_ufo_enable_late_holds_post_interaction')) {
|
|
343
|
+
// add hold timestamp to post interaction log if interaction is complete
|
|
344
|
+
postInteractionLog.addHoldInfo(labelStack, name, performance.now());
|
|
345
|
+
}
|
|
342
346
|
if (interaction != null) {
|
|
343
347
|
var start = performance.now();
|
|
344
348
|
var holdActive = {
|
|
@@ -542,7 +546,7 @@ export var ModuleLoadingProfiler = {
|
|
|
542
546
|
removeHoldByID(currentInteractionId, id);
|
|
543
547
|
}
|
|
544
548
|
};
|
|
545
|
-
export function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError, errorHash) {
|
|
549
|
+
export function addError(interactionId, name, labelStack, errorType, errorMessage, errorStack, forcedError, errorHash, errorStatusCode) {
|
|
546
550
|
var interaction = interactions.get(interactionId);
|
|
547
551
|
if (interaction != null) {
|
|
548
552
|
interaction.errors.push({
|
|
@@ -552,11 +556,12 @@ export function addError(interactionId, name, labelStack, errorType, errorMessag
|
|
|
552
556
|
errorMessage: errorMessage,
|
|
553
557
|
errorStack: errorStack,
|
|
554
558
|
forcedError: forcedError,
|
|
555
|
-
errorHash: errorHash
|
|
559
|
+
errorHash: errorHash,
|
|
560
|
+
errorStatusCode: errorStatusCode
|
|
556
561
|
});
|
|
557
562
|
}
|
|
558
563
|
}
|
|
559
|
-
export function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack, errorHash) {
|
|
564
|
+
export function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack, errorHash, errorStatusCode) {
|
|
560
565
|
interactions.forEach(function (interaction) {
|
|
561
566
|
interaction.errors.push({
|
|
562
567
|
name: name,
|
|
@@ -564,7 +569,8 @@ export function addErrorToAll(name, labelStack, errorType, errorMessage, errorSt
|
|
|
564
569
|
errorType: errorType,
|
|
565
570
|
errorMessage: errorMessage,
|
|
566
571
|
errorStack: errorStack,
|
|
567
|
-
errorHash: errorHash
|
|
572
|
+
errorHash: errorHash,
|
|
573
|
+
errorStatusCode: errorStatusCode
|
|
568
574
|
});
|
|
569
575
|
});
|
|
570
576
|
}
|
|
@@ -25,6 +25,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
25
25
|
* Store the scheduled sink timeout Id so that it can be cancelled when needed
|
|
26
26
|
*/
|
|
27
27
|
_defineProperty(this, "sinkTimeoutId", null);
|
|
28
|
+
_defineProperty(this, "holdInfo", []);
|
|
28
29
|
/**
|
|
29
30
|
* independent VC observer, that observes until `custom.post-interaction-logs` event is sent
|
|
30
31
|
*/
|
|
@@ -91,6 +92,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
91
92
|
value: function reset() {
|
|
92
93
|
this.lastInteractionFinish = null;
|
|
93
94
|
this.reactProfilerTimings = [];
|
|
95
|
+
this.holdInfo = [];
|
|
94
96
|
if (this.sinkTimeoutId != null) {
|
|
95
97
|
clearTimeout(this.sinkTimeoutId);
|
|
96
98
|
this.sinkTimeoutId = null;
|
|
@@ -155,7 +157,8 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
155
157
|
lastInteractionFinish: this.lastInteractionFinish,
|
|
156
158
|
reactProfilerTimings: this.reactProfilerTimings,
|
|
157
159
|
postInteractionFinishVCResult: postInteractionFinishVCResult,
|
|
158
|
-
lastInteractionFinishVCResult: this.lastInteractionFinishVCResult
|
|
160
|
+
lastInteractionFinishVCResult: this.lastInteractionFinishVCResult,
|
|
161
|
+
postInteractionHoldInfo: this.holdInfo
|
|
159
162
|
});
|
|
160
163
|
this.reset();
|
|
161
164
|
case 13:
|
|
@@ -236,6 +239,15 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
236
239
|
});
|
|
237
240
|
}
|
|
238
241
|
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "addHoldInfo",
|
|
244
|
+
value: function addHoldInfo(labelStack, name, start) {
|
|
245
|
+
this.holdInfo.push({
|
|
246
|
+
name: name,
|
|
247
|
+
labelStack: labelStack,
|
|
248
|
+
start: start
|
|
249
|
+
});
|
|
250
|
+
}
|
|
239
251
|
}]);
|
|
240
252
|
}();
|
|
241
253
|
export { PostInteractionLog as default };
|
|
@@ -14,6 +14,11 @@ var REVISION_NO = 'fy25.03';
|
|
|
14
14
|
var getConsideredEntryTypes = function getConsideredEntryTypes(include3p) {
|
|
15
15
|
var entryTypes = ['mutation:child-element', 'mutation:element', 'mutation:attribute', 'layout-shift', 'window:event'];
|
|
16
16
|
|
|
17
|
+
// in rolling this out, still include it in TTVC v3
|
|
18
|
+
if (fg('platform_ufo_vc_next_filter_ls_entries_same_rect')) {
|
|
19
|
+
entryTypes.push('layout-shift:same-rect');
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
// If not exclude 3p elements from ttvc,
|
|
18
23
|
// including the tags into the ConsideredEntryTypes so that it won't be ignored for TTVC calculation
|
|
19
24
|
if (!fg('platform_ufo_exclude_3p_elements_from_ttvc') || include3p) {
|
|
@@ -14,6 +14,9 @@ var REVISION_NO = 'next';
|
|
|
14
14
|
var getConsideredEntryTypes = function getConsideredEntryTypes() {
|
|
15
15
|
return ['mutation:display-contents-children-element'];
|
|
16
16
|
};
|
|
17
|
+
var getExcludedEntryTypes = function getExcludedEntryTypes() {
|
|
18
|
+
return ['layout-shift:same-rect'];
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
// NOTE: `VCNext` to be renamed `FY26_04` once stable
|
|
19
22
|
var VCNextCalculator = /*#__PURE__*/function (_VCCalculator_FY25_) {
|
|
@@ -26,7 +29,7 @@ var VCNextCalculator = /*#__PURE__*/function (_VCCalculator_FY25_) {
|
|
|
26
29
|
key: "isEntryIncluded",
|
|
27
30
|
value: function isEntryIncluded(entry, include3p) {
|
|
28
31
|
var isEntryIncludedInV3 = _superPropGet(VCNextCalculator, "isEntryIncluded", this, 3)([entry, include3p]);
|
|
29
|
-
if (isEntryIncludedInV3) {
|
|
32
|
+
if (isEntryIncludedInV3 && !getExcludedEntryTypes().includes(entry.data.type)) {
|
|
30
33
|
return true;
|
|
31
34
|
}
|
|
32
35
|
return getConsideredEntryTypes().includes(entry.data.type);
|
|
@@ -17,37 +17,11 @@ import createPerformanceObserver from './performance-observer';
|
|
|
17
17
|
import checkCssProperty from './utils/check-display-content';
|
|
18
18
|
import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
|
|
19
19
|
import { getMutatedElements } from './utils/get-mutated-elements';
|
|
20
|
+
import { isElementVisible } from './utils/is-element-visible';
|
|
20
21
|
import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
|
|
22
|
+
import { isSameRectDimensions } from './utils/is-same-rect-dimensions';
|
|
23
|
+
import { isSameRectSize } from './utils/is-same-rect-size';
|
|
21
24
|
import trackDisplayContentsOccurrence from './utils/track-display-content-occurrence';
|
|
22
|
-
function isElementVisible(element) {
|
|
23
|
-
if (!(element instanceof HTMLElement)) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
var visible = element.checkVisibility({
|
|
28
|
-
// @ts-ignore - visibilityProperty may not exist in all TS environments
|
|
29
|
-
visibilityProperty: true,
|
|
30
|
-
contentVisibilityAuto: true,
|
|
31
|
-
opacityProperty: true
|
|
32
|
-
});
|
|
33
|
-
return visible;
|
|
34
|
-
} catch (e) {
|
|
35
|
-
// there is no support for checkVisibility
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function sameRectSize(a, b) {
|
|
40
|
-
if (!a || !b) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
return a.width === b.width && a.height === b.height;
|
|
44
|
-
}
|
|
45
|
-
function sameRectDimensions(a, b) {
|
|
46
|
-
if (!a || !b) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;
|
|
50
|
-
}
|
|
51
25
|
var createElementMutationsWatcher = function createElementMutationsWatcher(removedNodeRects) {
|
|
52
26
|
return function (_ref) {
|
|
53
27
|
var target = _ref.target,
|
|
@@ -61,7 +35,7 @@ var createElementMutationsWatcher = function createElementMutationsWatcher(remov
|
|
|
61
35
|
return 'mutation:rll-placeholder';
|
|
62
36
|
}
|
|
63
37
|
var wasDeleted = removedNodeRects.some(function (nr) {
|
|
64
|
-
return
|
|
38
|
+
return isSameRectDimensions(nr, rect);
|
|
65
39
|
});
|
|
66
40
|
if (wasDeleted && isInIgnoreLsMarker) {
|
|
67
41
|
return 'mutation:element-replacement';
|
|
@@ -372,7 +346,7 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
372
346
|
};
|
|
373
347
|
}
|
|
374
348
|
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
375
|
-
if (lastElementRect &&
|
|
349
|
+
if (lastElementRect && isSameRectSize(rect, lastElementRect)) {
|
|
376
350
|
return {
|
|
377
351
|
type: 'mutation:attribute:no-layout-shift',
|
|
378
352
|
mutationData: {
|
|
@@ -402,14 +376,26 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
402
376
|
var changedRect = _step4.value;
|
|
403
377
|
var target = changedRect.node;
|
|
404
378
|
if (target) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
379
|
+
if (fg('platform_ufo_vc_next_filter_ls_entries_same_rect')) {
|
|
380
|
+
var isSameCurrentAndPreviousRects = isSameRectDimensions(changedRect.rect, changedRect.previousRect);
|
|
381
|
+
_this.onChange({
|
|
382
|
+
time: time,
|
|
383
|
+
elementRef: new WeakRef(target),
|
|
384
|
+
visible: true,
|
|
385
|
+
rect: changedRect.rect,
|
|
386
|
+
previousRect: changedRect.previousRect,
|
|
387
|
+
type: isSameCurrentAndPreviousRects ? 'layout-shift:same-rect' : 'layout-shift'
|
|
388
|
+
});
|
|
389
|
+
} else {
|
|
390
|
+
_this.onChange({
|
|
391
|
+
time: time,
|
|
392
|
+
elementRef: new WeakRef(target),
|
|
393
|
+
visible: true,
|
|
394
|
+
rect: changedRect.rect,
|
|
395
|
+
previousRect: changedRect.previousRect,
|
|
396
|
+
type: 'layout-shift'
|
|
397
|
+
});
|
|
398
|
+
}
|
|
413
399
|
}
|
|
414
400
|
}
|
|
415
401
|
} catch (err) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function isElementVisible(element) {
|
|
2
|
+
if (!(element instanceof HTMLElement)) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
var visible = element.checkVisibility({
|
|
7
|
+
// @ts-ignore - visibilityProperty may not exist in all TS environments
|
|
8
|
+
visibilityProperty: true,
|
|
9
|
+
contentVisibilityAuto: true,
|
|
10
|
+
opacityProperty: true
|
|
11
|
+
});
|
|
12
|
+
return visible;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
// there is no support for checkVisibility
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var DIMENSIONS_CHECK_TOLERANCE_MARGIN_IN_PX = 1;
|
|
2
|
+
export function isSameRectDimensions(a, b) {
|
|
3
|
+
if (!a || !b) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
return Math.abs(a.width - b.width) <= DIMENSIONS_CHECK_TOLERANCE_MARGIN_IN_PX && Math.abs(a.height - b.height) <= DIMENSIONS_CHECK_TOLERANCE_MARGIN_IN_PX && Math.abs(a.x - b.x) <= DIMENSIONS_CHECK_TOLERANCE_MARGIN_IN_PX && Math.abs(a.y - b.y) <= DIMENSIONS_CHECK_TOLERANCE_MARGIN_IN_PX;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var SIZE_CHECK_TOLERANCE_MARGIN_IN_PX = 1;
|
|
2
|
+
export function isSameRectSize(a, b) {
|
|
3
|
+
if (!a || !b) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
return Math.abs(a.width - b.width) <= SIZE_CHECK_TOLERANCE_MARGIN_IN_PX && Math.abs(a.height - b.height) <= SIZE_CHECK_TOLERANCE_MARGIN_IN_PX;
|
|
7
|
+
}
|
|
@@ -38,6 +38,7 @@ export interface InteractionError {
|
|
|
38
38
|
errorStack?: string;
|
|
39
39
|
forcedError?: boolean;
|
|
40
40
|
errorHash?: string;
|
|
41
|
+
errorStatusCode?: number;
|
|
41
42
|
}
|
|
42
43
|
interface FlushInfo {
|
|
43
44
|
label?: string;
|
|
@@ -223,5 +224,6 @@ export type PostInteractionLogOutput = {
|
|
|
223
224
|
reactProfilerTimings?: ReactProfilerTiming[];
|
|
224
225
|
postInteractionFinishVCResult?: VCResult;
|
|
225
226
|
lastInteractionFinishVCResult?: VCResult;
|
|
227
|
+
postInteractionHoldInfo?: HoldActive[];
|
|
226
228
|
};
|
|
227
229
|
export {};
|