@atlaskit/react-ufo 3.3.0 → 3.3.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +1 -0
  3. package/dist/cjs/create-payload/index.js +63 -156
  4. package/dist/cjs/create-payload/utils/get-interaction-status.js +37 -0
  5. package/dist/cjs/create-payload/utils/get-page-visibility-up-to-ttai.js +12 -0
  6. package/dist/cjs/create-payload/utils/get-ssr-done-time-value.js +14 -0
  7. package/dist/cjs/create-payload/utils/get-vc-metrics.js +96 -0
  8. package/dist/cjs/interaction-metrics/post-interaction-log.js +1 -0
  9. package/dist/cjs/vc/vc-observer/heatmap/heatmap.js +4 -1
  10. package/dist/cjs/vc/vc-observer/index.js +27 -30
  11. package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +1 -0
  12. package/dist/es2019/create-payload/index.js +11 -80
  13. package/dist/es2019/create-payload/utils/get-interaction-status.js +31 -0
  14. package/dist/es2019/create-payload/utils/get-page-visibility-up-to-ttai.js +8 -0
  15. package/dist/es2019/create-payload/utils/get-ssr-done-time-value.js +5 -0
  16. package/dist/es2019/create-payload/utils/get-vc-metrics.js +53 -0
  17. package/dist/es2019/interaction-metrics/post-interaction-log.js +1 -0
  18. package/dist/es2019/vc/vc-observer/heatmap/heatmap.js +4 -1
  19. package/dist/es2019/vc/vc-observer/index.js +29 -29
  20. package/dist/esm/create-experimental-interaction-metrics-payload/index.js +1 -0
  21. package/dist/esm/create-payload/index.js +56 -149
  22. package/dist/esm/create-payload/utils/get-interaction-status.js +31 -0
  23. package/dist/esm/create-payload/utils/get-page-visibility-up-to-ttai.js +6 -0
  24. package/dist/esm/create-payload/utils/get-ssr-done-time-value.js +5 -0
  25. package/dist/esm/create-payload/utils/get-vc-metrics.js +89 -0
  26. package/dist/esm/interaction-metrics/post-interaction-log.js +1 -0
  27. package/dist/esm/vc/vc-observer/heatmap/heatmap.js +4 -1
  28. package/dist/esm/vc/vc-observer/index.js +27 -30
  29. package/dist/types/create-payload/utils/get-interaction-status.d.ts +27 -0
  30. package/dist/types/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -0
  31. package/dist/types/create-payload/utils/get-ssr-done-time-value.d.ts +2 -0
  32. package/dist/types/create-payload/utils/get-vc-metrics.d.ts +5 -0
  33. package/dist/types/vc/types.d.ts +1 -0
  34. package/dist/types/vc/vc-observer/heatmap/heatmap.d.ts +2 -0
  35. package/dist/types/vc/vc-observer/index.d.ts +1 -1
  36. package/dist/types-ts4.5/create-payload/utils/get-interaction-status.d.ts +27 -0
  37. package/dist/types-ts4.5/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -0
  38. package/dist/types-ts4.5/create-payload/utils/get-ssr-done-time-value.d.ts +2 -0
  39. package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +5 -0
  40. package/dist/types-ts4.5/vc/types.d.ts +1 -0
  41. package/dist/types-ts4.5/vc/vc-observer/heatmap/heatmap.d.ts +2 -0
  42. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +1 -1
  43. package/package.json +7 -4
@@ -10,6 +10,7 @@ var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _hiddenTiming = require("../../../hidden-timing");
13
14
  var UNUSED_SECTOR = 0;
