@atlaskit/react-ufo 3.13.13 → 3.13.15

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/config/index.js +4 -4
  3. package/dist/cjs/create-payload/index.js +1 -2
  4. package/dist/cjs/create-payload/utils/get-ssr-done-time-value.js +1 -2
  5. package/dist/cjs/interaction-ignore/ufo-interaction-ignore.js +1 -2
  6. package/dist/cjs/interaction-metrics/index.js +10 -10
  7. package/dist/cjs/interaction-metrics-init/index.js +1 -2
  8. package/dist/cjs/label/UFOLabel.js +1 -2
  9. package/dist/cjs/load-hold/UFOLoadHold.js +1 -2
  10. package/dist/cjs/placeholder/Placeholder.js +1 -2
  11. package/dist/cjs/placeholder/loosely-lazy/lazy-suspense.js +1 -2
  12. package/dist/cjs/segment/segment-highlight.js +1 -2
  13. package/dist/cjs/segment/segment.js +1 -2
  14. package/dist/cjs/trace-transition/index.js +1 -2
  15. package/dist/cjs/vc/vc-observer/getVCRevisionsData.js +15 -5
  16. package/dist/cjs/vc/vc-observer/index.js +25 -25
  17. package/dist/cjs/vc/vc-observer/media-wrapper/index.js +1 -2
  18. package/dist/cjs/vc/vc-observer-new/index.js +1 -3
  19. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +93 -90
  20. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +1 -1
  21. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +2 -2
  22. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/index.js +1 -2
  23. package/dist/es2019/interaction-metrics/index.js +10 -10
  24. package/dist/es2019/vc/vc-observer/getVCRevisionsData.js +15 -5
  25. package/dist/es2019/vc/vc-observer/index.js +3 -3
  26. package/dist/es2019/vc/vc-observer-new/index.js +1 -3
  27. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +32 -19
  28. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +1 -1
  29. package/dist/esm/config/index.js +4 -4
  30. package/dist/esm/interaction-metrics/index.js +10 -10
  31. package/dist/esm/vc/vc-observer/getVCRevisionsData.js +15 -5
  32. package/dist/esm/vc/vc-observer/index.js +25 -25
  33. package/dist/esm/vc/vc-observer-new/index.js +1 -3
  34. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +95 -92
  35. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +1 -1
  36. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +2 -2
  37. package/dist/types/common/vc/types.d.ts +1 -0
  38. package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +3 -2
  39. package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +4 -1
  40. package/dist/types-ts4.5/common/vc/types.d.ts +1 -0
  41. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +3 -2
  42. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +4 -1
  43. package/package.json +3 -9
