@atlaskit/react-ufo 3.10.4 → 3.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/config/index.js +51 -5
  3. package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +2 -1
  4. package/dist/cjs/create-payload/utils/get-vc-metrics.js +41 -20
  5. package/dist/cjs/create-post-interaction-log-payload/index.js +11 -0
  6. package/dist/cjs/interaction-metrics/index.js +2 -1
  7. package/dist/cjs/interaction-metrics/post-interaction-log.js +15 -5
  8. package/dist/cjs/vc/index.js +125 -36
  9. package/dist/cjs/vc/vc-observer/getVCRevisionsData.js +48 -23
  10. package/dist/cjs/vc/vc-observer/index.js +17 -6
  11. package/dist/es2019/config/index.js +49 -6
  12. package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +2 -1
  13. package/dist/es2019/create-payload/utils/get-vc-metrics.js +36 -19
  14. package/dist/es2019/create-post-interaction-log-payload/index.js +11 -0
  15. package/dist/es2019/interaction-metrics/index.js +2 -1
  16. package/dist/es2019/interaction-metrics/post-interaction-log.js +14 -4
  17. package/dist/es2019/vc/index.js +99 -36
  18. package/dist/es2019/vc/vc-observer/getVCRevisionsData.js +52 -25
  19. package/dist/es2019/vc/vc-observer/index.js +18 -6
  20. package/dist/esm/config/index.js +49 -5
  21. package/dist/esm/create-experimental-interaction-metrics-payload/index.js +2 -1
  22. package/dist/esm/create-payload/utils/get-vc-metrics.js +42 -21
  23. package/dist/esm/create-post-interaction-log-payload/index.js +11 -0
  24. package/dist/esm/interaction-metrics/index.js +2 -1
  25. package/dist/esm/interaction-metrics/post-interaction-log.js +15 -5
  26. package/dist/esm/vc/index.js +127 -37
  27. package/dist/esm/vc/vc-observer/getVCRevisionsData.js +48 -23
  28. package/dist/esm/vc/vc-observer/index.js +17 -6
  29. package/dist/types/common/common/types.d.ts +1 -1
  30. package/dist/types/common/react-ufo-payload-schema.d.ts +49 -3
  31. package/dist/types/config/index.d.ts +14 -3
  32. package/dist/types/create-post-interaction-log-payload/index.d.ts +3 -2
  33. package/dist/types/interaction-metrics/post-interaction-log.d.ts +3 -4
  34. package/dist/types/vc/index.d.ts +17 -1
  35. package/dist/types/vc/types.d.ts +3 -1
  36. package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +5 -3
  37. package/dist/types/vc/vc-observer/index.d.ts +1 -1
  38. package/dist/types-ts4.5/common/common/types.d.ts +1 -1
  39. package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +51 -3
  40. package/dist/types-ts4.5/config/index.d.ts +14 -3
  41. package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +3 -2
  42. package/dist/types-ts4.5/interaction-metrics/post-interaction-log.d.ts +3 -4
  43. package/dist/types-ts4.5/vc/index.d.ts +17 -1
  44. package/dist/types-ts4.5/vc/types.d.ts +3 -1
  45. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +5 -3
  46. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +1 -1
  47. package/package.json +7 -1
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getVCRevisionsData = getVCRevisionsData;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _config = require("../../config");
10
11
  var _hiddenTiming = require("../../hidden-timing");
11
12
  var _revisions = require("./revisions/revisions");
@@ -31,7 +32,7 @@ function createVCDetails(calculatedVC, shouldHaveVCmetric) {
31
32
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
32
33
  var key = _step.value;
33
34
  details[key] = {
34
- t: VC[key],
35
+ t: VC[key] || -1,
35
36
  e: VCBox[key] || READONLY_EMPTY_ARRAY
36
37
  };
37
38
  }