14
15
  var MultiRevisionHeatmap = exports.MultiRevisionHeatmap = /*#__PURE__*/function () {
15
16
  function MultiRevisionHeatmap(_ref) {
@@ -107,8 +108,10 @@ var MultiRevisionHeatmap = exports.MultiRevisionHeatmap = /*#__PURE__*/function
107
108
  }, {
108
109
  key: "getPayloadShapedData",
109
110
  value: function getPayloadShapedData(args) {
111
+ var pageVisibilityUpToTTAI = (0, _hiddenTiming.getPageVisibilityState)(args.interactionStart, args.ttai);
110
112
  var result = this.processData(args);
111
113
  var payload = this.revisions.map(function (rev, i) {
114
+ var _vcDetails$;
112
115
  var vcDetails = {};
113
116
  args.VCParts.forEach(function (VCPart) {
114
117
  vcDetails[VCPart] = {
@@ -120,7 +123,7 @@ var MultiRevisionHeatmap = exports.MultiRevisionHeatmap = /*#__PURE__*/function
120
123
  revision: rev.name,
121
124
  vcDetails: vcDetails,
122
125
  clean: args.clean,
123
- 'metric:vc90': null // will be set or not in the payload generator
126
+ 'metric:vc90': args.clean && !args.isEventAborted && pageVisibilityUpToTTAI === 'visible' ? vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t : null
124
127
  };
125
128
  });
126
129
  return payload;
@@ -103,11 +103,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
103
103
  });
104
104
  (0, _defineProperty2.default)(this, "getVCResult", /*#__PURE__*/function () {
105
105
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref3) {
106
- var start, stop, tti, prefix, ssr, vc, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, _VCObserver$calculate, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, isMultiHeatmapEnabled, revisionsData, isCalcSpeedIndexEnabled;
106
+ var start, stop, tti, prefix, ssr, vc, isEventAborted, startTime, fullPrefix, rawData, abortReason, abortReasonInfo, heatmap, heatmapNext, outOfBoundaryInfo, totalTime, componentsLog, viewport, devToolsEnabled, ratios, multiHeatmap, _VCObserver$calculate, VC, VCBox, VCEntries, totalPainted, _componentsLog, vcNext, outOfBoundary, stopTime, isMultiHeatmapEnabled, revisionsData, isCalcSpeedIndexEnabled, speedIndex;
107
107
  return _regenerator.default.wrap(function _callee$(_context) {
108
108
  while (1) switch (_context.prev = _context.next) {
109
109
  case 0:
110
- start = _ref3.start, stop = _ref3.stop, tti = _ref3.tti, prefix = _ref3.prefix, ssr = _ref3.ssr, vc = _ref3.vc;
110
+ start = _ref3.start, stop = _ref3.stop, tti = _ref3.tti, prefix = _ref3.prefix, ssr = _ref3.ssr, vc = _ref3.vc, isEventAborted = _ref3.isEventAborted;
111
111
  startTime = performance.now(); // add local measurement
112
112
  fullPrefix = prefix !== undefined && prefix !== '' ? "".concat(prefix, ":") : '';
113
113
  rawData = vc !== undefined ? vc : _this.getVCRawData();
@@ -240,8 +240,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
240
240
  } catch (e) {
241
241
  /* do nothing */
242
242
  }
243
- isMultiHeatmapEnabled = (0, _platformFeatureFlags.fg)('ufo_vc_multiheatmap');
244
- revisionsData = isMultiHeatmapEnabled && multiHeatmap !== null ? (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), multiHeatmap.getPayloadShapedData({
243
+ isMultiHeatmapEnabled = !(0, _platformFeatureFlags.fg)('platform_ufo_multiheatmap_killswitch');
244
+ revisionsData = isMultiHeatmapEnabled && multiHeatmap !== null ? (0, _defineProperty2.default)({}, "".concat(fullPrefix, "vc:rev"), multiHeatmap === null || multiHeatmap === void 0 ? void 0 : multiHeatmap.getPayloadShapedData({
245
245
  VCParts: VCObserver.VCParts.map(function (v) {
246
246
  return parseInt(v);
247
247
  }),
@@ -253,15 +253,18 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
253
253
  var classifier = _ref10.classifier;
254
254
  return classifier.filterComponentsLog;
255
255
  }),
256
+ isEventAborted: isEventAborted,
257
+ interactionStart: start,
256
258
  ttai: stop,
257
259
  ssr: ssr,
258
260
  clean: !abortReasonInfo
259
261
  })) : null; // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
260
262
  isCalcSpeedIndexEnabled = (0, _platformFeatureFlags.fg)('ufo-calc-speed-index');
263
+ speedIndex = (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "ufo:speedIndex", VCEntries.speedIndex), "ufo:next:speedIndex", vcNext.VCEntries.speedIndex);
261
264
  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)({
262
265
  'metrics:vc': VC
263
- }, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"), !abortReasonInfo), "".concat(fullPrefix, "vc:dom"), VCBox), "".concat(fullPrefix, "vc:updates"), 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"), vcNext.VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:next:dom"), vcNext.VCBox), "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "ufo:speedIndex", isCalcSpeedIndexEnabled ? VCEntries.speedIndex : undefined), "ufo:next:speedIndex", isCalcSpeedIndexEnabled ? vcNext.VCEntries.speedIndex : undefined)));
264
- case 23:
266
+ }, "".concat(fullPrefix, "vc:state"), true), "".concat(fullPrefix, "vc:clean"), !abortReasonInfo), "".concat(fullPrefix, "vc:dom"), VCBox), "".concat(fullPrefix, "vc:updates"), 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"), vcNext.VCEntries.rel.slice(0, 50)), "".concat(fullPrefix, "vc:next:dom"), vcNext.VCBox), "".concat(fullPrefix, "vc:ignored"), _this.getIgnoredElements(componentsLog)), revisionsData), isCalcSpeedIndexEnabled ? speedIndex : {}));
267
+ case 24:
265
268
  case "end":
