@atlaskit/react-ufo 3.12.5 → 3.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/config/index.js +15 -20
  3. package/dist/cjs/create-payload/utils/get-vc-metrics.js +5 -44
  4. package/dist/cjs/vc/index.js +49 -101
  5. package/dist/cjs/vc/vc-observer/getVCRevisionsData.js +13 -67
  6. package/dist/cjs/vc/vc-observer/index.js +31 -107
  7. package/dist/cjs/vc/vc-observer/observers/index.js +3 -2
  8. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +38 -12
  9. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +9 -0
  10. package/dist/es2019/config/index.js +18 -23
  11. package/dist/es2019/create-payload/utils/get-vc-metrics.js +12 -41
  12. package/dist/es2019/vc/index.js +44 -88
  13. package/dist/es2019/vc/vc-observer/getVCRevisionsData.js +15 -71
  14. package/dist/es2019/vc/vc-observer/index.js +11 -87
  15. package/dist/es2019/vc/vc-observer/observers/index.js +2 -1
  16. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +38 -13
  17. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +9 -1
  18. package/dist/esm/config/index.js +15 -20
  19. package/dist/esm/create-payload/utils/get-vc-metrics.js +6 -45
  20. package/dist/esm/vc/index.js +49 -101
  21. package/dist/esm/vc/vc-observer/getVCRevisionsData.js +13 -67
  22. package/dist/esm/vc/vc-observer/index.js +31 -107
  23. package/dist/esm/vc/vc-observer/observers/index.js +3 -2
  24. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +38 -12
  25. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.js +9 -0
  26. package/dist/types/common/vc/types.d.ts +0 -2
  27. package/dist/types/config/index.d.ts +1 -0
  28. package/dist/types/create-post-interaction-log-payload/index.d.ts +1 -1
  29. package/dist/types/vc/types.d.ts +1 -0
  30. package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +2 -17
  31. package/dist/types/vc/vc-observer/index.d.ts +0 -4
  32. package/dist/types/vc/vc-observer/observers/index.d.ts +3 -0
  33. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +4 -1
  34. package/dist/types/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -1
  35. package/dist/types-ts4.5/common/vc/types.d.ts +0 -2
  36. package/dist/types-ts4.5/config/index.d.ts +1 -0
  37. package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +1 -1
  38. package/dist/types-ts4.5/vc/types.d.ts +1 -0
  39. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +2 -17
  40. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +0 -4
  41. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +3 -0
  42. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +4 -1
  43. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/ssr-scripts/collectSSRPlaceholderDimensions.d.ts +1 -1
  44. package/package.json +1 -4
  45. package/dist/cjs/vc/vc-observer/heatmap/heatmap.js +0 -281
  46. package/dist/cjs/vc/vc-observer/revisions/ViewportUpdateClassifier.js +0 -68
  47. package/dist/cjs/vc/vc-observer/revisions/fy25_01.js +0 -76
  48. package/dist/cjs/vc/vc-observer/revisions/fy25_02.js +0 -59
  49. package/dist/cjs/vc/vc-observer/revisions/revisions.js +0 -24
  50. package/dist/cjs/vc/vc-observer/revisions/types.js +0 -5
  51. package/dist/es2019/vc/vc-observer/heatmap/heatmap.js +0 -247
  52. package/dist/es2019/vc/vc-observer/revisions/ViewportUpdateClassifier.js +0 -48
  53. package/dist/es2019/vc/vc-observer/revisions/fy25_01.js +0 -55
  54. package/dist/es2019/vc/vc-observer/revisions/fy25_02.js +0 -35
  55. package/dist/es2019/vc/vc-observer/revisions/revisions.js +0 -18
  56. package/dist/es2019/vc/vc-observer/revisions/types.js +0 -1
  57. package/dist/esm/vc/vc-observer/heatmap/heatmap.js +0 -274
  58. package/dist/esm/vc/vc-observer/revisions/ViewportUpdateClassifier.js +0 -61
  59. package/dist/esm/vc/vc-observer/revisions/fy25_01.js +0 -69
  60. package/dist/esm/vc/vc-observer/revisions/fy25_02.js +0 -52
  61. package/dist/esm/vc/vc-observer/revisions/revisions.js +0 -18
  62. package/dist/esm/vc/vc-observer/revisions/types.js +0 -1
  63. package/dist/types/vc/vc-observer/heatmap/heatmap.d.ts +0 -79
  64. package/dist/types/vc/vc-observer/revisions/ViewportUpdateClassifier.d.ts +0 -31
  65. package/dist/types/vc/vc-observer/revisions/fy25_01.d.ts +0 -13
  66. package/dist/types/vc/vc-observer/revisions/fy25_02.d.ts +0 -16
  67. package/dist/types/vc/vc-observer/revisions/revisions.d.ts +0 -2
  68. package/dist/types/vc/vc-observer/revisions/types.d.ts +0 -28
  69. package/dist/types-ts4.5/vc/vc-observer/heatmap/heatmap.d.ts +0 -79
  70. package/dist/types-ts4.5/vc/vc-observer/revisions/ViewportUpdateClassifier.d.ts +0 -31
  71. package/dist/types-ts4.5/vc/vc-observer/revisions/fy25_01.d.ts +0 -13
  72. package/dist/types-ts4.5/vc/vc-observer/revisions/fy25_02.d.ts +0 -16
  73. package/dist/types-ts4.5/vc/vc-observer/revisions/revisions.d.ts +0 -2
  74. package/dist/types-ts4.5/vc/vc-observer/revisions/types.d.ts +0 -28
