@atlaskit/react-ufo 3.13.20 → 3.13.22

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 (28) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/create-payload/utils/get-vc-metrics.js +23 -10
  3. package/dist/cjs/interaction-metrics/index.js +15 -0
  4. package/dist/cjs/interaction-metrics-init/index.js +2 -1
  5. package/dist/cjs/vc/vc-observer/index.js +4 -2
  6. package/dist/cjs/vc/vc-observer/observers/index.js +6 -2
  7. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +22 -6
  8. package/dist/es2019/create-payload/utils/get-vc-metrics.js +9 -3
  9. package/dist/es2019/interaction-metrics/index.js +15 -0
  10. package/dist/es2019/interaction-metrics-init/index.js +2 -1
  11. package/dist/es2019/vc/vc-observer/index.js +4 -2
  12. package/dist/es2019/vc/vc-observer/observers/index.js +5 -2
  13. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +18 -2
  14. package/dist/esm/create-payload/utils/get-vc-metrics.js +23 -10
  15. package/dist/esm/interaction-metrics/index.js +15 -0
  16. package/dist/esm/interaction-metrics-init/index.js +2 -1
  17. package/dist/esm/vc/vc-observer/index.js +4 -2
  18. package/dist/esm/vc/vc-observer/observers/index.js +6 -2
  19. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +22 -6
  20. package/dist/types/config/index.d.ts +4 -0
  21. package/dist/types/vc/types.d.ts +4 -0
  22. package/dist/types/vc/vc-observer/observers/index.d.ts +4 -0
  23. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +10 -1
  24. package/dist/types-ts4.5/config/index.d.ts +4 -0
  25. package/dist/types-ts4.5/vc/types.d.ts +4 -0
  26. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +4 -0
  27. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +10 -1
  28. package/package.json +4 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 3.13.22