266
269
  return _context.stop();
267
270
  }
@@ -274,16 +277,14 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
274
277
  (0, _defineProperty2.default)(this, "handleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason) {
275
278
  _this.measureStart();
276
279
  _this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason);
277
- if ((0, _platformFeatureFlags.fg)('ufo_vc_multiheatmap')) {
278
- _this.onViewportChangeDetected({
279
- timestamp: rawTime,
280
- intersectionRect: intersectionRect,
281
- targetName: targetName,
282
- element: element,
283
- type: type,
284
- ignoreReason: ignoreReason
285
- });
286
- }
280
+ _this.onViewportChangeDetected({
281
+ timestamp: rawTime,
282
+ intersectionRect: intersectionRect,
283
+ targetName: targetName,
284
+ element: element,
285
+ type: type,
286
+ ignoreReason: ignoreReason
287
+ });
287
288
  _this.measureStop();
288
289
  });
289
290
  (0, _defineProperty2.default)(this, "legacyHandleUpdate", function (rawTime, intersectionRect, targetName, element, type, ignoreReason) {
@@ -423,13 +424,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
423
424
  });
424
425
  this.heatmap = this.getCleanHeatmap();
425
426
  this.heatmapNext = this.getCleanHeatmap();
426
- if ((0, _platformFeatureFlags.fg)('ufo_vc_multiheatmap')) {
427
- this.multiHeatmap = new _heatmap.MultiRevisionHeatmap({
428
- viewport: this.viewport,
429
- revisions: (0, _revisions.getRevisions)(),
430
- devToolsEnabled: this.devToolsEnabled
431
- });
432
- }
427
+ this.multiHeatmap = new _heatmap.MultiRevisionHeatmap({
428
+ viewport: this.viewport,
429
+ revisions: (0, _revisions.getRevisions)(),
430
+ devToolsEnabled: this.devToolsEnabled
431
+ });
433
432
  this.isPostInteraction = options.isPostInteraction || false;
434
433
  }