@@ -1,5 +1,4 @@
1
1
  var _process, _process$env;
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
2
  import { isVCRevisionEnabled } from '../config';
4
3
  import { VCObserverNOOP } from './no-op-vc-observer';
5
4
  import { VCObserver } from './vc-observer';
@@ -7,22 +6,13 @@ import VCObserverNew from './vc-observer-new';
7
6
  export class VCObserverWrapper {
8
7
  constructor(opts = {}) {
9
8
  this.newVCObserver = null;
10
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
11
- this.oldVCObserver = null;
12
- if (isVCRevisionEnabled('fy25.03')) {
13
- this.newVCObserver = new VCObserverNew({
14
- selectorConfig: opts.selectorConfig
15
- });
16
- }
17
- if (isVCRevisionEnabled('fy25.01') || isVCRevisionEnabled('fy25.02')) {
18
- this.oldVCObserver = new VCObserver(opts);
19
- }
20
- } else {
21
- if (isVCRevisionEnabled('fy25.03')) {
22
- this.newVCObserver = new VCObserverNew({
23
- selectorConfig: opts.selectorConfig
24
- });
25
- }
9
+ this.oldVCObserver = null;
10
+ if (isVCRevisionEnabled('fy25.03')) {
11
+ this.newVCObserver = new VCObserverNew({
12
+ selectorConfig: opts.selectorConfig
13
+ });
14
+ }
15
+ if (isVCRevisionEnabled('fy25.01') || isVCRevisionEnabled('fy25.02')) {
26
16
  this.oldVCObserver = new VCObserver(opts);
27
17
  }
28
18
  }
@@ -30,96 +20,62 @@ export class VCObserverWrapper {
30
20
  startTime,
31
21
  experienceKey
32
22
  }) {
33
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
34
- if (isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey)) {
35
- var _this$oldVCObserver;
36
- (_this$oldVCObserver = this.oldVCObserver) === null || _this$oldVCObserver === void 0 ? void 0 : _this$oldVCObserver.start({
37
- startTime
38
- });
39
- }
40
- if (isVCRevisionEnabled('fy25.03', experienceKey)) {
41
- var _this$newVCObserver;
42
- (_this$newVCObserver = this.newVCObserver) === null || _this$newVCObserver === void 0 ? void 0 : _this$newVCObserver.start({
43
- startTime
44
- });
45
- }
46
- } else {
47
- var _this$oldVCObserver2, _this$newVCObserver2;
48
- (_this$oldVCObserver2 = this.oldVCObserver) === null || _this$oldVCObserver2 === void 0 ? void 0 : _this$oldVCObserver2.start({
23
+ if (isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey)) {
24
+ var _this$oldVCObserver;
25
+ (_this$oldVCObserver = this.oldVCObserver) === null || _this$oldVCObserver === void 0 ? void 0 : _this$oldVCObserver.start({
49
26
  startTime
50
27
  });
51
- (_this$newVCObserver2 = this.newVCObserver) === null || _this$newVCObserver2 === void 0 ? void 0 : _this$newVCObserver2.start({
28
+ }
29
+ if (isVCRevisionEnabled('fy25.03', experienceKey)) {
30
+ var _this$newVCObserver;
31
+ (_this$newVCObserver = this.newVCObserver) === null || _this$newVCObserver === void 0 ? void 0 : _this$newVCObserver.start({
52
32
  startTime
53
33
  });
54
34
  }
55
35
  }
56
36
  stop(experienceKey) {
57
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
58
- if (isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey)) {
59
- var _this$oldVCObserver3;
60
- (_this$oldVCObserver3 = this.oldVCObserver) === null || _this$oldVCObserver3 === void 0 ? void 0 : _this$oldVCObserver3.stop();
61
- }
62
- if (isVCRevisionEnabled('fy25.03', experienceKey)) {
63
- var _this$newVCObserver3;
64
- (_this$newVCObserver3 = this.newVCObserver) === null || _this$newVCObserver3 === void 0 ? void 0 : _this$newVCObserver3.stop();
65
- }
66
- } else {
67
- var _this$oldVCObserver4, _this$newVCObserver4;
68
- (_this$oldVCObserver4 = this.oldVCObserver) === null || _this$oldVCObserver4 === void 0 ? void 0 : _this$oldVCObserver4.stop();
69
- (_this$newVCObserver4 = this.newVCObserver) === null || _this$newVCObserver4 === void 0 ? void 0 : _this$newVCObserver4.stop();
37
+ if (isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey)) {
38
+ var _this$oldVCObserver2;
39
+ (_this$oldVCObserver2 = this.oldVCObserver) === null || _this$oldVCObserver2 === void 0 ? void 0 : _this$oldVCObserver2.stop();
40
+ }
41
+ if (isVCRevisionEnabled('fy25.03', experienceKey)) {
42
+ var _this$newVCObserver2;
43
+ (_this$newVCObserver2 = this.newVCObserver) === null || _this$newVCObserver2 === void 0 ? void 0 : _this$newVCObserver2.stop();
70
44
  }
71
45
  }
72
46
  getVCRawData() {
73
- var _this$oldVCObserver$g, _this$oldVCObserver5;
74
- return (_this$oldVCObserver$g = (_this$oldVCObserver5 = this.oldVCObserver) === null || _this$oldVCObserver5 === void 0 ? void 0 : _this$oldVCObserver5.getVCRawData()) !== null && _this$oldVCObserver$g !== void 0 ? _this$oldVCObserver$g : null;
47
+ var _this$oldVCObserver$g, _this$oldVCObserver3;
48
+ return (_this$oldVCObserver$g = (_this$oldVCObserver3 = this.oldVCObserver) === null || _this$oldVCObserver3 === void 0 ? void 0 : _this$oldVCObserver3.getVCRawData()) !== null && _this$oldVCObserver$g !== void 0 ? _this$oldVCObserver$g : null;
75
49
  }
76
50
  async getVCResult(param) {
77
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
78
- var _this$oldVCObserver6, _this$newVCObserver5, _ref;
79
- const {
80
- experienceKey
81
- } = param;
82
- const v1v2Result = isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey) ? await ((_this$oldVCObserver6 = this.oldVCObserver) === null || _this$oldVCObserver6 === void 0 ? void 0 : _this$oldVCObserver6.getVCResult(param)) : {};
83
- const v3Result = isVCRevisionEnabled('fy25.03', experienceKey) ? await ((_this$newVCObserver5 = this.newVCObserver) === null || _this$newVCObserver5 === void 0 ? void 0 : _this$newVCObserver5.getVCResult({
84
- start: param.start,
85
- stop: param.stop,
86
- interactionId: param.interactionId
87
- })) : [];
88
- if (!v3Result) {
89
- return v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {};
90
- }
91
- return {
92
- ...v1v2Result,
93
- 'ufo:vc:rev': [...((_ref = v1v2Result === null || v1v2Result === void 0 ? void 0 : v1v2Result['ufo:vc:rev']) !== null && _ref !== void 0 ? _ref : []), ...(v3Result !== null && v3Result !== void 0 ? v3Result : [])]
94
- };
95
- } else {
96
- var _this$oldVCObserver7, _this$newVCObserver6, _ref2;
97
- const oldResult = await ((_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 ? void 0 : _this$oldVCObserver7.getVCResult(param));
98
- const newResult = await ((_this$newVCObserver6 = this.newVCObserver) === null || _this$newVCObserver6 === void 0 ? void 0 : _this$newVCObserver6.getVCResult({
99
- start: param.start,
100
- stop: param.stop,
101
- interactionId: param.interactionId
102
- }));
103
- if (oldResult && !newResult) {
104
- return oldResult;
105
- }
106
- return {
107
- ...(oldResult !== null && oldResult !== void 0 ? oldResult : {}),
108
- 'ufo:vc:rev': [...((_ref2 = oldResult === null || oldResult === void 0 ? void 0 : oldResult['ufo:vc:rev']) !== null && _ref2 !== void 0 ? _ref2 : []), ...(newResult !== null && newResult !== void 0 ? newResult : [])]
109
- };
51
+ var _this$oldVCObserver4, _this$newVCObserver3, _ref;
52
+ const {
53
+ experienceKey
54
+ } = param;
55
+ const v1v2Result = isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey) ? await ((_this$oldVCObserver4 = this.oldVCObserver) === null || _this$oldVCObserver4 === void 0 ? void 0 : _this$oldVCObserver4.getVCResult(param)) : {};
56
+ const v3Result = isVCRevisionEnabled('fy25.03', experienceKey) ? await ((_this$newVCObserver3 = this.newVCObserver) === null || _this$newVCObserver3 === void 0 ? void 0 : _this$newVCObserver3.getVCResult({
57
+ start: param.start,
58
+ stop: param.stop
59
+ })) : [];
60
+ if (!v3Result) {
61
+ return v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {};
110
62
  }
63
+ return {
64
+ ...v1v2Result,
65
+ 'ufo:vc:rev': [...((_ref = v1v2Result === null || v1v2Result === void 0 ? void 0 : v1v2Result['ufo:vc:rev']) !== null && _ref !== void 0 ? _ref : []), ...(v3Result !== null && v3Result !== void 0 ? v3Result : [])]
66
+ };
111
67
  }
