@atlaskit/react-ufo 4.1.12 → 4.2.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/create-payload/index.js +22 -4
  3. package/dist/cjs/create-payload/utils/add-performance-measures.js +62 -0
  4. package/dist/cjs/interaction-metrics/index.js +26 -2
  5. package/dist/cjs/interaction-metrics-init/index.js +1 -2
  6. package/dist/cjs/vc/index.js +7 -59
  7. package/dist/cjs/vc/vc-observer/index.js +1 -3
  8. package/dist/cjs/vc/vc-observer/observers/index.js +2 -3
  9. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +3 -13
  10. package/dist/cjs/vc/vc-observer-new/index.js +2 -6
  11. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +8 -14
  12. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +25 -0
  13. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +63 -0
  14. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +28 -0
  15. package/dist/es2019/create-payload/index.js +21 -3
  16. package/dist/es2019/create-payload/utils/add-performance-measures.js +54 -0
  17. package/dist/es2019/interaction-metrics/index.js +26 -2
  18. package/dist/es2019/interaction-metrics-init/index.js +1 -2
  19. package/dist/es2019/vc/index.js +4 -54
  20. package/dist/es2019/vc/vc-observer/index.js +1 -3
  21. package/dist/es2019/vc/vc-observer/observers/index.js +2 -3
  22. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +3 -12
  23. package/dist/es2019/vc/vc-observer-new/index.js +2 -6
  24. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +6 -15
  25. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +19 -0
  26. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +55 -0
  27. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +21 -0
  28. package/dist/esm/create-payload/index.js +22 -4
  29. package/dist/esm/create-payload/utils/add-performance-measures.js +56 -0
  30. package/dist/esm/interaction-metrics/index.js +26 -2
  31. package/dist/esm/interaction-metrics-init/index.js +1 -2
  32. package/dist/esm/vc/index.js +7 -59
  33. package/dist/esm/vc/vc-observer/index.js +1 -3
  34. package/dist/esm/vc/vc-observer/observers/index.js +2 -3
  35. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +3 -13
  36. package/dist/esm/vc/vc-observer-new/index.js +2 -6
  37. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +6 -14
  38. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.js +19 -0
  39. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component.js +55 -0
  40. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.js +21 -0
  41. package/dist/types/config/index.d.ts +0 -4
  42. package/dist/types/create-payload/utils/add-performance-measures.d.ts +2 -0
  43. package/dist/types/ssr/index.d.ts +7 -1
  44. package/dist/types/vc/index.d.ts +0 -1
  45. package/dist/types/vc/types.d.ts +0 -4
  46. package/dist/types/vc/vc-observer/observers/index.d.ts +0 -4
  47. package/dist/types/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -7
  48. package/dist/types/vc/vc-observer-new/index.d.ts +0 -4
  49. package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +1 -0
  50. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.d.ts +1 -0
  51. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +4 -0
  52. package/dist/types/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.d.ts +1 -0
  53. package/dist/types-ts4.5/config/index.d.ts +0 -4
  54. package/dist/types-ts4.5/create-payload/utils/add-performance-measures.d.ts +2 -0
  55. package/dist/types-ts4.5/ssr/index.d.ts +7 -1
  56. package/dist/types-ts4.5/vc/index.d.ts +0 -1
  57. package/dist/types-ts4.5/vc/types.d.ts +0 -4
  58. package/dist/types-ts4.5/vc/vc-observer/observers/index.d.ts +0 -4
  59. package/dist/types-ts4.5/vc/vc-observer/observers/ssr-placeholders/index.d.ts +1 -7
  60. package/dist/types-ts4.5/vc/vc-observer-new/index.d.ts +0 -4
  61. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +1 -0
  62. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-fiber-within-component.d.ts +1 -0
  63. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component.d.ts +4 -0
  64. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/find-fiber-with-cache.d.ts +1 -0
  65. package/package.json +1 -1
  66. package/dist/cjs/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -69
  67. package/dist/es2019/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -60
  68. package/dist/esm/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.js +0 -62
  69. package/dist/types/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.d.ts +0 -8
  70. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/utils/check-within-component-and-extract-child-props.d.ts +0 -8
@@ -21,6 +21,7 @@ import { roundEpsilon } from '../round-number';
21
21
  import * as ssr from '../ssr';
22
22
  import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
23
23
  import { createCriticalMetricsPayloads } from './critical-metrics-payload';
24
+ import { addPerformanceMeasures } from './utils/add-performance-measures';
24
25
  import { getBrowserMetadataToLegacyFormat } from './utils/get-browser-metadata';
25
26
  import getInteractionStatus from './utils/get-interaction-status';