435
434
  return (0, _createClass2.default)(VCObserver, [{
@@ -512,13 +511,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
512
511
  this.detachAbortListeners();
513
512
  this.heatmap = this.getCleanHeatmap();
514
513
  this.heatmapNext = this.getCleanHeatmap();
515
- if ((0, _platformFeatureFlags.fg)('ufo_vc_multiheatmap')) {
516
- this.multiHeatmap = new _heatmap.MultiRevisionHeatmap({
517
- viewport: this.viewport,
518
- revisions: (0, _revisions.getRevisions)(),
519
- devToolsEnabled: this.devToolsEnabled
520
- });
521
- }
514
+ this.multiHeatmap = new _heatmap.MultiRevisionHeatmap({
515
+ viewport: this.viewport,
516
+ revisions: (0, _revisions.getRevisions)(),
517
+ devToolsEnabled: this.devToolsEnabled
518
+ });
522
519
  this.totalTime = 0;
523
520
  this.componentsLog = {};
524
521
  this.vcRatios = {};
@@ -65,6 +65,7 @@ export const getExperimentalVCMetrics = async interaction => {
65
65
  start: interaction.start,
66
66
  stop: interaction.end,
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
+ isEventAborted: !!interaction.abortReason,
68
69
  prefix,
69
70
  vc: interaction.vc
70
71
  });
@@ -11,12 +11,15 @@ import { getBm3Timings } from '../custom-timings';
11
11
  import { getGlobalErrorCount } from '../global-error-handler';
12
12
  import { getPageVisibilityState } from '../hidden-timing';
13
13
  import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
14
- import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
14
+ import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
15
15
  import * as resourceTiming from '../resource-timing';
16
16
  import { roundEpsilon } from '../round-number';
17
17
  import * as ssr from '../ssr';
18
- import { getVCObserver } from '../vc';
19
18
  import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
19
+ import getInteractionStatus from './utils/get-interaction-status';
20
+ import getPageVisibilityUpToTTAI from './utils/get-page-visibility-up-to-ttai';
21
+ import getSSRDoneTimeValue from './utils/get-ssr-done-time-value';
22
+ import getVCMetrics from './utils/get-vc-metrics';
20
23
  function getUfoNameOverride(interaction) {
21
24
  const {
22
25
  ufoName,
@@ -65,13 +68,6 @@ const getPageVisibilityUpToTTI = interaction => {
65
68
  const bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
66
69
  return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
67
70
  };
68
- const getPageVisibilityUpToTTAI = interaction => {
69
- const {
70
- start,
71
- end
72
- } = interaction;
73
- return getPageVisibilityState(start, end);
74
- };
75
71
  const getVisibilityStateFromPerformance = stop => {
76
72
  try {
77
73
  const results = performance.getEntriesByType('visibility-state');
@@ -126,15 +122,6 @@ const getMoreAccuratePageVisibilityUpToTTAI = interaction => {
126
122
  }
127
123
  return old;
128
124
  };
129
- const getInteractionStatus = interaction => {
130
- const originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
131
- const hasBm3TTI = interaction.apdex.length > 0;
132
- const overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
133
- return {
134
- originalInteractionStatus,
135
- overrideStatus
136
- };
137
- };
138
125
  const getResourceTimings = (start, end) => {
139
126
  var _resourceTiming$getRe;
140
127
  return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
@@ -165,58 +152,6 @@ const getTTAI = interaction => {
165
152
  const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
166
153
  return !interaction.abortReason && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
167
154
  };
168
- const getVCMetrics = async interaction => {
169
- var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _interaction$apdex$, _config$experimentalI;
170
- const config = getConfig();
171
- if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
172
- return {};
173
- }
174
- if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
175
- return {};
176
- }
177
- 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));
178
- const ssr = interaction.type === 'page_load' && isSSREnabled ? {
179
- ssr: getSSRDoneTimeValue(config)
180
- } : null;
181
- postInteractionLog.setVCObserverSSRConfig(ssr);
182
- const 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;
183
- const prefix = 'ufo';
184
- const result = await getVCObserver().getVCResult({
185
- start: interaction.start,
186
- stop: interaction.end,
187
- tti,
188
- prefix,
189
- vc: interaction.vc,
190
- ...ssr
191
- });
192
- if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
193
- getVCObserver().stop();
194
- }
195
- postInteractionLog.setLastInteractionFinishVCResult(result);
196
- const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
197
- if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
198
- return result;
199
- }
200
- const interactionStatus = getInteractionStatus(interaction);
201
- const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
202
- if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
203
- return result;
204
- }
205
- if (fg('ufo_vc_multiheatmap')) {
206
- var _result;
207
- (_result = result[`${prefix}:vc:rev`]) === null || _result === void 0 ? void 0 : _result.forEach(element => {
208
- var _element$vcDetails, _element$vcDetails$;
209
- if ((_element$vcDetails = element.vcDetails) !== null && _element$vcDetails !== void 0 && (_element$vcDetails$ = _element$vcDetails['90']) !== null && _element$vcDetails$ !== void 0 && _element$vcDetails$.t) {
210
- var _element$vcDetails$2;
211
- element['metric:vc90'] = (_element$vcDetails$2 = element.vcDetails['90']) === null || _element$vcDetails$2 === void 0 ? void 0 : _element$vcDetails$2.t;
212
- }
213
- });
214
- }
215
- return {
216
- ...result,
217
- 'metric:vc90': VC['90']
218
- };
219
- };
220
155
  const getNavigationMetrics = type => {
221
156
  if (type !== 'page_load') {
222
157
  return {};
@@ -264,7 +199,7 @@ const getNavigationMetrics = type => {
264
199
  };
265
200
  };
266
201
  const getPPSMetrics = interaction => {
267
- var _interaction$apdex2, _interaction$apdex2$;
202
+ var _interaction$apdex, _interaction$apdex$;
268
203
  const {
269
204
  start,
270
205
  end
@@ -272,7 +207,7 @@ const getPPSMetrics = interaction => {
272
207
  const config = getConfig();
273
208
  const interactionStatus = getInteractionStatus(interaction);
274
209
  const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
275
- const tti = (_interaction$apdex2 = interaction.apdex) === null || _interaction$apdex2 === void 0 ? void 0 : (_interaction$apdex2$ = _interaction$apdex2[0]) === null || _interaction$apdex2$ === void 0 ? void 0 : _interaction$apdex2$.stopTime;
210
+ const 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;
276
211
  const ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
277
212
  const PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
278
213
  start,
@@ -644,10 +579,6 @@ function getBm3TrackerTimings(interaction) {
644
579
  legacyMetrics
645
580
  };
646
581
  }
647
- function getSSRDoneTimeValue(config) {
648
- var _config$ssr, _config$ssr2;
649
- return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
650
- }
651
582
  function getPayloadSize(payload) {
652
583
  return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
653
584
  }
@@ -734,7 +665,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
734
665
  } : {};
735
666
  // Page Load
736
667
  const getPageLoadInteractionMetrics = () => {
737
- var _config$ssr3;
668
+ var _config$ssr;
738
669
  if (!isPageLoad) {
739
670
  return {};
740
671
  }
@@ -746,7 +677,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
746
677
  return {
747
678
  ...SSRDoneTime,
748
679
  isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
749
- isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr3 = config.ssr) !== null && _config$ssr3 !== void 0 && _config$ssr3.getSSRDoneTime)
680
+ isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
750
681
  };
751
682
  };