112
68
  setSSRElement(element) {
113
- var _this$oldVCObserver8;
114
- (_this$oldVCObserver8 = this.oldVCObserver) === null || _this$oldVCObserver8 === void 0 ? void 0 : _this$oldVCObserver8.setSSRElement(element);
69
+ var _this$oldVCObserver5;
70
+ (_this$oldVCObserver5 = this.oldVCObserver) === null || _this$oldVCObserver5 === void 0 ? void 0 : _this$oldVCObserver5.setSSRElement(element);
115
71
  }
116
72
  setReactRootRenderStart(startTime) {
117
- var _this$oldVCObserver9;
118
- (_this$oldVCObserver9 = this.oldVCObserver) === null || _this$oldVCObserver9 === void 0 ? void 0 : _this$oldVCObserver9.setReactRootRenderStart(startTime || performance.now());
73
+ var _this$oldVCObserver6;
74
+ (_this$oldVCObserver6 = this.oldVCObserver) === null || _this$oldVCObserver6 === void 0 ? void 0 : _this$oldVCObserver6.setReactRootRenderStart(startTime || performance.now());
119
75
  }
120
76
  setReactRootRenderStop(stopTime) {
121
- var _this$oldVCObserver10;
122
- (_this$oldVCObserver10 = this.oldVCObserver) === null || _this$oldVCObserver10 === void 0 ? void 0 : _this$oldVCObserver10.setReactRootRenderStop(stopTime || performance.now());
77
+ var _this$oldVCObserver7;
78
+ (_this$oldVCObserver7 = this.oldVCObserver) === null || _this$oldVCObserver7 === void 0 ? void 0 : _this$oldVCObserver7.setReactRootRenderStop(stopTime || performance.now());
123
79
  }