@@ -659,11 +659,11 @@ function callCancelCallbacks(interaction) {
659
659
  export function abort(interactionId, abortReason) {
660
660
  var interaction = interactions.get(interactionId);
661
661
  if (interaction != null) {
662
- var _getConfig10;
662
+ var _getConfig0;
663
663
  callCancelCallbacks(interaction);
664
664
  interaction.abortReason = abortReason;
665
665
  finishInteraction(interactionId, interaction);
666
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
666
+ if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
667
667
  onExperimentalInteractionComplete(interactionId, interaction);
668
668
  remove(interactionId);
669
669
  }
@@ -672,12 +672,12 @@ export function abort(interactionId, abortReason) {
672
672
  export function abortByNewInteraction(interactionId, interactionName) {
673
673
  var interaction = interactions.get(interactionId);
674
674
  if (interaction != null) {
675
- var _getConfig11;
675
+ var _getConfig1;
676
676
  callCancelCallbacks(interaction);
677
677
  interaction.abortReason = 'new_interaction';
678
678
  interaction.abortedByInteractionName = interactionName;
679
679
  finishInteraction(interactionId, interaction);
680
- if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.experimentalInteractionMetrics) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
680
+ if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
681
681
  onExperimentalInteractionComplete(interactionId, interaction);
682
682
  remove(interactionId);
683
683
  }
@@ -685,7 +685,7 @@ export function abortByNewInteraction(interactionId, interactionName) {
685
685
  }
686
686
  export function abortAll(abortReason, abortedByInteractionName) {
687
687
  interactions.forEach(function (interaction, interactionId) {
688
- var _getConfig12;
688
+ var _getConfig10;
689
689
  var noMoreHolds = interaction.holdActive.size === 0;
690
690
  if (!noMoreHolds) {
691
691
  callCancelCallbacks(interaction);
@@ -695,7 +695,7 @@ export function abortAll(abortReason, abortedByInteractionName) {
695
695
  }
696
696
  }
697
697
  finishInteraction(interactionId, interaction);
698
- if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.experimentalInteractionMetrics) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
698
+ if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
699
699
  onExperimentalInteractionComplete(interactionId, interaction);
700
700
  remove(interactionId);
701
701
  }
@@ -706,9 +706,9 @@ export function addOnCancelCallback(id, cancelCallback) {
706
706
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
707
707
  }
708
708
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
709
- var _getConfig13;
709
+ var _getConfig11;
710
710
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
711
- if ((_getConfig13 = getConfig()) !== null && _getConfig13 !== void 0 && (_getConfig13 = _getConfig13.postInteractionLog) !== null && _getConfig13 !== void 0 && _getConfig13.enabled) {
711
+ if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
712
712
  postInteractionLog.reset();
713
713
  }
714
714
  var previousTime = startTime;
@@ -796,7 +796,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
796
796
  addHoldByID(interactionId, [], ufoName, ufoName, true);
797
797
  }
798
798
  if (type === 'transition') {
799
- var _getConfig14;
799
+ var _getConfig12;
800
800
  getVCObserver().start({
801
801
  startTime: startTime,
802
802
  experienceKey: ufoName
@@ -804,7 +804,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
804
804
  postInteractionLog.startVCObserver({
805
805
  startTime: startTime
806
806
  });
807
- if ((_getConfig14 = getConfig()) !== null && _getConfig14 !== void 0 && (_getConfig14 = _getConfig14.experimentalInteractionMetrics) !== null && _getConfig14 !== void 0 && _getConfig14.enabled) {
807
+ if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.experimentalInteractionMetrics) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
808
808
  experimentalVC.start({
809
809
  startTime: startTime
810
810
  });
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; } } }; }
3
3
  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; } }
4
4
  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; }
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { isVCRevisionEnabled } from '../../config';
6
7
  import { getPageVisibilityState } from '../../hidden-timing';
7
8
  var VCParts = ['25', '50', '75', '80', '85', '90', '95', '98', '99'];
@@ -43,26 +44,35 @@ export function getVCRevisionsData(_ref) {
43
44
  isEventAborted = _ref.isEventAborted,
44
45
  calculatedVC = _ref.calculatedVC,
45
46
  calculatedVCNext = _ref.calculatedVCNext,
46
- experienceKey = _ref.experienceKey;
47
+ experienceKey = _ref.experienceKey,
48
+ ratios = _ref.ratios;
47
49
  var pageVisibilityUpToTTAI = getPageVisibilityState(interaction.start, interaction.end);
48
50
  var isVisiblePageVisibleUpToTTAI = pageVisibilityUpToTTAI === 'visible';
49
51
  var shouldHaveVCmetric = isVCClean && !isEventAborted && isVisiblePageVisibleUpToTTAI;
50
52
  var availableVCRevisionPayloads = [];
51
53
  if (isVCRevisionEnabled('fy25.01', experienceKey)) {
52
- availableVCRevisionPayloads.push({
54
+ var revision = {
53
55
  revision: 'fy25.01',
54
56
  clean: isVCClean,
55
57
  'metric:vc90': shouldHaveVCmetric ? calculatedVC.VC['90'] : null,
56
58
  vcDetails: createVCDetails(calculatedVC, shouldHaveVCmetric)
57
- });
59
+ };
60
+ if (shouldHaveVCmetric && fg('platform_ufo_rev_ratios')) {
61
+ revision.ratios = ratios;
62
+ }
63
+ availableVCRevisionPayloads.push(revision);
58
64
  }
59
65
  if (isVCRevisionEnabled('fy25.02', experienceKey)) {
60
- availableVCRevisionPayloads.push({
66
+ var _revision = {
61
67
  revision: 'fy25.02',
62
68
  clean: isVCClean,
63
69
  'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
64
70
  vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
65
- });
71
+ };
72
+ if (shouldHaveVCmetric && fg('platform_ufo_rev_ratios')) {
73
+ _revision.ratios = ratios;
74
+ }
75
+ availableVCRevisionPayloads.push(_revision);
66
76
  }
67
77
  return _defineProperty({}, "".concat(fullPrefix, "vc:rev"), availableVCRevisionPayloads);
68
78
  }