@@ -52,8 +53,13 @@ function getVCRevisionsData(_ref) {
52
53
  multiHeatmap = _ref.multiHeatmap,
53
54
  ssr = _ref.ssr,
54
55
  calculatedVC = _ref.calculatedVC,
55
- calculatedVCNext = _ref.calculatedVCNext;
56
- if (!(0, _config.isVCRevisionEnabled)('fy25.03')) {
56
+ calculatedVCNext = _ref.calculatedVCNext,
57
+ experienceKey = _ref.experienceKey;
58
+ var isTTVCv3Enabled = (0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience') ? (0, _config.isVCRevisionEnabled)('fy25.03', experienceKey) : (0, _config.isVCRevisionEnabled)('fy25.03');
59
+
60
+ // As part of `platform_ufo_vc_enable_revisions_by_experience`, we are looking to turn off the `multiHeatmap` branch of code
61
+ // for calculating TTVC, and instead rely on existing values already available, e.g. `calculatedVC` and `calculatedVCNext`
62
+ if (!isTTVCv3Enabled && !(0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience')) {
57
63
  if (!multiHeatmap) {
58
64
  return null;
59
65
  }
@@ -76,29 +82,48 @@ function getVCRevisionsData(_ref) {
76
82
  clean: isVCClean
77
83
  }));
78
84
  }
79
-
80
- // Calculate these conditions once
81
85
  var pageVisibilityUpToTTAI = (0, _hiddenTiming.getPageVisibilityState)(interaction.start, interaction.end);
82
86
  var isVisiblePageVisibleUpToTTAI = pageVisibilityUpToTTAI === 'visible';
83
87
  var shouldHaveVCmetric = isVCClean && !isEventAborted && isVisiblePageVisibleUpToTTAI;
88
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience')) {
89
+ var availableVCRevisionPayloads = [];
90
+ if ((0, _config.isVCRevisionEnabled)('fy25.01', experienceKey)) {
91
+ availableVCRevisionPayloads.push({
92
+ revision: 'fy25.01',
93
+ clean: isVCClean,
94
+ 'metric:vc90': shouldHaveVCmetric ? calculatedVC.VC['90'] : null,
95
+ vcDetails: createVCDetails(calculatedVC, shouldHaveVCmetric)
96
+ });
97
+ }
98
+ if ((0, _config.isVCRevisionEnabled)('fy25.02', experienceKey)) {
99
+ availableVCRevisionPayloads.push({
100
+ revision: 'fy25.02',
101
+ clean: isVCClean,
102
+ 'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
103
+ vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
104
+ });
105
+ }
106
+ return (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), availableVCRevisionPayloads);
107
+ } else {
108
+ // Create the V2 revision object which is always needed
109
+ var ttvcV2Revision = {
110
+ revision: 'fy25.02',
111
+ clean: isVCClean,
112
+ 'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
113
+ vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
114
+ };
115
+ var isTTVCv1Disabled = !(0, _config.isVCRevisionEnabled)('fy25.01');
116
+ if (isTTVCv1Disabled) {
117
+ return (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), [ttvcV2Revision]);
118
+ }
84
119
 
85
- // Create the V2 revision object which is always needed
86
- var ttvcV2Revision = {
87
- revision: 'fy25.02',
88
- clean: isVCClean,
89
- 'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
90
- vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
91
- };
92
- if (!(0, _config.isVCRevisionEnabled)('fy25.01')) {
93
- return (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), [ttvcV2Revision]);
120
+ // Only create ttvcV1Revision when we're actually going to use it
121
+ var ttvcV1Revision = {
122
+ revision: 'fy25.01',
123
+ clean: isVCClean,
124
+ 'metric:vc90': shouldHaveVCmetric ? calculatedVC.VC['90'] : null,
125
+ vcDetails: createVCDetails(calculatedVC, shouldHaveVCmetric)
126
+ };
127
+ return (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), [ttvcV1Revision, ttvcV2Revision]);
94
128
  }
95
-
96
- // Only create ttvcV1Revision when we're actually going to use it
97
- var ttvcV1Revision = {
98
- revision: 'fy25.01',
99
- clean: isVCClean,
100
- 'metric:vc90': shouldHaveVCmetric ? calculatedVC.VC['90'] : null,
101
- vcDetails: createVCDetails(calculatedVC, shouldHaveVCmetric)
102
- };
103
- return (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), [ttvcV1Revision, ttvcV2Revision]);
104
129
  }
@@ -15,6 +15,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
15
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
17
  var _config = require("../../config");
18
+ var _interactionMetrics = require("../../interaction-metrics");
18
19
  var _attachAbortListeners = require("./attachAbortListeners");
19
20
  var _getVCRevisionsData = require("./getVCRevisionsData");
20
21
  var _getViewport = require("./getViewport");
@@ -105,11 +106,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
105
106
  });