4
+
5
+ ### Patch Changes
6
+
7
+ - [#169345](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169345)
8
+ [`6fab3e0da9d68`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6fab3e0da9d68) -
9
+ Added API to disable checks for size and position of SSR placeholders
10
+
11
+ ## 3.13.21
12
+
13
+ ### Patch Changes
14
+
15
+ - [#169263](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/169263)
16
+ [`42bff795e359c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/42bff795e359c) -
17
+ Add vc to interactions
18
+
3
19
  ## 3.13.20
4
20
 
5
21
  ### Patch Changes
@@ -34,30 +34,43 @@ function _getVCMetrics() {
34
34
  }
35
35
  return _context.abrupt("return", {});
36
36
  case 3:
37
+ if (!(0, _platformFeatureFlags.fg)('platform_ufo_enable_interactions_vc')) {
38
+ _context.next = 8;
39
+ break;
40
+ }
41
+ if (!(interaction.type !== 'page_load' && interaction.type !== 'transition' && interaction.type !== 'press')) {
42
+ _context.next = 6;
43
+ break;
44
+ }
45
+ return _context.abrupt("return", {});
46
+ case 6:
47
+ _context.next = 10;
48
+ break;
49
+ case 8:
37
50
  if (!(interaction.type !== 'page_load' && interaction.type !== 'transition')) {
38
- _context.next = 5;
51
+ _context.next = 10;
39
52
  break;
40
53
  }
41
54
  return _context.abrupt("return", {});
42
- case 5:
55
+ case 10:
43
56
  interactionStatus = (0, _getInteractionStatus.default)(interaction);
44
57
  pageVisibilityUpToTTAI = (0, _getPageVisibilityUpToTtai.default)(interaction);
45
58
  shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
46
59
  if (!(!shouldReportVCMetrics && (0, _platformFeatureFlags.fg)('platform_ufo_no_vc_on_aborted'))) {
47
- _context.next = 11;
60
+ _context.next = 16;
48
61
  break;
49
62
  }
50
63
  (0, _vc.getVCObserver)().stop(interaction.ufoName);
51
64
  return _context.abrupt("return", {});
52
- case 11:
53
- isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
65
+ case 16:
66
+ isSSREnabled = interaction.type === 'page_load' && ((config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName)));
54
67
  ssr = interaction.type === 'page_load' && isSSREnabled ? {
55
68
  ssr: (0, _getSsrDoneTimeValue.default)(config)
56
69
  } : null;
57
70
  _interactionMetrics.postInteractionLog.setVCObserverSSRConfig(ssr);
58
71
  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;
59
72
  prefix = 'ufo';
60
- _context.next = 18;
73
+ _context.next = 23;
61
74
  return (0, _vc.getVCObserver)().getVCResult(_objectSpread({
62
75
  start: interaction.start,
63
76
  stop: interaction.end,
@@ -70,7 +83,7 @@ function _getVCMetrics() {
70
83
  interactionId: interaction.id,
71
84
  includeSSRRatio: (_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.includeSSRRatio
72
85
  }, ssr));
73
- case 18:
86
+ case 23:
74
87
  result = _context.sent;
75
88
  if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
76
89
  (0, _vc.getVCObserver)().stop(interaction.ufoName);
@@ -82,15 +95,15 @@ function _getVCMetrics() {
82
95
  return revision === mostRecentVCRevision;
83
96
  });
84
97
  if (!(!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean))) {
85
- _context.next = 25;
98
+ _context.next = 30;
86
99
  break;
87
100
  }
88
101
  return _context.abrupt("return", result);
89
- case 25:
102
+ case 30:
90
103
  return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
91
104
  'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
92
105
  }));
93
- case 26:
106
+ case 31:
94
107
  case "end":
95
108
  return _context.stop();
96
109
  }
@@ -856,6 +856,21 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
856
856
  });
857
857
  }
858
858
  }
859
+ if (type === 'press' && (0, _platformFeatureFlags.fg)('platform_ufo_enable_interactions_vc')) {
860
+ var _getConfig13;
861
+ (0, _vc.getVCObserver)().start({
862
+ startTime: startTime,
863
+ experienceKey: ufoName
864
+ });
865
+ postInteractionLog.startVCObserver({
866
+ startTime: startTime
867
+ });
868
+ if ((_getConfig13 = (0, _config.getConfig)()) !== null && _getConfig13 !== void 0 && (_getConfig13 = _getConfig13.experimentalInteractionMetrics) !== null && _getConfig13 !== void 0 && _getConfig13.enabled) {
869
+ _createExperimentalInteractionMetricsPayload.experimentalVC.start({
870
+ startTime: startTime
871
+ });
872
+ }
873
+ }
859
874
  }
860
875
  function addBrowserMetricEvent(event) {
861
876
  var interaction = getActiveInteraction();
@@ -95,7 +95,8 @@ function init(analyticsWebClientAsync, config) {
95
95
  oldDomUpdates: config.vc.oldDomUpdates,
96
96
  devToolsEnabled: config.vc.devToolsEnabled,
97
97
  selectorConfig: config.vc.selectorConfig,
98
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
98
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
99
+ disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
99
100
  };
100
101
  (0, _vc.getVCObserver)(vcOptions).start({
101
102
  startTime: 0
@@ -454,7 +454,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
454
454
  this.arraySize = options.heatmapSize || 200;
455
455
  this.devToolsEnabled = options.devToolsEnabled || false;
456
456
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
457
- var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder;
457
+ var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
458
+ disableSizeAndPositionCheck = options.disableSizeAndPositionCheck;
458
459
  this.observers = new _observers.Observers({
459
460
  selectorConfig: options.selectorConfig || {
460
461
  id: false,
@@ -464,7 +465,8 @@ var VCObserver = exports.VCObserver = /*#__PURE__*/function () {
464
465
  dataVC: true
465
466
  },
466
467
  SSRConfig: {
467
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
468
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
469
+ disableSizeAndPositionCheck: disableSizeAndPositionCheck
468
470
  }
469
471
  });
470
472
  this.heatmap = !(0, _config.isVCRevisionEnabled)('fy25.01') ? [] : this.getCleanHeatmap();
@@ -33,7 +33,8 @@ function isElementVisible(target) {
33
33
  var Observers = exports.Observers = /*#__PURE__*/function () {
34
34
  function Observers(opts) {
35
35
  var _this = this,
36
- _opts$SSRConfig;
36
+ _opts$SSRConfig,
37
+ _opts$SSRConfig2;
37
38
  (0, _classCallCheck2.default)(this, Observers);
38
39
  (0, _defineProperty2.default)(this, "observedMutations", new WeakMap());
39
40
  (0, _defineProperty2.default)(this, "elementsInView", new Set());
@@ -73,7 +74,10 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
73
74
  this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
74
75
  this.intersectionObserver = this.getIntersectionObserver();
75
76
  this.mutationObserver = this.getMutationObserver();
76
- this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers((_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder);
77
+ this.ssrPlaceholderHandler = new _ssrPlaceholders.SSRPlaceholderHandlers({
78
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
79
+ disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
80
+ });
77
81
  }
78
82
  return (0, _createClass2.default)(Observers, [{
79
83
  key: "isBrowserSupported",
@@ -11,9 +11,15 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
  var ANCESTOR_LOOKUP_LIMIT = 10;
12
12
  var PAGE_LAYOUT_ID = 'page-layout.root';
13
13
  var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/function () {
14
- function SSRPlaceholderHandlers() {
14
+ function SSRPlaceholderHandlers(_ref) {
15
15
  var _this = this;
16
- var enablePageLayoutPlaceholder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
16
+ var _ref$enablePageLayout = _ref.enablePageLayoutPlaceholder,
17
+ enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout,
18
+ _ref$disableSizeAndPo = _ref.disableSizeAndPositionCheck,
19
+ disableSizeAndPositionCheck = _ref$disableSizeAndPo === void 0 ? {
20
+ v: false,
21
+ h: false
22
+ } : _ref$disableSizeAndPo;
17
23
  (0, _classCallCheck2.default)(this, SSRPlaceholderHandlers);
18
24
  (0, _defineProperty2.default)(this, "staticPlaceholders", new Map());
19
25
  (0, _defineProperty2.default)(this, "callbacks", new Map());
@@ -42,10 +48,10 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
42
48
  }
43
49
  return '';
44
50
  });
45
- (0, _defineProperty2.default)(this, "intersectionObserverCallback", function (_ref) {
51
+ (0, _defineProperty2.default)(this, "intersectionObserverCallback", function (_ref2) {
46
52
  var _this$intersectionObs;
47
- var target = _ref.target,
48
- boundingClientRect = _ref.boundingClientRect;
53
+ var target = _ref2.target,
54
+ boundingClientRect = _ref2.boundingClientRect;
49
55
  (_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.unobserve(target);
50
56
  if (!(target instanceof HTMLElement)) {
51
57
  // impossible case - keep typescript healthy
@@ -102,6 +108,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
102
108
  });
103
109
  }
104
110
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
111
+ this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
105
112
  if (window.document) {
106
113
  try {
107
114
  var selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
@@ -223,7 +230,16 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
223
230
  }, {
224
231
  key: "hasSameSizePosition",
225
232
  value: function hasSameSizePosition(rect, boundingClientRect) {
226
- return rect && Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD || false;
233
+ var _this$disableSizeAndP, _this$disableSizeAndP2;
234
+ if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
235
+ return true;
236
+ }
237
+ if (!rect) {
238
+ return false;
239
+ }
240
+ var horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
241
+ var verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
242
+ return horizontalCheck && verticalCheck || false;
227
243
  }
228
244
  }, {
229
245
  key: "isDummyRect",
@@ -11,8 +11,14 @@ async function getVCMetrics(interaction) {
11
11
  if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
12
12
  return {};
13
13
  }
14
- if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
15
- return {};
14
+ if (fg('platform_ufo_enable_interactions_vc')) {
15
+ if (interaction.type !== 'page_load' && interaction.type !== 'transition' && interaction.type !== 'press') {
16
+ return {};
17
+ }
18
+ } else {
19
+ if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
20
+ return {};
21
+ }
16
22
  }
17
23
  const interactionStatus = getInteractionStatus(interaction);
18
24
  const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
@@ -21,7 +27,7 @@ async function getVCMetrics(interaction) {
21
27
  getVCObserver().stop(interaction.ufoName);
22
28
  return {};
23
29
  }
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));
30
+ const isSSREnabled = interaction.type === 'page_load' && ((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)));
25
31
  const ssr = interaction.type === 'page_load' && isSSREnabled ? {
26
32
  ssr: getSSRDoneTimeValue(config)
27
33
  } : null;
@@ -732,6 +732,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
732
732
  });
733
733
  }
734
734
  }
735
+ if (type === 'press' && fg('platform_ufo_enable_interactions_vc')) {
736
+ var _getConfig13, _getConfig13$experime;
737
+ getVCObserver().start({
738
+ startTime,
739
+ experienceKey: ufoName
740
+ });
741
+ postInteractionLog.startVCObserver({
742
+ startTime
743
+ });
744
+ if ((_getConfig13 = getConfig()) !== null && _getConfig13 !== void 0 && (_getConfig13$experime = _getConfig13.experimentalInteractionMetrics) !== null && _getConfig13$experime !== void 0 && _getConfig13$experime.enabled) {
745
+ experimentalVC.start({
746
+ startTime
747
+ });
748
+ }
749
+ }
735
750
  }
736
751
  export function addBrowserMetricEvent(event) {
737
752
  const interaction = getActiveInteraction();
@@ -85,7 +85,8 @@ export function init(analyticsWebClientAsync, config) {
85
85
  oldDomUpdates: config.vc.oldDomUpdates,
86
86
  devToolsEnabled: config.vc.devToolsEnabled,
87
87
  selectorConfig: config.vc.selectorConfig,
88
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
88
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
89
+ disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
89
90
  };
90
91
  getVCObserver(vcOptions).start({
91
92
  startTime: 0
@@ -494,7 +494,8 @@ export class VCObserver {
494
494
  this.devToolsEnabled = options.devToolsEnabled || false;
495
495
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
496
496
  const {
497
- ssrEnablePageLayoutPlaceholder
497
+ ssrEnablePageLayoutPlaceholder,
498
+ disableSizeAndPositionCheck
498
499
  } = options;
499
500
  this.observers = new Observers({
500
501
  selectorConfig: options.selectorConfig || {
@@ -505,7 +506,8 @@ export class VCObserver {
505
506
  dataVC: true
506
507
  },
507
508
  SSRConfig: {
508
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
509
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
510
+ disableSizeAndPositionCheck: disableSizeAndPositionCheck
509
511
  }
510
512
  });
511
513
  this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
@@ -21,7 +21,7 @@ function isElementVisible(target) {
21
21
  }
22
22
  export class Observers {
23
23
  constructor(opts) {
24
- var _opts$SSRConfig;
24
+ var _opts$SSRConfig, _opts$SSRConfig2;
25
25
  _defineProperty(this, "observedMutations", new WeakMap());
26
26
  _defineProperty(this, "elementsInView", new Set());
27
27
  _defineProperty(this, "callbacks", new Set());
@@ -61,7 +61,10 @@ export class Observers {
61
61
  };
62
62
  this.intersectionObserver = this.getIntersectionObserver();
63
63
  this.mutationObserver = this.getMutationObserver();
64
- this.ssrPlaceholderHandler = new SSRPlaceholderHandlers((_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder);
64
+ this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
65
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
66
+ disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
67
+ });
65
68
  }
66
69
  isBrowserSupported() {
67
70
  return typeof window.IntersectionObserver === 'function' && typeof window.MutationObserver === 'function';
@@ -2,7 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  const ANCESTOR_LOOKUP_LIMIT = 10;
3
3
  const PAGE_LAYOUT_ID = 'page-layout.root';
4
4
  export class SSRPlaceholderHandlers {
5
- constructor(enablePageLayoutPlaceholder = false) {
5
+ constructor({
6
+ enablePageLayoutPlaceholder = false,
7
+ disableSizeAndPositionCheck = {
8
+ v: false,
9
+ h: false
10
+ }
11
+ }) {
6
12
  _defineProperty(this, "staticPlaceholders", new Map());
7
13
  _defineProperty(this, "callbacks", new Map());
8
14
  _defineProperty(this, "getSizeCallbacks", new Map());
@@ -87,6 +93,7 @@ export class SSRPlaceholderHandlers {
87
93
  this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
88
94
  }
89
95
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
96
+ this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
90
97
  if (window.document) {
91
98
  try {
92
99
  const selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
@@ -187,7 +194,16 @@ export class SSRPlaceholderHandlers {
187
194
  });
188
195
  }
189
196
  hasSameSizePosition(rect, boundingClientRect) {
190
- return rect && Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD || false;
197
+ var _this$disableSizeAndP, _this$disableSizeAndP2;
198
+ if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
199
+ return true;
200
+ }
201
+ if (!rect) {
202
+ return false;
203
+ }
204
+ const horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
205
+ const verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
206
+ return horizontalCheck && verticalCheck || false;
191
207
  }
192
208
  isDummyRect(rect) {
193
209
  return rect && rect.width < 0 && rect.height < 0 || false;
@@ -27,30 +27,43 @@ function _getVCMetrics() {
27
27
  }
28
28
  return _context.abrupt("return", {});
29
29
  case 3:
30
+ if (!fg('platform_ufo_enable_interactions_vc')) {
31
+ _context.next = 8;
32
+ break;
33
+ }
34
+ if (!(interaction.type !== 'page_load' && interaction.type !== 'transition' && interaction.type !== 'press')) {
35
+ _context.next = 6;
36
+ break;
37
+ }
38
+ return _context.abrupt("return", {});
39
+ case 6:
40
+ _context.next = 10;
41
+ break;
42
+ case 8:
30
43
  if (!(interaction.type !== 'page_load' && interaction.type !== 'transition')) {
31
- _context.next = 5;
44
+ _context.next = 10;
32
45
  break;
33
46
  }
34
47
  return _context.abrupt("return", {});
35
- case 5:
48
+ case 10:
36
49
  interactionStatus = getInteractionStatus(interaction);
37
50
  pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
38
51
  shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
39
52
  if (!(!shouldReportVCMetrics && fg('platform_ufo_no_vc_on_aborted'))) {
40
- _context.next = 11;
53
+ _context.next = 16;
41
54
  break;
42
55
  }
43
56
  getVCObserver().stop(interaction.ufoName);
44
57
  return _context.abrupt("return", {});
45
- case 11:
46
- isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
58
+ case 16:
59
+ isSSREnabled = interaction.type === 'page_load' && ((config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName)));
47
60
  ssr = interaction.type === 'page_load' && isSSREnabled ? {
48
61
  ssr: getSSRDoneTimeValue(config)
49
62
  } : null;
50
63
  postInteractionLog.setVCObserverSSRConfig(ssr);
51
64
  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;
52
65
  prefix = 'ufo';
53
- _context.next = 18;
66
+ _context.next = 23;
54
67
  return getVCObserver().getVCResult(_objectSpread({
55
68
  start: interaction.start,
56
69
  stop: interaction.end,
@@ -63,7 +76,7 @@ function _getVCMetrics() {
63
76
  interactionId: interaction.id,
64
77
  includeSSRRatio: (_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.includeSSRRatio
65
78
  }, ssr));
66
- case 18:
79
+ case 23:
67
80
  result = _context.sent;
68
81
  if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
69
82
  getVCObserver().stop(interaction.ufoName);
@@ -75,15 +88,15 @@ function _getVCMetrics() {
75
88
  return revision === mostRecentVCRevision;
76
89
  });
77
90
  if (!(!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean))) {
78
- _context.next = 25;
91
+ _context.next = 30;
79
92
  break;
80
93
  }
81
94
  return _context.abrupt("return", result);
82
- case 25:
95
+ case 30:
83
96
  return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
84
97
  'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
85
98
  }));
86
- case 26:
99
+ case 31:
87
100
  case "end":
88
101
  return _context.stop();
89
102
  }
@@ -811,6 +811,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
811
811
  });
812
812
  }
813
813
  }
814
+ if (type === 'press' && fg('platform_ufo_enable_interactions_vc')) {
815
+ var _getConfig13;
816
+ getVCObserver().start({
817
+ startTime: startTime,
818
+ experienceKey: ufoName
819
+ });
820
+ postInteractionLog.startVCObserver({
821
+ startTime: startTime
822
+ });
823
+ if ((_getConfig13 = getConfig()) !== null && _getConfig13 !== void 0 && (_getConfig13 = _getConfig13.experimentalInteractionMetrics) !== null && _getConfig13 !== void 0 && _getConfig13.enabled) {
824
+ experimentalVC.start({
825
+ startTime: startTime
826
+ });
827
+ }
828
+ }
814
829
  }
815
830
  export function addBrowserMetricEvent(event) {
816
831
  var interaction = getActiveInteraction();
@@ -86,7 +86,8 @@ export function init(analyticsWebClientAsync, config) {
86
86
  oldDomUpdates: config.vc.oldDomUpdates,
87
87
  devToolsEnabled: config.vc.devToolsEnabled,
88
88
  selectorConfig: config.vc.selectorConfig,
89
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
89
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
90
+ disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
90
91
  };
91
92
  getVCObserver(vcOptions).start({
92
93
  startTime: 0
@@ -447,7 +447,8 @@ export var VCObserver = /*#__PURE__*/function () {
447
447
  this.arraySize = options.heatmapSize || 200;
448
448
  this.devToolsEnabled = options.devToolsEnabled || false;
449
449
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
450
- var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder;
450
+ var ssrEnablePageLayoutPlaceholder = options.ssrEnablePageLayoutPlaceholder,
451
+ disableSizeAndPositionCheck = options.disableSizeAndPositionCheck;
451
452
  this.observers = new Observers({
452
453
  selectorConfig: options.selectorConfig || {
453
454
  id: false,
@@ -457,7 +458,8 @@ export var VCObserver = /*#__PURE__*/function () {
457
458
  dataVC: true
458
459
  },
459
460
  SSRConfig: {
460
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
461
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
462
+ disableSizeAndPositionCheck: disableSizeAndPositionCheck
461
463
  }
462
464
  });
463
465
  this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
@@ -26,7 +26,8 @@ function isElementVisible(target) {
26
26
  export var Observers = /*#__PURE__*/function () {
27
27
  function Observers(opts) {
28
28
  var _this = this,
29
- _opts$SSRConfig;
29
+ _opts$SSRConfig,
30
+ _opts$SSRConfig2;
30
31
  _classCallCheck(this, Observers);
31
32
  _defineProperty(this, "observedMutations", new WeakMap());
32
33
  _defineProperty(this, "elementsInView", new Set());
@@ -66,7 +67,10 @@ export var Observers = /*#__PURE__*/function () {
66
67
  this.selectorConfig = _objectSpread(_objectSpread({}, this.selectorConfig), opts.selectorConfig);
67
68
  this.intersectionObserver = this.getIntersectionObserver();
68
69
  this.mutationObserver = this.getMutationObserver();
69
- this.ssrPlaceholderHandler = new SSRPlaceholderHandlers((_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder);
70
+ this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
71
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
72
+ disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
73
+ });
70
74
  }
71
75
  return _createClass(Observers, [{
72
76
  key: "isBrowserSupported",
@@ -4,9 +4,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var ANCESTOR_LOOKUP_LIMIT = 10;
5
5
  var PAGE_LAYOUT_ID = 'page-layout.root';
6
6
  export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
7
- function SSRPlaceholderHandlers() {
7
+ function SSRPlaceholderHandlers(_ref) {
8
8
  var _this = this;
9
- var enablePageLayoutPlaceholder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
9
+ var _ref$enablePageLayout = _ref.enablePageLayoutPlaceholder,
10
+ enablePageLayoutPlaceholder = _ref$enablePageLayout === void 0 ? false : _ref$enablePageLayout,
11
+ _ref$disableSizeAndPo = _ref.disableSizeAndPositionCheck,
12
+ disableSizeAndPositionCheck = _ref$disableSizeAndPo === void 0 ? {
13
+ v: false,
14
+ h: false
15
+ } : _ref$disableSizeAndPo;
10
16
  _classCallCheck(this, SSRPlaceholderHandlers);
11
17
  _defineProperty(this, "staticPlaceholders", new Map());
12
18
  _defineProperty(this, "callbacks", new Map());
@@ -35,10 +41,10 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
35
41
  }
36
42
  return '';
37
43
  });
38
- _defineProperty(this, "intersectionObserverCallback", function (_ref) {
44
+ _defineProperty(this, "intersectionObserverCallback", function (_ref2) {
39
45
  var _this$intersectionObs;
40
- var target = _ref.target,
41
- boundingClientRect = _ref.boundingClientRect;
46
+ var target = _ref2.target,
47
+ boundingClientRect = _ref2.boundingClientRect;
42
48
  (_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.unobserve(target);
43
49
  if (!(target instanceof HTMLElement)) {
44
50
  // impossible case - keep typescript healthy
@@ -95,6 +101,7 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
95
101
  });
96
102
  }
97
103
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
104
+ this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
98
105
  if (window.document) {
99
106
  try {
100
107
  var selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
@@ -216,7 +223,16 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
216
223
  }, {
217
224
  key: "hasSameSizePosition",
218
225
  value: function hasSameSizePosition(rect, boundingClientRect) {
219
- return rect && Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD || false;
226
+ var _this$disableSizeAndP, _this$disableSizeAndP2;
227
+ if ((_this$disableSizeAndP = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP !== void 0 && _this$disableSizeAndP.v && (_this$disableSizeAndP2 = this.disableSizeAndPositionCheck) !== null && _this$disableSizeAndP2 !== void 0 && _this$disableSizeAndP2.h) {
228
+ return true;
229
+ }
230
+ if (!rect) {
231
+ return false;
232
+ }
233
+ var horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
234
+ var verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
235
+ return horizontalCheck && verticalCheck || false;
220
236
  }
221
237
  }, {
222
238
  key: "isDummyRect",
@@ -74,6 +74,10 @@ export type Config = {
74
74
  readonly ssr?: boolean;
75
75
  readonly ssrWhitelist?: string[];
76
76
  readonly ssrEnablePageLayoutPlaceholder?: boolean;
77
+ readonly disableSizeAndPositionCheck?: {
78
+ v: boolean;
79
+ h: boolean;
80
+ };
77
81
  readonly includeSSRInV3?: boolean;
78
82
  readonly stopVCAtInteractionFinish?: boolean;
79
83
  readonly includeSSRRatio?: boolean;
@@ -26,6 +26,10 @@ export type VCObserverOptions = {
26
26
  selectorConfig?: SelectorConfig | undefined;
27
27
  isPostInteraction?: boolean;
28
28
  ssrEnablePageLayoutPlaceholder?: boolean;
29
+ disableSizeAndPositionCheck?: {
30
+ v: boolean;
31
+ h: boolean;
32
+ };
29
33
  };
30
34
  export interface VCObserverInterface {
31
35
  start(startArg: {
@@ -11,6 +11,10 @@ type ConstructorOptions = {
11
11
  selectorConfig: SelectorConfig;
12
12
  SSRConfig?: {
13
13
  enablePageLayoutPlaceholder: boolean;
14
+ disableSizeAndPositionCheck?: {
15
+ v: boolean;
16
+ h: boolean;
17
+ };
14
18
  };
15
19
  };
16
20
  export declare class Observers implements BrowserObservers {
@@ -4,6 +4,14 @@ type Rect = {
4
4
  width: number;
5
5
  height: number;
6
6
  };
7
+ type DisableSizeAndPositionCheckType = {
8
+ v: boolean;
9
+ h: boolean;
10
+ };
11
+ type SSRPlaceholderHandlersConfig = {
12
+ enablePageLayoutPlaceholder?: boolean;
13
+ disableSizeAndPositionCheck?: DisableSizeAndPositionCheckType;
14
+ };
7
15
  export declare class SSRPlaceholderHandlers {
8
16
  private staticPlaceholders;
9
17
  private callbacks;
@@ -12,7 +20,8 @@ export declare class SSRPlaceholderHandlers {
12
20
  private intersectionObserver;
13
21
  private EQUALITY_THRESHOLD;
14
22
  private enablePageLayoutPlaceholder;
15
- constructor(enablePageLayoutPlaceholder?: boolean);
23
+ private disableSizeAndPositionCheck;
24
+ constructor({ enablePageLayoutPlaceholder, disableSizeAndPositionCheck }: SSRPlaceholderHandlersConfig);
16
25
  private getPlaceholderId;
17
26
  private getPlaceholderReplacementId;
18
27
  clear(): void;
@@ -74,6 +74,10 @@ export type Config = {
74
74
  readonly ssr?: boolean;
75
75
  readonly ssrWhitelist?: string[];
76
76
  readonly ssrEnablePageLayoutPlaceholder?: boolean;
77
+ readonly disableSizeAndPositionCheck?: {
78
+ v: boolean;
79
+ h: boolean;
80
+ };
77
81
  readonly includeSSRInV3?: boolean;
78
82
  readonly stopVCAtInteractionFinish?: boolean;
79
83
  readonly includeSSRRatio?: boolean;
@@ -26,6 +26,10 @@ export type VCObserverOptions = {
26
26
  selectorConfig?: SelectorConfig | undefined;
27
27
  isPostInteraction?: boolean;
28
28
  ssrEnablePageLayoutPlaceholder?: boolean;
29
+ disableSizeAndPositionCheck?: {
30
+ v: boolean;
31
+ h: boolean;
32
+ };
29
33
  };
30
34
  export interface VCObserverInterface {
31
35
  start(startArg: {
@@ -11,6 +11,10 @@ type ConstructorOptions = {
11
11
  selectorConfig: SelectorConfig;
12
12
  SSRConfig?: {
13
13
  enablePageLayoutPlaceholder: boolean;
14
+ disableSizeAndPositionCheck?: {
15
+ v: boolean;
16
+ h: boolean;
17
+ };
14
18
  };
15
19
  };
16
20
  export declare class Observers implements BrowserObservers {
@@ -4,6 +4,14 @@ type Rect = {
4
4
  width: number;
5
5
  height: number;
6
6
  };
7
+ type DisableSizeAndPositionCheckType = {
8
+ v: boolean;
9
+ h: boolean;
10
+ };
11
+ type SSRPlaceholderHandlersConfig = {
12
+ enablePageLayoutPlaceholder?: boolean;
13
+ disableSizeAndPositionCheck?: DisableSizeAndPositionCheckType;
14
+ };
7
15
  export declare class SSRPlaceholderHandlers {
8
16
  private staticPlaceholders;
9
17
  private callbacks;
@@ -12,7 +20,8 @@ export declare class SSRPlaceholderHandlers {
12
20
  private intersectionObserver;
13
21
  private EQUALITY_THRESHOLD;
14
22
  private enablePageLayoutPlaceholder;
15
- constructor(enablePageLayoutPlaceholder?: boolean);
23
+ private disableSizeAndPositionCheck;
24
+ constructor({ enablePageLayoutPlaceholder, disableSizeAndPositionCheck }: SSRPlaceholderHandlersConfig);
16
25
  private getPlaceholderId;
17
26
  private getPlaceholderReplacementId;
18
27
  clear(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "3.13.20",
3
+ "version": "3.13.22",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -171,6 +171,9 @@
171
171
  },
172
172
  "platform_ufo_timeout_simplification": {
173
173
  "type": "boolean"
174
+ },
175
+ "platform_ufo_enable_interactions_vc": {
176
+ "type": "boolean"
174
177
  }
175
178
  }
176
179
  }