752
683
  // Detailed payload. Page visibility = visible
@@ -776,14 +707,14 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
776
707
  };
777
708
  // Page load & detailed payload
778
709
  const getPageLoadDetailedInteractionMetrics = () => {
779
- var _config$ssr4;
710
+ var _config$ssr2;
780
711
  if (!isPageLoad || !isDetailedPayload) {
781
712
  return {};
782
713
  }
783
714
  const config = getConfig();
784
715
  return {
785
716
  initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
786
- SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
717
+ SSRTimings: config !== null && config !== void 0 && (_config$ssr2 = config.ssr) !== null && _config$ssr2 !== void 0 && _config$ssr2.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
787
718
  };
788
719
  };
789
720
  if (experimental) {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Determines the interaction status based on abort reason and BM3 TTI presence.
3
+ *
4
+ * @param {InteractionMetrics} interaction - The interaction metrics object containing abort reason and apdex data
5
+ * @returns {{
6
+ * originalInteractionStatus: 'ABORTED' | 'SUCCEEDED',
7
+ * overrideStatus: 'ABORTED' | 'SUCCEEDED'
8
+ * }} An object containing both the original and override status
9
+ *
10
+ * @description
11
+ * This function evaluates the interaction status in two ways:
12
+ * 1. originalInteractionStatus: Based on whether there's an abort reason
13
+ * 2. overrideStatus: Based on the presence of BM3 TTI (apdex data)
14
+ *
15
+ * @example
16
+ * const interaction = {
17
+ * abortReason: null,
18
+ * apdex: [1, 2, 3]
19
+ * };
20
+ * const result = getInteractionStatus(interaction);
21
+ * // Returns: { originalInteractionStatus: 'SUCCEEDED', overrideStatus: 'SUCCEEDED' }
22
+ */
23
+ export default function getInteractionStatus(interaction) {
24
+ const originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
25
+ const hasBm3TTI = interaction.apdex.length > 0;
26
+ const overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
27
+ return {
28
+ originalInteractionStatus,
29
+ overrideStatus
30
+ };
31
+ }
@@ -0,0 +1,8 @@
1
+ import { getPageVisibilityState } from '../../hidden-timing';
2
+ export default function getPageVisibilityUpToTTAI(interaction) {
3
+ const {
4
+ start,
5
+ end
6
+ } = interaction;
7
+ return getPageVisibilityState(start, end);
8
+ }
@@ -0,0 +1,5 @@
1
+ import * as ssr from '../../ssr';
2
+ export default function getSSRDoneTimeValue(config) {
3
+ var _config$ssr, _config$ssr2;
4
+ return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
5
+ }
@@ -0,0 +1,53 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { getConfig } from '../../config';
3
+ import { postInteractionLog } from '../../interaction-metrics';
4
+ import { getVCObserver } from '../../vc';
5
+ import getInteractionStatus from './get-interaction-status';
6
+ import getPageVisibilityUpToTTAI from './get-page-visibility-up-to-ttai';
7
+ import getSSRDoneTimeValue from './get-ssr-done-time-value';
8
+ export default async function getVCMetrics(interaction) {
9
+ var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _interaction$apdex$, _config$experimentalI;
10
+ const config = getConfig();
11
+ if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
12
+ return {};
13
+ }
14
+ if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
15
+ return {};
16
+ }
17
+ const interactionStatus = getInteractionStatus(interaction);
18
+ const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
19
+ if ((interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') && fg('platform_ufo_no_vc_on_aborted')) {
20
+ return {};
21
+ }
22
+ 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));
23
+ const ssr = interaction.type === 'page_load' && isSSREnabled ? {
24
+ ssr: getSSRDoneTimeValue(config)
25
+ } : null;
26
+ postInteractionLog.setVCObserverSSRConfig(ssr);
27
+ const 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;
28
+ const prefix = 'ufo';
29
+ const result = await getVCObserver().getVCResult({
30
+ start: interaction.start,
31
+ stop: interaction.end,
32
+ tti,
33
+ prefix,
34
+ vc: interaction.vc,
35
+ isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED',
36
+ ...ssr
37
+ });
38
+ if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
39
+ getVCObserver().stop();
40
+ }
41
+ postInteractionLog.setLastInteractionFinishVCResult(result);
42
+ const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
43
+ if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
44
+ return result;
45
+ }
46
+ if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
47
+ return result;
48
+ }
49
+ return {
50
+ ...result,
51
+ 'metric:vc90': VC['90']
52
+ };
53
+ }
@@ -101,6 +101,7 @@ export default class PostInteractionLog {
101
101
  stop: performance.now(),
102
102
  tti: -1,
103
103
  // no need for TTI value here
104
+ isEventAborted: !!this.lastInteractionFinish.abortReason,
104
105
  prefix: 'ufo',
105
106
  ...this.vcObserverSSRConfig
106
107
  }));
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { getPageVisibilityState } from '../../../hidden-timing';
2
3
  const UNUSED_SECTOR = 0;
