@atlaskit/react-ufo 2.15.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/assets/index.js +96 -0
  3. package/dist/cjs/assets/utils.js +32 -0
  4. package/dist/cjs/common/assets/types.js +5 -0
  5. package/dist/cjs/create-payload/index.js +32 -5
  6. package/dist/cjs/interaction-id-context/index.js +3 -19
  7. package/dist/cjs/vc/vc-observer/heatmap/heatmap.js +9 -20
  8. package/dist/cjs/vc/vc-observer/index.js +32 -28
  9. package/dist/cjs/vc/vc-observer/revisions/ViewportUpdateClassifier.js +8 -0
  10. package/dist/cjs/vc/vc-observer/revisions/fy24_01.js +34 -2
  11. package/dist/es2019/assets/index.js +82 -0
  12. package/dist/es2019/assets/utils.js +26 -0
  13. package/dist/es2019/common/assets/types.js +1 -0
  14. package/dist/es2019/create-payload/index.js +33 -3
  15. package/dist/es2019/interaction-id-context/index.js +3 -18
  16. package/dist/es2019/vc/vc-observer/heatmap/heatmap.js +10 -18
  17. package/dist/es2019/vc/vc-observer/index.js +3 -0
  18. package/dist/es2019/vc/vc-observer/revisions/ViewportUpdateClassifier.js +6 -0
  19. package/dist/es2019/vc/vc-observer/revisions/fy24_01.js +29 -0
  20. package/dist/esm/assets/index.js +89 -0
  21. package/dist/esm/assets/utils.js +26 -0
  22. package/dist/esm/common/assets/types.js +1 -0
  23. package/dist/esm/create-payload/index.js +32 -5
  24. package/dist/esm/interaction-id-context/index.js +3 -18
  25. package/dist/esm/vc/vc-observer/heatmap/heatmap.js +9 -20
  26. package/dist/esm/vc/vc-observer/index.js +32 -28
  27. package/dist/esm/vc/vc-observer/revisions/ViewportUpdateClassifier.js +8 -0
  28. package/dist/esm/vc/vc-observer/revisions/fy24_01.js +34 -2
  29. package/dist/types/assets/index.d.ts +25 -0
  30. package/dist/types/assets/utils.d.ts +6 -0
  31. package/dist/types/common/assets/types.d.ts +18 -0
  32. package/dist/types/common/index.d.ts +1 -0
  33. package/dist/types/config/index.d.ts +2 -1
  34. package/dist/types/create-payload/index.d.ts +11616 -0
  35. package/dist/types/resource-timing/index.d.ts +1 -1
  36. package/dist/types/vc/vc-observer/heatmap/heatmap.d.ts +5 -8
  37. package/dist/types/vc/vc-observer/revisions/ViewportUpdateClassifier.d.ts +5 -0
  38. package/dist/types/vc/vc-observer/revisions/fy24_01.d.ts +2 -0
  39. package/dist/types/vc/vc-observer/revisions/types.d.ts +18 -0
  40. package/dist/types-ts4.5/assets/index.d.ts +25 -0
  41. package/dist/types-ts4.5/assets/utils.d.ts +6 -0
  42. package/dist/types-ts4.5/common/assets/types.d.ts +18 -0
  43. package/dist/types-ts4.5/common/index.d.ts +1 -0
  44. package/dist/types-ts4.5/config/index.d.ts +2 -1
  45. package/dist/types-ts4.5/create-payload/index.d.ts +11616 -0
  46. package/dist/types-ts4.5/resource-timing/index.d.ts +1 -1
  47. package/dist/types-ts4.5/vc/vc-observer/heatmap/heatmap.d.ts +5 -8
  48. package/dist/types-ts4.5/vc/vc-observer/revisions/ViewportUpdateClassifier.d.ts +5 -0
  49. package/dist/types-ts4.5/vc/vc-observer/revisions/fy24_01.d.ts +2 -0
  50. package/dist/types-ts4.5/vc/vc-observer/revisions/types.d.ts +18 -0
  51. package/package.json +4 -4
