@atlaskit/react-ufo 3.13.12 → 3.13.14

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 (42) hide show
  1. package/CHANGELOG.md +19 -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 +38 -51
  17. package/dist/cjs/vc/vc-observer/media-wrapper/index.js +1 -2
  18. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +76 -42
  19. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +1 -15
  20. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +2 -2
  21. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/index.js +1 -2
  22. package/dist/es2019/interaction-metrics/index.js +10 -10
  23. package/dist/es2019/vc/vc-observer/getVCRevisionsData.js +15 -5
  24. package/dist/es2019/vc/vc-observer/index.js +3 -18
  25. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +40 -22
  26. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +1 -13
  27. package/dist/esm/config/index.js +4 -4
  28. package/dist/esm/interaction-metrics/index.js +10 -10
  29. package/dist/esm/vc/vc-observer/getVCRevisionsData.js +15 -5
  30. package/dist/esm/vc/vc-observer/index.js +38 -51
  31. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +77 -43
  32. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +1 -15
  33. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +2 -2
  34. package/dist/types/common/vc/types.d.ts +1 -0
  35. package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +3 -2
  36. package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +4 -1
  37. package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +0 -1
  38. package/dist/types-ts4.5/common/vc/types.d.ts +1 -0
  39. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +3 -2
  40. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +4 -1
  41. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +0 -1
  42. package/package.json +4 -7
@@ -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
  }
@@ -96,7 +96,7 @@ export var VCObserver = /*#__PURE__*/function () {
96
96
  });