124
80
  }
125
81
 
@@ -1,7 +1,5 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
1
  import { isVCRevisionEnabled } from '../../config';
3
2
  import { getPageVisibilityState } from '../../hidden-timing';
4
- import { getRevisions } from './revisions/revisions';
5
3
  const VCParts = ['25', '50', '75', '80', '85', '90', '95', '98', '99'];
6
4
  const READONLY_EMPTY_ARRAY = Array.from({
7
5
  length: 0
@@ -33,85 +31,31 @@ export function getVCRevisionsData({
33
31
  interaction,
34
32
  isVCClean,
35
33
  isEventAborted,
36
- multiHeatmap,
37
- ssr,
38
34
  calculatedVC,
39
35
  calculatedVCNext,
40
36
  experienceKey
41
37
  }) {
42
- const isTTVCv3Enabled = fg('platform_ufo_vc_enable_revisions_by_experience') ? isVCRevisionEnabled('fy25.03', experienceKey) : isVCRevisionEnabled('fy25.03');
43
-
44
- // As part of `platform_ufo_vc_enable_revisions_by_experience`, we are looking to turn off the `multiHeatmap` branch of code
45
- // for calculating TTVC, and instead rely on existing values already available, e.g. `calculatedVC` and `calculatedVCNext`
46
- if (!isTTVCv3Enabled && !fg('platform_ufo_vc_enable_revisions_by_experience')) {
47
- if (!multiHeatmap) {
48
- return null;
49
- }
50
- return {
51
- [`${fullPrefix}vc:rev`]: multiHeatmap === null || multiHeatmap === void 0 ? void 0 : multiHeatmap.getPayloadShapedData({
52
- VCParts: VCParts.map(v => parseInt(v)),
53
- VCCalculationMethods: getRevisions().map(({
54
- classifier
55
- }) => classifier.VCCalculationMethod),
56
- filterComponentsLog: getRevisions().map(({
57
- classifier
58
- }) => classifier.filterComponentsLog),
59
- isEventAborted,
60
- interactionStart: interaction.start,
61
- ttai: interaction.end,
62
- ssr,
63
- clean: isVCClean
64
- })
65
- };
66
- }
67
38
  const pageVisibilityUpToTTAI = getPageVisibilityState(interaction.start, interaction.end);
68
39
  const isVisiblePageVisibleUpToTTAI = pageVisibilityUpToTTAI === 'visible';
69
40
  const shouldHaveVCmetric = isVCClean && !isEventAborted && isVisiblePageVisibleUpToTTAI;
70
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
71
- const availableVCRevisionPayloads = [];
72
- if (isVCRevisionEnabled('fy25.01', experienceKey)) {
73
- availableVCRevisionPayloads.push({
74
- revision: 'fy25.01',
75
- clean: isVCClean,
76
- 'metric:vc90': shouldHaveVCmetric ? calculatedVC.VC['90'] : null,
77
- vcDetails: createVCDetails(calculatedVC, shouldHaveVCmetric)
78
- });
79
- }
80
- if (isVCRevisionEnabled('fy25.02', experienceKey)) {
81
- availableVCRevisionPayloads.push({
82
- revision: 'fy25.02',
83
- clean: isVCClean,
84
- 'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
85
- vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
86
- });
87
- }
88
- return {
89
- [`${fullPrefix}vc:rev`]: availableVCRevisionPayloads
90
- };
91
- } else {
92
- // Create the V2 revision object which is always needed
93
- const ttvcV2Revision = {
94
- revision: 'fy25.02',
95
- clean: isVCClean,
96
- 'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
97
- vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
98
- };
99
- const isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01');
100
- if (isTTVCv1Disabled) {
101
- return {
102
- [`${fullPrefix}vc:rev`]: [ttvcV2Revision]
103
- };
104
- }
105
-
106
- // Only create ttvcV1Revision when we're actually going to use it
107
- const ttvcV1Revision = {
41
+ const availableVCRevisionPayloads = [];
42
+ if (isVCRevisionEnabled('fy25.01', experienceKey)) {
43
+ availableVCRevisionPayloads.push({
108
44
  revision: 'fy25.01',
109
45
  clean: isVCClean,
110
46
  'metric:vc90': shouldHaveVCmetric ? calculatedVC.VC['90'] : null,
111
47
  vcDetails: createVCDetails(calculatedVC, shouldHaveVCmetric)
112
- };
113
- return {
114
- [`${fullPrefix}vc:rev`]: [ttvcV1Revision, ttvcV2Revision]
115
- };
48
+ });
49
+ }
50
+ if (isVCRevisionEnabled('fy25.02', experienceKey)) {
51
+ availableVCRevisionPayloads.push({
52
+ revision: 'fy25.02',
53
+ clean: isVCClean,
54
+ 'metric:vc90': shouldHaveVCmetric ? calculatedVCNext.VC['90'] : null,
55
+ vcDetails: createVCDetails(calculatedVCNext, shouldHaveVCmetric)
56
+ });
116
57
  }
58
+ return {
59
+ [`${fullPrefix}vc:rev`]: availableVCRevisionPayloads
60
+ };
117
61
  }
@@ -6,9 +6,7 @@ import { attachAbortListeners } from './attachAbortListeners';
6
6
  import { getVCRevisionDebugDetails } from './getVCRevisionDebugDetails';
7
7
  import { getVCRevisionsData } from './getVCRevisionsData';
8
8
  import { getViewportHeight, getViewportWidth } from './getViewport';
9
- import { MultiRevisionHeatmap } from './heatmap/heatmap';
10
9
  import { Observers } from './observers';
11
- import { getRevisions } from './revisions/revisions';
12
10
  const abortReason = {
13
11
  scroll: 'scroll',
14
12
  keypress: 'keypress',
@@ -41,7 +39,6 @@ export class VCObserver {
41
39
  });
42
40
  /* heatmap */
43
41
  _defineProperty(this, "arraySize", 0);
44
- _defineProperty(this, "multiHeatmap", null);
45
42
  _defineProperty(this, "componentsLog", {});
46
43
  _defineProperty(this, "vcRatios", {});
47
44
  _defineProperty(this, "active", false);
@@ -75,7 +72,6 @@ export class VCObserver {
75
72
  },
76
73
  heatmap: this.heatmap,
77
74
  heatmapNext: this.heatmapNext,
78
- multiHeatmap: this.multiHeatmap,
79
75
  outOfBoundaryInfo: this.outOfBoundaryInfo,
80
76
  totalTime: Math.round(this.totalTime + this.observers.getTotalTime()),
81
77
  componentsLog: {
@@ -117,10 +113,9 @@ export class VCObserver {
117
113
  componentsLog,
118
114
  viewport,
119
115
  devToolsEnabled,
120
- ratios,
121
- multiHeatmap
116
+ ratios
122
117
  } = rawData;
123
- const isTTVCv1Disabled = fg('platform_ufo_vc_enable_revisions_by_experience') ? !isVCRevisionEnabled('fy25.01', experienceKey) : !isVCRevisionEnabled('fy25.01');
118
+ const isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01', experienceKey);
124
119
 
125
120
  // NOTE: as part of platform_ufo_add_vc_abort_reason_by_revisions feature,
126
121
  // we want to report abort by scroll events the same way as other abort reasons
@@ -339,8 +334,6 @@ export class VCObserver {
339
334
  end: stop
340
335
  },
341
336
  isVCClean,
342
- multiHeatmap,
343
- ssr,
344
337
  calculatedVC: {
345
338
  VC,
346
339
  VCBox
@@ -367,7 +360,7 @@ export class VCObserver {
367
360
  ...speedIndex
368
361
  };
369
362
  }
370
- const isTTVCv3Enabled = fg('platform_ufo_vc_enable_revisions_by_experience') ? isVCRevisionEnabled('fy25.03', experienceKey) : isVCRevisionEnabled('fy25.03');
363
+ const isTTVCv3Enabled = isVCRevisionEnabled('fy25.03', experienceKey);
371
364
  return {
372
365
  'metrics:vc': VC,
373
366
  [`${fullPrefix}vc:state`]: true,
@@ -390,29 +383,6 @@ export class VCObserver {
390
383
  };
391
384
  });
392
385
  _defineProperty(this, "handleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) => {
393
- this.measureStart();
394
- this.legacyHandleUpdate(rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue);
395
- let isTTVCv3Disabled = !isVCRevisionEnabled('fy25.03');
396
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
397
- const interaction = getActiveInteraction();
398
- isTTVCv3Disabled = !isVCRevisionEnabled('fy25.03', interaction === null || interaction === void 0 ? void 0 : interaction.ufoName);
399
- }
400
- if (isTTVCv3Disabled) {
401
- this.onViewportChangeDetected({
402
- timestamp: rawTime,
403
- intersectionRect,
404
- targetName,
405
- element,
406
- type,
407
- ignoreReason,
408
- attributeName,
409
- oldValue,
410
- newValue
411
- });
412
- }
413
- this.measureStop();
414
- });
415
- _defineProperty(this, "legacyHandleUpdate", (rawTime, intersectionRect, targetName, element, type, ignoreReason, attributeName, oldValue, newValue) => {
416
386
  if (this.abortReason.reason === null || this.abortReason.blocking === false) {
417
387
  const time = Math.round(rawTime - this.startTime);
418
388
  const mappedValues = this.mapPixelsToHeatmap(intersectionRect.left, intersectionRect.top, intersectionRect.width, intersectionRect.height);
@@ -420,11 +390,8 @@ export class VCObserver {
420
390
  if (!ignoreReason) {
421
391
  this.applyChangesToHeatMap(mappedValues, time, this.heatmapNext);
422
392
  }
423
- let isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01');
424
- if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
425
- const interaction = getActiveInteraction();
426
- isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01', interaction === null || interaction === void 0 ? void 0 : interaction.ufoName);
427
- }
393
+ const interaction = getActiveInteraction();
394
+ const isTTVCv1Disabled = !isVCRevisionEnabled('fy25.01', interaction === null || interaction === void 0 ? void 0 : interaction.ufoName);
428
395
  if (!isTTVCv1Disabled && (!ignoreReason || ignoreReason === 'not-visible') && type !== 'attr') {
429
396
  this.applyChangesToHeatMap(mappedValues, time, this.heatmap);
430
397
  }
@@ -443,45 +410,6 @@ export class VCObserver {
443
410
  });
444
411
  }
445
412
  });