@@ -1,6 +1,7 @@
1
1
  import Bowser from 'bowser-ultralight';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { getLighthouseMetrics } from '../additional-payload';
4
+ import { CHRReporter } from '../assets';
4
5
  import * as bundleEvalTiming from '../bundle-eval-timing';
5
6
  import coinflip from '../coinflip';
6
7
  import { REACT_UFO_VERSION } from '../common/constants';
@@ -298,6 +299,33 @@ function getSSRProperties(type) {
298
299
  'ssr:featureFlags': getSSRFeatureFlags(type)
299
300
  };
300
301
  }
302
+ const getAssetsMetrics = (interaction, resourceTimings) => {
303
+ try {
304
+ const config = getConfig();
305
+ const {
306
+ type
307
+ } = interaction;
308
+ const isCHREnabled = fg('ufo_chr_config');
309
+ const allowedTypes = ['page_load', 'transition'];
310
+ const assetsClassification = config === null || config === void 0 ? void 0 : config.assetsClassification;
311
+ if (!isCHREnabled || !allowedTypes.includes(type) || !assetsClassification) {
312
+ // Skip if: FG disabled, not allowed type or assetsClassification isn't configured
313
+ return {};
314
+ }
315
+ const reporter = new CHRReporter();
316
+ const assets = reporter.get(resourceTimings, assetsClassification);
317
+ if (assets) {
318
+ // Only add assets in case it exists
319
+ return {
320
+ 'event:assets': assets
321
+ };
322
+ }
323
+ return {};
324
+ } catch (error) {
325
+ // Skip CHR in case of error
326
+ return {};
327
+ }
328
+ };
301
329
  const getBrowserMetadata = () => {
302
330
  const data = {};
303
331
  const now = new Date();
@@ -723,7 +751,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
723
751
  };
724
752
  };
725
753
  // Detailed payload. Page visibility = visible
726
- const getDetailedInteractionMetrics = () => {
754
+ const getDetailedInteractionMetrics = resourceTimings => {
727
755
  if (experimental || window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
728
756
  return {};
729
757
  }
@@ -744,7 +772,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
744
772
  requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
745
773
  customTimings: optimizeCustomTimings(interaction.customTimings, start),
746
774
  bundleEvalTimings: objectToArray(getBundleEvalTimings(start)),
747
- resourceTimings: objectToArray(getResourceTimings(start, end))
775
+ resourceTimings: objectToArray(resourceTimings)
748
776
  };
749
777
  };
750
778
  // Page load & detailed payload
@@ -765,6 +793,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
765
793
  regularTTAI = getTTAI(interaction);
766
794
  }
767
795
  const newUFOName = sanitizeUfoName(ufoName);
796
+ const resourceTimings = getResourceTimings(start, end);
768
797
  const payload = {
769
798
  actionSubject: 'experience',
770
799
  action: 'measured',
@@ -789,6 +818,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
789
818
  // root
790
819
  ...getBrowserMetadata(),
791
820
  ...getSSRProperties(type),
821
+ ...getAssetsMetrics(interaction, resourceTimings),
792
822
  ...getPPSMetrics(interaction),
793
823
  ...getPaintMetrics(type),
794
824
  ...getNavigationMetrics(type),
@@ -831,7 +861,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
831
861
  reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start),
832
862
  ...labelStack,
833
863
  ...getPageLoadInteractionMetrics(),
834
- ...getDetailedInteractionMetrics(),
864
+ ...getDetailedInteractionMetrics(resourceTimings),
835
865
  ...getPageLoadDetailedInteractionMetrics(),
836
866
  ...getBm3TrackerTimings(interaction),
837
867
  'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
@@ -1,21 +1,4 @@
1
1
  import { createContext } from 'react';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- function getGlobalDefaultInteractionID() {
4
- if (!fg('platform_ufo_AFO-3379_fix_default_interaction')) {
5
- return {
6
- current: null
7
- };
8
- }
9
- const ref = globalThis.__react_ufo__DefaultInteractionID;
10
- if (ref) {
11
- return ref;
12
- }
13
- const nextRef = {
14
- current: null
15
- };
16
- globalThis.__react_ufo__DefaultInteractionID = nextRef;
17
- return nextRef;
18
- }
19
2
 