106
107
  (0, _defineProperty2.default)(this, "getVCResult", /*#__PURE__*/function () {
107
108
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
108
- var start, stop, tti, prefix, ssr, vc, isEventAborted, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, isTTVCv1Disabled, vcAbortedResultWithRevisions, ttvcV1Result, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, ttvcV1DevToolInfo, ttvcV2DevToolInfo, isVCClean, revisionsData, speedIndex, isTTVCv3Enabled;
109
+ var start, stop, tti, prefix, ssr, vc, isEventAborted, experienceKey, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, isTTVCv1Disabled, vcAbortedResultWithRevisions, ttvcV1Result, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, ttvcV1DevToolInfo, ttvcV2DevToolInfo, isVCClean, revisionsData, speedIndex, isTTVCv3Enabled;
109
110
  return _regenerator.default.wrap(function _callee$(_context) {
110
111
  while (1) switch (_context.prev = _context.next) {
111
112
  case 0:
112
- start = _ref3.start, stop = _ref3.stop, tti = _ref3.tti, prefix = _ref3.prefix, ssr = _ref3.ssr, vc = _ref3.vc, isEventAborted = _ref3.isEventAborted;
113
+ start = _ref3.start, stop = _ref3.stop, tti = _ref3.tti, prefix = _ref3.prefix, ssr = _ref3.ssr, vc = _ref3.vc, isEventAborted = _ref3.isEventAborted, experienceKey = _ref3.experienceKey;
113
114
  startTime = performance.now(); // add local measurement
114
115
  fullPrefix = prefix !== undefined && prefix !== '' ? "".concat(prefix, ":") : '';
115
116
  rawData = vc !== undefined ? vc : _this.getVCRawData();
@@ -120,7 +121,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
120
121
  return _context.abrupt("return", {});
121
122
  case 6:
122
123
  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, multiHeatmap = rawData.multiHeatmap;
123
- isTTVCv1Disabled = !(0, _config.isVCRevisionEnabled)('fy25.01'); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
124
+ isTTVCv1Disabled = (0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience') ? !(0, _config.isVCRevisionEnabled)('fy25.01', experienceKey) : !(0, _config.isVCRevisionEnabled)('fy25.01'); // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
124
125
  // we want to report abort by scroll events the same way as other abort reasons
125
126
  // i.e. not have the concept of `abortReason.blocking` anymore
126
127
  if (!(abortReasonInfo !== null && (0, _platformFeatureFlags.fg)('platform_ufo_add_vc_abort_reason_by_revisions'))) {
@@ -308,7 +309,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
308
309
  VC: vcNext.VC,
309
310
  VCBox: vcNext.VCBox
310
311
  },
311
- isEventAborted: isEventAborted
312
+ isEventAborted: isEventAborted,
313
+ experienceKey: experienceKey
312
314
  });
313
315
  speedIndex = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "ufo:speedIndex", isTTVCv1Disabled ? vcNext.VCEntries.speedIndex : VCEntries.speedIndex), "ufo:next:speedIndex", vcNext.VCEntries.speedIndex);
314
316
  if (!isTTVCv1Disabled) {
@@ -317,7 +319,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
317
319
  }
318
320
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:size"), viewport), "".concat(fullPrefix, "vc:time"), Math.round(totalTime + (stopTime - startTime))), "".concat(fullPrefix, "vc:ratios"), ratios), outOfBoundary), {}, (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
319
321
  case 32:
320
- isTTVCv3Enabled = (0, _config.isVCRevisionEnabled)('fy25.03');
322
+ isTTVCv3Enabled = (0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience') ? (0, _config.isVCRevisionEnabled)('fy25.03', experienceKey) : (0, _config.isVCRevisionEnabled)('fy25.03');
321
323
  return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({
322
324
  'metrics:vc': VC
323
325
  }, "".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), outOfBoundary), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".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), "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), speedIndex));
@@ -334,7 +336,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
334
336
  (0, _defineProperty2.default)(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) {
335
337
  _this.measureStart();
336
338
  _this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue);
