@atlaskit/react-ufo 3.1.1 → 3.1.2

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 3.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#119178](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/119178)
8
+ [`f0b97fc480d38`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f0b97fc480d38) -
9
+ dedupe DOM element selectors within VC debug data
10
+ - [#119697](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/119697)
11
+ [`62268803ec9e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62268803ec9e6) -
12
+ refactor logic to get react ufo version
13
+
3
14
  ## 3.1.1
4
15
 
5
16
  ### Patch Changes
@@ -3,7 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.REACT_UFO_VERSION = void 0;
6
+ exports.getReactUFOVersion = void 0;
7
7
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
- // eslint-disable-next-line @atlaskit/platform/no-module-level-eval
9
- var REACT_UFO_VERSION = exports.REACT_UFO_VERSION = (0, _platformFeatureFlags.fg)('enable-react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
8
+ var getReactUFOVersion = exports.getReactUFOVersion = function getReactUFOVersion(interactionType) {
9
+ if (interactionType !== 'page_load' && interactionType !== 'transition') {
10
+ return '1.0.1';
11
+ }
12
+
13
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
14
+ if (!(0, _platformFeatureFlags.fg)('enable-react-ufo-payload-segment-compressed')) {
15
+ return '1.0.1';
16
+ }
17
+ return '2.0.0';
18
+ };
@@ -11,9 +11,8 @@ exports.optimizeLabelStack = optimizeLabelStack;
11
11
  exports.sanitizeUfoName = void 0;
12
12
  exports.stringifyLabelStackFully = stringifyLabelStackFully;
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _constants = require("../../../common/constants");
15
14
  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; }
16
- 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) { (0, _defineProperty2.default)(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; } /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
15
+ 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) { (0, _defineProperty2.default)(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; }
17
16
  var sanitizeUfoName = exports.sanitizeUfoName = function sanitizeUfoName(name) {
18
17
  return name.replace(/_/g, '-');
19
18
  };
@@ -62,8 +61,8 @@ function getLabelStackReference(labelStack) {
62
61
  function labelStackStartWith(labelStack, startWith) {
63
62
  return stringifyLabelStackFully(labelStack).startsWith(stringifyLabelStackFully(startWith));
64
63
  }
65
- function optimizeLabelStack(labelStack) {
66
- return _constants.REACT_UFO_VERSION === '2.0.0' ? getLabelStackReference(labelStack) : labelStack.map(function (ls) {
64
+ function optimizeLabelStack(labelStack, reactUFOVersion) {
65
+ return reactUFOVersion ? getLabelStackReference(labelStack) : labelStack.map(function (ls) {
67
66
  return _objectSpread({
68
67
  n: ls.name
69
68
  }, ls.segmentId ? {
@@ -393,7 +393,7 @@ function optimizeCustomData(interaction) {
393
393
  var label = (0, _utils.stringifyLabelStackFully)(labelStack);
394
394
  var value = (_result$get$data = (_result$get = result.get(label)) === null || _result$get === void 0 ? void 0 : _result$get.data) !== null && _result$get$data !== void 0 ? _result$get$data : {};
395
395
  result.set(label, {
396
- labelStack: (0, _utils.optimizeLabelStack)(labelStack),
396
+ labelStack: (0, _utils.optimizeLabelStack)(labelStack, (0, _constants.getReactUFOVersion)(interaction.type)),
397
397
  data: Object.assign(value, data)
398
398
  });
399
399
  return result;
@@ -410,7 +410,7 @@ function optimizeCustomData(interaction) {
410
410
  var label = (0, _utils.stringifyLabelStackFully)([]);
411
411
  var labelValue = (_result$get$data2 = (_result$get2 = result.get(label)) === null || _result$get2 === void 0 ? void 0 : _result$get2.data) !== null && _result$get$data2 !== void 0 ? _result$get$data2 : {};
412
412
  result.set(label, {
413
- labelStack: (0, _utils.optimizeLabelStack)([]),
413
+ labelStack: (0, _utils.optimizeLabelStack)([], (0, _constants.getReactUFOVersion)(interaction.type)),
414
414
  data: Object.assign(labelValue, (0, _defineProperty2.default)({}, _key, value))
415
415
  });
416
416
  }
@@ -420,7 +420,7 @@ function optimizeCustomData(interaction) {
420
420
  }
421
421
  return (0, _toConsumableArray2.default)(customDataMap.values());
422
422
  }
423
- function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart) {
423
+ function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
424
424
  var reactProfilerTimingsMap = reactProfilerTimings.reduce(function (result, _ref3) {
425
425
  var labelStack = _ref3.labelStack,
426
426
  startTime = _ref3.startTime,
@@ -432,7 +432,7 @@ function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart) {
432
432
  var start = Math.round(startTime);
433
433
  var end = Math.round(commitTime);
434
434
  var timing = result.get(label) || {
435
- labelStack: (0, _utils.optimizeLabelStack)(labelStack),
435
+ labelStack: (0, _utils.optimizeLabelStack)(labelStack, reactUFOVersion),
436
436
  startTime: start,
437
437
  endTime: end,
438
438
  mountCount: 0,
@@ -479,7 +479,7 @@ function optimizeRedirects(redirects, interactionStart) {
479
479
  }, []);
480
480
  return updatedRedirects;
481
481
  }
482
- function optimizeHoldInfo(holdInfo, interactionStart) {
482
+ function optimizeHoldInfo(holdInfo, interactionStart, reactUFOVersion) {
483
483
  var holdInfoMap = holdInfo.reduce(function (result, hold) {
484
484
  var labelStack = hold.labelStack,
485
485
  name = hold.name,
@@ -495,7 +495,7 @@ function optimizeHoldInfo(holdInfo, interactionStart) {
495
495
  var timing = result.get(label) || {
496
496
  labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
497
497
  name: name
498
- }])),
498
+ }]), reactUFOVersion),
499
499
  startTime: startTime,
500
500
  endTime: endTime
501
501
  };
@@ -511,7 +511,7 @@ function optimizeHoldInfo(holdInfo, interactionStart) {
511
511
  }, new Map());
512
512
  return (0, _toConsumableArray2.default)(holdInfoMap.values());
513
513
  }
514
- function optimizeSpans(spans, interactionStart) {
514
+ function optimizeSpans(spans, interactionStart, reactUFOVersion) {
515
515
  var updatedSpans = spans.reduce(function (result, span) {
516
516
  var labelStack = span.labelStack,
517
517
  type = span.type,
@@ -522,7 +522,7 @@ function optimizeSpans(spans, interactionStart) {
522
522
  result.push({
523
523
  labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
524
524
  name: name
525
- }])),
525
+ }]), reactUFOVersion),
526
526
  startTime: Math.round(start),
527
527
  endTime: Math.round(end),
528
528
  type: type
@@ -532,7 +532,7 @@ function optimizeSpans(spans, interactionStart) {
532
532
  }, []);
533
533
  return updatedSpans;
534
534
  }
535
- function optimizeRequestInfo(requestInfo, interactionStart) {
535
+ function optimizeRequestInfo(requestInfo, interactionStart, reactUFOVersion) {
536
536
  var updatedRequestInfo = requestInfo.reduce(function (result, reqInfo) {
537
537
  var labelStack = reqInfo.labelStack,
538
538
  name = reqInfo.name,
@@ -546,7 +546,7 @@ function optimizeRequestInfo(requestInfo, interactionStart) {
546
546
  result.push({
547
547
  labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
548
548
  name: name
549
- }])),
549
+ }]), reactUFOVersion),
550
550
  startTime: Math.round(startTime),
551
551
  endTime: Math.round(endTime)
552
552
  });
@@ -571,18 +571,18 @@ function optimizeCustomTimings(customTimings, interactionStart) {
571
571
  return result;
572
572
  }, []);
573
573
  }
574
- function optimizeMarks(marks) {
574
+ function optimizeMarks(marks, reactUFOVersion) {
575
575
  return marks.map(function (_ref4) {
576
576
  var labelStack = _ref4.labelStack,
577
577
  time = _ref4.time,
578
578
  others = (0, _objectWithoutProperties2.default)(_ref4, _excluded);
579
579
  return _objectSpread(_objectSpread({}, others), {}, {
580
- labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack),
580
+ labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack, reactUFOVersion),
581
581
  time: Math.round(time)
582
582
  });
583
583
  });
584
584
  }
585
- function optimizeApdex(apdex) {
585
+ function optimizeApdex(apdex, reactUFOVersion) {
586
586
  return apdex.map(function (_ref5) {
587
587
  var stopTime = _ref5.stopTime,
588
588
  labelStack = _ref5.labelStack,
@@ -590,7 +590,7 @@ function optimizeApdex(apdex) {
590
590
  return _objectSpread(_objectSpread({}, others), {}, {
591
591
  stopTime: Math.round(stopTime)
592
592
  }, labelStack ? {
593
- labelStack: (0, _utils.optimizeLabelStack)(labelStack)
593
+ labelStack: (0, _utils.optimizeLabelStack)(labelStack, reactUFOVersion)
594
594
  } : {});
595
595
  });
596
596
  }
@@ -726,7 +726,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
726
726
  var pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
727
727
  var pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
728
728
  var segments = config.killswitchNestedSegments ? [] : knownSegments;
729
- var segmentTree = _constants.REACT_UFO_VERSION === '2.0.0' ? (0, _utils.buildSegmentTree)(segments.map(function (segment) {
729
+ var segmentTree = (0, _constants.getReactUFOVersion)(interaction.type) === '2.0.0' ? (0, _utils.buildSegmentTree)(segments.map(function (segment) {
730
730
  return segment.labelStack;
731
731
  })) : {};
732
732
  var isDetailedPayload = pageVisibilityAtTTAI === 'visible';
@@ -735,7 +735,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
735
735
  var moreAccuratePageVisibilityAtTTI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTI(interaction) : null;
736
736
  var moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTAI(interaction) : null;
737
737
  var labelStack = interaction.labelStack ? {
738
- labelStack: (0, _utils.optimizeLabelStack)(interaction.labelStack)
738
+ labelStack: (0, _utils.optimizeLabelStack)(interaction.labelStack, (0, _constants.getReactUFOVersion)(interaction.type))
739
739
  } : {};
740
740
  // Page Load
741
741
  var getPageLoadInteractionMetrics = function getPageLoadInteractionMetrics() {
@@ -765,14 +765,14 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
765
765
  var labelStack = _ref6.labelStack,
766
766
  others = (0, _objectWithoutProperties2.default)(_ref6, _excluded3);
767
767
  return _objectSpread(_objectSpread({}, others), {}, {
768
- labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack)
768
+ labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack, (0, _constants.getReactUFOVersion)(interaction.type))
769
769
  });
770
770
  }),
771
771
  holdActive: (0, _toConsumableArray2.default)(interaction.holdActive.values()),
772
772
  redirects: optimizeRedirects(interaction.redirects, start),
773
- holdInfo: optimizeHoldInfo(experimental ? interaction.holdExpInfo : interaction.holdInfo, start),
774
- spans: optimizeSpans(spans, start),
775
- requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
773
+ holdInfo: optimizeHoldInfo(experimental ? interaction.holdExpInfo : interaction.holdInfo, start, (0, _constants.getReactUFOVersion)(interaction.type)),
774
+ spans: optimizeSpans(spans, start, (0, _constants.getReactUFOVersion)(interaction.type)),
775
+ requestInfo: optimizeRequestInfo(interaction.requestInfo, start, (0, _constants.getReactUFOVersion)(interaction.type)),
776
776
  customTimings: optimizeCustomTimings(interaction.customTimings, start),
777
777
  bundleEvalTimings: objectToArray(getBundleEvalTimings(start)),
778
778
  resourceTimings: objectToArray(resourceTimings)
@@ -812,8 +812,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
812
812
  'event:sizeInKb': 0,
813
813
  'event:source': {
814
814
  name: 'react-ufo/web',
815
- version: _constants.REACT_UFO_VERSION,
816
- payloadSource: 'platform'
815
+ version: (0, _constants.getReactUFOVersion)(interaction.type)
817
816
  },
818
817
  'event:region': config.region || 'unknown',
819
818
  'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
@@ -837,19 +836,19 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
837
836
  isPreviousInteractionAborted: isPreviousInteractionAborted,
838
837
  abortedByInteractionName: abortedByInteractionName,
839
838
  // performance
840
- apdex: optimizeApdex(interaction.apdex),
839
+ apdex: optimizeApdex(interaction.apdex, (0, _constants.getReactUFOVersion)(interaction.type)),
841
840
  end: Math.round(end),
842
841
  start: Math.round(start),
843
- segments: _constants.REACT_UFO_VERSION === '2.0.0' ? segmentTree : segments.map(function (_ref7) {
842
+ segments: (0, _constants.getReactUFOVersion)(interaction.type) === '2.0.0' ? segmentTree : segments.map(function (_ref7) {
844
843
  var labelStack = _ref7.labelStack,
845
844
  others = (0, _objectWithoutProperties2.default)(_ref7, _excluded4);
846
845
  return _objectSpread(_objectSpread({}, others), {}, {
847
- labelStack: (0, _utils.optimizeLabelStack)(labelStack)
846
+ labelStack: (0, _utils.optimizeLabelStack)(labelStack, (0, _constants.getReactUFOVersion)(interaction.type))
848
847
  });
849
848
  }),
850
- marks: optimizeMarks(interaction.marks),
849
+ marks: optimizeMarks(interaction.marks, (0, _constants.getReactUFOVersion)(interaction.type)),
851
850
  customData: optimizeCustomData(interaction),
852
- reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
851
+ reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start, (0, _constants.getReactUFOVersion)(interaction.type))
853
852
  }, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics(resourceTimings)), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)), {}, {
854
853
  'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
855
854
  'metric:experimental:ttai': expTTAI
@@ -188,7 +188,7 @@ function createPostInteractionLogPayload(_ref2) {
188
188
  'event:schema': '1.0.0',
189
189
  'event:source': {
190
190
  name: 'react-ufo/web',
191
- version: _constants.REACT_UFO_VERSION,
191
+ version: (0, _constants.getReactUFOVersion)(lastInteractionFinish.type),
192
192
  payloadSource: 'platform'
193
193
  },
194
194
  'event:region': config.region || 'unknown',
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.VCObserver = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
8
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -660,9 +661,9 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
660
661
  if ((VC[key] === null || VC[key] === undefined) && VCRatio >= value / 100) {
661
662
  var _componentsLog$time;
662
663
  VC[key] = time;
663
- VCBox[key] = (_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.map(function (v) {
664
+ VCBox[key] = (0, _toConsumableArray2.default)(new Set((_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.map(function (v) {
664
665
  return v.targetName;
665
- });
666
+ })));
666
667
  }
667
668
  });
668
669
  return VCRatio;
@@ -674,9 +675,9 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
674
675
  entryPainted = _ref19[1];
675
676
  var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
676
677
  var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
677
- var logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
678
+ var logEntry = (0, _toConsumableArray2.default)(new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
678
679
  return v.targetName;
679
- });
680
+ })));
680
681
  var ratioDelta = (currentlyPaintedRatio - ((_acc$rel$vc = (_acc$rel = acc.rel[i - 1]) === null || _acc$rel === void 0 ? void 0 : _acc$rel.vc) !== null && _acc$rel$vc !== void 0 ? _acc$rel$vc : 0)) / 100;
681
682
  if (isCalcSpeedIndexEnabled) {
682
683
  var speedIndex = timestamp * ratioDelta;
@@ -1,4 +1,12 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
+ export const getReactUFOVersion = interactionType => {
3
+ if (interactionType !== 'page_load' && interactionType !== 'transition') {
4
+ return '1.0.1';
5
+ }
2
6
 
3
- // eslint-disable-next-line @atlaskit/platform/no-module-level-eval
4
- export const REACT_UFO_VERSION = fg('enable-react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
7
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
8
+ if (!fg('enable-react-ufo-payload-segment-compressed')) {
9
+ return '1.0.1';
10
+ }
11
+ return '2.0.0';
12
+ };
@@ -1,5 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
2
- import { REACT_UFO_VERSION } from '../../../common/constants';
3
1
  export const sanitizeUfoName = name => {
4
2
  return name.replace(/_/g, '-');
5
3
  };
@@ -46,8 +44,8 @@ function getLabelStackReference(labelStack) {
46
44
  export function labelStackStartWith(labelStack, startWith) {
47
45
  return stringifyLabelStackFully(labelStack).startsWith(stringifyLabelStackFully(startWith));
48
46
  }
49
- export function optimizeLabelStack(labelStack) {
50
- return REACT_UFO_VERSION === '2.0.0' ? getLabelStackReference(labelStack) : labelStack.map(ls => ({
47
+ export function optimizeLabelStack(labelStack, reactUFOVersion) {
48
+ return reactUFOVersion ? getLabelStackReference(labelStack) : labelStack.map(ls => ({
51
49
  n: ls.name,
52
50
  ...(ls.segmentId ? {
53
51
  s: ls.segmentId
@@ -4,7 +4,7 @@ import { getLighthouseMetrics } from '../additional-payload';
4
4
  import { CHRReporter } from '../assets';
5
5
  import * as bundleEvalTiming from '../bundle-eval-timing';
6
6
  import coinflip from '../coinflip';
7
- import { REACT_UFO_VERSION } from '../common/constants';
7
+ import { getReactUFOVersion } from '../common/constants';
8
8
  import { getConfig, getExperimentalInteractionRate, getUfoNameOverrides } from '../config';
9
9
  import { getExperimentalVCMetrics } from '../create-experimental-interaction-metrics-payload';
10
10
  import { getBm3Timings } from '../custom-timings';
@@ -383,7 +383,7 @@ function optimizeCustomData(interaction) {
383
383
  const label = stringifyLabelStackFully(labelStack);
384
384
  const value = (_result$get$data = (_result$get = result.get(label)) === null || _result$get === void 0 ? void 0 : _result$get.data) !== null && _result$get$data !== void 0 ? _result$get$data : {};
385
385
  result.set(label, {
386
- labelStack: optimizeLabelStack(labelStack),
386
+ labelStack: optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type)),
387
387
  data: Object.assign(value, data)
388
388
  });
389
389
  return result;
@@ -395,7 +395,7 @@ function optimizeCustomData(interaction) {
395
395
  const label = stringifyLabelStackFully([]);
396
396
  const labelValue = (_result$get$data2 = (_result$get2 = result.get(label)) === null || _result$get2 === void 0 ? void 0 : _result$get2.data) !== null && _result$get$data2 !== void 0 ? _result$get$data2 : {};
397
397
  result.set(label, {
398
- labelStack: optimizeLabelStack([]),
398
+ labelStack: optimizeLabelStack([], getReactUFOVersion(interaction.type)),
399
399
  data: Object.assign(labelValue, {
400
400
  [key]: value
401
401
  })
@@ -407,7 +407,7 @@ function optimizeCustomData(interaction) {
407
407
  }
408
408
  return [...customDataMap.values()];
409
409
  }
410
- function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart) {
410
+ function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
411
411
  const reactProfilerTimingsMap = reactProfilerTimings.reduce((result, {
412
412
  labelStack,
413
413
  startTime,
@@ -420,7 +420,7 @@ function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart) {
420
420
  const start = Math.round(startTime);
421
421
  const end = Math.round(commitTime);
422
422
  const timing = result.get(label) || {
423
- labelStack: optimizeLabelStack(labelStack),
423
+ labelStack: optimizeLabelStack(labelStack, reactUFOVersion),
424
424
  startTime: start,
425
425
  endTime: end,
426
426
  mountCount: 0,
@@ -467,7 +467,7 @@ function optimizeRedirects(redirects, interactionStart) {
467
467
  }, []);
468
468
  return updatedRedirects;
469
469
  }
470
- function optimizeHoldInfo(holdInfo, interactionStart) {
470
+ function optimizeHoldInfo(holdInfo, interactionStart, reactUFOVersion) {
471
471
  const holdInfoMap = holdInfo.reduce((result, hold) => {
472
472
  const {
473
473
  labelStack,
@@ -485,7 +485,7 @@ function optimizeHoldInfo(holdInfo, interactionStart) {
485
485
  const timing = result.get(label) || {
486
486
  labelStack: optimizeLabelStack([...labelStack, {
487
487
  name
488
- }]),
488
+ }], reactUFOVersion),
489
489
  startTime,
490
490
  endTime
491
491
  };
@@ -501,7 +501,7 @@ function optimizeHoldInfo(holdInfo, interactionStart) {
501
501
  }, new Map());
502
502
  return [...holdInfoMap.values()];
503
503
  }
504
- function optimizeSpans(spans, interactionStart) {
504
+ function optimizeSpans(spans, interactionStart, reactUFOVersion) {
505
505
  const updatedSpans = spans.reduce((result, span) => {
506
506
  const {
507
507
  labelStack,
@@ -514,7 +514,7 @@ function optimizeSpans(spans, interactionStart) {
514
514
  result.push({
515
515
  labelStack: optimizeLabelStack([...labelStack, {
516
516
  name
517
- }]),
517
+ }], reactUFOVersion),
518
518
  startTime: Math.round(start),
519
519
  endTime: Math.round(end),
520
520
  type
@@ -524,7 +524,7 @@ function optimizeSpans(spans, interactionStart) {
524
524
  }, []);
525
525
  return updatedSpans;
526
526
  }
527
- function optimizeRequestInfo(requestInfo, interactionStart) {
527
+ function optimizeRequestInfo(requestInfo, interactionStart, reactUFOVersion) {
528
528
  const updatedRequestInfo = requestInfo.reduce((result, reqInfo) => {
529
529
  const {
530
530
  labelStack,
@@ -540,7 +540,7 @@ function optimizeRequestInfo(requestInfo, interactionStart) {
540
540
  result.push({
541
541
  labelStack: optimizeLabelStack([...labelStack, {
542
542
  name
543
- }]),
543
+ }], reactUFOVersion),
544
544
  startTime: Math.round(startTime),
545
545
  endTime: Math.round(endTime)
546
546
  });
@@ -565,18 +565,18 @@ function optimizeCustomTimings(customTimings, interactionStart) {
565
565
  return result;
566
566
  }, []);
567
567
  }
568
- function optimizeMarks(marks) {
568
+ function optimizeMarks(marks, reactUFOVersion) {
569
569
  return marks.map(({
570
570
  labelStack,
571
571
  time,
572
572
  ...others
573
573
  }) => ({
574
574
  ...others,
575
- labelStack: labelStack && optimizeLabelStack(labelStack),
575
+ labelStack: labelStack && optimizeLabelStack(labelStack, reactUFOVersion),
576
576
  time: Math.round(time)
577
577
  }));
578
578
  }
579
- function optimizeApdex(apdex) {
579
+ function optimizeApdex(apdex, reactUFOVersion) {
580
580
  return apdex.map(({
581
581
  stopTime,
582
582
  labelStack,
@@ -585,7 +585,7 @@ function optimizeApdex(apdex) {
585
585
  ...others,
586
586
  stopTime: Math.round(stopTime),
587
587
  ...(labelStack ? {
588
- labelStack: optimizeLabelStack(labelStack)
588
+ labelStack: optimizeLabelStack(labelStack, reactUFOVersion)
589
589
  } : {})
590
590
  }));
591
591
  }
@@ -723,14 +723,14 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
723
723
  const pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
724
724
  const pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
725
725
  const segments = config.killswitchNestedSegments ? [] : knownSegments;
726
- const segmentTree = REACT_UFO_VERSION === '2.0.0' ? buildSegmentTree(segments.map(segment => segment.labelStack)) : {};
726
+ const segmentTree = getReactUFOVersion(interaction.type) === '2.0.0' ? buildSegmentTree(segments.map(segment => segment.labelStack)) : {};
727
727
  const isDetailedPayload = pageVisibilityAtTTAI === 'visible';
728
728
  const isPageLoad = type === 'page_load';
729
729
  const calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
730
730
  const moreAccuratePageVisibilityAtTTI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTI(interaction) : null;
731
731
  const moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTAI(interaction) : null;
732
732
  const labelStack = interaction.labelStack ? {
733
- labelStack: optimizeLabelStack(interaction.labelStack)
733
+ labelStack: optimizeLabelStack(interaction.labelStack, getReactUFOVersion(interaction.type))
734
734
  } : {};
735
735
  // Page Load
736
736
  const getPageLoadInteractionMetrics = () => {
@@ -762,13 +762,13 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
762
762
  ...others
763
763
  }) => ({
764
764
  ...others,
765
- labelStack: labelStack && optimizeLabelStack(labelStack)
765
+ labelStack: labelStack && optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type))
766
766
  })),
767
767
  holdActive: [...interaction.holdActive.values()],
768
768
  redirects: optimizeRedirects(interaction.redirects, start),
769
- holdInfo: optimizeHoldInfo(experimental ? interaction.holdExpInfo : interaction.holdInfo, start),
770
- spans: optimizeSpans(spans, start),
771
- requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
769
+ holdInfo: optimizeHoldInfo(experimental ? interaction.holdExpInfo : interaction.holdInfo, start, getReactUFOVersion(interaction.type)),
770
+ spans: optimizeSpans(spans, start, getReactUFOVersion(interaction.type)),
771
+ requestInfo: optimizeRequestInfo(interaction.requestInfo, start, getReactUFOVersion(interaction.type)),
772
772
  customTimings: optimizeCustomTimings(interaction.customTimings, start),
773
773
  bundleEvalTimings: objectToArray(getBundleEvalTimings(start)),
774
774
  resourceTimings: objectToArray(resourceTimings)
@@ -808,8 +808,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
808
808
  'event:sizeInKb': 0,
809
809
  'event:source': {
810
810
  name: 'react-ufo/web',
811
- version: REACT_UFO_VERSION,
812
- payloadSource: 'platform'
811
+ version: getReactUFOVersion(interaction.type)
813
812
  },
814
813
  'event:region': config.region || 'unknown',
815
814
  'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
@@ -845,19 +844,19 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
845
844
  isPreviousInteractionAborted,
846
845
  abortedByInteractionName,
847
846
  // performance
848
- apdex: optimizeApdex(interaction.apdex),
847
+ apdex: optimizeApdex(interaction.apdex, getReactUFOVersion(interaction.type)),
849
848
  end: Math.round(end),
850
849
  start: Math.round(start),
851
- segments: REACT_UFO_VERSION === '2.0.0' ? segmentTree : segments.map(({
850
+ segments: getReactUFOVersion(interaction.type) === '2.0.0' ? segmentTree : segments.map(({
852
851
  labelStack,
853
852
  ...others
854
853
  }) => ({
855
854
  ...others,
856
- labelStack: optimizeLabelStack(labelStack)
855
+ labelStack: optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type))
857
856
  })),
858
- marks: optimizeMarks(interaction.marks),
857
+ marks: optimizeMarks(interaction.marks, getReactUFOVersion(interaction.type)),
859
858
  customData: optimizeCustomData(interaction),
860
- reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start),
859
+ reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start, getReactUFOVersion(interaction.type)),
861
860
  ...labelStack,
862
861
  ...getPageLoadInteractionMetrics(),
863
862
  ...getDetailedInteractionMetrics(resourceTimings),
@@ -1,5 +1,5 @@
1
1
  import coinflip from '../coinflip';
2
- import { REACT_UFO_VERSION } from '../common/constants';
2
+ import { getReactUFOVersion } from '../common/constants';
3
3
  import { getConfig, getPostInteractionRate } from '../config';
4
4
  import { isSegmentLabel, sanitizeUfoName } from '../create-payload/common/utils';
5
5
  import { getPageVisibilityState } from '../hidden-timing';
@@ -168,7 +168,7 @@ export default function createPostInteractionLogPayload({
168
168
  'event:schema': '1.0.0',
169
169
  'event:source': {
170
170
  name: 'react-ufo/web',
171
- version: REACT_UFO_VERSION,
171
+ version: getReactUFOVersion(lastInteractionFinish.type),
172
172
  payloadSource: 'platform'
173
173
  },
174
174
  'event:region': config.region || 'unknown',
@@ -541,7 +541,7 @@ export class VCObserver {
541
541
  if ((VC[key] === null || VC[key] === undefined) && VCRatio >= value / 100) {
542
542
  var _componentsLog$time;
543
543
  VC[key] = time;
544
- VCBox[key] = (_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.map(v => v.targetName);
544
+ VCBox[key] = [...new Set((_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.map(v => v.targetName))];
545
545
  }
546
546
  });
547
547
  return VCRatio;
@@ -550,7 +550,7 @@ export class VCObserver {
550
550
  var _acc$abs, _componentsLog$timest, _acc$rel$vc, _acc$rel;
551
551
  const currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
552
552
  const currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
553
- const logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(v => v.targetName);
553
+ const logEntry = [...new Set((_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(v => v.targetName))];
554
554
  const ratioDelta = (currentlyPaintedRatio - ((_acc$rel$vc = (_acc$rel = acc.rel[i - 1]) === null || _acc$rel === void 0 ? void 0 : _acc$rel.vc) !== null && _acc$rel$vc !== void 0 ? _acc$rel$vc : 0)) / 100;
555
555
  if (isCalcSpeedIndexEnabled) {
556
556
  const speedIndex = timestamp * ratioDelta;
@@ -1,4 +1,12 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
+ export var getReactUFOVersion = function getReactUFOVersion(interactionType) {
3
+ if (interactionType !== 'page_load' && interactionType !== 'transition') {
4
+ return '1.0.1';
5
+ }
2
6
 
3
- // eslint-disable-next-line @atlaskit/platform/no-module-level-eval
4
- export var REACT_UFO_VERSION = fg('enable-react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
7
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
8
+ if (!fg('enable-react-ufo-payload-segment-compressed')) {
9
+ return '1.0.1';
10
+ }
11
+ return '2.0.0';
12
+ };
@@ -1,8 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
- /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
5
- import { REACT_UFO_VERSION } from '../../../common/constants';
6
4
  export var sanitizeUfoName = function sanitizeUfoName(name) {
7
5
  return name.replace(/_/g, '-');
8
6
  };
@@ -51,8 +49,8 @@ function getLabelStackReference(labelStack) {
51
49
  export function labelStackStartWith(labelStack, startWith) {
52
50
  return stringifyLabelStackFully(labelStack).startsWith(stringifyLabelStackFully(startWith));
53
51
  }
54
- export function optimizeLabelStack(labelStack) {
55
- return REACT_UFO_VERSION === '2.0.0' ? getLabelStackReference(labelStack) : labelStack.map(function (ls) {
52
+ export function optimizeLabelStack(labelStack, reactUFOVersion) {
53
+ return reactUFOVersion ? getLabelStackReference(labelStack) : labelStack.map(function (ls) {
56
54
  return _objectSpread({
57
55
  n: ls.name
58
56
  }, ls.segmentId ? {