26
27
  import { getNavigationMetricsToLegacyFormat } from './utils/get-navigation-metrics';
@@ -186,7 +187,7 @@ function getPPSMetrics(interaction) {
186
187
  function getSSRProperties(type) {
187
188
  const ssrPhases = getSSRPhaseSuccess(type);
188
189
  return {
189
- 'ssr:success': getSSRSuccessUtil(type),
190
+ 'ssr:success': (ssrPhases === null || ssrPhases === void 0 ? void 0 : ssrPhases.done) != null ? ssrPhases.done : getSSRSuccessUtil(type),
190
191
  'ssr:featureFlags': getSSRFeatureFlags(type),
191
192
  ...((ssrPhases === null || ssrPhases === void 0 ? void 0 : ssrPhases.earlyFlush) != null ? {
192
193
  'ssr:earlyflush:success': ssrPhases.earlyFlush
@@ -622,10 +623,24 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
622
623
  const SSRDoneTime = SSRDoneTimeValue !== undefined ? {
623
624
  SSRDoneTime: Math.round(SSRDoneTimeValue)
624
625
  } : {};
626
+ const isBM3ConfigSSRDoneAsFmp = interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp;
627
+ const isUFOConfigSSRDoneAsFmp = interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime);
628
+ if (!experimental && (isBM3ConfigSSRDoneAsFmp || isUFOConfigSSRDoneAsFmp) && SSRDoneTimeValue !== undefined && fg('ufo_chrome_devtools_uplift')) {
629
+ try {
630
+ performance.mark(`FMP`, {
631
+ startTime: SSRDoneTimeValue,
632
+ detail: {
633
+ devtools: {
634
+ dataType: 'marker'
635
+ }
636
+ }
637
+ });
638
+ } catch (e) {}
639
+ }
625
640
  return {
626
641
  ...SSRDoneTime,
627
- isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
628
- isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
642
+ isBM3ConfigSSRDoneAsFmp,
643
+ isUFOConfigSSRDoneAsFmp
629
644
  };
630
645
  };
631
646
  const pageLoadInteractionMetrics = getInitialPageLoadSSRMetrics();
@@ -675,6 +690,9 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
675
690
  const newUFOName = sanitizeUfoName(ufoName);
676
691
  const resourceTimings = getResourceTimings(start, end);
677
692
  const [finalVCMetrics, experimentalMetrics, paintMetrics] = await Promise.all([vcMetrics || (await getVCMetrics(interaction)), experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined), getPaintMetricsToLegacyFormat(type, end)]);
693
+ if (!experimental) {
694
+ fg('ufo_chrome_devtools_uplift') && addPerformanceMeasures(interaction.start, [...((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || [])]);
695
+ }
678
696
  const payload = {
679
697
  actionSubject: 'experience',
680
698
  action: 'measured',
@@ -0,0 +1,54 @@
1
+ export const addPerformanceMeasures = (start, measures) => {
2
+ try {
3
+ measures.sort((a, b) => b.revision.localeCompare(a.revision)).slice(0, 2).forEach(entry => {
4
+ var _entry$vcDetails, _entry$vcDetails$;
5
+ if (((_entry$vcDetails = entry.vcDetails) === null || _entry$vcDetails === void 0 ? void 0 : (_entry$vcDetails$ = _entry$vcDetails['90']) === null || _entry$vcDetails$ === void 0 ? void 0 : _entry$vcDetails$.t) !== undefined) {
6
+ var _entry$vcDetails2, _entry$vcDetails2$;
7
+ performance.mark(`VC90 (${entry.revision})`, {
8
+ startTime: start + ((_entry$vcDetails2 = entry.vcDetails) === null || _entry$vcDetails2 === void 0 ? void 0 : (_entry$vcDetails2$ = _entry$vcDetails2['90']) === null || _entry$vcDetails2$ === void 0 ? void 0 : _entry$vcDetails2$.t),
9
+ detail: {
10
+ devtools: {
11
+ dataType: 'marker'
12
+ }
13
+ }
14
+ });
15
+ }
16
+ });
17
+ measures.forEach(entry => {
18
+ var _entry$vcDetails3, _entry$vcDetails3$;
19
+ if (!entry || !entry.vcDetails) {
20
+ return;
21
+ }
22
+ const VCParts = Object.keys(entry.vcDetails);
23
+ performance.measure(`VC90 (${entry.revision})`, {
24
+ start,
25
+ duration: (_entry$vcDetails3 = entry.vcDetails) === null || _entry$vcDetails3 === void 0 ? void 0 : (_entry$vcDetails3$ = _entry$vcDetails3['90']) === null || _entry$vcDetails3$ === void 0 ? void 0 : _entry$vcDetails3$.t,
26
+ detail: {
27
+ devtools: {
28
+ track: `main metrics`,
29
+ trackGroup: '🛸 reactUFO metrics',
30
+ color: 'tertiary'
31
+ }
32
+ }
33
+ });
34
+ VCParts.forEach(key => {
35
+ var _entry$vcDetails4;
36
+ const duration = (_entry$vcDetails4 = entry.vcDetails) === null || _entry$vcDetails4 === void 0 ? void 0 : _entry$vcDetails4[key].t;
37
+ if (typeof duration !== 'number') {
38
+ return;
39
+ }
40
+ performance.measure(`VC${key}`, {
41
+ start,
42
+ duration,
43
+ detail: {
44
+ devtools: {
45
+ track: `VC ${entry.revision}`,
46
+ trackGroup: '🛸 reactUFO metrics',
47
+ color: key === '90' ? 'tertiary' : 'primary-light'
48
+ }
49
+ }
50
+ });
51
+ });
52
+ });
53
+ } catch (error) {}
54
+ };
@@ -539,6 +539,7 @@ function finishInteraction(id, data, endTime = performance.now()) {
539
539
  data.end = endTime;
540
540
  try {
541
541
  // for Firefox 102 and older
542
+
542
543
  if (fg('ufo_chrome_devtools_uplift')) {
543
544
  performance.measure(`🛸 [${data.type}] ${data.ufoName} [ttai]`, {
544
545
  start: data.start,
@@ -551,6 +552,14 @@ function finishInteraction(id, data, endTime = performance.now()) {
551
552
  }
552
553
  }
553
554
  });
555
+ performance.mark(`TTAI`, {
556
+ startTime: data.end,
557
+ detail: {
558
+ devtools: {
559
+ dataType: 'marker'
560
+ }
561
+ }
562
+ });
554
563
  } else {
555
564
  performance.measure(`🛸 [${data.type}] ${data.ufoName} [ttai]`, {
556
565
  start: data.start,
@@ -800,8 +809,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
800
809
  oldDomUpdates: config.vc.oldDomUpdates,
801
810
  devToolsEnabled: config.vc.devToolsEnabled,
802
811
  selectorConfig: config.vc.selectorConfig,
803
- ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
804
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
812
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
805
813
  };
806
814
  vcObserver = newVCObserver(vcOptions);
807
815
  }
@@ -949,6 +957,14 @@ export function addApdexToAll(apdex) {
949
957
  }
950
958
  }
951
959
  });
960
+ performance.mark(`[bm3] TTI`, {
961
+ startTime: apdex.stopTime,
962
+ detail: {
963
+ devtools: {
964
+ dataType: 'marker'
965
+ }
966
+ }
967
+ });
952
968
  } else {
953
969
  var _apdex$startTime2;
954
970
  performance.measure(`🛸 ${apdex.key} [bm3_tti]`, {
@@ -983,6 +999,14 @@ export function addApdex(interactionId, apdexInfo) {
983
999
  }
984
1000
  }
985
1001
  });
1002
+ performance.mark(`[bm3] TTI`, {
1003
+ startTime: apdexInfo.stopTime,
1004
+ detail: {
1005
+ devtools: {
1006
+ dataType: 'marker'
1007
+ }
1008
+ }
1009
+ });
986
1010
  } else {
987
1011
  var _apdexInfo$startTime2;
988
1012
  performance.measure(`🛸 ${apdexInfo.key} [bm3_tti]`, {
@@ -85,8 +85,7 @@ 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,
89
- disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
88
+ ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder
90
89
  };
91
90
  postInteractionLog.initializeVCObserver(vcOptions);
92
91
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
@@ -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';
@@ -8,29 +7,21 @@ import { RLLPlaceholderHandlers } from './vc-observer/observers/rll-placeholders
8
7
  import { SSRPlaceholderHandlers } from './vc-observer/observers/ssr-placeholders';
9
8
  export class VCObserverWrapper {
10
9
  constructor(opts = {}) {
11
- var _opts$ssrEnablePageLa, _opts$disableSizeAndP;
10
+ var _opts$ssrEnablePageLa;
12
11
  this.newVCObserver = null;
13
12
  this.oldVCObserver = null;
14
13
 
15
14
  // Initialize SSR placeholder handler once
16
15
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
17
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false,
18
- disableSizeAndPositionCheck: (_opts$disableSizeAndP = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP !== void 0 ? _opts$disableSizeAndP : {
19
- v: false,
20
- h: false
21
- }
16
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa !== void 0 ? _opts$ssrEnablePageLa : false
22
17
  });
23
18
  if (isVCRevisionEnabled('fy25.03')) {
24
- var _opts$ssrEnablePageLa2, _opts$disableSizeAndP2;
19
+ var _opts$ssrEnablePageLa2;
25
20
  this.newVCObserver = new VCObserverNew({
26
21
  selectorConfig: opts.selectorConfig,
27
22
  isPostInteraction: opts.isPostInteraction,
28
23
  SSRConfig: {
29
- enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false,
30
- disableSizeAndPositionCheck: (_opts$disableSizeAndP2 = opts.disableSizeAndPositionCheck) !== null && _opts$disableSizeAndP2 !== void 0 ? _opts$disableSizeAndP2 : {
31
- v: false,
32
- h: false
33
- }
24
+ enablePageLayoutPlaceholder: (_opts$ssrEnablePageLa2 = opts.ssrEnablePageLayoutPlaceholder) !== null && _opts$ssrEnablePageLa2 !== void 0 ? _opts$ssrEnablePageLa2 : false
34
25
  },
35
26
  ssrPlaceholderHandler: this.ssrPlaceholderHandler
36
27
  });
@@ -112,7 +103,6 @@ export class VCObserverWrapper {
112
103
  interactionId: param.interactionId,
113
104
  ssr: param.includeSSRInV3 ? param.ssr : undefined
114
105
  })) : [];
115
- fg('ufo_chrome_devtools_uplift') && this.addPerformanceMeasures(param.start, [...((v1v2Result === null || v1v2Result === void 0 ? void 0 : v1v2Result['ufo:vc:rev']) || []), ...(v3Result !== null && v3Result !== void 0 ? v3Result : [])]);
116
106
  if (!v3Result) {
117
107
  return v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {};
118
108
  }
@@ -139,46 +129,6 @@ export class VCObserverWrapper {
139
129
  collectSSRPlaceholders() {
140
130
  this.ssrPlaceholderHandler.collectExistingPlaceholders();
141
131
  }
142
- addPerformanceMeasures(start, measures) {
143
- try {
144
- measures.forEach(entry => {
145
- var _entry$vcDetails, _entry$vcDetails$;
146
- if (!entry || !entry.vcDetails) {
147
- return;
148
- }
149
- const VCParts = Object.keys(entry.vcDetails);
150
- performance.measure(`VC90 (${entry.revision})`, {
151
- start,
152
- duration: (_entry$vcDetails = entry.vcDetails) === null || _entry$vcDetails === void 0 ? void 0 : (_entry$vcDetails$ = _entry$vcDetails['90']) === null || _entry$vcDetails$ === void 0 ? void 0 : _entry$vcDetails$.t,
153
- detail: {
154
- devtools: {
155
- track: `main metrics`,
156
- trackGroup: '🛸 reactUFO metrics',
157
- color: 'tertiary'
158
- }
159
- }
160
- });
161
- VCParts.forEach(key => {
162
- var _entry$vcDetails2;
163
- const duration = (_entry$vcDetails2 = entry.vcDetails) === null || _entry$vcDetails2 === void 0 ? void 0 : _entry$vcDetails2[key].t;
164
- if (typeof duration !== 'number') {
165
- return;
166
- }
167
- performance.measure(`VC${key}`, {
168
- start,
169
- duration,
170
- detail: {
171
- devtools: {
172
- track: `VC ${entry.revision}`,
173
- trackGroup: '🛸 reactUFO metrics',
174
- color: key === '90' ? 'tertiary' : 'primary-light'
175
- }
176
- }
177
- });
178
- });
179
- });
180
- } catch (error) {}
181
- }
182
132
  }
183
133
 
184
134
  // Some products set this variable to indicate it is running in SSR
@@ -501,7 +501,6 @@ export class VCObserver {
501
501
  this.oldDomUpdatesEnabled = options.oldDomUpdates || false;
502
502
  const {
503
503
  ssrEnablePageLayoutPlaceholder,
504
- disableSizeAndPositionCheck,
505
504
  ssrPlaceholderHandler
506
505
  } = options;
507
506
  this.observers = new Observers({
@@ -513,8 +512,7 @@ export class VCObserver {
513
512
  dataVC: true
514
513
  },
515
514
  SSRConfig: {
516
- enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false,
517
- disableSizeAndPositionCheck: disableSizeAndPositionCheck
515
+ enablePageLayoutPlaceholder: ssrEnablePageLayoutPlaceholder || false
518
516
  },
519
517
  ssrPlaceholderHandler: ssrPlaceholderHandler
520
518
  });
@@ -65,10 +65,9 @@ export class Observers {
65
65
  if (opts.ssrPlaceholderHandler) {
66
66
  this.ssrPlaceholderHandler = opts.ssrPlaceholderHandler;
67
67
  } else {
68
- var _opts$SSRConfig, _opts$SSRConfig2;
68
+ var _opts$SSRConfig;
69
69
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
70
- enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder,
71
- disableSizeAndPositionCheck: (_opts$SSRConfig2 = opts.SSRConfig) === null || _opts$SSRConfig2 === void 0 ? void 0 : _opts$SSRConfig2.disableSizeAndPositionCheck
70
+ enablePageLayoutPlaceholder: (_opts$SSRConfig = opts.SSRConfig) === null || _opts$SSRConfig === void 0 ? void 0 : _opts$SSRConfig.enablePageLayoutPlaceholder
72
71
  });
73
72
  }
74
73
  }
@@ -3,11 +3,7 @@ const ANCESTOR_LOOKUP_LIMIT = 10;
3
3
  const PAGE_LAYOUT_ID = 'page-layout.root';
4
4
  export class SSRPlaceholderHandlers {
5
5
  constructor({
6
- enablePageLayoutPlaceholder = false,
7
- disableSizeAndPositionCheck = {
8
- v: false,
9
- h: false
10
- }
6
+ enablePageLayoutPlaceholder = false
11
7
  }) {
12
8
  _defineProperty(this, "staticPlaceholders", new Map());
13
9
  _defineProperty(this, "callbacks", new Map());
@@ -93,7 +89,6 @@ export class SSRPlaceholderHandlers {
93
89
  this.intersectionObserver = new IntersectionObserver(entries => entries.filter(entry => entry.intersectionRatio > 0).forEach(this.intersectionObserverCallback));
94
90
  }
95
91
  this.enablePageLayoutPlaceholder = enablePageLayoutPlaceholder;
96
- this.disableSizeAndPositionCheck = disableSizeAndPositionCheck;
97
92
  if (window.document) {
98
93
  try {
99
94
  // Collect initial placeholders using SSR dimensions
@@ -225,15 +220,11 @@ export class SSRPlaceholderHandlers {
225
220
  });
226
221
  }
227
222
  hasSameSizePosition(rect, boundingClientRect) {
228
- var _this$disableSizeAndP, _this$disableSizeAndP2;
229
- 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) {
230
- return true;
231
- }
232
223
  if (!rect) {
233
224
  return false;
234
225
  }
235
- const horizontalCheck = this.disableSizeAndPositionCheck.h ? true : Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
236
- const verticalCheck = this.disableSizeAndPositionCheck.v ? true : Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
226
+ const horizontalCheck = Math.abs(rect.x - boundingClientRect.x) < this.EQUALITY_THRESHOLD && Math.abs(rect.width - boundingClientRect.width) < this.EQUALITY_THRESHOLD;
227
+ const verticalCheck = Math.abs(rect.y - boundingClientRect.y) < this.EQUALITY_THRESHOLD && Math.abs(rect.height - boundingClientRect.height) < this.EQUALITY_THRESHOLD;
237
228
  return horizontalCheck && verticalCheck || false;
238
229
  }
239
230
  isDummyRect(rect) {
@@ -40,13 +40,9 @@ export default class VCObserverNew {
40
40
  if (config.ssrPlaceholderHandler) {
41
41
  this.ssrPlaceholderHandler = config.ssrPlaceholderHandler;
42
42
  } else {
43
- var _config$SSRConfig$ena, _config$SSRConfig, _config$SSRConfig$dis, _config$SSRConfig2;
43
+ var _config$SSRConfig$ena, _config$SSRConfig;
44
44
  this.ssrPlaceholderHandler = new SSRPlaceholderHandlers({
45
- enablePageLayoutPlaceholder: (_config$SSRConfig$ena = (_config$SSRConfig = config.SSRConfig) === null || _config$SSRConfig === void 0 ? void 0 : _config$SSRConfig.enablePageLayoutPlaceholder) !== null && _config$SSRConfig$ena !== void 0 ? _config$SSRConfig$ena : false,
46
- disableSizeAndPositionCheck: (_config$SSRConfig$dis = (_config$SSRConfig2 = config.SSRConfig) === null || _config$SSRConfig2 === void 0 ? void 0 : _config$SSRConfig2.disableSizeAndPositionCheck) !== null && _config$SSRConfig$dis !== void 0 ? _config$SSRConfig$dis : {
47
- v: false,
48
- h: false
49
- }
45
+ enablePageLayoutPlaceholder: (_config$SSRConfig$ena = (_config$SSRConfig = config.SSRConfig) === null || _config$SSRConfig === void 0 ? void 0 : _config$SSRConfig.enablePageLayoutPlaceholder) !== null && _config$SSRConfig$ena !== void 0 ? _config$SSRConfig$ena : false
50
46
  });
51
47
  }
52
48
  this.viewportObserver = new ViewportObserver({
@@ -5,7 +5,7 @@ import { RLLPlaceholderHandlers } from '../../vc-observer/observers/rll-placehol
5
5
  import { createIntersectionObserver } from './intersection-observer';
6
6
  import createMutationObserver from './mutation-observer';
7
7
  import createPerformanceObserver from './performance-observer';
8
- import checkWithinComponentAndExtractChildProps from './utils/check-within-component-and-extract-child-props';
8
+ import checkWithinComponent, { cleanupCaches } from './utils/check-within-component';
9
9
  import isInVCIgnoreIfNoLayoutShiftMarker from './utils/is-in-vc-ignore-if-no-layout-shift-marker';
10
10
  function isElementVisible(element) {
11
11
  if (!(element instanceof HTMLElement)) {
@@ -179,7 +179,7 @@ export default class ViewportObserver {
179
179
  }
180
180
  const {
181
181
  isWithin: isWithinThirdPartySegment
182
- } = checkWithinComponentAndExtractChildProps(addedNode, 'UFOThirdPartySegment');
182
+ } = checkWithinComponent(addedNode, 'UFOThirdPartySegment', this.mapIs3pResult);
183
183
  if (isWithinThirdPartySegment) {
184
184
  var _this$intersectionObs7;
185
185
  (_this$intersectionObs7 = this.intersectionObserver) === null || _this$intersectionObs7 === void 0 ? void 0 : _this$intersectionObs7.watchAndTag(addedNode, 'mutation:third-party-element');
@@ -234,19 +234,6 @@ export default class ViewportObserver {
234
234
  }
235
235
  };
236
236
  }
237
- const {
238
- isWithin: isWithinThirdPartySegment
239
- } = checkWithinComponentAndExtractChildProps(target, 'UFOThirdPartySegment');
240
- if (isWithinThirdPartySegment) {
241
- return {
242
- type: 'mutation:third-party-element',
243
- mutationData: {
244
- attributeName,
245
- oldValue,
246
- newValue
247
- }
248
- };
249
- }
250
237
  const lastElementRect = this.mapVisibleNodeRects.get(target);
251
238
  if (lastElementRect && sameRectSize(rect, lastElementRect)) {
252
239
  return {
@@ -267,6 +254,7 @@ export default class ViewportObserver {
267
254
  }
268
255
  };
269
256
  });
257
+ // }
270
258
  });
271
259
  _defineProperty(this, "handleLayoutShift", ({
272
260
  time,
@@ -287,6 +275,7 @@ export default class ViewportObserver {
287
275
  }
288
276
  });
289
277
  this.mapVisibleNodeRects = new WeakMap();
278
+ this.mapIs3pResult = new WeakMap();
290
279
  this.onChange = onChange;
291
280
  this.isStarted = false;
292
281
  this.intersectionObserver = null;
@@ -341,5 +330,7 @@ export default class ViewportObserver {
341
330
  (_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 ? void 0 : _this$intersectionObs0.disconnect();
342
331
  (_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 ? void 0 : _this$performanceObse2.disconnect();
343
332
  this.isStarted = false;
333
+ // Clean up caches when stopping
334
+ cleanupCaches(this.mapIs3pResult);
344
335
  }
345
336
  }
@@ -0,0 +1,19 @@
1
+ import getComponentName from './get-component-name';
2
+
3
+ // Helper to check fiber within component
4
+ export default function checkFiberWithinComponent(fiber, targetComponentName, maxLevel) {
5
+ // Stop when no more levels to traverse
6
+ if (maxLevel <= 0) {
7
+ return false;
8
+ }
9
+ if (!fiber) {
10
+ return false;
11
+ }
12
+ const componentName = getComponentName(fiber);
13
+ if (componentName === targetComponentName) {
14
+ return true;
15
+ }
16
+
17
+ // Recursively traverse up the fiber tree
18
+ return checkFiberWithinComponent(fiber.return, targetComponentName, maxLevel - 1);
19
+ }
@@ -0,0 +1,55 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import coinflip from '../../../../coinflip';
3
+ import checkFiberWithinComponent from './check-fiber-within-component';
4
+ import findFiberWithCache from './find-fiber-with-cache';
5
+ import findReactFiber from './find-react-fiber';
6
+ const DEFAULT_MAX_LEVEL = 20;
7
+
8
+ // Cache cleanup
9
+ let callCount = 0;
10
+ const CLEANUP_THRESHOLD = 50;
11
+ function maybeCleanup(resultCache) {
12
+ callCount++;
13
+ if (callCount >= CLEANUP_THRESHOLD && coinflip(0.3)) {
14
+ cleanupCaches(resultCache);
15
+ }
16
+ }
17
+ export function cleanupCaches(resultCache) {
18
+ resultCache = new WeakMap();
19
+ callCount = 0;
20
+ }
21
+ export default function checkWithinComponent(node, targetComponentName, resultCache) {
22
+ maybeCleanup(resultCache);
23
+ if (resultCache.has(node)) {
24
+ var _resultCache$get;
25
+ return {
26
+ isWithin: (_resultCache$get = resultCache.get(node)) !== null && _resultCache$get !== void 0 ? _resultCache$get : false
27
+ };
28
+ }
29
+ let fiber = null;
30
+ let checkedNodes = [];
31
+ if (fg('platform_ufo_handle_non_react_element_for_3p')) {
32
+ fiber = findFiberWithCache(node, DEFAULT_MAX_LEVEL, checkedNodes);
33
+ } else {
34
+ fiber = findReactFiber(node);
35
+ }
36
+ if (!fiber) {
37
+ if (fg('platform_ufo_handle_non_react_element_for_3p')) {
38
+ checkedNodes.forEach(checkedNode => {
39
+ resultCache.set(checkedNode, false);
40
+ });
41
+ }
42
+ return {
43
+ isWithin: false
44
+ };
45
+ }
46
+ const isWithin = checkFiberWithinComponent(fiber, targetComponentName, DEFAULT_MAX_LEVEL);
47
+ if (fg('platform_ufo_handle_non_react_element_for_3p')) {
48
+ checkedNodes.forEach(checkedNode => {
49
+ resultCache.set(checkedNode, isWithin);
50
+ });
51
+ }
52
+ return {
53
+ isWithin
54
+ };
55
+ }
@@ -0,0 +1,21 @@
1
+ import findReactFiber from './find-react-fiber';
2
+ export default function findFiberWithCache(element, maxLevel, checkedNodes) {
3
+ // Stop when no more levels to traverse
4
+ if (maxLevel <= 0) {
5
+ return null;
6
+ }
7
+ checkedNodes.push(element);
8
+ const fiber = findReactFiber(element);
9
+ if (fiber) {
10
+ return fiber;
11
+ }
12
+
13
+ // Walk up the DOM tree to find the fiber
14
+ const parent = element.parentElement;
15
+ if (!parent) {
16
+ return null;
17
+ }
18
+
19
+ // Recursively check parent
20
+ return findFiberWithCache(parent, maxLevel - 1, checkedNodes);
21
+ }
@@ -33,6 +33,7 @@ import { roundEpsilon } from '../round-number';
33
33
  import * as ssr from '../ssr';
34
34
  import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
35
35
  import { createCriticalMetricsPayloads } from './critical-metrics-payload';
36
+ import { addPerformanceMeasures } from './utils/add-performance-measures';
36
37
  import { getBrowserMetadataToLegacyFormat } from './utils/get-browser-metadata';
37
38
  import getInteractionStatus from './utils/get-interaction-status';
38
39
  import { getNavigationMetricsToLegacyFormat } from './utils/get-navigation-metrics';
@@ -194,7 +195,7 @@ function getPPSMetrics(interaction) {
194
195
  function getSSRProperties(type) {
195
196
  var ssrPhases = getSSRPhaseSuccess(type);
196
197
  return _objectSpread(_objectSpread({
197
- 'ssr:success': getSSRSuccessUtil(type),
198
+ 'ssr:success': (ssrPhases === null || ssrPhases === void 0 ? void 0 : ssrPhases.done) != null ? ssrPhases.done : getSSRSuccessUtil(type),
198
199
  'ssr:featureFlags': getSSRFeatureFlags(type)
199
200
  }, (ssrPhases === null || ssrPhases === void 0 ? void 0 : ssrPhases.earlyFlush) != null ? {
200
201
  'ssr:earlyflush:success': ssrPhases.earlyFlush
@@ -612,9 +613,23 @@ function _createInteractionMetricsPayload() {
612
613
  var SSRDoneTime = SSRDoneTimeValue !== undefined ? {
613
614
  SSRDoneTime: Math.round(SSRDoneTimeValue)
614
615
  } : {};
616
+ var isBM3ConfigSSRDoneAsFmp = interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp;
617
+ var isUFOConfigSSRDoneAsFmp = interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime);
618
+ if (!experimental && (isBM3ConfigSSRDoneAsFmp || isUFOConfigSSRDoneAsFmp) && SSRDoneTimeValue !== undefined && fg('ufo_chrome_devtools_uplift')) {
619
+ try {
620
+ performance.mark("FMP", {
621
+ startTime: SSRDoneTimeValue,
622
+ detail: {
623
+ devtools: {
624
+ dataType: 'marker'
625
+ }
626
+ }
627
+ });
628
+ } catch (e) {}
629
+ }
615
630
  return _objectSpread(_objectSpread({}, SSRDoneTime), {}, {
616
- isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
617
- isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
631
+ isBM3ConfigSSRDoneAsFmp: isBM3ConfigSSRDoneAsFmp,
632
+ isUFOConfigSSRDoneAsFmp: isUFOConfigSSRDoneAsFmp
618
633
  });
619
634
  };
620
635
  pageLoadInteractionMetrics = getInitialPageLoadSSRMetrics(); // Detailed payload. Page visibility = visible
@@ -683,6 +698,9 @@ function _createInteractionMetricsPayload() {
683
698
  finalVCMetrics = _yield$Promise$all2[0];
684
699
  experimentalMetrics = _yield$Promise$all2[1];
685
700
  paintMetrics = _yield$Promise$all2[2];
701
+ if (!experimental) {
702
+ fg('ufo_chrome_devtools_uplift') && addPerformanceMeasures(interaction.start, _toConsumableArray((finalVCMetrics === null || finalVCMetrics === void 0 ? void 0 : finalVCMetrics['ufo:vc:rev']) || []));
703
+ }
686
704
  payload = {
687
705
  actionSubject: 'experience',
688
706
  action: 'measured',
@@ -761,7 +779,7 @@ function _createInteractionMetricsPayload() {
761
779
  }
762
780
  payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
763
781
  return _context.abrupt("return", payload);
764
- case 43:
782
+ case 44:
765
783
  case "end":
766
784
  return _context.stop();
767
785
  }
@@ -0,0 +1,56 @@
1
+ export var addPerformanceMeasures = function addPerformanceMeasures(start, measures) {
2
+ try {
3
+ measures.sort(function (a, b) {
4
+ return b.revision.localeCompare(a.revision);
5
+ }).slice(0, 2).forEach(function (entry) {
6
+ var _entry$vcDetails;
7
+ if (((_entry$vcDetails = entry.vcDetails) === null || _entry$vcDetails === void 0 || (_entry$vcDetails = _entry$vcDetails['90']) === null || _entry$vcDetails === void 0 ? void 0 : _entry$vcDetails.t) !== undefined) {
8
+ var _entry$vcDetails2;
9
+ performance.mark("VC90 (".concat(entry.revision, ")"), {
10
+ startTime: start + ((_entry$vcDetails2 = entry.vcDetails) === null || _entry$vcDetails2 === void 0 || (_entry$vcDetails2 = _entry$vcDetails2['90']) === null || _entry$vcDetails2 === void 0 ? void 0 : _entry$vcDetails2.t),
11
+ detail: {
12
+ devtools: {
13
+ dataType: 'marker'
14
+ }
15
+ }
16
+ });
17
+ }
18
+ });
19
+ measures.forEach(function (entry) {
20
+ var _entry$vcDetails3;
21
+ if (!entry || !entry.vcDetails) {
22
+ return;
23
+ }
24
+ var VCParts = Object.keys(entry.vcDetails);
25
+ performance.measure("VC90 (".concat(entry.revision, ")"), {
26
+ start: start,
27
+ duration: (_entry$vcDetails3 = entry.vcDetails) === null || _entry$vcDetails3 === void 0 || (_entry$vcDetails3 = _entry$vcDetails3['90']) === null || _entry$vcDetails3 === void 0 ? void 0 : _entry$vcDetails3.t,
28
+ detail: {
29
+ devtools: {
30
+ track: "main metrics",
31
+ trackGroup: '🛸 reactUFO metrics',
32
+ color: 'tertiary'
33
+ }
34
+ }
35
+ });
36
+ VCParts.forEach(function (key) {
37
+ var _entry$vcDetails4;
38
+ var duration = (_entry$vcDetails4 = entry.vcDetails) === null || _entry$vcDetails4 === void 0 ? void 0 : _entry$vcDetails4[key].t;
39
+ if (typeof duration !== 'number') {
40
+ return;
41
+ }
42
+ performance.measure("VC".concat(key), {
43
+ start: start,
44
+ duration: duration,
45
+ detail: {
46
+ devtools: {
47
+ track: "VC ".concat(entry.revision),
48
+ trackGroup: '🛸 reactUFO metrics',
49
+ color: key === '90' ? 'tertiary' : 'primary-light'
50
+ }
51
+ }
52
+ });
53
+ });
54
+ });
55
+ } catch (error) {}
56
+ };