337
- if (!(0, _config.isVCRevisionEnabled)('fy25.03')) {
339
+ var isTTVCv3Disabled = !(0, _config.isVCRevisionEnabled)('fy25.03');
340
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience')) {
341
+ var interaction = (0, _interactionMetrics.getActiveInteraction)();
342
+ isTTVCv3Disabled = !(0, _config.isVCRevisionEnabled)('fy25.03', interaction === null || interaction === void 0 ? void 0 : interaction.ufoName);
343
+ }
344
+ if (isTTVCv3Disabled) {
338
345
  _this.onViewportChangeDetected({
339
346
  timestamp: rawTime,
340
347
  intersectionRect: intersectionRect,
@@ -358,6 +365,10 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
358
365
  _this.applyChangesToHeatMap(mappedValues, time, _this.heatmapNext);
359
366
  }
360
367
  var isTTVCv1Disabled = !(0, _config.isVCRevisionEnabled)('fy25.01');
368
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_vc_enable_revisions_by_experience')) {
369
+ var interaction = (0, _interactionMetrics.getActiveInteraction)();
370
+ isTTVCv1Disabled = !(0, _config.isVCRevisionEnabled)('fy25.01', interaction === null || interaction === void 0 ? void 0 : interaction.ufoName);
371
+ }
361
372
  if (!isTTVCv1Disabled && (!ignoreReason || ignoreReason === 'not-visible') && type !== 'attr') {
362
373
  _this.applyChangesToHeatMap(mappedValues, time, _this.heatmap);
363
374
  }
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  let config;
2
3
  const DEFAULT_TTVC_REVISION = 'fy25.02';
3
4
 
@@ -5,28 +6,70 @@ const DEFAULT_TTVC_REVISION = 'fy25.02';
5
6
  // and they could delete empty members
6
7
 
7
8
  export function setUFOConfig(newConfig) {
8
- config = newConfig;
9
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
10
+ var _newConfig$vc;
11
+ // Handle edge cases with `enabledVCRevisions`
12
+ const {
13
+ enabledVCRevisions
14
+ } = (_newConfig$vc = newConfig === null || newConfig === void 0 ? void 0 : newConfig.vc) !== null && _newConfig$vc !== void 0 ? _newConfig$vc : {};
15
+ if (typeof (enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.byExperience) === 'object') {
16
+ config = {
17
+ ...newConfig,
18
+ vc: {
19
+ ...newConfig.vc,
20
+ enabledVCRevisions: {
21
+ // enforce axiom about `enabledVCRevisions.all` config
22
+ all: Array.from(new Set([DEFAULT_TTVC_REVISION, ...(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.all), ...Object.values(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.byExperience).flat()])),
23
+ byExperience: {
24
+ ...(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.byExperience)
25
+ }
26
+ }
27
+ }
28
+ };
29
+ } else {
30
+ config = newConfig;
31
+ }
32
+ } else {
33
+ config = newConfig;
34
+ }
9
35
  }
10
36
  export function getConfig() {
11
37
  return config;
12
38
  }