20
3
  // Same structure as react's useRef.
21
4
  // This allows modals to use a ref to scope their value
@@ -25,7 +8,9 @@ function getGlobalDefaultInteractionID() {
25
8
  // The default InteractionID object is a global singleton
26
9
  // It's the one that holds the root value used in routing,
27
10
  // and is overwritten when we have new interactions start.
28
- export const DefaultInteractionID = getGlobalDefaultInteractionID();
11
+ export const DefaultInteractionID = {
12
+ current: null
13
+ };
29
14
 
30
15
  // We use a context to allow modals to have their own lifecycle
31
16
  export default /*#__PURE__*/createContext(DefaultInteractionID);
@@ -111,6 +111,7 @@ export class MultiRevisionHeatmap {
111
111
  }
112
112
  processData({
113
113
  VCParts,
114
+ VCCalculationMethods,
114
115
  ssr = UNUSED_SECTOR
115
116
  }) {
116
117
  return this.heatmaps.map((heatmap, i) => {
@@ -149,24 +150,15 @@ export class MultiRevisionHeatmap {
149
150
  }
150
151
  }
151
152
  const entries = Object.entries(lastUpdate).map(a => [parseInt(a[0], 10), a[1]]).sort((a, b) => a[0] > b[0] ? 1 : -1);
152
- const VC = MultiRevisionHeatmap.makeVCReturnObj(VCParts);
153
- const VCBox = MultiRevisionHeatmap.makeVCReturnObj(VCParts);
154
- entries.reduce((acc = 0, v) => {
155
- const VCRatio = v[1] / totalPainted + acc;
156
- const time = v[0];
157
- VCParts.forEach(value => {
158
- if ((VC[value] === null || VC[value] === undefined) && VCRatio >= value / 100) {
159
- var _componentsLog$time;
160
- VC[value] = time;
161
- VCBox[value] = new Set();
162
- (_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.forEach(v => {
163
- var _VCBox$value;
164
- return (_VCBox$value = VCBox[value]) === null || _VCBox$value === void 0 ? void 0 : _VCBox$value.add(v.targetName);
165
- });
166
- }
167
- });
168
- return VCRatio;
169
- }, 0);
153
+ const {
154
+ VC,
155
+ VCBox
156
+ } = VCCalculationMethods[i]({
157
+ VCParts,
158
+ componentsLog,
159
+ entries,
160
+ totalPainted
161
+ });
170
162
  const VCEntries = entries.reduce((acc, [timestamp, entryPainted], i) => {
171
163
  var _acc$abs, _componentsLog$timest;
172
164
  const currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
@@ -253,6 +253,9 @@ export class VCObserver {
253
253
  const revisionsData = isMultiHeatmapEnabled && multiHeatmap !== null ? {
254
254
  [`${fullPrefix}vc:rev`]: multiHeatmap.getPayloadShapedData({
255
255
  VCParts: VCObserver.VCParts.map(v => parseInt(v)),
256
+ VCCalculationMethods: getRevisions().map(({
257
+ classifier
258
+ }) => classifier.VCCalculationMethod),
256
259
  ssr,
257
260
  clean: !abortReasonInfo
258
261
  })
@@ -7,6 +7,12 @@ export class ViewportUpdateClassifier {
7
7
  _defineProperty(this, "__combinedTypes", []);
8
8
  _defineProperty(this, "__combinedFilters", []);
9
9
  }
10
+ VCCalculationMethod(_) {
11
+ return {
12
+ VC: {},
13
+ VCBox: {}
14
+ };
15
+ }
10
16
  mergeConfig() {
11
17
  this.__combinedTypes = [...this.types, ...((this === null || this === void 0 ? void 0 : this.__combinedTypes) || [])];
12
18
  const previousFilters = this.removedFilters.length === 0 ? this.__combinedFilters : this.__combinedFilters.filter(filter => !this.removedFilters.includes(filter.name));
@@ -2,6 +2,35 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { ViewportUpdateClassifier } from './ViewportUpdateClassifier';
3
3
  const legacyIgnoreReasons = ['image', 'ssr-hydration', 'editor-lazy-node-view', 'editor-container-mutation'];
4
4
  export class FY24_01Classifier extends ViewportUpdateClassifier {
5
+ VCCalculationMethod({
6
+ VCParts,
7
+ entries,
8
+ totalPainted,
9
+ componentsLog
10
+ }) {
11
+ const VC = {};
12
+ const VCBox = {};
13
+ entries.reduce((acc = 0, v) => {
14
+ const VCRatio = v[1] / totalPainted + acc;
15
+ const time = v[0];
16
+ VCParts.forEach(value => {
17
+ if ((VC[value] === null || VC[value] === undefined) && VCRatio >= value / 100) {
18
+ var _componentsLog$time;
19
+ VC[value] = time;
20
+ VCBox[value] = new Set();
21
+ (_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 ? void 0 : _componentsLog$time.forEach(v => {
22
+ var _VCBox$value;
23
+ return (_VCBox$value = VCBox[value]) === null || _VCBox$value === void 0 ? void 0 : _VCBox$value.add(v.targetName);
24
+ });
25
+ }
26
+ });
27
+ return VCRatio;
28
+ }, 0);
29
+ return {
30
+ VC,
31
+ VCBox
32
+ };
33
+ }
5
34
  constructor() {
6
35
  super();
7
36
  _defineProperty(this, "revision", 'fy24.01');
@@ -0,0 +1,89 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import { calculateTransferType, DISK_KEY, MEMORY_KEY, NETWORK_KEY, round } from './utils';
6
+ export var CHRSummary = /*#__PURE__*/function () {
7
+ function CHRSummary() {
8
+ _classCallCheck(this, CHRSummary);
9
+ _defineProperty(this, "bundles", _defineProperty(_defineProperty(_defineProperty({}, MEMORY_KEY, 0), DISK_KEY, 0), NETWORK_KEY, 0));
10
+ _defineProperty(this, "bundlesCount", 0);
11
+ _defineProperty(this, "size", _defineProperty(_defineProperty(_defineProperty({}, MEMORY_KEY, 0), DISK_KEY, 0), NETWORK_KEY, 0));
12
+ _defineProperty(this, "sizeTotal", 0);
13
+ }
14
+ return _createClass(CHRSummary, [{
15
+ key: "add",
16
+ value: function add(asset) {
17
+ var size = 'size' in asset ? asset.size : undefined;
18
+ var encodedSize = 'encodedSize' in asset ? Number(asset.encodedSize) : 0;
19
+ var type = calculateTransferType(asset.type, asset.duration, size);
20
+ if (type === null) {
21
+ return;
22
+ }
23
+ this.bundles[type] += 1;
24
+ this.bundlesCount += 1;
25
+ this.size[type] += encodedSize;
26
+ this.sizeTotal += encodedSize;
27
+ }
28
+ }], [{
29
+ key: "makePayload",
30
+ value: function makePayload(summary) {
31
+ var size = summary.size,
32
+ bundlesCount = summary.bundlesCount,
33
+ sizeTotal = summary.sizeTotal;
34
+ var cachedSize = size[MEMORY_KEY] + size[DISK_KEY];
35
+ var sizeRatio = round(cachedSize / summary.sizeTotal);
36
+ return {
37
+ size: sizeTotal,
38
+ chr: sizeRatio,
39
+ count: bundlesCount
40
+ };
41
+ }
42
+ }]);
43
+ }();
44
+ export var CHRReporter = /*#__PURE__*/function () {
45
+ function CHRReporter() {
46
+ _classCallCheck(this, CHRReporter);
47
+ _defineProperty(this, "all", new CHRSummary());
48
+ _defineProperty(this, "allAtlassian", new CHRSummary());
49
+ _defineProperty(this, "preloaded", new CHRSummary());
50
+ }
51
+ return _createClass(CHRReporter, [{
52
+ key: "get",
53
+ value: function get(resourceTimings, assetsClassification) {
54
+ var _this = this;
55
+ try {
56
+ Object.entries(resourceTimings).map(function (_ref) {
57
+ var _ref2 = _slicedToArray(_ref, 2),
58
+ label = _ref2[0],
59
+ entry = _ref2[1];
60
+ if (assetsClassification.all) {
61
+ _this.all.add(entry);
62
+ }
63
+ if (assetsClassification.allAtlassian({
64
+ label: label,
65
+ entry: entry
66
+ })) {
67
+ _this.allAtlassian.add(entry);
68
+ }
69
+ if (assetsClassification.preloaded({
70
+ label: label,
71
+ entry: entry
72
+ })) {
73
+ _this.preloaded.add(entry);
74
+ }
75
+ });
76
+ if (this.all.bundlesCount === 0) {
77
+ return null;
78
+ }
79
+ return {
80
+ all: CHRSummary.makePayload(this.all),
81
+ allAtlassian: CHRSummary.makePayload(this.allAtlassian),
82
+ preloaded: CHRSummary.makePayload(this.preloaded)
83
+ };
84
+ } catch (error) {
85
+ return null;
86
+ }
87
+ }
88
+ }]);
89
+ }();
@@ -0,0 +1,26 @@
1
+ /* Borrowed from https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/performance/browser-metrics/src/plugins/timings/resource.ts */
2
+ export var cacheableTypes = ['script', 'link'];
3
+ export var MEMORY_KEY = 'mem';
4
+ export var DISK_KEY = 'disk';
5
+ export var NETWORK_KEY = 'net';
6
+ export var calculateTransferType = function calculateTransferType(type, duration, size) {
7
+ if (!cacheableTypes.includes(type)) {
8
+ return null;
9
+ }
10
+ if ((size === undefined || size === 0) && duration === 0) {
11
+ return MEMORY_KEY;
12
+ }
13
+ if (size === 0 && duration > 0) {
14
+ return DISK_KEY;
15
+ }
16
+ if (size === undefined) {
17
+ return null;
18
+ }
19
+ return NETWORK_KEY;
20
+ };
21
+ export var round = function round(n) {
22
+ if (isNaN(n)) {
23
+ return 0;
24
+ }
25
+ return Math.round(n * 10000) / 10000;
26
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -11,6 +11,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
11
11
  import Bowser from 'bowser-ultralight';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import { getLighthouseMetrics } from '../additional-payload';
14
+ import { CHRReporter } from '../assets';
14
15
  import * as bundleEvalTiming from '../bundle-eval-timing';
15
16
  import coinflip from '../coinflip';
16
17
  import { REACT_UFO_VERSION } from '../common/constants';
@@ -304,6 +305,31 @@ function getSSRProperties(type) {
304
305
  'ssr:featureFlags': getSSRFeatureFlags(type)
305
306
  };
306
307
  }
308
+ var getAssetsMetrics = function getAssetsMetrics(interaction, resourceTimings) {
309
+ try {
310
+ var config = getConfig();
311
+ var type = interaction.type;
312
+ var isCHREnabled = fg('ufo_chr_config');
313
+ var allowedTypes = ['page_load', 'transition'];
314
+ var assetsClassification = config === null || config === void 0 ? void 0 : config.assetsClassification;
315
+ if (!isCHREnabled || !allowedTypes.includes(type) || !assetsClassification) {
316
+ // Skip if: FG disabled, not allowed type or assetsClassification isn't configured
317
+ return {};
318
+ }
319
+ var reporter = new CHRReporter();
320
+ var assets = reporter.get(resourceTimings, assetsClassification);
321
+ if (assets) {
322
+ // Only add assets in case it exists
323
+ return {
324
+ 'event:assets': assets
325
+ };
326
+ }
327
+ return {};
328
+ } catch (error) {
329
+ // Skip CHR in case of error
330
+ return {};
331
+ }
332
+ };
307
333
  var getBrowserMetadata = function getBrowserMetadata() {
308
334
  var data = {};
309
335
  var now = new Date();
@@ -718,7 +744,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
718
744
  });
719
745
  };
720
746
  // Detailed payload. Page visibility = visible
721
- var getDetailedInteractionMetrics = function getDetailedInteractionMetrics() {
747
+ var getDetailedInteractionMetrics = function getDetailedInteractionMetrics(resourceTimings) {
722
748
  if (experimental || window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
723
749
  return {};
724
750
  }
@@ -739,7 +765,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
739
765
  requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
740
766
  customTimings: optimizeCustomTimings(interaction.customTimings, start),
741
767
  bundleEvalTimings: objectToArray(getBundleEvalTimings(start)),
742
- resourceTimings: objectToArray(getResourceTimings(start, end))
768
+ resourceTimings: objectToArray(resourceTimings)
743
769
  };
744
770
  };
745
771
  // Page load & detailed payload
@@ -760,6 +786,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
760
786
  regularTTAI = getTTAI(interaction);
761
787
  }
762
788
  var newUFOName = sanitizeUfoName(ufoName);
789
+ var resourceTimings = getResourceTimings(start, end);
763
790
  var payload = {
764
791
  actionSubject: 'experience',
765
792
  action: 'measured',
@@ -767,7 +794,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
767
794
  source: 'measured',
768
795
  tags: ['observability'],
769
796
  attributes: {
770
- properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
797
+ properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
771
798
  // basic
772
799
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
773
800
  'event:product': config.product,
@@ -781,7 +808,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
781
808
  'event:region': config.region || 'unknown',
782
809
  'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
783
810
  'experience:name': newUFOName
784
- }, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), experimental ? getExperimentalVCMetrics(interaction) : undefined), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
811
+ }, getBrowserMetadata()), getSSRProperties(type)), getAssetsMetrics(interaction, resourceTimings)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), experimental ? getExperimentalVCMetrics(interaction) : undefined), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
785
812
  interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
786
813
  namePrefix: config.namePrefix || '',
787
814
  segmentPrefix: config.segmentPrefix || '',
@@ -813,7 +840,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
813
840
  marks: optimizeMarks(interaction.marks),
814
841
  customData: optimizeCustomData(interaction),
815
842
  reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
816
- }, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)), {}, {
843
+ }, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics(resourceTimings)), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)), {}, {
817
844
  'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
818
845
  'metric:experimental:ttai': expTTAI
819
846
  }),