@@ -9,7 +9,6 @@ var _excluded = ["__debug__element"];
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  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; }
11
11
  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; }
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { isVCRevisionEnabled } from '../../config';
14
13
  import { getActiveInteraction } from '../../interaction-metrics';
15
14
  import { attachAbortListeners } from './attachAbortListeners';
@@ -267,7 +266,7 @@ export var VCObserver = /*#__PURE__*/function () {
267
266
  }));
268
267
 
269
268
  // Add devtool callback for both v1 and v2
270
- if (typeof window.__ufo_devtool_onVCRevisionReady__ === 'function' && fg('platform_ufo_ttvc_v3_devtool')) {
269
+ if (typeof window.__ufo_devtool_onVCRevisionReady__ === 'function') {
271
270
  // Handle v1 if not disabled
272
271
  if (!isTTVCv1Disabled) {
273
272
  (_ufo_devtool_onVCRev = (_ref8 = window).__ufo_devtool_onVCRevisionReady__) === null || _ufo_devtool_onVCRev === void 0 || _ufo_devtool_onVCRev.call(_ref8, getVCRevisionDebugDetails({
@@ -311,7 +310,8 @@ export var VCObserver = /*#__PURE__*/function () {
311
310
  VCBox: vcNext.VCBox
312
311
  },
313
312
  isEventAborted: isEventAborted,
314
- experienceKey: experienceKey
313
+ experienceKey: experienceKey,
314
+ ratios: ratios
315
315
  });
316
316
  speedIndex = _defineProperty(_defineProperty({}, "ufo:speedIndex", isTTVCv1Disabled ? vcNext.VCEntries.speedIndex : VCEntries.speedIndex), "ufo:next:speedIndex", vcNext.VCEntries.speedIndex);
317
317
  SSRRatio = VCObserver.getSSRRatio(VCEntries.rel, ssr);
@@ -420,10 +420,10 @@ export var VCObserver = /*#__PURE__*/function () {
420
420
  _this.detachAbortListeners();
421
421
  var unbinds = attachAbortListeners(window, _this.viewport, _this.abortReasonCallback);
422
422
  if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
423
- Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref11) {
424
- var _ref12 = _slicedToArray(_ref11, 2),
425
- key = _ref12[0],
426
- time = _ref12[1];
423
+ Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref1) {
424
+ var _ref10 = _slicedToArray(_ref1, 2),
425
+ key = _ref10[0],
426
+ time = _ref10[1];
427
427
  if (time) {
428
428
  _this.abortReasonCallback(key, time);
429
429
  }
@@ -453,8 +453,8 @@ export var VCObserver = /*#__PURE__*/function () {
453
453
  }
454
454
  return _createClass(VCObserver, [{
455
455
  key: "start",
456
- value: function start(_ref13) {
457
- var startTime = _ref13.startTime;
456
+ value: function start(_ref11) {
457
+ var startTime = _ref11.startTime;
458
458
  this.active = true;
459
459
  if (this.observers.isBrowserSupported()) {
460
460
  this.setViewportSize();
@@ -476,12 +476,12 @@ export var VCObserver = /*#__PURE__*/function () {
476
476
  }, {
477
477
  key: "getIgnoredElements",
478
478
  value: function getIgnoredElements(componentsLog) {
479
- return Object.values(componentsLog).flat().filter(function (_ref14) {
480
- var ignoreReason = _ref14.ignoreReason;
479
+ return Object.values(componentsLog).flat().filter(function (_ref12) {
480
+ var ignoreReason = _ref12.ignoreReason;
481
481
  return Boolean(ignoreReason);
482
- }).map(function (_ref15) {
483
- var targetName = _ref15.targetName,
484
- ignoreReason = _ref15.ignoreReason;
482
+ }).map(function (_ref13) {
483
+ var targetName = _ref13.targetName,
484
+ ignoreReason = _ref13.ignoreReason;
485
485
  return {
486
486
  targetName: targetName,
487
487
  ignoreReason: ignoreReason
@@ -611,13 +611,13 @@ export var VCObserver = /*#__PURE__*/function () {
611
611
  }
612
612
  }, {
613
613
  key: "calculateVC",
614
- value: function calculateVC(_ref16) {
615
- var heatmap = _ref16.heatmap,
616
- _ref16$ssr = _ref16.ssr,
617
- ssr = _ref16$ssr === void 0 ? UNUSED_SECTOR : _ref16$ssr,
618
- componentsLog = _ref16.componentsLog,
619
- viewport = _ref16.viewport,
620
- fixSSRAttribution = _ref16.fixSSRAttribution;
614
+ value: function calculateVC(_ref14) {
615
+ var heatmap = _ref14.heatmap,
616
+ _ref14$ssr = _ref14.ssr,
617
+ ssr = _ref14$ssr === void 0 ? UNUSED_SECTOR : _ref14$ssr,
618
+ componentsLog = _ref14.componentsLog,
619
+ viewport = _ref14.viewport,
620
+ fixSSRAttribution = _ref14.fixSSRAttribution;
621
621
  var lastUpdate = {};
622
622
  var totalPainted = 0;
623
623
  var ssrTime = fixSSRAttribution ? Math.floor(ssr) : ssr;
@@ -684,11 +684,11 @@ export var VCObserver = /*#__PURE__*/function () {
684
684
  });
685
685
  return VCRatio;
686
686
  }, 0);
687
- var VCEntries = entries.reduce(function (acc, _ref17, i) {
687
+ var VCEntries = entries.reduce(function (acc, _ref15, i) {
688
688
  var _acc$abs, _componentsLog$timest, _acc$rel$vc, _acc$rel;
689
- var _ref18 = _slicedToArray(_ref17, 2),
690
- timestamp = _ref18[0],
691
- entryPainted = _ref18[1];
689
+ var _ref16 = _slicedToArray(_ref15, 2),
690
+ timestamp = _ref16[0],
691
+ entryPainted = _ref16[1];
692
692
  var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
693
693
  var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
694
694
  var logEntry = _toConsumableArray(new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.filter(function (v) {
@@ -121,9 +121,7 @@ var VCObserverNew = /*#__PURE__*/function () {
121
121
  case 0:
122
122
  start = param.start, stop = param.stop, interactionId = param.interactionId;
123
123
  results = [];
124
- if (fg('platform_ufo_v3_add_start_entry')) {
125
- this.addStartEntry(start);
126
- }
124
+ this.addStartEntry(start);
127
125
  calculator_fy25_03 = new VCCalculator_FY25_03();
128
126
  orderedEntries = this.entriesTimeline.getOrderedEntries({
129
127
  start: start,
@@ -1,12 +1,13 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
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; } } }; }
5
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; } }
6
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; }
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
9
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { calculateTTVCPercentiles, calculateTTVCPercentilesWithDebugInfo } from './percentile-calc';
10
+ import { calculateTTVCPercentilesWithDebugInfo } from './percentile-calc';
10
11
  import getViewportHeight from './utils/get-viewport-height';
11
12
  import getViewportWidth from './utils/get-viewport-width';
12
13
  var AbstractVCCalculatorBase = /*#__PURE__*/function () {
@@ -21,52 +22,64 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
21
22
  return 'rect' in entry.data;
22
23
  });
23
24
  }
25
+
26
+ /**
27
+ * Calculate ratios for each element based on their viewport coverage.
28
+ */
24
29
  }, {
25
- key: "calculateBasic",
26
- value: function () {
27
- var _calculateBasic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filteredEntries, startTime, stopTime) {
28
- var percentiles, viewportEntries, vcLogs;
29
- return _regeneratorRuntime.wrap(function _callee$(_context) {
30
- while (1) switch (_context.prev = _context.next) {
31
- case 0:
32
- percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
33
- viewportEntries = this.filterViewportEntries(filteredEntries);
34
- _context.next = 4;
35
- return calculateTTVCPercentiles({
36
- viewport: {
37
- width: getViewportWidth(),
38
- height: getViewportHeight()
39
- },
40
- startTime: startTime,
41
- stopTime: stopTime,
42
- orderedEntries: viewportEntries,
43
- percentiles: percentiles
44
- });
45
- case 4:
46
- vcLogs = _context.sent;
47
- return _context.abrupt("return", vcLogs);
48
- case 6:
49
- case "end":
50
- return _context.stop();
30
+ key: "calculateRatios",
31
+ value: function calculateRatios(filteredEntries) {
32
+ var ratios = {};
33
+ var viewportWidth = getViewportWidth();
34
+ var viewportHeight = getViewportHeight();
35
+ var totalViewportArea = viewportWidth * viewportHeight;
36
+ if (totalViewportArea === 0) {
37
+ return ratios;
38
+ }
39
+ var elementRects = new Map();
40
+ var _iterator = _createForOfIteratorHelper(filteredEntries),
41
+ _step;
42
+ try {
43
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
+ var _entry = _step.value;
45
+ if ('rect' in _entry.data) {
46
+ var viewportEntry = _entry.data;
47
+ elementRects.set(viewportEntry.elementName, viewportEntry.rect);
51
48
  }
52
- }, _callee, this);
53
- }));
54
- function calculateBasic(_x, _x2, _x3) {
55
- return _calculateBasic.apply(this, arguments);
49
+ }
50
+ } catch (err) {
51
+ _iterator.e(err);
52
+ } finally {
53
+ _iterator.f();
56
54
  }
57
- return calculateBasic;
58
- }()
55
+ var _iterator2 = _createForOfIteratorHelper(elementRects),
56
+ _step2;
57
+ try {
58
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
59
+ var _step2$value = _slicedToArray(_step2.value, 2),
60
+ elementName = _step2$value[0],
61
+ rect = _step2$value[1];
62
+ var elementArea = rect.width * rect.height;
63
+ ratios[elementName] = elementArea / totalViewportArea;
64
+ }
65
+ } catch (err) {
66
+ _iterator2.e(err);
67
+ } finally {
68
+ _iterator2.f();
69
+ }
70
+ return ratios;
71
+ }
59
72
  }, {
60
73
  key: "calculateWithDebugInfo",
61
74
  value: function () {
62
- var _calculateWithDebugInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason) {
63
- var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator, _step, _entry, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, _ufo_devtool_onVCRev, _ref;
64
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
65
- while (1) switch (_context2.prev = _context2.next) {
75
+ var _calculateWithDebugInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason) {
76
+ var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator3, _step3, _entry2, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, _ufo_devtool_onVCRev, _ref;
77
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
78
+ while (1) switch (_context.prev = _context.next) {
66
79
  case 0:
67
80
  percentiles = [25, 50, 75, 80, 85, 90, 95, 98, 99];
68
81
  viewportEntries = this.filterViewportEntries(filteredEntries);
69
- _context2.next = 4;
82
+ _context.next = 4;
70
83
  return calculateTTVCPercentilesWithDebugInfo({
71
84
  viewport: {
72
85
  width: getViewportWidth(),
@@ -77,29 +90,29 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
77
90
  orderedEntries: viewportEntries
78
91
  });
79
92
  case 4:
80
- vcLogs = _context2.sent;
93
+ vcLogs = _context.sent;
81
94
  vcDetails = {};
82
95
  percentileIndex = 0;
83
96
  entryDataBuffer = new Set();
84
97
  if (!vcLogs) {
85
- _context2.next = 28;
98
+ _context.next = 28;
86
99
  break;
87
100
  }
88
- _iterator = _createForOfIteratorHelper(vcLogs);
89
- _context2.prev = 10;
90
- _iterator.s();
101
+ _iterator3 = _createForOfIteratorHelper(vcLogs);
102
+ _context.prev = 10;
103
+ _iterator3.s();
91
104
  case 12:
92
- if ((_step = _iterator.n()).done) {
93
- _context2.next = 20;
105
+ if ((_step3 = _iterator3.n()).done) {
106
+ _context.next = 20;
94
107
  break;
95
108
  }
96
- _entry = _step.value;
97
- time = _entry.time, viewportPercentage = _entry.viewportPercentage, entries = _entry.entries; // Only process entries if we haven't reached all percentiles
109
+ _entry2 = _step3.value;
110
+ time = _entry2.time, viewportPercentage = _entry2.viewportPercentage, entries = _entry2.entries; // Only process entries if we haven't reached all percentiles
98
111
  if (!(percentileIndex >= percentiles.length)) {
99
- _context2.next = 17;
112
+ _context.next = 17;
100
113
  break;
101
114
  }
102
- return _context2.abrupt("break", 20);
115
+ return _context.abrupt("break", 20);
103
116
  case 17:
104
117
  // Check if this entry matches any checkpoint percentiles
105
118
  if (viewportPercentage >= percentiles[percentileIndex]) {
@@ -123,19 +136,19 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
123
136
  });
124
137
  }
125
138
  case 18:
126
- _context2.next = 12;
139
+ _context.next = 12;
127
140
  break;
128
141
  case 20:
129
- _context2.next = 25;
142
+ _context.next = 25;
130
143
  break;
131
144
  case 22:
132
- _context2.prev = 22;
133
- _context2.t0 = _context2["catch"](10);
134
- _iterator.e(_context2.t0);
145
+ _context.prev = 22;
146
+ _context.t0 = _context["catch"](10);
147
+ _iterator3.e(_context.t0);
135
148
  case 25:
136
- _context2.prev = 25;
137
- _iterator.f();
138
- return _context2.finish(25);
149
+ _context.prev = 25;
150
+ _iterator3.f();
151
+ return _context.finish(25);
139
152
  case 28:
140
153
  // Fill in any missing percentiles with the last known values
141
154
  previousResult = {
@@ -152,7 +165,7 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
152
165
  }
153
166
 
154
167
  // Handle devtool callback
155
- if (!isPostInteraction && typeof window !== 'undefined' && typeof window.__ufo_devtool_onVCRevisionReady__ === 'function' && fg('platform_ufo_ttvc_v3_devtool')) {
168
+ if (!isPostInteraction && typeof window !== 'undefined' && typeof window.__ufo_devtool_onVCRevisionReady__ === 'function') {
156
169
  try {
157
170
  (_ufo_devtool_onVCRev = (_ref = window).__ufo_devtool_onVCRevisionReady__) === null || _ufo_devtool_onVCRev === void 0 || _ufo_devtool_onVCRev.call(_ref, {
158
171
  revision: this.revisionNo,
@@ -167,14 +180,14 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
167
180
  console.error('Error in onVCRevisionReady', e);
168
181
  }
169
182
  }
170
- return _context2.abrupt("return", vcDetails);
183
+ return _context.abrupt("return", vcDetails);
171
184
  case 32:
172
185
  case "end":
173
- return _context2.stop();
186
+ return _context.stop();
174
187
  }
175
- }, _callee2, this, [[10, 22, 25, 28]]);
188
+ }, _callee, this, [[10, 22, 25, 28]]);
176
189
  }));
177
- function calculateWithDebugInfo(_x4, _x5, _x6, _x7, _x8, _x9, _x10) {
190
+ function calculateWithDebugInfo(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
178
191
  return _calculateWithDebugInfo.apply(this, arguments);
179
192
  }
180
193
  return calculateWithDebugInfo;
@@ -182,13 +195,13 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
182
195
  }, {
183
196
  key: "calculate",
184
197
  value: function () {
185
- var _calculate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
198
+ var _calculate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
186
199
  var _this = this,
187
200
  _vcDetails$90$t,
188
201
  _vcDetails$;
189
- var startTime, stopTime, orderedEntries, interactionId, isPostInteraction, filteredEntries, isVCClean, dirtyReason, getVCCleanStatusResult, useDebugInfo, vcDetails;
190
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
191
- while (1) switch (_context3.prev = _context3.next) {
202
+ var startTime, stopTime, orderedEntries, interactionId, isPostInteraction, filteredEntries, isVCClean, dirtyReason, getVCCleanStatusResult, vcDetails, result;
203
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
204
+ while (1) switch (_context2.prev = _context2.next) {
192
205
  case 0:
193
206
  startTime = _ref2.startTime, stopTime = _ref2.stopTime, orderedEntries = _ref2.orderedEntries, interactionId = _ref2.interactionId, isPostInteraction = _ref2.isPostInteraction;
194
207
  filteredEntries = orderedEntries.filter(function (entry) {
@@ -198,47 +211,37 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
198
211
  isVCClean = getVCCleanStatusResult.isVCClean;
199
212
  dirtyReason = getVCCleanStatusResult.dirtyReason;
200
213
  if (isVCClean) {
201
- _context3.next = 7;
214
+ _context2.next = 7;
202
215
  break;
203
216
  }
204
- return _context3.abrupt("return", {
217
+ return _context2.abrupt("return", {
205
218
  revision: this.revisionNo,
206
219
  'metric:vc90': null,
207
220
  clean: false,
208
221
  abortReason: dirtyReason
209
222
  });
210
223
  case 7:
211
- useDebugInfo = fg('platform_ufo_ttvc_v3_devtool');
212
- if (!useDebugInfo) {
213
- _context3.next = 14;
214
- break;
215
- }
216
- _context3.next = 11;
224
+ _context2.next = 9;
217
225
  return this.calculateWithDebugInfo(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason);
218
- case 11:
219
- _context3.t0 = _context3.sent;
220
- _context3.next = 17;
221
- break;
222
- case 14:
223
- _context3.next = 16;
224
- return this.calculateBasic(filteredEntries, startTime, stopTime);
225
- case 16:
226
- _context3.t0 = _context3.sent;
227
- case 17:
228
- vcDetails = _context3.t0;
229
- return _context3.abrupt("return", {
226
+ case 9:
227
+ vcDetails = _context2.sent;
228
+ result = {
230
229
  revision: this.revisionNo,
231
230
  clean: true,
232
231
  'metric:vc90': (_vcDetails$90$t = vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t) !== null && _vcDetails$90$t !== void 0 ? _vcDetails$90$t : null,
233
232
  vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
234
- });
235
- case 19:
233
+ };
234
+ if (fg('platform_ufo_rev_ratios')) {
235
+ result.ratios = this.calculateRatios(filteredEntries);
236
+ }
237
+ return _context2.abrupt("return", result);
238
+ case 13:
236
239
  case "end":
237
- return _context3.stop();
240
+ return _context2.stop();
238
241
  }
239
- }, _callee3, this);
242
+ }, _callee2, this);
240
243
  }));
241
- function calculate(_x11) {
244
+ function calculate(_x8) {
242
245
  return _calculate.apply(this, arguments);
243
246
  }
244
247
  return calculate;
@@ -40,7 +40,7 @@ var VCCalculator_FY25_03 = /*#__PURE__*/function (_AbstractVCCalculator) {
40
40
  if (attributeName === 'data-aui-version' && fg('platform_ufo_filter_out_aui_attribute_changes')) {
41
41
  return false;
42
42
  }
43
- if ((attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName)) && fg('platform_ufo_ignore_non_vis_attributes')) {
43
+ if (attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName)) {
44
44
  return false;
45
45
  }
46
46
  return true;
@@ -204,8 +204,8 @@ export function calculatePercentilesWithDebugInfo(timePixelCounts, elementMap, t
204
204
  var sortedEntries = Array.from(timePixelCounts.entries()).sort(function (_ref7, _ref8) {
205
205
  var _ref9 = _slicedToArray(_ref7, 1),
206
206
  timeA = _ref9[0];
207
- var _ref10 = _slicedToArray(_ref8, 1),
208
- timeB = _ref10[0];
207
+ var _ref0 = _slicedToArray(_ref8, 1),
208
+ timeB = _ref0[0];
209
209
  return Number(timeA) - Number(timeB);
210
210
  });
211
211
  for (var i = 0; i < sortedEntries.length; i++) {
@@ -113,6 +113,7 @@ export type RevisionPayloadEntry = {
113
113
  revision: string;
114
114
  clean: boolean;
115
115
  vcDetails?: RevisionPayloadVCDetails;
116
+ ratios?: VCRatioType;
116
117
  abortReason?: VCAbortReason | null;
117
118
  };
118
119
  export type RevisionPayload = RevisionPayloadEntry[];
@@ -1,5 +1,5 @@
1
1
  import type { InteractionMetrics } from '../../common/common/types';
2
- import type { RevisionPayload } from '../../common/vc/types';
2
+ import type { RevisionPayload, VCRatioType } from '../../common/vc/types';
3
3
  type CalculatedVC = {
4
4
  VC: {
5
5
  [key: string]: number | null;
@@ -8,7 +8,7 @@ type CalculatedVC = {
8
8
  [key: string]: string[] | null;
9
9
  };
10
10
  };
11
- export declare function getVCRevisionsData({ fullPrefix, interaction, isVCClean, isEventAborted, calculatedVC, calculatedVCNext, experienceKey, }: {
11
+ export declare function getVCRevisionsData({ fullPrefix, interaction, isVCClean, isEventAborted, calculatedVC, calculatedVCNext, experienceKey, ratios, }: {
12
12
  fullPrefix?: string;
13
13
  interaction: Pick<InteractionMetrics, 'start' | 'end'>;
14
14
  isVCClean: boolean;
@@ -16,6 +16,7 @@ export declare function getVCRevisionsData({ fullPrefix, interaction, isVCClean,
16
16
  calculatedVC: CalculatedVC;
17
17
  calculatedVCNext: CalculatedVC;
18
18
  experienceKey: string;
19
+ ratios: VCRatioType;
19
20
  }): {
20
21
  [x: string]: RevisionPayload;
21
22
  };
@@ -10,7 +10,10 @@ export default abstract class AbstractVCCalculatorBase implements VCCalculator {
10
10
  dirtyReason?: VCAbortReason;
11
11
  };
12
12
  private filterViewportEntries;
13
- private calculateBasic;
13
+ /**
14
+ * Calculate ratios for each element based on their viewport coverage.
15
+ */
16
+ private calculateRatios;
14
17
  private calculateWithDebugInfo;
15
18
  calculate({ startTime, stopTime, orderedEntries, interactionId, isPostInteraction, }: VCCalculatorParam): Promise<RevisionPayloadEntry | undefined>;
16
19
  }
@@ -113,6 +113,7 @@ export type RevisionPayloadEntry = {
113
113
  revision: string;
114
114
  clean: boolean;
115
115
  vcDetails?: RevisionPayloadVCDetails;
116
+ ratios?: VCRatioType;
116
117
  abortReason?: VCAbortReason | null;
117
118
  };
118
119
  export type RevisionPayload = RevisionPayloadEntry[];