13
- export function getEnabledVCRevisions() {
39
+ const isValidConfigArray = array => {
40
+ return Array.isArray(array) && array.length > 0;
41
+ };
42
+ export function getEnabledVCRevisions(experienceKey = '') {
14
43
  try {
15
44
  var _config$vc;
16
45
  if (!config) {
17
46
  return [];
18
47
  }
19
48
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
20
- var _config$vc2, _config$vc3;
21
- return Array.isArray((_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.enabledVCRevisions) && ((_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.enabledVCRevisions.length) > 0 ? config.vc.enabledVCRevisions : [DEFAULT_TTVC_REVISION];
49
+ var _config$vc2, _enabledVCRevisions$b;
50
+ const {
51
+ enabledVCRevisions
52
+ } = (_config$vc2 = config.vc) !== null && _config$vc2 !== void 0 ? _config$vc2 : {};
53
+ if (isValidConfigArray(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : (_enabledVCRevisions$b = enabledVCRevisions.byExperience) === null || _enabledVCRevisions$b === void 0 ? void 0 : _enabledVCRevisions$b[experienceKey]) && fg('platform_ufo_vc_enable_revisions_by_experience')) {
54
+ var _enabledVCRevisions$b2;
55
+ return (_enabledVCRevisions$b2 = enabledVCRevisions.byExperience) === null || _enabledVCRevisions$b2 === void 0 ? void 0 : _enabledVCRevisions$b2[experienceKey];
56
+ }
57
+ if (isValidConfigArray(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.all)) {
58
+ return enabledVCRevisions.all;
59
+ }
60
+ return [DEFAULT_TTVC_REVISION];
22
61
  }
23
62
  return [];
24
63
  } catch {
25
64
  return [];
26
65
  }
27
66
  }
28
- export function isVCRevisionEnabled(revision) {
29
- return getEnabledVCRevisions().includes(revision);
67
+ export function isVCRevisionEnabled(revision, experienceKey) {
68
+ return getEnabledVCRevisions(experienceKey).includes(revision);
69
+ }
70
+ export function getMostRecentVCRevision(experienceKey = '') {
71
+ const enabledVCRevisions = getEnabledVCRevisions(experienceKey);
72
+ return enabledVCRevisions[enabledVCRevisions.length - 1];
30
73
  }
31
74
  export function getInteractionRate(name, interactionKind) {
32
75
  try {
@@ -67,7 +67,8 @@ export async function getExperimentalVCMetrics(interaction) {
67
67
  tti: (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime,
68
68
  isEventAborted: !!interaction.abortReason,
69
69
  prefix,
70
- vc: interaction.vc
70
+ vc: interaction.vc,
71
+ experienceKey: interaction.ufoName
71
72
  });
72
73
  const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
73
74
  if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
@@ -1,5 +1,5 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
- import { getConfig, isVCRevisionEnabled } from '../../config';
2
+ import { getConfig, getMostRecentVCRevision, isVCRevisionEnabled } from '../../config';
3
3
  import { postInteractionLog } from '../../interaction-metrics';
4
4
  import { getVCObserver } from '../../vc';
5
5
  import getInteractionStatus from './get-interaction-status';
@@ -16,8 +16,9 @@ async function getVCMetrics(interaction) {
16
16
  }
17
17
  const interactionStatus = getInteractionStatus(interaction);
18
18
  const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
19
- if ((interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') && fg('platform_ufo_no_vc_on_aborted')) {
20
- getVCObserver().stop();
19
+ const shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
20
+ if (!shouldReportVCMetrics && fg('platform_ufo_no_vc_on_aborted')) {
21
+ getVCObserver().stop(interaction.ufoName);
21
22
  return {};
22
23
  }
23
24
  const isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 ? void 0 : (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
@@ -34,36 +35,52 @@ async function getVCMetrics(interaction) {
34
35
  prefix,
35
36
  vc: interaction.vc,
36
37
  isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED',
38
+ experienceKey: interaction.ufoName,
37
39
  ...ssr
38
40
  });
39
41
  if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
40
- getVCObserver().stop();
42
+ getVCObserver().stop(interaction.ufoName);
41
43
  }
42
44
  postInteractionLog.setLastInteractionFinishVCResult(result);
43
- if (!isVCRevisionEnabled('fy25.01')) {
45
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
44
46
  var _result$ufoVcRev;
45
- const ttvcV2Revision = result === null || result === void 0 ? void 0 : (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(({
47
+ const mostRecentVCRevision = getMostRecentVCRevision(interaction.ufoName);
48
+ const mostRecentVCRevisionPayload = result === null || result === void 0 ? void 0 : (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(({
46
49
  revision
47
- }) => revision === 'fy25.02');
48
- if (!(ttvcV2Revision !== null && ttvcV2Revision !== void 0 && ttvcV2Revision.clean)) {
50
+ }) => revision === mostRecentVCRevision);
51
+ if (!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean)) {
49
52
  return result;
50
53
  }
51
54
  return {
52
55
  ...result,
53
- 'metric:vc90': ttvcV2Revision['metric:vc90']
56
+ 'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
54
57
  };
55
58
  } else {
56
- const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
57
- if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
58
- return result;
59
- }
60
- if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
61
- return result;
59
+ if (!isVCRevisionEnabled('fy25.01')) {
60
+ var _result$ufoVcRev2;
61
+ const ttvcV2Revision = result === null || result === void 0 ? void 0 : (_result$ufoVcRev2 = result['ufo:vc:rev']) === null || _result$ufoVcRev2 === void 0 ? void 0 : _result$ufoVcRev2.find(({
62
+ revision
63
+ }) => revision === 'fy25.02');
64
+ if (!(ttvcV2Revision !== null && ttvcV2Revision !== void 0 && ttvcV2Revision.clean)) {
65
+ return result;
66
+ }
67
+ return {
68
+ ...result,
69
+ 'metric:vc90': ttvcV2Revision['metric:vc90']
70
+ };
71
+ } else {
72
+ const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
73
+ if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
74
+ return result;
75
+ }
76
+ if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
77
+ return result;
78
+ }
79
+ return {
80
+ ...result,
81
+ 'metric:vc90': VC['90']
82
+ };
62
83
  }
63
- return {
64
- ...result,
65
- 'metric:vc90': VC['90']
66
- };
67
84
  }
68
85
  }
69
86
  export default getVCMetrics;
@@ -120,6 +120,17 @@ function createPostInteractionLogPayload({
120
120
  if (pageVisibilityState !== 'visible') {
121
121
  return null;
122
122
  }
123
+
124
+ // Align post-interaction-logs closer to UFO event behaviour,
125
+ // e.g. also check for aborted or failed events
126
+ if (fg('platform_ufo_vc_align_revisions_on_watchdog_event')) {
127
+ if (lastInteractionFinish.abortReason) {
128
+ return null;
129
+ }
130
+ if (lastInteractionFinish.errors.length > 0) {
131
+ return null;
132
+ }
133
+ }
123
134
  const maxEndTimeFromProfiler = reactProfilerTimings ? Math.max(...reactProfilerTimings.map(t => t.commitTime)) : lastInteractionFinish.end;
124
135
  const revisedEndTime = Math.round(maxEndTimeFromProfiler);
125
136
  const revisedTtai = Math.round(maxEndTimeFromProfiler - lastInteractionFinish.start);
@@ -719,7 +719,8 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
719
719
  if (type === 'transition') {
720
720
  var _getConfig14, _getConfig14$experime;
721
721
  getVCObserver().start({
722
- startTime
722
+ startTime,
723
+ experienceKey: ufoName
723
724
  });
724
725
  postInteractionLog.startVCObserver({
725
726
  startTime
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { getConfig } from '../config';
4
+ import { VCObserverWrapper } from '../vc';
3
5
  import { VCObserver } from '../vc/vc-observer';
4
6
  const POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT = 3000;
5
7
  export default class PostInteractionLog {
@@ -27,7 +29,12 @@ export default class PostInteractionLog {
27
29
  _defineProperty(this, "sinkHandlerFn", () => {});
28
30
  }
29
31
  initializeVCObserver(options) {
30
- if (this.vcObserver === null) {
32
+ if (fg('platform_ufo_vc_align_revisions_on_watchdog_event')) {
33
+ this.vcObserver = new VCObserverWrapper({
34
+ ...options,
35
+ isPostInteraction: true
36
+ });
37
+ } else if (this.vcObserver === null) {
31
38
  this.vcObserver = new VCObserver({
32
39
  ...options,
33
40
  isPostInteraction: true
@@ -103,7 +110,8 @@ export default class PostInteractionLog {
103
110
  // no need for TTI value here
104
111
  isEventAborted: !!this.lastInteractionFinish.abortReason,
105
112
  prefix: 'ufo',
106
- ...this.vcObserverSSRConfig
113
+ ...this.vcObserverSSRConfig,
114
+ experienceKey: this.lastInteractionFinish.ufoName
107
115
  }));
108
116
  if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2$experimen = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2$experimen !== void 0 && _getConfig2$experimen.enabled) {
109
117
  var _this$vcObserver4;
@@ -134,7 +142,8 @@ export default class PostInteractionLog {
134
142
  routeName,
135
143
  type,
136
144
  experimentalTTAI,
137
- experimentalVC90
145
+ experimentalVC90,
146
+ errors
138
147
  }) {
139
148
  var _getConfig3;
140
149
  this.lastInteractionFinish = {
@@ -147,7 +156,8 @@ export default class PostInteractionLog {
147
156
  routeName,
148
157
  type,
149
158
  experimentalTTAI,
150
- experimentalVC90
159
+ experimentalVC90,
160
+ errors
151
161
  };
152
162
  const timeout = ((_getConfig3 = getConfig()) === null || _getConfig3 === void 0 ? void 0 : _getConfig3.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
153
163
  this.sinkTimeoutId = window.setTimeout(async () => {
@@ -1,60 +1,123 @@
1
1
  var _process, _process$env;
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { isVCRevisionEnabled } from '../config';
3
4
  import { VCObserverNOOP } from './no-op-vc-observer';
4
5
  import { VCObserver } from './vc-observer';
5
6
  import VCObserverNew from './vc-observer-new';
6
- class VCObserverWrapper {
7
+ export class VCObserverWrapper {
7
8
  constructor(opts = {}) {
8
9
  this.newVCObserver = null;
9
- if (isVCRevisionEnabled('fy25.03')) {
10
- this.newVCObserver = new VCObserverNew({
11
- selectorConfig: opts.selectorConfig
12
- });
10
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
11
+ this.oldVCObserver = null;
12
+ if (isVCRevisionEnabled('fy25.03')) {
13
+ this.newVCObserver = new VCObserverNew({
14
+ selectorConfig: opts.selectorConfig
15
+ });
16
+ }
17
+ if (isVCRevisionEnabled('fy25.01') || isVCRevisionEnabled('fy25.02')) {
18
+ this.oldVCObserver = new VCObserver(opts);
19
+ }
20
+ } else {
21
+ if (isVCRevisionEnabled('fy25.03')) {
22
+ this.newVCObserver = new VCObserverNew({
23
+ selectorConfig: opts.selectorConfig
24
+ });
25
+ }
26
+ this.oldVCObserver = new VCObserver(opts);
13
27
  }
14
- this.oldVCObserver = new VCObserver(opts);
15
28
  }
16
- start(startArg) {
17
- var _this$oldVCObserver, _this$newVCObserver;
18
- (_this$oldVCObserver = this.oldVCObserver) === null || _this$oldVCObserver === void 0 ? void 0 : _this$oldVCObserver.start(startArg);
19
- (_this$newVCObserver = this.newVCObserver) === null || _this$newVCObserver === void 0 ? void 0 : _this$newVCObserver.start({
20
- startTime: startArg.startTime
21
- });
29
+ start({
30
+ startTime,
31
+ experienceKey
32
+ }) {
33
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
34
+ if (isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey)) {
35
+ var _this$oldVCObserver;
36
+ (_this$oldVCObserver = this.oldVCObserver) === null || _this$oldVCObserver === void 0 ? void 0 : _this$oldVCObserver.start({
37
+ startTime
38
+ });
39
+ }
40
+ if (isVCRevisionEnabled('fy25.03', experienceKey)) {
41
+ var _this$newVCObserver;
42
+ (_this$newVCObserver = this.newVCObserver) === null || _this$newVCObserver === void 0 ? void 0 : _this$newVCObserver.start({
43
+ startTime
44
+ });
45
+ }
46
+ } else {
47
+ var _this$oldVCObserver2, _this$newVCObserver2;
48
+ (_this$oldVCObserver2 = this.oldVCObserver) === null || _this$oldVCObserver2 === void 0 ? void 0 : _this$oldVCObserver2.start({
49
+ startTime
50
+ });
51
+ (_this$newVCObserver2 = this.newVCObserver) === null || _this$newVCObserver2 === void 0 ? void 0 : _this$newVCObserver2.start({
52
+ startTime
53
+ });
54
+ }
22
55
  }
23
- stop() {
24
- var _this$oldVCObserver2, _this$newVCObserver2;
25
- (_this$oldVCObserver2 = this.oldVCObserver) === null || _this$oldVCObserver2 === void 0 ? void 0 : _this$oldVCObserver2.stop();
26
- (_this$newVCObserver2 = this.newVCObserver) === null || _this$newVCObserver2 === void 0 ? void 0 : _this$newVCObserver2.stop();
56
+ stop(experienceKey) {
57
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
58
+ if (isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey)) {
59
+ var _this$oldVCObserver3;
60
+ (_this$oldVCObserver3 = this.oldVCObserver) === null || _this$oldVCObserver3 === void 0 ? void 0 : _this$oldVCObserver3.stop();
61
+ }
62
+ if (isVCRevisionEnabled('fy25.03', experienceKey)) {
63
+ var _this$newVCObserver3;
64
+ (_this$newVCObserver3 = this.newVCObserver) === null || _this$newVCObserver3 === void 0 ? void 0 : _this$newVCObserver3.stop();
65
+ }
66
+ } else {
67
+ var _this$oldVCObserver4, _this$newVCObserver4;
68
+ (_this$oldVCObserver4 = this.oldVCObserver) === null || _this$oldVCObserver4 === void 0 ? void 0 : _this$oldVCObserver4.stop();
69
+ (_this$newVCObserver4 = this.newVCObserver) === null || _this$newVCObserver4 === void 0 ? void 0 : _this$newVCObserver4.stop();
70
+ }
27
71
  }
28
72
  getVCRawData() {
29
- var _this$oldVCObserver$g, _this$oldVCObserver3;
30
- return (_this$oldVCObserver$g = (_this$oldVCObserver3 = this.oldVCObserver) === null || _this$oldVCObserver3 === void 0 ? void 0 : _this$oldVCObserver3.getVCRawData()) !== null && _this$oldVCObserver$g !== void 0 ? _this$oldVCObserver$g : null;
73
+ var _this$oldVCObserver$g, _this$oldVCObserver5;
74
+ return (_this$oldVCObserver$g = (_this$oldVCObserver5 = this.oldVCObserver) === null || _this$oldVCObserver5 === void 0 ? void 0 : _this$oldVCObserver5.getVCRawData()) !== null && _this$oldVCObserver$g !== void 0 ? _this$oldVCObserver$g : null;
31
75
  }
32
76
  async getVCResult(param) {
33
- var _this$oldVCObserver4, _this$newVCObserver3, _ref;
34
- const oldResult = await ((_this$oldVCObserver4 = this.oldVCObserver) === null || _this$oldVCObserver4 === void 0 ? void 0 : _this$oldVCObserver4.getVCResult(param));
35
- const newResult = await ((_this$newVCObserver3 = this.newVCObserver) === null || _this$newVCObserver3 === void 0 ? void 0 : _this$newVCObserver3.getVCResult({
36
- start: param.start,
37
- stop: param.stop
38
- }));
39
- if (oldResult && !newResult) {
40
- return oldResult;
77
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
78
+ var _this$oldVCObserver6, _this$newVCObserver5, _ref;
79
+ const {
80
+ experienceKey
81
+ } = param;
82
+ const v1v2Result = isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey) ? await ((_this$oldVCObserver6 = this.oldVCObserver) === null || _this$oldVCObserver6 === void 0 ? void 0 : _this$oldVCObserver6.getVCResult(param)) : {};
83
+ const v3Result = isVCRevisionEnabled('fy25.03', experienceKey) ? await ((_this$newVCObserver5 = this.newVCObserver) === null || _this$newVCObserver5 === void 0 ? void 0 : _this$newVCObserver5.getVCResult({
84
+ start: param.start,
85
+ stop: param.stop
86
+ })) : [];
87
+ if (!v3Result) {
88
+ return v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {};
89
+ }
90
+ return {
91
+ ...v1v2Result,
92
+ 'ufo:vc:rev': [...((_ref = v1v2Result === null || v1v2Result === void 0 ? void 0 : v1v2Result['ufo:vc:rev']) !== null && _ref !== void 0 ? _ref : []), ...(v3Result !== null && v3Result !== void 0 ? v3Result : [])]
93
+ };
94
+ } else {
95
+ var _this$oldVCObserver7, _this$newVCObserver6, _ref2;
96
+ const oldResult = await ((_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 ? void 0 : _this$oldVCObserver7.getVCResult(param));
97
+ const newResult = await ((_this$newVCObserver6 = this.newVCObserver) === null || _this$newVCObserver6 === void 0 ? void 0 : _this$newVCObserver6.getVCResult({
98
+ start: param.start,
99
+ stop: param.stop
100
+ }));
101
+ if (oldResult && !newResult) {
102
+ return oldResult;
103
+ }
104
+ return {
105
+ ...(oldResult !== null && oldResult !== void 0 ? oldResult : {}),
106
+ 'ufo:vc:rev': [...((_ref2 = oldResult === null || oldResult === void 0 ? void 0 : oldResult['ufo:vc:rev']) !== null && _ref2 !== void 0 ? _ref2 : []), ...(newResult !== null && newResult !== void 0 ? newResult : [])]
107
+ };
41
108
  }
42
- return {
43
- ...(oldResult !== null && oldResult !== void 0 ? oldResult : {}),
44
- 'ufo:vc:rev': [...((_ref = oldResult === null || oldResult === void 0 ? void 0 : oldResult['ufo:vc:rev']) !== null && _ref !== void 0 ? _ref : []), ...(newResult !== null && newResult !== void 0 ? newResult : [])]
45
- };
46
109
  }
47
110
  setSSRElement(element) {
48
- var _this$oldVCObserver5;
49
- (_this$oldVCObserver5 = this.oldVCObserver) === null || _this$oldVCObserver5 === void 0 ? void 0 : _this$oldVCObserver5.setSSRElement(element);
111
+ var _this$oldVCObserver8;
112
+ (_this$oldVCObserver8 = this.oldVCObserver) === null || _this$oldVCObserver8 === void 0 ? void 0 : _this$oldVCObserver8.setSSRElement(element);
50
113
  }
51
114
  setReactRootRenderStart(startTime) {
52
- var _this$oldVCObserver6;
53
- (_this$oldVCObserver6 = this.oldVCObserver) === null || _this$oldVCObserver6 === void 0 ? void 0 : _this$oldVCObserver6.setReactRootRenderStart(startTime || performance.now());
115
+ var _this$oldVCObserver9;
116
+ (_this$oldVCObserver9 = this.oldVCObserver) === null || _this$oldVCObserver9 === void 0 ? void 0 : _this$oldVCObserver9.setReactRootRenderStart(startTime || performance.now());
54
117
  }
55
118
  setReactRootRenderStop(stopTime) {
56
- var _this$oldVCObserver7;
57
- (_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 ? void 0 : _this$oldVCObserver7.setReactRootRenderStop(stopTime || performance.now());
119
+ var _this$oldVCObserver10;
120
+ (_this$oldVCObserver10 = this.oldVCObserver) === null || _this$oldVCObserver10 === void 0 ? void 0 : _this$oldVCObserver10.setReactRootRenderStop(stopTime || performance.now());
58
121
  }
59
122
  }
60
123