@atlaskit/react-ufo 2.4.6 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#176642](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176642)
8
+ [`66ae71c3d1e72`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/66ae71c3d1e72) -
9
+ Revert "AFO-3080: NO-ISSUE Experimental UFO holds and TTAI - 2nd iteration"
10
+
11
+ ### Patch Changes
12
+
13
+ - [#174793](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/174793)
14
+ [`abbfbb3b49665`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/abbfbb3b49665) -
15
+ remove VC observations after TTAI
16
+ - Updated dependencies
17
+
18
+ ## 2.4.7
19
+
20
+ ### Patch Changes
21
+
22
+ - [#175818](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/175818)
23
+ [`1401a5646d271`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1401a5646d271) -
24
+ Add experimentalTTAI and experimentalVC90 to custom.post-interaction-log
25
+ - [#173211](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173211)
26
+ [`202bc8df0c75a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/202bc8df0c75a) -
27
+ Experimental UFO holds, VC90 and TTAI metrics
28
+ - [#175826](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/175826)
29
+ [`b5c5bf59d1cff`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b5c5bf59d1cff) -
30
+ add rate limiting to experimental interaction metrics
31
+
3
32
  ## 2.4.6
4
33
 
5
34
  ### Patch Changes
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.REACT_UFO_VERSION = void 0;
7
7
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
- var REACT_UFO_VERSION = exports.REACT_UFO_VERSION = (0, _platformFeatureFlags.fg)('react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
8
+ var REACT_UFO_VERSION = exports.REACT_UFO_VERSION = (0, _platformFeatureFlags.fg)('enable-react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
@@ -58,10 +58,7 @@ function removeCascadingParentTimingReport(reactProfilerTimings) {
58
58
  if (parentSegmentId) {
59
59
  var parentTimings = timingIndex.get(parentSegmentId);
60
60
  var filteredParentTimings = parentTimings === null || parentTimings === void 0 ? void 0 : parentTimings.filter(function (parentTiming) {
61
- if (parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration) {
62
- return false;
63
- }
64
- return true;
61
+ return !(parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration);
65
62
  });
66
63
  if (filteredParentTimings) {
67
64
  timingIndex.set(parentSegmentId, filteredParentTimings);
@@ -482,7 +482,7 @@ var finishInteraction = function finishInteraction(id, data) {
482
482
  (0, _experienceTraceIdContext.clearActiveTrace)();
483
483
  callCleanUpCallbacks(data);
484
484
  if ((_getConfig3 = (0, _config.getConfig)()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && _getConfig3.stopVCAtInteractionFinish) {
485
- data.vc = (0, _vc.getVCObserver)().getVCRawData();
485
+ data.vc = (0, _vc.getVCObserver)().getVCRawData(data.end);
486
486
  }
487
487
  remove(id);
488
488
  PreviousInteractionLog.name = data.ufoName || 'unknown';
@@ -151,7 +151,9 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
151
151
  abortReason = _ref2.abortReason,
152
152
  abortedByInteractionName = _ref2.abortedByInteractionName,
153
153
  routeName = _ref2.routeName,
154
- type = _ref2.type;
154
+ type = _ref2.type,
155
+ experimentalTTAI = _ref2.experimentalTTAI,
156
+ experimentalVC90 = _ref2.experimentalVC90;
155
157
  this.lastInteractionFinish = {
156
158
  ufoName: ufoName,
157
159
  start: start,
@@ -160,7 +162,9 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
160
162
  abortReason: abortReason,
161
163
  abortedByInteractionName: abortedByInteractionName,
162
164
  routeName: routeName,
163
- type: type
165
+ type: type,
166
+ experimentalTTAI: experimentalTTAI,
167
+ experimentalVC90: experimentalVC90
164
168
  };
165
169
  var timeout = ((_getConfig = (0, _config.getConfig)()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
166
170
  this.sinkTimeoutId = window.setTimeout(function () {
@@ -10,6 +10,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _attachAbortListeners = require("./attachAbortListeners");
14
15
  var _getViewport = require("./getViewport");
15
16
  var _observers = require("./observers");
@@ -70,7 +71,7 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
70
71
  var info = _this.abortReason.info !== '' ? " ".concat(_this.abortReason.info) : '';
71
72
  return "".concat(_this.abortReason.reason).concat(info);
72
73
  });
73
- (0, _defineProperty2.default)(this, "getVCRawData", function () {
74
+ (0, _defineProperty2.default)(this, "getVCRawData", function (stopTime) {
74
75
  _this.measureStart();
75
76
  if (!_this.active) {
76
77
  _this.measureStop();
@@ -79,6 +80,20 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
79
80
  _this.stop();
80
81
  var abortReasonInfo = _this.getAbortReasonInfo();
81
82
  _this.measureStop();
83
+ var componentsLog = {};
84
+ if (stopTime && (0, _platformFeatureFlags.fg)('ufo-remove-vc-component-observations-after-ttai')) {
85
+ Object.entries(_this.componentsLog).forEach(function (_ref3) {
86
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
87
+ _timestamp = _ref4[0],
88
+ value = _ref4[1];
89
+ var timestamp = Number(_timestamp);
90
+ if (stopTime > timestamp) {
91
+ componentsLog[timestamp] = value;
92
+ }
93
+ });
94
+ } else {
95
+ componentsLog = _objectSpread({}, _this.componentsLog);
96
+ }
82
97
  return {
83
98
  abortReasonInfo: abortReasonInfo,
84
99
  abortReason: _objectSpread({}, _this.abortReason),
@@ -86,25 +101,25 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
86
101
  heatmapNext: _this.heatmapNext,
87
102
  outOfBoundaryInfo: _this.outOfBoundaryInfo,
88
103
  totalTime: Math.round(_this.totalTime + _this.observers.getTotalTime()),
89
- componentsLog: _objectSpread({}, _this.componentsLog),
104
+ componentsLog: componentsLog,
90
105
  viewport: _objectSpread({}, _this.viewport),
91
106
  oldDomUpdatesEnabled: _this.oldDomUpdatesEnabled,
92
107
  devToolsEnabled: _this.devToolsEnabled,
93
108
  ratios: _this.vcRatios
94
109
  };
95
110
  });
96
- (0, _defineProperty2.default)(this, "getVCResult", function (_ref3) {
111
+ (0, _defineProperty2.default)(this, "getVCResult", function (_ref5) {
97
112
  var _objectSpread2, _objectSpread3;
98
- var start = _ref3.start,
99
- stop = _ref3.stop,
100
- tti = _ref3.tti,
101
- prefix = _ref3.prefix,
102
- ssr = _ref3.ssr,
103
- vc = _ref3.vc;
113
+ var start = _ref5.start,
114
+ stop = _ref5.stop,
115
+ tti = _ref5.tti,
116
+ prefix = _ref5.prefix,
117
+ ssr = _ref5.ssr,
118
+ vc = _ref5.vc;
104
119
  var startTime = performance.now();
105
120
  // add local measurement
106
121
  var fullPrefix = prefix !== undefined && prefix !== '' ? "".concat(prefix, ":") : '';
107
- var rawData = vc !== undefined ? vc : _this.getVCRawData();
122
+ var rawData = vc !== undefined ? vc : _this.getVCRawData(stop);
108
123
  if (rawData === null) {
109
124
  return {};
110
125
  }
@@ -119,14 +134,14 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
119
134
  devToolsEnabled = rawData.devToolsEnabled,
120
135
  ratios = rawData.ratios;
121
136
  if (abortReasonInfo !== null && abortReason.blocking) {
122
- var _ref4;
137
+ var _ref6;
123
138
  // exposing data to devtools
124
139
  try {
125
140
  if (devToolsEnabled && !_this.isPostInteraction) {
126
141
  window.__vcNotAvailableReason = abortReasonInfo;
127
142
  }
128
143
  } catch (e) {}
129
- return _ref4 = {}, (0, _defineProperty2.default)(_ref4, "".concat(fullPrefix, "vc:state"), false), (0, _defineProperty2.default)(_ref4, "".concat(fullPrefix, "vc:abort:reason"), abortReasonInfo), (0, _defineProperty2.default)(_ref4, "".concat(fullPrefix, "vc:abort:timestamp"), abortReason.timestamp), _ref4;
144
+ return _ref6 = {}, (0, _defineProperty2.default)(_ref6, "".concat(fullPrefix, "vc:state"), false), (0, _defineProperty2.default)(_ref6, "".concat(fullPrefix, "vc:abort:reason"), abortReasonInfo), (0, _defineProperty2.default)(_ref6, "".concat(fullPrefix, "vc:abort:timestamp"), abortReason.timestamp), _ref6;
130
145
  }
131
146
  var _VCObserver$calculate = VCObserver.calculateVC({
132
147
  heatmap: heatmap,
@@ -281,10 +296,10 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
281
296
  var unbinds = (0, _attachAbortListeners.attachAbortListeners)(window, _this.viewport, _this.abortReasonCallback);
282
297
  if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
283
298
  var _window2;
284
- Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref6) {
285
- var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
286
- key = _ref7[0],
287
- time = _ref7[1];
299
+ Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref8) {
300
+ var _ref9 = (0, _slicedToArray2.default)(_ref8, 2),
301
+ key = _ref9[0],
302
+ time = _ref9[1];
288
303
  if (time) {
289
304
  _this.abortReasonCallback(key, time);
290
305
  }
@@ -312,8 +327,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
312
327
  }
313
328
  (0, _createClass2.default)(VCObserver, [{
314
329
  key: "start",
315
- value: function start(_ref8) {
316
- var startTime = _ref8.startTime;
330
+ value: function start(_ref10) {
331
+ var startTime = _ref10.startTime;
317
332
  this.active = true;
318
333
  if (this.observers.isBrowserSupported()) {
319
334
  this.setViewportSize();
@@ -335,12 +350,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
335
350
  }, {
336
351
  key: "getIgnoredElements",
337
352
  value: function getIgnoredElements(componentsLog) {
338
- return Object.values(componentsLog).flat().filter(function (_ref9) {
339
- var ignoreReason = _ref9.ignoreReason;
353
+ return Object.values(componentsLog).flat().filter(function (_ref11) {
354
+ var ignoreReason = _ref11.ignoreReason;
340
355
  return Boolean(ignoreReason);
341
- }).map(function (_ref10) {
342
- var targetName = _ref10.targetName,
343
- ignoreReason = _ref10.ignoreReason;
356
+ }).map(function (_ref12) {
357
+ var targetName = _ref12.targetName,
358
+ ignoreReason = _ref12.ignoreReason;
344
359
  return {
345
360
  targetName: targetName,
346
361
  ignoreReason: ignoreReason
@@ -461,12 +476,12 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
461
476
  }
462
477
  }], [{
463
478
  key: "calculateVC",
464
- value: function calculateVC(_ref11) {
465
- var heatmap = _ref11.heatmap,
466
- _ref11$ssr = _ref11.ssr,
467
- ssr = _ref11$ssr === void 0 ? UNUSED_SECTOR : _ref11$ssr,
468
- componentsLog = _ref11.componentsLog,
469
- viewport = _ref11.viewport;
479
+ value: function calculateVC(_ref13) {
480
+ var heatmap = _ref13.heatmap,
481
+ _ref13$ssr = _ref13.ssr,
482
+ ssr = _ref13$ssr === void 0 ? UNUSED_SECTOR : _ref13$ssr,
483
+ componentsLog = _ref13.componentsLog,
484
+ viewport = _ref13.viewport;
470
485
  var lastUpdate = {};
471
486
  var totalPainted = 0;
472
487
  if (ssr !== UNUSED_SECTOR) {
@@ -526,11 +541,11 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
526
541
  });
527
542
  return VCRatio;
528
543
  }, 0);
529
- var VCEntries = entries.reduce(function (acc, _ref12, i) {
544
+ var VCEntries = entries.reduce(function (acc, _ref14, i) {
530
545
  var _acc$abs, _componentsLog$timest;
531
- var _ref13 = (0, _slicedToArray2.default)(_ref12, 2),
532
- timestamp = _ref13[0],
533
- entryPainted = _ref13[1];
546
+ var _ref15 = (0, _slicedToArray2.default)(_ref14, 2),
547
+ timestamp = _ref15[0],
548
+ entryPainted = _ref15[1];
534
549
  var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
535
550
  var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
536
551
  var logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
@@ -1,2 +1,2 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
- export const REACT_UFO_VERSION = fg('react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
2
+ export const REACT_UFO_VERSION = fg('enable-react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
@@ -47,10 +47,7 @@ function removeCascadingParentTimingReport(reactProfilerTimings) {
47
47
  if (parentSegmentId) {
48
48
  const parentTimings = timingIndex.get(parentSegmentId);
49
49
  const filteredParentTimings = parentTimings === null || parentTimings === void 0 ? void 0 : parentTimings.filter(parentTiming => {
50
- if (parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration) {
51
- return false;
52
- }
53
- return true;
50
+ return !(parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration);
54
51
  });
55
52
  if (filteredParentTimings) {
56
53
  timingIndex.set(parentSegmentId, filteredParentTimings);
@@ -411,7 +411,7 @@ const finishInteraction = (id, data, endTime = performance.now()) => {
411
411
  clearActiveTrace();
412
412
  callCleanUpCallbacks(data);
413
413
  if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3$vc = _getConfig3.vc) !== null && _getConfig3$vc !== void 0 && _getConfig3$vc.stopVCAtInteractionFinish) {
414
- data.vc = getVCObserver().getVCRawData();
414
+ data.vc = getVCObserver().getVCRawData(data.end);
415
415
  }
416
416
  remove(id);
417
417
  PreviousInteractionLog.name = data.ufoName || 'unknown';
@@ -121,7 +121,9 @@ export default class PostInteractionLog {
121
121
  abortReason,
122
122
  abortedByInteractionName,
123
123
  routeName,
124
- type
124
+ type,
125
+ experimentalTTAI,
126
+ experimentalVC90
125
127
  }) {
126
128
  var _getConfig;
127
129
  this.lastInteractionFinish = {
@@ -132,7 +134,9 @@ export default class PostInteractionLog {
132
134
  abortReason,
133
135
  abortedByInteractionName,
134
136
  routeName,
135
- type
137
+ type,
138
+ experimentalTTAI,
139
+ experimentalVC90
136
140
  };
137
141
  const timeout = ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
138
142
  this.sinkTimeoutId = window.setTimeout(() => {
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { fg } from '@atlaskit/platform-feature-flags';
2
3
  import { attachAbortListeners } from './attachAbortListeners';
3
4
  import { getViewportHeight, getViewportWidth } from './getViewport';
4
5
  import { Observers } from './observers';
@@ -51,7 +52,7 @@ export class VCObserver {
51
52
  const info = this.abortReason.info !== '' ? ` ${this.abortReason.info}` : '';
52
53
  return `${this.abortReason.reason}${info}`;
53
54
  });
54
- _defineProperty(this, "getVCRawData", () => {
55
+ _defineProperty(this, "getVCRawData", stopTime => {
55
56
  this.measureStart();
56
57
  if (!this.active) {
57
58
  this.measureStop();
@@ -60,6 +61,19 @@ export class VCObserver {
60
61
  this.stop();
61
62
  const abortReasonInfo = this.getAbortReasonInfo();
62
63
  this.measureStop();
64
+ let componentsLog = {};
65
+ if (stopTime && fg('ufo-remove-vc-component-observations-after-ttai')) {
66
+ Object.entries(this.componentsLog).forEach(([_timestamp, value]) => {
67
+ const timestamp = Number(_timestamp);
68
+ if (stopTime > timestamp) {
69
+ componentsLog[timestamp] = value;
70
+ }
71
+ });
72
+ } else {
73
+ componentsLog = {
74
+ ...this.componentsLog
75
+ };
76
+ }
63
77
  return {
64
78
  abortReasonInfo,
65
79
  abortReason: {
@@ -69,9 +83,7 @@ export class VCObserver {
69
83
  heatmapNext: this.heatmapNext,
70
84
  outOfBoundaryInfo: this.outOfBoundaryInfo,
71
85
  totalTime: Math.round(this.totalTime + this.observers.getTotalTime()),
72
- componentsLog: {
73
- ...this.componentsLog
74
- },
86
+ componentsLog,
75
87
  viewport: {
76
88
  ...this.viewport
77
89
  },
@@ -91,7 +103,7 @@ export class VCObserver {
91
103
  const startTime = performance.now();
92
104
  // add local measurement
93
105
  const fullPrefix = prefix !== undefined && prefix !== '' ? `${prefix}:` : '';
94
- const rawData = vc !== undefined ? vc : this.getVCRawData();
106
+ const rawData = vc !== undefined ? vc : this.getVCRawData(stop);
95
107
  if (rawData === null) {
96
108
  return {};
97
109
  }
@@ -1,2 +1,2 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
- export var REACT_UFO_VERSION = fg('react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
2
+ export var REACT_UFO_VERSION = fg('enable-react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
@@ -51,10 +51,7 @@ function removeCascadingParentTimingReport(reactProfilerTimings) {
51
51
  if (parentSegmentId) {
52
52
  var parentTimings = timingIndex.get(parentSegmentId);
53
53
  var filteredParentTimings = parentTimings === null || parentTimings === void 0 ? void 0 : parentTimings.filter(function (parentTiming) {
54
- if (parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration) {
55
- return false;
56
- }
57
- return true;
54
+ return !(parentTiming.startTime === timing.startTime && parentTiming.actualDuration === timing.actualDuration);
58
55
  });
59
56
  if (filteredParentTimings) {
60
57
  timingIndex.set(parentSegmentId, filteredParentTimings);
@@ -439,7 +439,7 @@ var finishInteraction = function finishInteraction(id, data) {
439
439
  clearActiveTrace();
440
440
  callCleanUpCallbacks(data);
441
441
  if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && _getConfig3.stopVCAtInteractionFinish) {
442
- data.vc = getVCObserver().getVCRawData();
442
+ data.vc = getVCObserver().getVCRawData(data.end);
443
443
  }
444
444
  remove(id);
445
445
  PreviousInteractionLog.name = data.ufoName || 'unknown';
@@ -144,7 +144,9 @@ var PostInteractionLog = /*#__PURE__*/function () {
144
144
  abortReason = _ref2.abortReason,
145
145
  abortedByInteractionName = _ref2.abortedByInteractionName,
146
146
  routeName = _ref2.routeName,
147
- type = _ref2.type;
147
+ type = _ref2.type,
148
+ experimentalTTAI = _ref2.experimentalTTAI,
149
+ experimentalVC90 = _ref2.experimentalVC90;
148
150
  this.lastInteractionFinish = {
149
151
  ufoName: ufoName,
150
152
  start: start,
@@ -153,7 +155,9 @@ var PostInteractionLog = /*#__PURE__*/function () {
153
155
  abortReason: abortReason,
154
156
  abortedByInteractionName: abortedByInteractionName,
155
157
  routeName: routeName,
156
- type: type
158
+ type: type,
159
+ experimentalTTAI: experimentalTTAI,
160
+ experimentalVC90: experimentalVC90
157
161
  };
158
162
  var timeout = ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
159
163
  this.sinkTimeoutId = window.setTimeout(function () {
@@ -6,6 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
6
6
  var _excluded = ["__debug__element"];
7
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { attachAbortListeners } from './attachAbortListeners';
10
11
  import { getViewportHeight, getViewportWidth } from './getViewport';
11
12
  import { Observers } from './observers';
@@ -63,7 +64,7 @@ export var VCObserver = /*#__PURE__*/function () {
63
64
  var info = _this.abortReason.info !== '' ? " ".concat(_this.abortReason.info) : '';
64
65
  return "".concat(_this.abortReason.reason).concat(info);
65
66
  });
66
- _defineProperty(this, "getVCRawData", function () {
67
+ _defineProperty(this, "getVCRawData", function (stopTime) {
67
68
  _this.measureStart();
68
69
  if (!_this.active) {
69
70
  _this.measureStop();
@@ -72,6 +73,20 @@ export var VCObserver = /*#__PURE__*/function () {
72
73
  _this.stop();
73
74
  var abortReasonInfo = _this.getAbortReasonInfo();
74
75
  _this.measureStop();
76
+ var componentsLog = {};
77
+ if (stopTime && fg('ufo-remove-vc-component-observations-after-ttai')) {
78
+ Object.entries(_this.componentsLog).forEach(function (_ref3) {
79
+ var _ref4 = _slicedToArray(_ref3, 2),
80
+ _timestamp = _ref4[0],
81
+ value = _ref4[1];
82
+ var timestamp = Number(_timestamp);
83
+ if (stopTime > timestamp) {
84
+ componentsLog[timestamp] = value;
85
+ }
86
+ });
87
+ } else {
88
+ componentsLog = _objectSpread({}, _this.componentsLog);
89
+ }
75
90
  return {
76
91
  abortReasonInfo: abortReasonInfo,
77
92
  abortReason: _objectSpread({}, _this.abortReason),
@@ -79,25 +94,25 @@ export var VCObserver = /*#__PURE__*/function () {
79
94
  heatmapNext: _this.heatmapNext,
80
95
  outOfBoundaryInfo: _this.outOfBoundaryInfo,
81
96
  totalTime: Math.round(_this.totalTime + _this.observers.getTotalTime()),
82
- componentsLog: _objectSpread({}, _this.componentsLog),
97
+ componentsLog: componentsLog,
83
98
  viewport: _objectSpread({}, _this.viewport),
84
99
  oldDomUpdatesEnabled: _this.oldDomUpdatesEnabled,
85
100
  devToolsEnabled: _this.devToolsEnabled,
86
101
  ratios: _this.vcRatios
87
102
  };
88
103
  });
89
- _defineProperty(this, "getVCResult", function (_ref3) {
104
+ _defineProperty(this, "getVCResult", function (_ref5) {
90
105
  var _objectSpread2, _objectSpread3;
91
- var start = _ref3.start,
92
- stop = _ref3.stop,
93
- tti = _ref3.tti,
94
- prefix = _ref3.prefix,
95
- ssr = _ref3.ssr,
96
- vc = _ref3.vc;
106
+ var start = _ref5.start,
107
+ stop = _ref5.stop,
108
+ tti = _ref5.tti,
109
+ prefix = _ref5.prefix,
110
+ ssr = _ref5.ssr,
111
+ vc = _ref5.vc;
97
112
  var startTime = performance.now();
98
113
  // add local measurement
99
114
  var fullPrefix = prefix !== undefined && prefix !== '' ? "".concat(prefix, ":") : '';
100
- var rawData = vc !== undefined ? vc : _this.getVCRawData();
115
+ var rawData = vc !== undefined ? vc : _this.getVCRawData(stop);
101
116
  if (rawData === null) {
102
117
  return {};
103
118
  }
@@ -112,14 +127,14 @@ export var VCObserver = /*#__PURE__*/function () {
112
127
  devToolsEnabled = rawData.devToolsEnabled,
113
128
  ratios = rawData.ratios;
114
129
  if (abortReasonInfo !== null && abortReason.blocking) {
115
- var _ref4;
130
+ var _ref6;
116
131
  // exposing data to devtools
117
132
  try {
118
133
  if (devToolsEnabled && !_this.isPostInteraction) {
119
134
  window.__vcNotAvailableReason = abortReasonInfo;
120
135
  }
121
136
  } catch (e) {}
122
- return _ref4 = {}, _defineProperty(_ref4, "".concat(fullPrefix, "vc:state"), false), _defineProperty(_ref4, "".concat(fullPrefix, "vc:abort:reason"), abortReasonInfo), _defineProperty(_ref4, "".concat(fullPrefix, "vc:abort:timestamp"), abortReason.timestamp), _ref4;
137
+ return _ref6 = {}, _defineProperty(_ref6, "".concat(fullPrefix, "vc:state"), false), _defineProperty(_ref6, "".concat(fullPrefix, "vc:abort:reason"), abortReasonInfo), _defineProperty(_ref6, "".concat(fullPrefix, "vc:abort:timestamp"), abortReason.timestamp), _ref6;
123
138
  }
124
139
  var _VCObserver$calculate = VCObserver.calculateVC({
125
140
  heatmap: heatmap,
@@ -274,10 +289,10 @@ export var VCObserver = /*#__PURE__*/function () {
274
289
  var unbinds = attachAbortListeners(window, _this.viewport, _this.abortReasonCallback);
275
290
  if ((_window = window) !== null && _window !== void 0 && _window.__SSR_ABORT_LISTENERS__) {
276
291
  var _window2;
277
- Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref6) {
278
- var _ref7 = _slicedToArray(_ref6, 2),
279
- key = _ref7[0],
280
- time = _ref7[1];
292
+ Object.entries(window.__SSR_ABORT_LISTENERS__.aborts).forEach(function (_ref8) {
293
+ var _ref9 = _slicedToArray(_ref8, 2),
294
+ key = _ref9[0],
295
+ time = _ref9[1];
281
296
  if (time) {
282
297
  _this.abortReasonCallback(key, time);
283
298
  }
@@ -305,8 +320,8 @@ export var VCObserver = /*#__PURE__*/function () {
305
320
  }
306
321
  _createClass(VCObserver, [{
307
322
  key: "start",
308
- value: function start(_ref8) {
309
- var startTime = _ref8.startTime;
323
+ value: function start(_ref10) {
324
+ var startTime = _ref10.startTime;
310
325
  this.active = true;
311
326
  if (this.observers.isBrowserSupported()) {
312
327
  this.setViewportSize();
@@ -328,12 +343,12 @@ export var VCObserver = /*#__PURE__*/function () {
328
343
  }, {
329
344
  key: "getIgnoredElements",
330
345
  value: function getIgnoredElements(componentsLog) {
331
- return Object.values(componentsLog).flat().filter(function (_ref9) {
332
- var ignoreReason = _ref9.ignoreReason;
346
+ return Object.values(componentsLog).flat().filter(function (_ref11) {
347
+ var ignoreReason = _ref11.ignoreReason;
333
348
  return Boolean(ignoreReason);
334
- }).map(function (_ref10) {
335
- var targetName = _ref10.targetName,
336
- ignoreReason = _ref10.ignoreReason;
349
+ }).map(function (_ref12) {
350
+ var targetName = _ref12.targetName,
351
+ ignoreReason = _ref12.ignoreReason;
337
352
  return {
338
353
  targetName: targetName,
339
354
  ignoreReason: ignoreReason
@@ -454,12 +469,12 @@ export var VCObserver = /*#__PURE__*/function () {
454
469
  }
455
470
  }], [{
456
471
  key: "calculateVC",
457
- value: function calculateVC(_ref11) {
458
- var heatmap = _ref11.heatmap,
459
- _ref11$ssr = _ref11.ssr,
460
- ssr = _ref11$ssr === void 0 ? UNUSED_SECTOR : _ref11$ssr,
461
- componentsLog = _ref11.componentsLog,
462
- viewport = _ref11.viewport;
472
+ value: function calculateVC(_ref13) {
473
+ var heatmap = _ref13.heatmap,
474
+ _ref13$ssr = _ref13.ssr,
475
+ ssr = _ref13$ssr === void 0 ? UNUSED_SECTOR : _ref13$ssr,
476
+ componentsLog = _ref13.componentsLog,
477
+ viewport = _ref13.viewport;
463
478
  var lastUpdate = {};
464
479
  var totalPainted = 0;
465
480
  if (ssr !== UNUSED_SECTOR) {
@@ -519,11 +534,11 @@ export var VCObserver = /*#__PURE__*/function () {
519
534
  });
520
535
  return VCRatio;
521
536
  }, 0);
522
- var VCEntries = entries.reduce(function (acc, _ref12, i) {
537
+ var VCEntries = entries.reduce(function (acc, _ref14, i) {
523
538
  var _acc$abs, _componentsLog$timest;
524
- var _ref13 = _slicedToArray(_ref12, 2),
525
- timestamp = _ref13[0],
526
- entryPainted = _ref13[1];
539
+ var _ref15 = _slicedToArray(_ref14, 2),
540
+ timestamp = _ref15[0],
541
+ entryPainted = _ref15[1];
527
542
  var currentlyPainted = entryPainted + (((_acc$abs = acc.abs[i - 1]) === null || _acc$abs === void 0 ? void 0 : _acc$abs[1]) || 0);
528
543
  var currentlyPaintedRatio = Math.round(currentlyPainted / totalPainted * 1000) / 10;
529
544
  var logEntry = (_componentsLog$timest = componentsLog[timestamp]) === null || _componentsLog$timest === void 0 ? void 0 : _componentsLog$timest.map(function (v) {
@@ -150,6 +150,8 @@ export interface InteractionMetrics {
150
150
  trace: TraceIdContext | null;
151
151
  legacyMetrics?: BM3Event[];
152
152
  vc?: VCRawDataType | null;
153
+ experimentalTTAI?: number;
154
+ experimentalVC90?: number;
153
155
  }
154
156
  export type LoadProfilerEventInfo = {
155
157
  identifier: string;
@@ -191,7 +193,7 @@ export type BM3Event = {
191
193
  pageVisibleState?: string;
192
194
  type: string;
193
195
  };
194
- export type LastInteractionFinishInfo = Pick<InteractionMetrics, 'ufoName' | 'start' | 'end' | 'id' | 'abortReason' | 'abortedByInteractionName' | 'routeName' | 'type'>;
196
+ export type LastInteractionFinishInfo = Pick<InteractionMetrics, 'ufoName' | 'start' | 'end' | 'id' | 'abortReason' | 'abortedByInteractionName' | 'routeName' | 'type' | 'experimentalVC90' | 'experimentalTTAI'>;
195
197
  export type PostInteractionLogOutput = {
196
198
  lastInteractionFinish: LastInteractionFinishInfo;
197
199
  reactProfilerTimings?: ReactProfilerTiming[];
@@ -30,6 +30,8 @@ export default function createPostInteractionLogPayload({ lastInteractionFinish,
30
30
  abortReason?: import("../common").AbortReasonType | undefined;
31
31
  abortedByInteractionName?: string | undefined;
32
32
  routeName: string | null;
33
+ experimentalVC90?: number | undefined;
34
+ experimentalTTAI?: number | undefined;
33
35
  };
34
36
  revisedEndTime: number;
35
37
  revisedTtai: number;
@@ -61,7 +61,7 @@ export default class PostInteractionLog {
61
61
  * Basic details about the finished interaction will be recorded
62
62
  * A timeout will be setup to send the post interaction observation after some time.
63
63
  */
64
- onInteractionComplete({ ufoName, start, end, id, abortReason, abortedByInteractionName, routeName, type, }: LastInteractionFinishInfo): void;
64
+ onInteractionComplete({ ufoName, start, end, id, abortReason, abortedByInteractionName, routeName, type, experimentalTTAI, experimentalVC90, }: LastInteractionFinishInfo): void;
65
65
  /**
66
66
  * This fn should be invoked when a React render happens after interaction has finished
67
67
  */
@@ -48,7 +48,7 @@ export declare class VCObserver {
48
48
  }): void;
49
49
  stop(): void;
50
50
  getAbortReasonInfo: () => string | null;
51
- getVCRawData: () => VCRawDataType | null;
51
+ getVCRawData: (stopTime?: number) => VCRawDataType | null;
52
52
  getIgnoredElements(componentsLog: ComponentsLogType): {
53
53
  targetName: string;
54
54
  ignoreReason: VCIgnoreReason | undefined;
@@ -150,6 +150,8 @@ export interface InteractionMetrics {
150
150
  trace: TraceIdContext | null;
151
151
  legacyMetrics?: BM3Event[];
152
152
  vc?: VCRawDataType | null;
153
+ experimentalTTAI?: number;
154
+ experimentalVC90?: number;
153
155
  }
154
156
  export type LoadProfilerEventInfo = {
155
157
  identifier: string;
@@ -191,7 +193,7 @@ export type BM3Event = {
191
193
  pageVisibleState?: string;
192
194
  type: string;
193
195
  };
194
- export type LastInteractionFinishInfo = Pick<InteractionMetrics, 'ufoName' | 'start' | 'end' | 'id' | 'abortReason' | 'abortedByInteractionName' | 'routeName' | 'type'>;
196
+ export type LastInteractionFinishInfo = Pick<InteractionMetrics, 'ufoName' | 'start' | 'end' | 'id' | 'abortReason' | 'abortedByInteractionName' | 'routeName' | 'type' | 'experimentalVC90' | 'experimentalTTAI'>;
195
197
  export type PostInteractionLogOutput = {
196
198
  lastInteractionFinish: LastInteractionFinishInfo;
197
199
  reactProfilerTimings?: ReactProfilerTiming[];
@@ -30,6 +30,8 @@ export default function createPostInteractionLogPayload({ lastInteractionFinish,
30
30
  abortReason?: import("../common").AbortReasonType | undefined;
31
31
  abortedByInteractionName?: string | undefined;
32
32
  routeName: string | null;
33
+ experimentalVC90?: number | undefined;
34
+ experimentalTTAI?: number | undefined;
33
35
  };
34
36
  revisedEndTime: number;
35
37
  revisedTtai: number;
@@ -61,7 +61,7 @@ export default class PostInteractionLog {
61
61
  * Basic details about the finished interaction will be recorded
62
62
  * A timeout will be setup to send the post interaction observation after some time.
63
63
  */
64
- onInteractionComplete({ ufoName, start, end, id, abortReason, abortedByInteractionName, routeName, type, }: LastInteractionFinishInfo): void;
64
+ onInteractionComplete({ ufoName, start, end, id, abortReason, abortedByInteractionName, routeName, type, experimentalTTAI, experimentalVC90, }: LastInteractionFinishInfo): void;
65
65
  /**
66
66
  * This fn should be invoked when a React render happens after interaction has finished
67
67
  */
@@ -48,7 +48,7 @@ export declare class VCObserver {
48
48
  }): void;
49
49
  stop(): void;
50
50
  getAbortReasonInfo: () => string | null;
51
- getVCRawData: () => VCRawDataType | null;
51
+ getVCRawData: (stopTime?: number) => VCRawDataType | null;
52
52
  getIgnoredElements(componentsLog: ComponentsLogType): {
53
53
  targetName: string;
54
54
  ignoreReason: VCIgnoreReason | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "2.4.6",
3
+ "version": "2.5.0",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -73,7 +73,7 @@
73
73
  ".": "./src/index.ts"
74
74
  },
75
75
  "dependencies": {
76
- "@atlaskit/interaction-context": "^2.1.4",
76
+ "@atlaskit/interaction-context": "^2.2.0",
77
77
  "@atlaskit/platform-feature-flags": "^0.3.0",
78
78
  "@babel/runtime": "^7.0.0",
79
79
  "bind-event-listener": "^3.0.0",
@@ -136,11 +136,14 @@
136
136
  "platform-ufo-vc-observe-attributes": {
137
137
  "type": "boolean"
138
138
  },
139
- "react-ufo-payload-segment-compressed": {
139
+ "enable-react-ufo-payload-segment-compressed": {
140
140
  "type": "boolean"
141
141
  },
142
142
  "ufo_capture_stylesheet_metrics": {
143
143
  "type": "boolean"
144
+ },
145
+ "ufo-remove-vc-component-observations-after-ttai": {
146
+ "type": "boolean"
144
147
  }
145
148
  }
146
149
  }