97
97
  _defineProperty(this, "getVCResult", /*#__PURE__*/function () {
98
98
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3) {
99
- var start, stop, tti, prefix, ssr, vc, isEventAborted, experienceKey, interactionId, includeSSRRatio, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, isTTVCv1Disabled, vcAbortedResultWithRevisions, ttvcV1Result, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, ttvcV1DevToolInfo, ttvcV2DevToolInfo, _ufo_devtool_onVCRev2, _ref10, _ufo_devtool_onVCRev, _ref9, isVCClean, revisionsData, speedIndex, SSRRatio, SSRRatioNext, SSRRatioPayload, isTTVCv3Enabled;
99
+ var start, stop, tti, prefix, ssr, vc, isEventAborted, experienceKey, interactionId, includeSSRRatio, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, isTTVCv1Disabled, vcAbortedResultWithRevisions, ttvcV1Result, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, ttvcV1DevToolInfo, ttvcV2DevToolInfo, _ufo_devtool_onVCRev2, _ref9, _ufo_devtool_onVCRev, _ref8, isVCClean, revisionsData, speedIndex, SSRRatio, SSRRatioNext, SSRRatioPayload, isTTVCv3Enabled;
100
100
  return _regeneratorRuntime.wrap(function _callee$(_context) {
101
101
  while (1) switch (_context.prev = _context.next) {
102
102
  case 0:
@@ -111,11 +111,9 @@ export var VCObserver = /*#__PURE__*/function () {
111
111
  return _context.abrupt("return", {});
112
112
  case 6:
113
113
  abortReason = rawData.abortReason, abortReasonInfo = rawData.abortReasonInfo, heatmap = rawData.heatmap, heatmapNext = rawData.heatmapNext, outOfBoundaryInfo = rawData.outOfBoundaryInfo, totalTime = rawData.totalTime, componentsLog = rawData.componentsLog, viewport = rawData.viewport, devToolsEnabled = rawData.devToolsEnabled, ratios = rawData.ratios;
114
- isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01', experienceKey); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
115
- // we want to report abort by scroll events the same way as other abort reasons
116
- // i.e. not have the concept of `abortReason.blocking` anymore
117
- if (!(abortReasonInfo !== null && fg('platform_ufo_add_vc_abort_reason_by_revisions'))) {
118
- _context.next = 15;
114
+ isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01', experienceKey);
115
+ if (!(abortReasonInfo !== null)) {
116
+ _context.next = 13;
119
117
  break;
120
118
  }
121
119
  // exposing data to devtools
@@ -139,19 +137,7 @@ export var VCObserver = /*#__PURE__*/function () {
139
137
  });
140
138
  }
141
139
  return _context.abrupt("return", vcAbortedResultWithRevisions);
142
- case 15:
143
- if (!(abortReasonInfo !== null && abortReason.blocking)) {
144
- _context.next = 18;
145
- break;
146
- }
147
- // exposing data to devtools
148
- try {
149
- if (devToolsEnabled && !_this.isPostInteraction) {
150
- window.__vcNotAvailableReason = abortReasonInfo;
151
- }
152
- } catch (e) {}
153
- return _context.abrupt("return", _defineProperty(_defineProperty(_defineProperty({}, "".concat(fullPrefix, "vc:state"), false), "".concat(fullPrefix, "vc:abort:reason"), abortReasonInfo), "".concat(fullPrefix, "vc:abort:timestamp"), abortReason.timestamp));
154
- case 18:
140
+ case 13:
155
141
  ttvcV1Result = isTTVCv1Disabled ? {
156
142
  VC: {},
157
143
  VCBox: {},
@@ -170,10 +156,10 @@ export var VCObserver = /*#__PURE__*/function () {
170
156
  });
171
157
  VC = ttvcV1Result.VC, VCBox = ttvcV1Result.VCBox, VCEntries = ttvcV1Result.VCEntries, totalPainted = ttvcV1Result.totalPainted;
172
158
  _componentsLog = {};
173
- Object.entries(_this.componentsLog).forEach(function (_ref6) {
174
- var _ref7 = _slicedToArray(_ref6, 2),
175
- _timestamp = _ref7[0],
176
- value = _ref7[1];
159
+ Object.entries(_this.componentsLog).forEach(function (_ref5) {
160
+ var _ref6 = _slicedToArray(_ref5, 2),
161
+ _timestamp = _ref6[0],
162
+ value = _ref6[1];
177
163
  var timestamp = Number(_timestamp);
178
164
  if (stop > timestamp) {
179
165
  _componentsLog[timestamp] = value;
@@ -284,7 +270,7 @@ export var VCObserver = /*#__PURE__*/function () {
284
270
  if (typeof window.__ufo_devtool_onVCRevisionReady__ === 'function' && fg('platform_ufo_ttvc_v3_devtool')) {
285
271
  // Handle v1 if not disabled
286
272
  if (!isTTVCv1Disabled) {
287
- (_ufo_devtool_onVCRev = (_ref9 = window).__ufo_devtool_onVCRevisionReady__) === null || _ufo_devtool_onVCRev === void 0 || _ufo_devtool_onVCRev.call(_ref9, getVCRevisionDebugDetails({
273
+ (_ufo_devtool_onVCRev = (_ref8 = window).__ufo_devtool_onVCRevisionReady__) === null || _ufo_devtool_onVCRev === void 0 || _ufo_devtool_onVCRev.call(_ref8, getVCRevisionDebugDetails({
288
274
  revision: 'fy25.01',
289
275
  isClean: !abortReasonInfo,
290
276
  abortReason: abortReason.reason,
@@ -295,7 +281,7 @@ export var VCObserver = /*#__PURE__*/function () {
295
281
  }
296
282
 
297
283
  // Handle v2
298
- (_ufo_devtool_onVCRev2 = (_ref10 = window).__ufo_devtool_onVCRevisionReady__) === null || _ufo_devtool_onVCRev2 === void 0 || _ufo_devtool_onVCRev2.call(_ref10, getVCRevisionDebugDetails({
284
+ (_ufo_devtool_onVCRev2 = (_ref9 = window).__ufo_devtool_onVCRevisionReady__) === null || _ufo_devtool_onVCRev2 === void 0 || _ufo_devtool_onVCRev2.call(_ref9, getVCRevisionDebugDetails({
299
285
  revision: 'fy25.02',
300
286
  isClean: !abortReasonInfo,
301
287
  abortReason: abortReason.reason,
@@ -325,23 +311,24 @@ export var VCObserver = /*#__PURE__*/function () {
325
311
  VCBox: vcNext.VCBox
326
312
  },
327
313
  isEventAborted: isEventAborted,
328
- experienceKey: experienceKey
314
+ experienceKey: experienceKey,
315
+ ratios: ratios
329
316
  });
330
317
  speedIndex = _defineProperty(_defineProperty({}, "ufo:speedIndex", isTTVCv1Disabled ? vcNext.VCEntries.speedIndex : VCEntries.speedIndex), "ufo:next:speedIndex", vcNext.VCEntries.speedIndex);
331
318
  SSRRatio = VCObserver.getSSRRatio(VCEntries.rel, ssr);
332
319
  SSRRatioNext = VCObserver.getSSRRatio(vcNext.VCEntries.rel, ssr);
333
320
  SSRRatioPayload = includeSSRRatio ? _defineProperty(_defineProperty({}, "".concat(fullPrefix, "vc:ssrRatio"), isTTVCv1Disabled ? SSRRatioNext : SSRRatio), "".concat(fullPrefix, "vc:next:ssrRatio"), SSRRatioNext) : {};
334
321
  if (!isTTVCv1Disabled) {
335
- _context.next = 35;
322
+ _context.next = 30;
336
323
  break;
337
324
  }
338
325
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread(_defineProperty(_defineProperty(_defineProperty({}, "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, _defineProperty({}, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), SSRRatioPayload), {}, _defineProperty({}, "".concat(fullPrefix, "vc:ssrRatio"), SSRRatioNext), revisionsData), speedIndex));
339
- case 35:
326
+ case 30:
340
327
  isTTVCv3Enabled = isVCRevisionEnabled('fy25.03', experienceKey);
341
328
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
342
329
  'metrics:vc': VC
343
330
  }, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"), isVCClean), "".concat(fullPrefix, "vc:dom"), VCBox), "".concat(fullPrefix, "vc:updates"), isTTVCv3Enabled ? undefined : VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:total"), totalPainted), "".concat(fullPrefix, "vc:ratios"), ratios), "".concat(fullPrefix, "vc:ssrRatio"), SSRRatio), outOfBoundary), {}, _defineProperty(_defineProperty(_defineProperty({}, "".concat(fullPrefix, "vc:next"), vcNext.VC), "".concat(fullPrefix, "vc:next:updates"), isTTVCv3Enabled ? undefined : vcNext.VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:next:dom"), vcNext.VCBox), SSRRatioPayload), {}, _defineProperty({}, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
344
- case 37:
331
+ case 32:
345
332
  case "end":
346
333
  return _context.stop();
347
334
  }
@@ -434,10 +421,10 @@ export var VCObserver = /*#__PURE__*/function () {
434
421
  _this.detachAbortListeners();
435
422
  var unbinds = attachAbortListeners(window, _this.viewport, _this.abortReasonCallback);
436
423
  if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
437
- Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref12) {
438
- var _ref13 = _slicedToArray(_ref12, 2),
439
- key = _ref13[0],
440
- time = _ref13[1];
424
+ Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref1) {
425
+ var _ref10 = _slicedToArray(_ref1, 2),
426
+ key = _ref10[0],
427
+ time = _ref10[1];
441
428
  if (time) {
442
429
  _this.abortReasonCallback(key, time);
443
430
  }
@@ -467,8 +454,8 @@ export var VCObserver = /*#__PURE__*/function () {
467
454
  }
468
455
  return _createClass(VCObserver, [{
469
456
  key: "start",
470
- value: function start(_ref14) {
471
- var startTime = _ref14.startTime;
457
+ value: function start(_ref11) {
458
+ var startTime = _ref11.startTime;
472
459
  this.active = true;
473
460
  if (this.observers.isBrowserSupported()) {
474
461
  this.setViewportSize();
@@ -490,12 +477,12 @@ export var VCObserver = /*#__PURE__*/function () {
490
477
  }, {
491
478
  key: "getIgnoredElements",
492
479
  value: function getIgnoredElements(componentsLog) {
493
- return Object.values(componentsLog).flat().filter(function (_ref15) {
494
- var ignoreReason = _ref15.ignoreReason;
480
+ return Object.values(componentsLog).flat().filter(function (_ref12) {
481
+ var ignoreReason = _ref12.ignoreReason;
495
482
  return Boolean(ignoreReason);
496
- }).map(function (_ref16) {
497
- var targetName = _ref16.targetName,
498
- ignoreReason = _ref16.ignoreReason;
483
+ }).map(function (_ref13) {
484
+ var targetName = _ref13.targetName,
485
+ ignoreReason = _ref13.ignoreReason;
499
486
  return {
500
487
  targetName: targetName,
501
488
  ignoreReason: ignoreReason
@@ -625,13 +612,13 @@ export var VCObserver = /*#__PURE__*/function () {
625
612
  }
626
613
  }, {
627
614
  key: "calculateVC",
628
- value: function calculateVC(_ref17) {
629
- var heatmap = _ref17.heatmap,
630
- _ref17$ssr = _ref17.ssr,
631
- ssr = _ref17$ssr === void 0 ? UNUSED_SECTOR : _ref17$ssr,
632
- componentsLog = _ref17.componentsLog,
633
- viewport = _ref17.viewport,
634
- fixSSRAttribution = _ref17.fixSSRAttribution;
615
+ value: function calculateVC(_ref14) {
616
+ var heatmap = _ref14.heatmap,
617
+ _ref14$ssr = _ref14.ssr,
618
+ ssr = _ref14$ssr === void 0 ? UNUSED_SECTOR : _ref14$ssr,
619
+ componentsLog = _ref14.componentsLog,
620
+ viewport = _ref14.viewport,
621
+ fixSSRAttribution = _ref14.fixSSRAttribution;
635
622
  var lastUpdate = {};
636
623
  var totalPainted = 0;
637
624
  var ssrTime = fixSSRAttribution ? Math.floor(ssr) : ssr;
@@ -698,11 +685,11 @@ export var VCObserver = /*#__PURE__*/function () {
698
685
  });
699
686
  return VCRatio;
700
687
  }, 0);
701
- var VCEntries = entries.reduce(function (acc, _ref18, i) {
688
+ var VCEntries = entries.reduce(function (acc, _ref15, i) {
702
689
  var _acc$abs, _componentsLog$timest, _acc$rel$vc, _acc$rel;
703
- var _ref19 = _slicedToArray(_ref18, 2),
704
- timestamp = _ref19[0],
705
- entryPainted = _ref19[1];
690
+ var _ref16 = _slicedToArray(_ref15, 2),
691
+ timestamp = _ref16[0],
692
+ entryPainted = _ref16[1];
706
693
  var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
707
694
  var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
708
695
  var logEntry = _toConsumableArray(new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.filter(function (v) {
@@ -1,10 +1,11 @@
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
10
  import { calculateTTVCPercentiles, calculateTTVCPercentilesWithDebugInfo } from './percentile-calc';
10
11
  import getViewportHeight from './utils/get-viewport-height';
@@ -21,6 +22,53 @@ 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
+ */
29
+ }, {
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);
48
+ }
49
+ }
50
+ } catch (err) {
51
+ _iterator.e(err);
52
+ } finally {
53
+ _iterator.f();
54
+ }
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
+ }
24
72
  }, {
25
73
  key: "calculateBasic",
26
74
  value: function () {
@@ -60,7 +108,7 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
60
108
  key: "calculateWithDebugInfo",
61
109
  value: function () {
62
110
  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;
111
+ var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator3, _step3, _entry2, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, _ufo_devtool_onVCRev, _ref;
64
112
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
65
113
  while (1) switch (_context2.prev = _context2.next) {
66
114
  case 0:
@@ -85,16 +133,16 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
85
133
  _context2.next = 28;
86
134
  break;
87
135
  }
88
- _iterator = _createForOfIteratorHelper(vcLogs);
136
+ _iterator3 = _createForOfIteratorHelper(vcLogs);
89
137
  _context2.prev = 10;
90
- _iterator.s();
138
+ _iterator3.s();
91
139
  case 12:
92
- if ((_step = _iterator.n()).done) {
140
+ if ((_step3 = _iterator3.n()).done) {
93
141
  _context2.next = 20;
94
142
  break;
95
143
  }
96
- _entry = _step.value;
97
- time = _entry.time, viewportPercentage = _entry.viewportPercentage, entries = _entry.entries; // Only process entries if we haven't reached all percentiles
144
+ _entry2 = _step3.value;
145
+ time = _entry2.time, viewportPercentage = _entry2.viewportPercentage, entries = _entry2.entries; // Only process entries if we haven't reached all percentiles
98
146
  if (!(percentileIndex >= percentiles.length)) {
99
147
  _context2.next = 17;
100
148
  break;
@@ -131,10 +179,10 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
131
179
  case 22:
132
180
  _context2.prev = 22;
133
181
  _context2.t0 = _context2["catch"](10);
134
- _iterator.e(_context2.t0);
182
+ _iterator3.e(_context2.t0);
135
183
  case 25:
136
184
  _context2.prev = 25;
137
- _iterator.f();
185
+ _iterator3.f();
138
186
  return _context2.finish(25);
139
187
  case 28:
140
188
  // Fill in any missing percentiles with the last known values
@@ -174,7 +222,7 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
174
222
  }
175
223
  }, _callee2, this, [[10, 22, 25, 28]]);
176
224
  }));
177
- function calculateWithDebugInfo(_x4, _x5, _x6, _x7, _x8, _x9, _x10) {
225
+ function calculateWithDebugInfo(_x4, _x5, _x6, _x7, _x8, _x9, _x0) {
178
226
  return _calculateWithDebugInfo.apply(this, arguments);
179
227
  }
180
228
  return calculateWithDebugInfo;
@@ -186,7 +234,7 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
186
234
  var _this = this,
187
235
  _vcDetails$90$t,
188
236
  _vcDetails$;
189
- var startTime, stopTime, orderedEntries, interactionId, isPostInteraction, filteredEntries, isVCClean, dirtyReason, getVCCleanStatusResult, useDebugInfo, vcDetails;
237
+ var startTime, stopTime, orderedEntries, interactionId, isPostInteraction, filteredEntries, isVCClean, dirtyReason, getVCCleanStatusResult, useDebugInfo, vcDetails, result;
190
238
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
191
239
  while (1) switch (_context3.prev = _context3.next) {
192
240
  case 0:
@@ -194,15 +242,11 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
194
242
  filteredEntries = orderedEntries.filter(function (entry) {
195
243
  return _this.isEntryIncluded(entry);
196
244
  });
197
- if (!fg('platform_ufo_add_vc_abort_reason_by_revisions')) {
198
- _context3.next = 10;
199
- break;
200
- }
201
245
  getVCCleanStatusResult = this.getVCCleanStatus(filteredEntries);
202
246
  isVCClean = getVCCleanStatusResult.isVCClean;
203
247
  dirtyReason = getVCCleanStatusResult.dirtyReason;
204
248
  if (isVCClean) {
205
- _context3.next = 8;
249
+ _context3.next = 7;
206
250
  break;
207
251
  }
208
252
  return _context3.abrupt("return", {
@@ -211,52 +255,42 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
211
255
  clean: false,
212
256
  abortReason: dirtyReason
213
257
  });
214
- case 8:
215
- _context3.next = 13;
216
- break;
217
- case 10:
218
- isVCClean = this.isVCClean(filteredEntries);
219
- if (isVCClean) {
220
- _context3.next = 13;
221
- break;
222
- }
223
- return _context3.abrupt("return", {
224
- revision: this.revisionNo,
225
- 'metric:vc90': null,
226
- clean: false
227
- });
228
- case 13:
258
+ case 7:
229
259
  useDebugInfo = fg('platform_ufo_ttvc_v3_devtool');
230
260
  if (!useDebugInfo) {
231
- _context3.next = 20;
261
+ _context3.next = 14;
232
262
  break;
233
263
  }
234
- _context3.next = 17;
264
+ _context3.next = 11;
235
265
  return this.calculateWithDebugInfo(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason);
236
- case 17:
266
+ case 11:
237
267
  _context3.t0 = _context3.sent;
238
- _context3.next = 23;
268
+ _context3.next = 17;
239
269
  break;
240
- case 20:
241
- _context3.next = 22;
270
+ case 14:
271
+ _context3.next = 16;
242
272
  return this.calculateBasic(filteredEntries, startTime, stopTime);
243
- case 22:
273
+ case 16:
244
274
  _context3.t0 = _context3.sent;
245
- case 23:
275
+ case 17:
246
276
  vcDetails = _context3.t0;
247
- return _context3.abrupt("return", {
277
+ result = {
248
278
  revision: this.revisionNo,
249
279
  clean: true,
250
280
  '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,
251
281
  vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
252
- });
253
- case 25:
282
+ };
283
+ if (fg('platform_ufo_rev_ratios')) {
284
+ result.ratios = this.calculateRatios(filteredEntries);
285
+ }
286
+ return _context3.abrupt("return", result);
287
+ case 21:
254
288
  case "end":
255
289
  return _context3.stop();
256
290
  }
257
291
  }, _callee3, this);
258
292
  }));
259
- function calculate(_x11) {
293
+ function calculate(_x1) {
260
294
  return _calculate.apply(this, arguments);
261
295
  }
262
296
  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;
@@ -50,20 +50,6 @@ var VCCalculator_FY25_03 = /*#__PURE__*/function (_AbstractVCCalculator) {
50
50
  }
51
51
  return true;
52
52
  }
53
- }, {
54
- key: "isVCClean",
55
- value: function isVCClean(filteredEntries) {
56
- var hasAbortEvent = filteredEntries.some(function (entry) {
57
- if (entry.data.type === 'window:event') {
58
- var data = entry.data;
59
- if (ABORTING_WINDOW_EVENT.includes(data.eventType)) {
60
- return true;
61
- }
62
- }
63
- return false;
64
- });
65
- return !hasAbortEvent;
66
- }
67
53
  }, {
68
54
  key: "getVCCleanStatus",
69
55
  value: function getVCCleanStatus(filteredEntries) {
@@ -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
  };
@@ -5,12 +5,15 @@ export default abstract class AbstractVCCalculatorBase implements VCCalculator {
5
5
  private revisionNo;
6
6
  constructor(revisionNo: string);
7
7
  protected abstract isEntryIncluded(entry: VCObserverEntry): boolean;
8
- protected abstract isVCClean(filteredEntries: ReadonlyArray<VCObserverEntry>): boolean;
9
8
  protected abstract getVCCleanStatus(filteredEntries: ReadonlyArray<VCObserverEntry>): {
10
9
  isVCClean: boolean;
11
10
  dirtyReason?: VCAbortReason;
12
11
  };
13
12
  private filterViewportEntries;
13
+ /**
14
+ * Calculate ratios for each element based on their viewport coverage.
15
+ */
16
+ private calculateRatios;
14
17
  private calculateBasic;
15
18
  private calculateWithDebugInfo;
16
19
  calculate({ startTime, stopTime, orderedEntries, interactionId, isPostInteraction, }: VCCalculatorParam): Promise<RevisionPayloadEntry | undefined>;
@@ -5,7 +5,6 @@ export declare const NON_VISUAL_ARIA_ATTRIBUTES: string[];
5
5
  export default class VCCalculator_FY25_03 extends AbstractVCCalculatorBase {
6
6
  constructor();
7
7
  protected isEntryIncluded(entry: VCObserverEntry): boolean;
8
- protected isVCClean(filteredEntries: readonly VCObserverEntry[]): boolean;
9
8
  protected getVCCleanStatus(filteredEntries: readonly VCObserverEntry[]): {
10
9
  isVCClean: boolean;
11
10
  dirtyReason: never;
@@ -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
  };
@@ -5,12 +5,15 @@ export default abstract class AbstractVCCalculatorBase implements VCCalculator {
5
5
  private revisionNo;
6
6
  constructor(revisionNo: string);
7
7
  protected abstract isEntryIncluded(entry: VCObserverEntry): boolean;
8
- protected abstract isVCClean(filteredEntries: ReadonlyArray<VCObserverEntry>): boolean;
9
8
  protected abstract getVCCleanStatus(filteredEntries: ReadonlyArray<VCObserverEntry>): {
10
9
  isVCClean: boolean;
11
10
  dirtyReason?: VCAbortReason;
12
11
  };
13
12
  private filterViewportEntries;
13
+ /**
14
+ * Calculate ratios for each element based on their viewport coverage.
15
+ */
16
+ private calculateRatios;
14
17
  private calculateBasic;
15
18
  private calculateWithDebugInfo;
16
19
  calculate({ startTime, stopTime, orderedEntries, interactionId, isPostInteraction, }: VCCalculatorParam): Promise<RevisionPayloadEntry | undefined>;
@@ -5,7 +5,6 @@ export declare const NON_VISUAL_ARIA_ATTRIBUTES: string[];
5
5
  export default class VCCalculator_FY25_03 extends AbstractVCCalculatorBase {
6
6
  constructor();
7
7
  protected isEntryIncluded(entry: VCObserverEntry): boolean;
8
- protected isVCClean(filteredEntries: readonly VCObserverEntry[]): boolean;
9
8
  protected getVCCleanStatus(filteredEntries: readonly VCObserverEntry[]): {
10
9
  isVCClean: boolean;
11
10
  dirtyReason: never;