446
- _defineProperty(this, "onViewportChangeDetected", ({
447
- element,
448
- type,
449
- ignoreReason,
450
- timestamp,
451
- targetName,
452
- intersectionRect,
453
- attributeName,
454
- oldValue,
455
- newValue
456
- }) => {
457
- if (this.multiHeatmap === null) {
458
- return;
459
- }
460
- // @todo add abort reason handling
461
- const time = Math.round(timestamp - this.startTime);
462
- const revisions = getRevisions();
463
- const revisionsClassification = revisions.map(revision => {
464
- return revision.classifier.classifyUpdate({
465
- element,
466
- type,
467
- ignoreReason
468
- });
469
- }, []);
470
- this.multiHeatmap.handleUpdate({
471
- time,
472
- targetName,
473
- intersectionRect,
474
- type,
475
- element,
476
- classification: revisionsClassification,
477
- onError: error => {
478
- this.setAbortReason(abortReason.error, error.time, error.error);
479
- },
480
- attributeName,
481
- oldValue,
482
- newValue
483
- });
484
- });
485
413
  _defineProperty(this, "mapPixelsToHeatmap", (left, top, width, height) => {
486
414
  const {
487
415
  w,
@@ -554,6 +482,9 @@ export class VCObserver {
554
482
  this.arraySize = options.heatmapSize || 200;
555
483
  this.devToolsEnabled = options.devToolsEnabled || false;
556
484
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
485
+ const {
486
+ ssrEnablePageLayoutPlaceholder
487
+ } = options;
557
488
  this.observers = new Observers({
558
489
  selectorConfig: options.selectorConfig || {
559
490
  id: false,
@@ -561,15 +492,13 @@ export class VCObserver {
561
492
  role: false,
562
493
  className: true,
563
494
  dataVC: true
495
+ },
496
+ SSRConfig: {
497
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
564
498
  }
565
499
  });
566
500
  this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
567
501
  this.heatmapNext = this.getCleanHeatmap();
568
- this.multiHeatmap = new MultiRevisionHeatmap({
569
- viewport: this.viewport,
570
- revisions: getRevisions(),
571
- devToolsEnabled: this.devToolsEnabled
572
- });
573
502
  this.isPostInteraction = options.isPostInteraction || false;
574
503
  }
575
504
  start({
@@ -721,11 +650,6 @@ export class VCObserver {
721
650
  this.detachAbortListeners();
722
651
  this.heatmap = !isVCRevisionEnabled('fy25.01') ? [] : this.getCleanHeatmap();
723
652
  this.heatmapNext = this.getCleanHeatmap();
724
- this.multiHeatmap = new MultiRevisionHeatmap({
725
- viewport: this.viewport,
726
- revisions: getRevisions(),
727
- devToolsEnabled: this.devToolsEnabled
728
- });
729
653
  this.totalTime = 0;
730
654
  this.componentsLog = {};
731
655
  this.vcRatios = {};
@@ -20,6 +20,7 @@ function isElementVisible(target) {
20
20
  }
21
21
  export class Observers {
22
22
  constructor(opts) {
23
+ var _opts$SSRConfig;
23
24
  _defineProperty(this, "observedMutations", new WeakMap());
24
25
  _defineProperty(this, "elementsInView", new Set());
25
26
  _defineProperty(this, "callbacks", new Set());
@@ -59,7 +60,7 @@ export class Observers {
59
60
  };
60
61
  this.intersectionObserver = this.getIntersectionObserver();
61
62
  this.mutationObserver = this.getMutationObserver();
62
- this.ssrPlaceholderHandler = new SSRPlaceholderHandlers();
63
+ this.ssrPlaceholderHandler = new SSRPlaceholderHandlers((_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder);
63
64
  }
64
65
  isBrowserSupported() {
65
66
  return typeof window.IntersectionObserver === 'function' && typeof window.MutationObserver === 'function';
@@ -1,12 +1,35 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  const ANCESTOR_LOOKUP_LIMIT = 10;
3
+ const PAGE_LAYOUT_ID = 'page-layout.root';
3
4
  export class SSRPlaceholderHandlers {
4
- constructor() {
5
+ constructor(enablePageLayoutPlaceholder = false) {
5
6
  _defineProperty(this, "staticPlaceholders", new Map());
6
7
  _defineProperty(this, "callbacks", new Map());
7
8
  _defineProperty(this, "getSizeCallbacks", new Map());
8
9
  _defineProperty(this, "reactValidateCallbacks", new Map());
9
10
  _defineProperty(this, "EQUALITY_THRESHOLD", 1);
11
+ _defineProperty(this, "getPlaceholderId", el => {
12
+ var _el$dataset;
13
+ const ssrPlaceholderId = el === null || el === void 0 ? void 0 : (_el$dataset = el.dataset) === null || _el$dataset === void 0 ? void 0 : _el$dataset.ssrPlaceholder;
14
+ if (!!ssrPlaceholderId) {
15
+ return ssrPlaceholderId;
16
+ }
17
+ if (this.enablePageLayoutPlaceholder && (el === null || el === void 0 ? void 0 : el.dataset.testid) === PAGE_LAYOUT_ID) {
18
+ return PAGE_LAYOUT_ID;
19
+ }
20
+ return '';
21
+ });
22
+ _defineProperty(this, "getPlaceholderReplacementId", el => {
23
+ var _el$dataset2;
24
+ const ssrPlaceholderReplaceId = el === null || el === void 0 ? void 0 : (_el$dataset2 = el.dataset) === null || _el$dataset2 === void 0 ? void 0 : _el$dataset2.ssrPlaceholderReplace;
25
+ if (!!ssrPlaceholderReplaceId) {
26
+ return ssrPlaceholderReplaceId;
27
+ }
28
+ if (this.enablePageLayoutPlaceholder && (el === null || el === void 0 ? void 0 : el.dataset.testid) === PAGE_LAYOUT_ID) {
29
+ return PAGE_LAYOUT_ID;
30
+ }
31
+ return '';
32
+ });
10
33
  _defineProperty(this, "intersectionObserverCallback", ({
11
34
  target,
12
35
  boundingClientRect
@@ -17,7 +40,7 @@ export class SSRPlaceholderHandlers {
17
40
  // impossible case - keep typescript healthy
18
41
  return;
19
42
  }
20
- const staticKey = target.dataset.ssrPlaceholder || '';
43
+ const staticKey = this.getPlaceholderId(target);
21
44
  if (staticKey) {
22
45
  if (this.staticPlaceholders.has(staticKey) && this.callbacks.has(staticKey)) {
23
46
  // validation
@@ -39,7 +62,7 @@ export class SSRPlaceholderHandlers {
39
62
  this.callbacks.delete(staticKey);
40
63
  }
41
64
  } else {
42
- const key = target.dataset.ssrPlaceholderReplace || '';
65
+ const key = this.getPlaceholderReplacementId(target);
43
66
  const resolve = this.reactValidateCallbacks.get(key);
44
67
  if (!resolve) {
45
68
  return;
@@ -63,25 +86,27 @@ export class SSRPlaceholderHandlers {
63
86
  // Only instantiate the IntersectionObserver if it's supported
64
87
  this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
65
88
  }
89
+ this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
66
90
  if (window.document) {
67
91
  try {
68
- const existingElements = document.querySelectorAll('[data-ssr-placeholder]');
92
+ const selector = this.enablePageLayoutPlaceholder ? '[data-ssr-placeholder],[data-testid="page-layout.root"]' : '[data-ssr-placeholder]';
93
+ const existingElements = document.querySelectorAll(selector);
69
94
  existingElements.forEach(el => {
70
- var _el$dataset;
71
- if (el instanceof HTMLElement && el !== null && el !== void 0 && (_el$dataset = el.dataset) !== null && _el$dataset !== void 0 && _el$dataset.ssrPlaceholder) {
95
+ const placeholderId = el instanceof HTMLElement && this.getPlaceholderId(el);
96
+ if (placeholderId) {
72
97
  var _window$__SSR_PLACEHO, _this$intersectionObs2;
73
98
  let width = -1;
74
99
  let height = -1;
75
100
  let x = -1;
76
101
  let y = -1;
77
- const boundingClientRect = (_window$__SSR_PLACEHO = window.__SSR_PLACEHOLDERS_DIMENSIONS__) === null || _window$__SSR_PLACEHO === void 0 ? void 0 : _window$__SSR_PLACEHO[el.dataset.ssrPlaceholder];
102
+ const boundingClientRect = (_window$__SSR_PLACEHO = window.__SSR_PLACEHOLDERS_DIMENSIONS__) === null || _window$__SSR_PLACEHO === void 0 ? void 0 : _window$__SSR_PLACEHO[placeholderId];
78
103
  if (boundingClientRect) {
79
104
  width = boundingClientRect.width;
80
105
  height = boundingClientRect.height;
81
106
  x = boundingClientRect.x;
82
107
  y = boundingClientRect.y;
83
108
  }
84
- this.staticPlaceholders.set(el.dataset.ssrPlaceholder, {
109
+ this.staticPlaceholders.set(placeholderId, {
85
110
  width,
86
111
  height,
87
112
  x,
@@ -102,10 +127,10 @@ export class SSRPlaceholderHandlers {
102
127
  this.reactValidateCallbacks = new Map();
103
128
  }
104
129
  isPlaceholder(element) {
105
- return Boolean(element.dataset.ssrPlaceholder);
130
+ return Boolean(this.getPlaceholderId(element));
106
131
  }
107
132
  isPlaceholderReplacement(element) {
108
- return Boolean(element.dataset.ssrPlaceholderReplace);
133
+ return Boolean(this.getPlaceholderReplacementId(element));
109
134
  }
110
135
  isPlaceholderIgnored(element) {
111
136
  // data-ssr-placeholder-ignored doesn't have a value.
@@ -128,7 +153,7 @@ export class SSRPlaceholderHandlers {
128
153
  }
129
154
  checkIfExistedAndSizeMatching(el) {
130
155
  el = this.findNearestPlaceholderContainerIfIgnored(el);
131
- const id = el.dataset.ssrPlaceholder || '';
156
+ const id = this.getPlaceholderId(el);
132
157
  return new Promise(resolve => {
133
158
  if (!this.staticPlaceholders.has(id)) {
134
159
  resolve(false);
@@ -143,13 +168,13 @@ export class SSRPlaceholderHandlers {
143
168
  getSize(el) {
144
169
  return new Promise(resolve => {
145
170
  var _this$intersectionObs4;
146
- this.getSizeCallbacks.set(el.dataset.ssrPlaceholder || '', resolve);
171
+ this.getSizeCallbacks.set(this.getPlaceholderId(el), resolve);
147
172
  (_this$intersectionObs4 = this.intersectionObserver) === null || _this$intersectionObs4 === void 0 ? void 0 : _this$intersectionObs4.observe(el);
148
173
  });
149
174
  }
150
175
  validateReactComponentMatchToPlaceholder(el) {
151
176
  el = this.findNearestPlaceholderContainerIfIgnored(el);
152
- const id = el.dataset.ssrPlaceholderReplace || '';
177
+ const id = this.getPlaceholderReplacementId(el);
153
178
  return new Promise(resolve => {
154
179
  if (!this.staticPlaceholders.has(id)) {
155
180
  resolve(false);
@@ -1,7 +1,7 @@
1
1
  // lightweight script to scan the SSR response and collect all elements with data-ssr-placeholder attribute
2
2
  // and save their size/positions in a map __SSR_PLACEHOLDERS_DIMENSIONS__ on the Window object. Each placeholderId is
3
3
  // unique and maps to its corresponding elements bounding client rectangle dimensions.
4
- export function collectSSRPlaceholderDimensions(document, window) {
4
+ export function collectSSRPlaceholderDimensions(document, window, enablePageLayoutPlaceholder = false) {
5
5
  const ssrPlaceholders = document === null || document === void 0 ? void 0 : document.querySelectorAll('[data-ssr-placeholder]');
6
6
  ssrPlaceholders.forEach(elem => {
7
7
  const placeholderId = elem.getAttribute('data-ssr-placeholder');
@@ -11,4 +11,12 @@ export function collectSSRPlaceholderDimensions(document, window) {
11
11
  window.__SSR_PLACEHOLDERS_DIMENSIONS__[placeholderId] = boundingClient;
12
12
  }
13
13
  });
14
+ if (enablePageLayoutPlaceholder) {
15
+ const pageLayoutRoot = document === null || document === void 0 ? void 0 : document.getElementById('unsafe-design-system-page-layout-root');
16
+ if (pageLayoutRoot) {
17
+ const boundingClient = pageLayoutRoot.getBoundingClientRect();
18
+ window.__SSR_PLACEHOLDERS_DIMENSIONS__ = window.__SSR_PLACEHOLDERS_DIMENSIONS__ || {};
19
+ window.__SSR_PLACEHOLDERS_DIMENSIONS__['page-layout.root'] = boundingClient;
20
+ }
21
+ }
14
22
  }