3
4
  export class MultiRevisionHeatmap {
4
5
  constructor({
@@ -91,8 +92,10 @@ export class MultiRevisionHeatmap {
91
92
  };
92
93
  }
93
94
  getPayloadShapedData(args) {
95
+ const pageVisibilityUpToTTAI = getPageVisibilityState(args.interactionStart, args.ttai);
94
96
  const result = this.processData(args);
95
97
  const payload = this.revisions.map((rev, i) => {
98
+ var _vcDetails$;
96
99
  const vcDetails = {};
97
100
  args.VCParts.forEach(VCPart => {
98
101
  vcDetails[VCPart] = {
@@ -104,7 +107,7 @@ export class MultiRevisionHeatmap {
104
107
  revision: rev.name,
105
108
  vcDetails,
106
109
  clean: args.clean,
107
- 'metric:vc90': null // will be set or not in the payload generator
110
+ 'metric:vc90': args.clean && !args.isEventAborted && pageVisibilityUpToTTAI === 'visible' ? vcDetails === null || vcDetails === void 0 ? void 0 : (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t : null
108
111
  };
109
112
  });
110
113
  return payload;
@@ -91,7 +91,8 @@ export class VCObserver {
91
91
  tti,
92
92
  prefix,
93
93
  ssr,
94
- vc
94
+ vc,
95
+ isEventAborted
95
96
  }) => {
96
97
  const startTime = performance.now();
97
98
  // add local measurement
@@ -249,9 +250,9 @@ export class VCObserver {
249
250
  } catch (e) {
250
251
  /* do nothing */
251
252
  }
252
- const isMultiHeatmapEnabled = fg('ufo_vc_multiheatmap');
253
+ const isMultiHeatmapEnabled = !fg('platform_ufo_multiheatmap_killswitch');
253
254
  const revisionsData = isMultiHeatmapEnabled && multiHeatmap !== null ? {
254
- [`${fullPrefix}vc:rev`]: multiHeatmap.getPayloadShapedData({
255
+ [`${fullPrefix}vc:rev`]: multiHeatmap === null || multiHeatmap === void 0 ? void 0 : multiHeatmap.getPayloadShapedData({
255
256
  VCParts: VCObserver.VCParts.map(v => parseInt(v)),
256
257
  VCCalculationMethods: getRevisions().map(({
257
258
  classifier
@@ -259,6 +260,8 @@ export class VCObserver {
259
260
  filterComponentsLog: getRevisions().map(({
260
261
  classifier
261
262
  }) => classifier.filterComponentsLog),
263
+ isEventAborted,
264
+ interactionStart: start,
262
265
  ttai: stop,
263
266
  ssr,
264
267
  clean: !abortReasonInfo
@@ -266,6 +269,10 @@ export class VCObserver {
266
269
  } : null;
267
270
  // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
268
271
  const isCalcSpeedIndexEnabled = fg('ufo-calc-speed-index');
272
+ const speedIndex = {
273
+ [`ufo:speedIndex`]: VCEntries.speedIndex,
274
+ [`ufo:next:speedIndex`]: vcNext.VCEntries.speedIndex
275
+ };
269
276
  return {
270
277
  'metrics:vc': VC,
271
278
  [`${fullPrefix}vc:state`]: true,
@@ -284,23 +291,20 @@ export class VCObserver {
284
291
  //...oldDomUpdates,
285
292
  [`${fullPrefix}vc:ignored`]: this.getIgnoredElements(componentsLog),
286
293
  ...revisionsData,
287
- [`ufo:speedIndex`]: isCalcSpeedIndexEnabled ? VCEntries.speedIndex : undefined,
288
- [`ufo:next:speedIndex`]: isCalcSpeedIndexEnabled ? vcNext.VCEntries.speedIndex : undefined
294
+ ...(isCalcSpeedIndexEnabled ? speedIndex : {})
289
295
  };
290
296
  });
291
297
  _defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason) => {
292
298
  this.measureStart();
293
299
  this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason);
294
- if (fg('ufo_vc_multiheatmap')) {
295
- this.onViewportChangeDetected({
296
- timestamp: rawTime,
297
- intersectionRect,
298
- targetName,
299
- element,
300
- type,
301
- ignoreReason
302
- });
303
- }
300
+ this.onViewportChangeDetected({
301
+ timestamp: rawTime,
302
+ intersectionRect,
303
+ targetName,
304
+ element,
305
+ type,
306
+ ignoreReason
307
+ });
304
308
  this.measureStop();
305
309
  });
306
310
  _defineProperty(this, "legacyHandleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason) => {
@@ -441,13 +445,11 @@ export class VCObserver {
441
445
  });
442
446
  this.heatmap = this.getCleanHeatmap();
443
447
  this.heatmapNext = this.getCleanHeatmap();
444
- if (fg('ufo_vc_multiheatmap')) {
445
- this.multiHeatmap = new MultiRevisionHeatmap({
446
- viewport: this.viewport,
447
- revisions: getRevisions(),
448
- devToolsEnabled: this.devToolsEnabled
449
- });
450
- }
448
+ this.multiHeatmap = new MultiRevisionHeatmap({
449
+ viewport: this.viewport,
450
+ revisions: getRevisions(),
451
+ devToolsEnabled: this.devToolsEnabled
452
+ });
451
453
  this.isPostInteraction = options.isPostInteraction || false;
452
454
  }
453
455
  start({
@@ -606,13 +608,11 @@ export class VCObserver {
606
608
  this.detachAbortListeners();
607
609
  this.heatmap = this.getCleanHeatmap();
608
610
  this.heatmapNext = this.getCleanHeatmap();
609
- if (fg('ufo_vc_multiheatmap')) {
610
- this.multiHeatmap = new MultiRevisionHeatmap({
611
- viewport: this.viewport,
612
- revisions: getRevisions(),
613
- devToolsEnabled: this.devToolsEnabled
614
- });
615
- }
611
+ this.multiHeatmap = new MultiRevisionHeatmap({
612
+ viewport: this.viewport,
613
+ revisions: getRevisions(),
614
+ devToolsEnabled: this.devToolsEnabled
615
+ });
616
616
  this.totalTime = 0;
617
617
  this.componentsLog = {};
618
618
  this.vcRatios = {};
@@ -95,6 +95,7 @@ export var getExperimentalVCMetrics = /*#__PURE__*/function () {
95
95
  start: interaction.start,
96
96
  stop: interaction.end,
97
97
  tti: (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime,
98
+ isEventAborted: !!interaction.abortReason,
98
99
  prefix: prefix,
99
100
  vc: interaction.vc
100
101
  });