@@ -1,21 +1,4 @@
1
1
  import { createContext } from 'react';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- function getGlobalDefaultInteractionID() {
4
- if (!fg('platform_ufo_AFO-3379_fix_default_interaction')) {
5
- return {
6
- current: null
7
- };
8
- }
9
- var ref = globalThis.__react_ufo__DefaultInteractionID;
10
- if (ref) {
11
- return ref;
12
- }
13
- var nextRef = {
14
- current: null
15
- };
16
- globalThis.__react_ufo__DefaultInteractionID = nextRef;
17
- return nextRef;
18
- }
19
2
 
20
3
  // Same structure as react's useRef.
21
4
  // This allows modals to use a ref to scope their value
@@ -25,7 +8,9 @@ function getGlobalDefaultInteractionID() {
25
8
  // The default InteractionID object is a global singleton
26
9
  // It's the one that holds the root value used in routing,
27
10
  // and is overwritten when we have new interactions start.
28
- export var DefaultInteractionID = getGlobalDefaultInteractionID();
11
+ export var DefaultInteractionID = {
12
+ current: null
13
+ };
29
14
 
30
15
  // We use a context to allow modals to have their own lifecycle
31
16
  export default /*#__PURE__*/createContext(DefaultInteractionID);
@@ -123,6 +123,7 @@ export var MultiRevisionHeatmap = /*#__PURE__*/function () {
123
123
  value: function processData(_ref4) {
124
124
  var _this3 = this;
125
125
  var VCParts = _ref4.VCParts,
126
+ VCCalculationMethods = _ref4.VCCalculationMethods,
126
127
  _ref4$ssr = _ref4.ssr,
127
128
  ssr = _ref4$ssr === void 0 ? UNUSED_SECTOR : _ref4$ssr;
128
129
  return this.heatmaps.map(function (heatmap, i) {
@@ -165,26 +166,14 @@ export var MultiRevisionHeatmap = /*#__PURE__*/function () {
165
166
  }).sort(function (a, b) {
166
167
  return a[0] > b[0] ? 1 : -1;
167
168
  });
168
- var VC = MultiRevisionHeatmap.makeVCReturnObj(VCParts);
169
- var VCBox = MultiRevisionHeatmap.makeVCReturnObj(VCParts);
170
- entries.reduce(function () {
171
- var acc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
172
- var v = arguments.length > 1 ? arguments[1] : undefined;
173
- var VCRatio = v[1] / totalPainted + acc;
174
- var time = v[0];
175
- VCParts.forEach(function (value) {
176
- if ((VC[value] === null || VC[value] === undefined) && VCRatio >= value / 100) {
177
- var _componentsLog$time;
178
- VC[value] = time;
179
- VCBox[value] = new Set();
180
- (_componentsLog$time = componentsLog[time]) === null || _componentsLog$time === void 0 || _componentsLog$time.forEach(function (v) {
181
- var _VCBox$value;
182
- return (_VCBox$value = VCBox[value]) === null || _VCBox$value === void 0 ? void 0 : _VCBox$value.add(v.targetName);
183
- });
184
- }
185
- });
186
- return VCRatio;
187
- }, 0);
169
+ var _VCCalculationMethods = VCCalculationMethods[i]({
170
+ VCParts: VCParts,
171
+ componentsLog: componentsLog,
172
+ entries: entries,
173
+ totalPainted: totalPainted
174
+ }),
175
+ VC = _VCCalculationMethods.VC,
176
+ VCBox = _VCCalculationMethods.VCBox;
188
177
  var VCEntries = entries.reduce(function (acc, _ref5, i) {
189
178
  var _acc$abs, _componentsLog$timest;
190
179
  var _ref6 = _slicedToArray(_ref5, 2),
@@ -249,6 +249,10 @@ export var VCObserver = /*#__PURE__*/function () {
249
249
  VCParts: VCObserver.VCParts.map(function (v) {
250
250
  return parseInt(v);
251
251
  }),
252
+ VCCalculationMethods: getRevisions().map(function (_ref8) {
253
+ var classifier = _ref8.classifier;
254
+ return classifier.VCCalculationMethod;
255
+ }),
252
256
  ssr: ssr,
253
257
  clean: !abortReasonInfo
254
258
  })) : null;
@@ -295,13 +299,13 @@ export var VCObserver = /*#__PURE__*/function () {
295
299
  });
296
300
  }
297
301
  });
298
- _defineProperty(this, "onViewportChangeDetected", function (_ref9) {
299
- var element = _ref9.element,
300
- type = _ref9.type,
301
- ignoreReason = _ref9.ignoreReason,
302
- timestamp = _ref9.timestamp,
303
- targetName = _ref9.targetName,
304
- intersectionRect = _ref9.intersectionRect;
302
+ _defineProperty(this, "onViewportChangeDetected", function (_ref10) {
303
+ var element = _ref10.element,
304
+ type = _ref10.type,
305
+ ignoreReason = _ref10.ignoreReason,
306
+ timestamp = _ref10.timestamp,
307
+ targetName = _ref10.targetName,
308
+ intersectionRect = _ref10.intersectionRect;
305
309
  if (_this.multiHeatmap === null) {
306
310
  return;
307
311
  }
@@ -383,10 +387,10 @@ export var VCObserver = /*#__PURE__*/function () {
383
387
  var unbinds = attachAbortListeners(window, _this.viewport, _this.abortReasonCallback);
384
388
  if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
385
389
  var _window2;
386
- Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref10) {
387
- var _ref11 = _slicedToArray(_ref10, 2),
388
- key = _ref11[0],
389
- time = _ref11[1];
390
+ Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref11) {
391
+ var _ref12 = _slicedToArray(_ref11, 2),
392
+ key = _ref12[0],
393
+ time = _ref12[1];
390
394
  if (time) {
391
395
  _this.abortReasonCallback(key, time);
392
396
  }
@@ -421,8 +425,8 @@ export var VCObserver = /*#__PURE__*/function () {
421
425
  }
422
426
  return _createClass(VCObserver, [{
423
427
  key: "start",
424
- value: function start(_ref12) {
425
- var startTime = _ref12.startTime;
428
+ value: function start(_ref13) {
429
+ var startTime = _ref13.startTime;
426
430
  this.active = true;
427
431
  if (this.observers.isBrowserSupported()) {
428
432
  this.setViewportSize();
@@ -444,12 +448,12 @@ export var VCObserver = /*#__PURE__*/function () {
444
448
  }, {
445
449
  key: "getIgnoredElements",
446
450
  value: function getIgnoredElements(componentsLog) {
447
- return Object.values(componentsLog).flat().filter(function (_ref13) {
448
- var ignoreReason = _ref13.ignoreReason;
451
+ return Object.values(componentsLog).flat().filter(function (_ref14) {
452
+ var ignoreReason = _ref14.ignoreReason;
449
453
  return Boolean(ignoreReason);
450
- }).map(function (_ref14) {
451
- var targetName = _ref14.targetName,
452
- ignoreReason = _ref14.ignoreReason;
454
+ }).map(function (_ref15) {
455
+ var targetName = _ref15.targetName,
456
+ ignoreReason = _ref15.ignoreReason;
453
457
  return {
454
458
  targetName: targetName,
455
459
  ignoreReason: ignoreReason
@@ -570,12 +574,12 @@ export var VCObserver = /*#__PURE__*/function () {
570
574
  }
571
575
  }], [{
572
576
  key: "calculateVC",
573
- value: function calculateVC(_ref15) {
574
- var heatmap = _ref15.heatmap,
575
- _ref15$ssr = _ref15.ssr,
576
- ssr = _ref15$ssr === void 0 ? UNUSED_SECTOR : _ref15$ssr,
577
- componentsLog = _ref15.componentsLog,
578
- viewport = _ref15.viewport;
577
+ value: function calculateVC(_ref16) {
578
+ var heatmap = _ref16.heatmap,
579
+ _ref16$ssr = _ref16.ssr,
580
+ ssr = _ref16$ssr === void 0 ? UNUSED_SECTOR : _ref16$ssr,
581
+ componentsLog = _ref16.componentsLog,
582
+ viewport = _ref16.viewport;
579
583
  var lastUpdate = {};
580
584
  var totalPainted = 0;
581
585
  if (ssr !== UNUSED_SECTOR) {
@@ -644,11 +648,11 @@ export var VCObserver = /*#__PURE__*/function () {
644
648
  });
645
649
  return VCRatio;
646
650
  }, 0);
647
- var VCEntries = entries.reduce(function (acc, _ref16, i) {
651
+ var VCEntries = entries.reduce(function (acc, _ref17, i) {
648
652
  var _acc$abs, _componentsLog$timest, _acc$rel$vc, _acc$rel;
649
- var _ref17 = _slicedToArray(_ref16, 2),
650
- timestamp = _ref17[0],
651
- entryPainted = _ref17[1];
653
+ var _ref18 = _slicedToArray(_ref17, 2),
654
+ timestamp = _ref18[0],
655
+ entryPainted = _ref18[1];
652
656
  var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
653
657
  var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
654
658
  var logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
@@ -12,6 +12,14 @@ export var ViewportUpdateClassifier = /*#__PURE__*/function () {
12
12
  _defineProperty(this, "__combinedFilters", []);
13
13
  }
14
14
  return _createClass(ViewportUpdateClassifier, [{
15
+ key: "VCCalculationMethod",
16
+ value: function VCCalculationMethod(_) {
17
+ return {
18
+ VC: {},
19
+ VCBox: {}
20
+ };
21
+ }
22
+ }, {
15
23
  key: "mergeConfig",
16
24
  value: function mergeConfig() {
17
25
  var _this = this;