@atlaskit/react-ufo 4.7.0 → 4.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/create-interaction-extra-metrics-payload/index.js +82 -15
  3. package/dist/cjs/create-payload/index.js +26 -218
  4. package/dist/cjs/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.js +20 -0
  5. package/dist/cjs/create-payload/utils/get-visibility-state-from-performance.js +35 -0
  6. package/dist/cjs/create-payload/utils/optimize-apdex.js +25 -0
  7. package/dist/cjs/create-payload/utils/optimize-custom-timings.js +22 -0
  8. package/dist/cjs/create-payload/utils/optimize-hold-info.js +41 -0
  9. package/dist/cjs/create-payload/utils/optimize-marks.js +24 -0
  10. package/dist/cjs/create-payload/utils/optimize-react-profiler-timings.js +53 -0
  11. package/dist/cjs/create-payload/utils/optimize-request-info.js +32 -0
  12. package/dist/cjs/create-payload/utils/optimize-spans.js +30 -0
  13. package/dist/cjs/interaction-metrics-init/index.js +1 -1
  14. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +2 -2
  15. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +4 -6
  16. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +30 -48
  17. package/dist/es2019/create-interaction-extra-metrics-payload/index.js +62 -9
  18. package/dist/es2019/create-payload/index.js +10 -205
  19. package/dist/es2019/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.js +13 -0
  20. package/dist/es2019/create-payload/utils/get-visibility-state-from-performance.js +28 -0
  21. package/dist/es2019/create-payload/utils/optimize-apdex.js +14 -0
  22. package/dist/es2019/create-payload/utils/optimize-custom-timings.js +16 -0
  23. package/dist/es2019/create-payload/utils/optimize-hold-info.js +35 -0
  24. package/dist/es2019/create-payload/utils/optimize-marks.js +12 -0
  25. package/dist/es2019/create-payload/utils/optimize-react-profiler-timings.js +46 -0
  26. package/dist/es2019/create-payload/utils/optimize-request-info.js +26 -0
  27. package/dist/es2019/create-payload/utils/optimize-spans.js +24 -0
  28. package/dist/es2019/interaction-metrics-init/index.js +1 -1
  29. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +2 -2
  30. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +9 -13
  31. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +20 -29
  32. package/dist/esm/create-interaction-extra-metrics-payload/index.js +83 -16
  33. package/dist/esm/create-payload/index.js +18 -208
  34. package/dist/esm/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.js +13 -0
  35. package/dist/esm/create-payload/utils/get-visibility-state-from-performance.js +29 -0
  36. package/dist/esm/create-payload/utils/optimize-apdex.js +18 -0
  37. package/dist/esm/create-payload/utils/optimize-custom-timings.js +16 -0
  38. package/dist/esm/create-payload/utils/optimize-hold-info.js +34 -0
  39. package/dist/esm/create-payload/utils/optimize-marks.js +17 -0
  40. package/dist/esm/create-payload/utils/optimize-react-profiler-timings.js +46 -0
  41. package/dist/esm/create-payload/utils/optimize-request-info.js +25 -0
  42. package/dist/esm/create-payload/utils/optimize-spans.js +23 -0
  43. package/dist/esm/interaction-metrics-init/index.js +1 -1
  44. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +2 -2
  45. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +4 -6
  46. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +30 -48
  47. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +56 -0
  48. package/dist/types/create-payload/index.d.ts +0 -3
  49. package/dist/types/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.d.ts +2 -0
  50. package/dist/types/create-payload/utils/get-visibility-state-from-performance.d.ts +1 -0
  51. package/dist/types/create-payload/utils/optimize-apdex.d.ts +12 -0
  52. package/dist/types/create-payload/utils/optimize-custom-timings.d.ts +7 -0
  53. package/dist/types/create-payload/utils/optimize-hold-info.d.ts +3 -0
  54. package/dist/types/create-payload/utils/optimize-marks.d.ts +12 -0
  55. package/dist/types/create-payload/utils/optimize-react-profiler-timings.d.ts +3 -0
  56. package/dist/types/create-payload/utils/optimize-request-info.d.ts +8 -0
  57. package/dist/types/create-payload/utils/optimize-spans.d.ts +9 -0
  58. package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +56 -0
  59. package/dist/types-ts4.5/create-payload/index.d.ts +0 -3
  60. package/dist/types-ts4.5/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.d.ts +2 -0
  61. package/dist/types-ts4.5/create-payload/utils/get-visibility-state-from-performance.d.ts +1 -0
  62. package/dist/types-ts4.5/create-payload/utils/optimize-apdex.d.ts +12 -0
  63. package/dist/types-ts4.5/create-payload/utils/optimize-custom-timings.d.ts +7 -0
  64. package/dist/types-ts4.5/create-payload/utils/optimize-hold-info.d.ts +3 -0
  65. package/dist/types-ts4.5/create-payload/utils/optimize-marks.d.ts +12 -0
  66. package/dist/types-ts4.5/create-payload/utils/optimize-react-profiler-timings.d.ts +3 -0
  67. package/dist/types-ts4.5/create-payload/utils/optimize-request-info.d.ts +8 -0
  68. package/dist/types-ts4.5/create-payload/utils/optimize-spans.d.ts +9 -0
  69. package/package.json +1 -7
@@ -13,7 +13,7 @@ import { getBm3Timings } from '../custom-timings';
13
13
  import { getGlobalErrorCount } from '../global-error-handler';
14
14
  import { getPageVisibilityState } from '../hidden-timing';
15
15
  import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
16
- import { interactionSpans as atlaskitInteractionSpans, segmentUnmountCache } from '../interaction-metrics';
16
+ import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
17
17
  import { createMemoryStateReport, createPressureStateReport } from '../machine-utilisation';
18
18
  import * as resourceTiming from '../resource-timing';
19
19
  import { filterResourceTimings } from '../resource-timing/common/utils/resource-timing-buffer';
@@ -24,6 +24,7 @@ import { createCriticalMetricsPayloads } from './critical-metrics-payload';
24
24
  import { addPerformanceMeasures } from './utils/add-performance-measures';
25
25
  import { getBrowserMetadataToLegacyFormat } from './utils/get-browser-metadata';
26
26
  import getInteractionStatus from './utils/get-interaction-status';
27
+ import { getMoreAccuratePageVisibilityUpToTTAI } from './utils/get-more-accurate-page-visibility-up-to-ttai';
27
28
  import { getNavigationMetricsToLegacyFormat } from './utils/get-navigation-metrics';
28
29
  import getPageVisibilityUpToTTAI from './utils/get-page-visibility-up-to-ttai';
29
30
  import { getPaintMetricsToLegacyFormat } from './utils/get-paint-metrics';
@@ -33,6 +34,14 @@ import getSSRDoneTimeValue from './utils/get-ssr-done-time-value';
33
34
  import getSSRSuccessUtil from './utils/get-ssr-success';
34
35
  import getTTAI from './utils/get-ttai';
35
36
  import getVCMetrics from './utils/get-vc-metrics';
37
+ import { getVisibilityStateFromPerformance } from './utils/get-visibility-state-from-performance';
38
+ import { optimizeApdex } from './utils/optimize-apdex';
39
+ import { optimizeCustomTimings } from './utils/optimize-custom-timings';
40
+ import { optimizeHoldInfo } from './utils/optimize-hold-info';
41
+ import { optimizeMarks } from './utils/optimize-marks';
42
+ import { optimizeReactProfilerTimings } from './utils/optimize-react-profiler-timings';
43
+ import { optimizeRequestInfo } from './utils/optimize-request-info';
44
+ import { optimizeSpans } from './utils/optimize-spans';
36
45
  function getUfoNameOverride(interaction) {
37
46
  const {
38
47
  ufoName,
@@ -81,34 +90,6 @@ function getPageVisibilityUpToTTI(interaction) {
81
90
  const bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
82
91
  return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
83
92
  }
84
- function getVisibilityStateFromPerformance(stop) {
85
- try {
86
- const results = performance.getEntriesByType('visibility-state');
87
- if (!results || results.length === 0) {
88
- return null;
89
- }
90
- return results.reduce((acc = null, {
91
- name,
92
- startTime
93
- }) => {
94
- if (startTime > stop) {
95
- return acc;
96
- }
97
- if (acc === null && name === null) {
98
- return null;
99
- }
100
- if (acc === null) {
101
- return name;
102
- }
103
- if (acc !== name) {
104
- return 'mixed';
105
- }
106
- return acc;
107
- }, null);
108
- } catch (e) {
109
- return null;
110
- }
111
- }
112
93
  function getMoreAccuratePageVisibilityUpToTTI(interaction) {
113
94
  const old = getPageVisibilityUpToTTI(interaction);
114
95
  const tti = getEarliestLegacyStopTime(interaction, []);
@@ -124,17 +105,6 @@ function getMoreAccuratePageVisibilityUpToTTI(interaction) {
124
105
  }
125
106
  return old;
126
107
  }
127
- export function getMoreAccuratePageVisibilityUpToTTAI(interaction) {
128
- const old = getPageVisibilityUpToTTAI(interaction);
129
- const buffered = getVisibilityStateFromPerformance(interaction.end);
130
- if (!buffered) {
131
- return old;
132
- }
133
- if (buffered !== old) {
134
- return 'mixed';
135
- }
136
- return old;
137
- }
138
108
  function getResourceTimings(start, end) {
139
109
  var _resourceTiming$getRe;
140
110
  return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
@@ -291,49 +261,6 @@ function optimizeCustomData(interaction) {
291
261
  }
292
262
  return [...customDataMap.values()];
293
263
  }
294
- function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
295
- const reactProfilerTimingsMap = reactProfilerTimings.reduce((result, {
296
- labelStack,
297
- startTime,
298
- commitTime,
299
- actualDuration,
300
- type
301
- }) => {
302
- if (labelStack && startTime >= interactionStart) {
303
- const label = stringifyLabelStackFully(labelStack);
304
- const start = Math.round(startTime);
305
- const end = Math.round(commitTime);
306
- const timing = result.get(label) || {
307
- labelStack: optimizeLabelStack(labelStack, reactUFOVersion),
308
- startTime: start,
309
- endTime: end,
310
- mountCount: 0,
311
- rerenderCount: 0,
312
- renderDuration: 0
313
- };
314
- if (start < timing.startTime) {
315
- timing.startTime = start;
316
- }
317
- if (end > timing.endTime) {
318
- timing.endTime = end;
319
- }
320
- if (type === 'mount') {
321
- timing.mountCount += 1;
322
- }
323
- if (type === 'update') {
324
- timing.rerenderCount += 1;
325
- }
326
- if (segmentUnmountCache.has(label) && fg('platform_ufo_segment_unmount_count')) {
327
- timing.unmountCount = segmentUnmountCache.get(label) || 0;
328
- segmentUnmountCache.delete(label);
329
- }
330
- timing.renderDuration += Math.round(actualDuration);
331
- result.set(label, timing);
332
- }
333
- return result;
334
- }, new Map());
335
- return [...reactProfilerTimingsMap.values()];
336
- }
337
264
  function optimizeRedirects(redirects, interactionStart) {
338
265
  let lastRedirectTime = interactionStart;
339
266
  const updatedRedirects = redirects.sort((a, b) => a.time - b.time).reduce((result, redirect) => {
@@ -355,128 +282,6 @@ function optimizeRedirects(redirects, interactionStart) {
355
282
  }, []);
356
283
  return updatedRedirects;
357
284
  }
358
- export function optimizeHoldInfo(holdInfo, interactionStart, reactUFOVersion) {
359
- const holdInfoMap = holdInfo.reduce((result, hold) => {
360
- const {
361
- labelStack,
362
- name,
363
- start,
364
- end,
365
- ignoreOnSubmit
366
- } = hold;
367
- if (labelStack && !ignoreOnSubmit && start >= interactionStart) {
368
- const label = stringifyLabelStackFully([...labelStack, {
369
- name
370
- }]);
371
- const startTime = Math.round(start);
372
- const endTime = Math.round(end);
373
- const timing = result.get(label) || {
374
- labelStack: optimizeLabelStack([...labelStack, {
375
- name
376
- }], reactUFOVersion),
377
- startTime,
378
- endTime
379
- };
380
- if (startTime < timing.startTime) {
381
- timing.startTime = startTime;
382
- }
383
- if (endTime > timing.endTime) {
384
- timing.endTime = endTime;
385
- }
386
- result.set(label, timing);
387
- }
388
- return result;
389
- }, new Map());
390
- return [...holdInfoMap.values()];
391
- }
392
- function optimizeSpans(spans, interactionStart, reactUFOVersion) {
393
- const updatedSpans = spans.reduce((result, span) => {
394
- const {
395
- labelStack,
396
- type,
397
- name,
398
- start,
399
- end
400
- } = span;
401
- if (labelStack && start >= interactionStart) {
402
- result.push({
403
- labelStack: optimizeLabelStack([...labelStack, {
404
- name
405
- }], reactUFOVersion),
406
- startTime: Math.round(start),
407
- endTime: Math.round(end),
408
- type
409
- });
410
- }
411
- return result;
412
- }, []);
413
- return updatedSpans;
414
- }
415
- function optimizeRequestInfo(requestInfo, interactionStart, reactUFOVersion) {
416
- const updatedRequestInfo = requestInfo.reduce((result, reqInfo) => {
417
- const {
418
- labelStack,
419
- name,
420
- start,
421
- end,
422
- networkStart,
423
- networkComplete
424
- } = reqInfo;
425
- const startTime = networkStart !== null && networkStart !== void 0 ? networkStart : start;
426
- const endTime = networkComplete !== null && networkComplete !== void 0 ? networkComplete : end;
427
- if (labelStack && start >= interactionStart && endTime) {
428
- result.push({
429
- labelStack: optimizeLabelStack([...labelStack, {
430
- name
431
- }], reactUFOVersion),
432
- startTime: Math.round(startTime),
433
- endTime: Math.round(endTime)
434
- });
435
- }
436
- return result;
437
- }, []);
438
- return updatedRequestInfo;
439
- }
440
- function optimizeCustomTimings(customTimings, interactionStart) {
441
- return customTimings.reduce((result, item) => {
442
- Object.keys(item.data).forEach(key => {
443
- if (item.data[key].startTime >= interactionStart) {
444
- result.push({
445
- labelStack: [{
446
- n: key
447
- }],
448
- startTime: Math.round(item.data[key].startTime),
449
- endTime: Math.round(item.data[key].endTime)
450
- });
451
- }
452
- });
453
- return result;
454
- }, []);
455
- }
456
- function optimizeMarks(marks, reactUFOVersion) {
457
- return marks.map(({
458
- labelStack,
459
- time,
460
- ...others
461
- }) => ({
462
- ...others,
463
- labelStack: labelStack && optimizeLabelStack(labelStack, reactUFOVersion),
464
- time: Math.round(time)
465
- }));
466
- }
467
- function optimizeApdex(apdex, reactUFOVersion) {
468
- return apdex.map(({
469
- stopTime,
470
- labelStack,
471
- ...others
472
- }) => ({
473
- ...others,
474
- stopTime: Math.round(stopTime),
475
- ...(labelStack ? {
476
- labelStack: optimizeLabelStack(labelStack, reactUFOVersion)
477
- } : {})
478
- }));
479
- }
480
285
  function objectToArray(obj = {}) {
481
286
  return Object.keys(obj).reduce((result, key) => {
482
287
  result.push({
@@ -0,0 +1,13 @@
1
+ import getPageVisibilityUpToTTAI from './get-page-visibility-up-to-ttai';
2
+ import { getVisibilityStateFromPerformance } from './get-visibility-state-from-performance';
3
+ export function getMoreAccuratePageVisibilityUpToTTAI(interaction) {
4
+ const old = getPageVisibilityUpToTTAI(interaction);
5
+ const buffered = getVisibilityStateFromPerformance(interaction.end);
6
+ if (!buffered) {
7
+ return old;
8
+ }
9
+ if (buffered !== old) {
10
+ return 'mixed';
11
+ }
12
+ return old;
13
+ }
@@ -0,0 +1,28 @@
1
+ export function getVisibilityStateFromPerformance(stop) {
2
+ try {
3
+ const results = performance.getEntriesByType('visibility-state');
4
+ if (!results || results.length === 0) {
5
+ return null;
6
+ }
7
+ return results.reduce((acc = null, {
8
+ name,
9
+ startTime
10
+ }) => {
11
+ if (startTime > stop) {
12
+ return acc;
13
+ }
14
+ if (acc === null && name === null) {
15
+ return null;
16
+ }
17
+ if (acc === null) {
18
+ return name;
19
+ }
20
+ if (acc !== name) {
21
+ return 'mixed';
22
+ }
23
+ return acc;
24
+ }, null);
25
+ } catch (e) {
26
+ return null;
27
+ }
28
+ }
@@ -0,0 +1,14 @@
1
+ import { optimizeLabelStack } from '../common/utils';
2
+ export function optimizeApdex(apdex, reactUFOVersion) {
3
+ return apdex.map(({
4
+ stopTime,
5
+ labelStack,
6
+ ...others
7
+ }) => ({
8
+ ...others,
9
+ stopTime: Math.round(stopTime),
10
+ ...(labelStack ? {
11
+ labelStack: optimizeLabelStack(labelStack, reactUFOVersion)
12
+ } : {})
13
+ }));
14
+ }
@@ -0,0 +1,16 @@
1
+ export function optimizeCustomTimings(customTimings, interactionStart) {
2
+ return customTimings.reduce((result, item) => {
3
+ Object.keys(item.data).forEach(key => {
4
+ if (item.data[key].startTime >= interactionStart) {
5
+ result.push({
6
+ labelStack: [{
7
+ n: key
8
+ }],
9
+ startTime: Math.round(item.data[key].startTime),
10
+ endTime: Math.round(item.data[key].endTime)
11
+ });
12
+ }
13
+ });
14
+ return result;
15
+ }, []);
16
+ }
@@ -0,0 +1,35 @@
1
+ import { optimizeLabelStack, stringifyLabelStackFully } from '../common/utils';
2
+ export function optimizeHoldInfo(holdInfo, interactionStart, reactUFOVersion) {
3
+ const holdInfoMap = holdInfo.reduce((result, hold) => {
4
+ const {
5
+ labelStack,
6
+ name,
7
+ start,
8
+ end,
9
+ ignoreOnSubmit
10
+ } = hold;
11
+ if (labelStack && !ignoreOnSubmit && start >= interactionStart) {
12
+ const label = stringifyLabelStackFully([...labelStack, {
13
+ name
14
+ }]);
15
+ const startTime = Math.round(start);
16
+ const endTime = Math.round(end);
17
+ const timing = result.get(label) || {
18
+ labelStack: optimizeLabelStack([...labelStack, {
19
+ name
20
+ }], reactUFOVersion),
21
+ startTime,
22
+ endTime
23
+ };
24
+ if (startTime < timing.startTime) {
25
+ timing.startTime = startTime;
26
+ }
27
+ if (endTime > timing.endTime) {
28
+ timing.endTime = endTime;
29
+ }
30
+ result.set(label, timing);
31
+ }
32
+ return result;
33
+ }, new Map());
34
+ return [...holdInfoMap.values()];
35
+ }
@@ -0,0 +1,12 @@
1
+ import { optimizeLabelStack } from '../common/utils';
2
+ export function optimizeMarks(marks, reactUFOVersion) {
3
+ return marks.map(({
4
+ labelStack,
5
+ time,
6
+ ...others
7
+ }) => ({
8
+ ...others,
9
+ labelStack: labelStack && optimizeLabelStack(labelStack, reactUFOVersion),
10
+ time: Math.round(time)
11
+ }));
12
+ }
@@ -0,0 +1,46 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { segmentUnmountCache } from '../../interaction-metrics';
3
+ import { optimizeLabelStack, stringifyLabelStackFully } from '../common/utils';
4
+ export function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
5
+ const reactProfilerTimingsMap = reactProfilerTimings.reduce((result, {
6
+ labelStack,
7
+ startTime,
8
+ commitTime,
9
+ actualDuration,
10
+ type
11
+ }) => {
12
+ if (labelStack && startTime >= interactionStart) {
13
+ const label = stringifyLabelStackFully(labelStack);
14
+ const start = Math.round(startTime);
15
+ const end = Math.round(commitTime);
16
+ const timing = result.get(label) || {
17
+ labelStack: optimizeLabelStack(labelStack, reactUFOVersion),
18
+ startTime: start,
19
+ endTime: end,
20
+ mountCount: 0,
21
+ rerenderCount: 0,
22
+ renderDuration: 0
23
+ };
24
+ if (start < timing.startTime) {
25
+ timing.startTime = start;
26
+ }
27
+ if (end > timing.endTime) {
28
+ timing.endTime = end;
29
+ }
30
+ if (type === 'mount') {
31
+ timing.mountCount += 1;
32
+ }
33
+ if (type === 'update') {
34
+ timing.rerenderCount += 1;
35
+ }
36
+ if (segmentUnmountCache.has(label) && fg('platform_ufo_segment_unmount_count')) {
37
+ timing.unmountCount = segmentUnmountCache.get(label) || 0;
38
+ segmentUnmountCache.delete(label);
39
+ }
40
+ timing.renderDuration += Math.round(actualDuration);
41
+ result.set(label, timing);
42
+ }
43
+ return result;
44
+ }, new Map());
45
+ return [...reactProfilerTimingsMap.values()];
46
+ }
@@ -0,0 +1,26 @@
1
+ import { optimizeLabelStack } from '../common/utils';
2
+ export function optimizeRequestInfo(requestInfo, interactionStart, reactUFOVersion) {
3
+ const updatedRequestInfo = requestInfo.reduce((result, reqInfo) => {
4
+ const {
5
+ labelStack,
6
+ name,
7
+ start,
8
+ end,
9
+ networkStart,
10
+ networkComplete
11
+ } = reqInfo;
12
+ const startTime = networkStart !== null && networkStart !== void 0 ? networkStart : start;
13
+ const endTime = networkComplete !== null && networkComplete !== void 0 ? networkComplete : end;
14
+ if (labelStack && start >= interactionStart && endTime) {
15
+ result.push({
16
+ labelStack: optimizeLabelStack([...labelStack, {
17
+ name
18
+ }], reactUFOVersion),
19
+ startTime: Math.round(startTime),
20
+ endTime: Math.round(endTime)
21
+ });
22
+ }
23
+ return result;
24
+ }, []);
25
+ return updatedRequestInfo;
26
+ }
@@ -0,0 +1,24 @@
1
+ import { optimizeLabelStack } from '../common/utils';
2
+ export function optimizeSpans(spans, interactionStart, reactUFOVersion) {
3
+ const updatedSpans = spans.reduce((result, span) => {
4
+ const {
5
+ labelStack,
6
+ type,
7
+ name,
8
+ start,
9
+ end
10
+ } = span;
11
+ if (labelStack && start >= interactionStart) {
12
+ result.push({
13
+ labelStack: optimizeLabelStack([...labelStack, {
14
+ name
15
+ }], reactUFOVersion),
16
+ startTime: Math.round(start),
17
+ endTime: Math.round(end),
18
+ type
19
+ });
20
+ }
21
+ return result;
22
+ }, []);
23
+ return updatedSpans;
24
+ }
@@ -111,7 +111,7 @@ export function init(analyticsWebClientAsync, config) {
111
111
  startTime: 0
112
112
  });
113
113
  }
114
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
114
+ if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
115
115
  interactionExtraMetrics.initializeVCObserver(vcOptions);
116
116
  }
117
117
  }
@@ -185,7 +185,7 @@ export class SSRPlaceholderHandlers {
185
185
  return element;
186
186
  }
187
187
 
188
- // NOTE - for use when the FG `platform_ufo_ssr_placeholder_resolution_ttvc_v3` is disabled
188
+ // Validates placeholder match using asynchronous observation and resolves with the result
189
189
  checkIfExistedAndSizeMatching(el) {
190
190
  el = this.findNearestPlaceholderContainerIfIgnored(el);
191
191
  const id = this.getPlaceholderId(el);
@@ -201,7 +201,7 @@ export class SSRPlaceholderHandlers {
201
201
  });
202
202
  }
203
203
 
204
- // NOTE - for use when the FG `platform_ufo_ssr_placeholder_resolution_ttvc_v3` is enabled
204
+ // Validates placeholder match synchronously using stored SSR dimensions and current bounds
205
205
  checkIfExistedAndSizeMatchingV3(el) {
206
206
  el = this.findNearestPlaceholderContainerIfIgnored(el);
207
207
  const id = this.getPlaceholderId(el);
@@ -121,15 +121,13 @@ export default class AbstractVCCalculatorBase {
121
121
  }
122
122
  let enhancedVcLogs = vcLogs ? vcLogs.map(log => ({
123
123
  ...log,
124
- ...(fg('platform_ufo_serialise_ttvc_v3_debug_data') && {
125
- entries: log.entries.map(entry => {
126
- var _entry$rect, _entry$previousRect;
127
- return {
128
- ...entry,
129
- rect: (_entry$rect = entry.rect) === null || _entry$rect === void 0 ? void 0 : _entry$rect.toJSON(),
130
- previousRect: (_entry$previousRect = entry.previousRect) === null || _entry$previousRect === void 0 ? void 0 : _entry$previousRect.toJSON()
131
- };
132
- })
124
+ entries: log.entries.map(entry => {
125
+ var _entry$rect, _entry$previousRect;
126
+ return {
127
+ ...entry,
128
+ rect: (_entry$rect = entry.rect) === null || _entry$rect === void 0 ? void 0 : _entry$rect.toJSON(),
129
+ previousRect: (_entry$previousRect = entry.previousRect) === null || _entry$previousRect === void 0 ? void 0 : _entry$previousRect.toJSON()
130
+ };
133
131
  }),
134
132
  viewportPercentage: log.viewportPercentage
135
133
  })) : [];
@@ -182,10 +180,8 @@ export default class AbstractVCCalculatorBase {
182
180
  }
183
181
  (_ignoredEntriesByTime = ignoredEntriesByTime.get(timestamp)) === null || _ignoredEntriesByTime === void 0 ? void 0 : _ignoredEntriesByTime.push({
184
182
  ...viewportData,
185
- ...(fg('platform_ufo_serialise_ttvc_v3_debug_data') && {
186
- rect: (_viewportData$rect = viewportData.rect) === null || _viewportData$rect === void 0 ? void 0 : _viewportData$rect.toJSON(),
187
- previousRect: (_viewportData$previou = viewportData.previousRect) === null || _viewportData$previou === void 0 ? void 0 : _viewportData$previou.toJSON()
188
- }),
183
+ rect: (_viewportData$rect = viewportData.rect) === null || _viewportData$rect === void 0 ? void 0 : _viewportData$rect.toJSON(),
184
+ previousRect: (_viewportData$previou = viewportData.previousRect) === null || _viewportData$previou === void 0 ? void 0 : _viewportData$previou.toJSON(),
189
185
  ignoreReason: viewportData.visible ? viewportData.type : 'not-visible'
190
186
  });
191
187
  }
@@ -142,27 +142,18 @@ export default class ViewportObserver {
142
142
  const ssrPlaceholderHandler = this.getSSRPlaceholderHandler();
143
143
  if (ssrPlaceholderHandler) {
144
144
  if (ssrPlaceholderHandler.isPlaceholder(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode)) {
145
- if (fg('platform_ufo_ssr_placeholder_resolution_ttvc_v3')) {
146
- if (ssrPlaceholderHandler.checkIfExistedAndSizeMatchingV3(addedNode)) {
147
- var _this$intersectionObs3;
148
- (_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, 'mutation:ssr-placeholder');
149
- continue;
150
- }
151
- } else {
152
- const result = await ssrPlaceholderHandler.checkIfExistedAndSizeMatching(addedNode);
153
- if (result !== false) {
154
- var _this$intersectionObs4;
155
- (_this$intersectionObs4 = this.intersectionObserver) === null || _this$intersectionObs4 === void 0 ? void 0 : _this$intersectionObs4.watchAndTag(addedNode, 'mutation:ssr-placeholder');
156
- continue;
157
- }
145
+ if (ssrPlaceholderHandler.checkIfExistedAndSizeMatchingV3(addedNode)) {
146
+ var _this$intersectionObs3;
147
+ (_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, 'mutation:ssr-placeholder');
148
+ continue;
158
149
  }
159
150
  // If result is false, continue to normal mutation logic below
160
151
  }
161
152
  if (ssrPlaceholderHandler.isPlaceholderReplacement(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode)) {
162
153
  const result = await ssrPlaceholderHandler.validateReactComponentMatchToPlaceholder(addedNode);
163
154
  if (result !== false) {
164
- var _this$intersectionObs5;
165
- (_this$intersectionObs5 = this.intersectionObserver) === null || _this$intersectionObs5 === void 0 ? void 0 : _this$intersectionObs5.watchAndTag(addedNode, 'mutation:ssr-placeholder');
155
+ var _this$intersectionObs4;
156
+ (_this$intersectionObs4 = this.intersectionObserver) === null || _this$intersectionObs4 === void 0 ? void 0 : _this$intersectionObs4.watchAndTag(addedNode, 'mutation:ssr-placeholder');
166
157
  continue;
167
158
  }
168
159
  // If result is false, continue to normal mutation logic below
@@ -178,36 +169,36 @@ export default class ViewportObserver {
178
169
  });
179
170
  const isInIgnoreLsMarker = isInVCIgnoreIfNoLayoutShiftMarker(addedNode);
180
171
  if (sameDeletedNode && isInIgnoreLsMarker) {
181
- var _this$intersectionObs6;
182
- (_this$intersectionObs6 = this.intersectionObserver) === null || _this$intersectionObs6 === void 0 ? void 0 : _this$intersectionObs6.watchAndTag(addedNode, 'mutation:remount');
172
+ var _this$intersectionObs5;
173
+ (_this$intersectionObs5 = this.intersectionObserver) === null || _this$intersectionObs5 === void 0 ? void 0 : _this$intersectionObs5.watchAndTag(addedNode, 'mutation:remount');
183
174
  continue;
184
175
  }
185
176
  if (isContainedWithinMediaWrapper(addedNode)) {
186
- var _this$intersectionObs7;
187
- (_this$intersectionObs7 = this.intersectionObserver) === null || _this$intersectionObs7 === void 0 ? void 0 : _this$intersectionObs7.watchAndTag(addedNode, 'mutation:media');
177
+ var _this$intersectionObs6;
178
+ (_this$intersectionObs6 = this.intersectionObserver) === null || _this$intersectionObs6 === void 0 ? void 0 : _this$intersectionObs6.watchAndTag(addedNode, 'mutation:media');
188
179
  continue;
189
180
  }
190
181
  const {
191
182
  isWithin: isWithinThirdPartySegment
192
183
  } = checkWithinComponent(addedNode, 'UFOThirdPartySegment', this.mapIs3pResult);
193
184
  if (isWithinThirdPartySegment) {
194
- var _this$intersectionObs8;
195
- (_this$intersectionObs8 = this.intersectionObserver) === null || _this$intersectionObs8 === void 0 ? void 0 : _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
185
+ var _this$intersectionObs7;
186
+ (_this$intersectionObs7 = this.intersectionObserver) === null || _this$intersectionObs7 === void 0 ? void 0 : _this$intersectionObs7.watchAndTag(addedNode, 'mutation:third-party-element');
196
187
  continue;
197
188
  }
198
189
  if (fg('platform_ufo_display_content_resolution_ttvc_v3')) {
199
190
  // Check if the target has display:content css property, return array of valid targets
200
191
  const validTargets = checkCssProperty(addedNode);
201
192
  for (const validTarget of validTargets) {
202
- var _this$intersectionObs9;
203
- (_this$intersectionObs9 = this.intersectionObserver) === null || _this$intersectionObs9 === void 0 ? void 0 : _this$intersectionObs9.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
193
+ var _this$intersectionObs8;
194
+ (_this$intersectionObs8 = this.intersectionObserver) === null || _this$intersectionObs8 === void 0 ? void 0 : _this$intersectionObs8.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
204
195
  }
205
196
  } else {
206
- var _this$intersectionObs0;
197
+ var _this$intersectionObs9;
207
198
  if (fg('platform_ufo_display_content_track_occurrence')) {
208
199
  trackDisplayContentsOccurrence(addedNode);
209
200
  }
210
- (_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 ? void 0 : _this$intersectionObs0.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
201
+ (_this$intersectionObs9 = this.intersectionObserver) === null || _this$intersectionObs9 === void 0 ? void 0 : _this$intersectionObs9.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
211
202
  }
212
203
  }
213
204
  });
@@ -217,8 +208,8 @@ export default class ViewportObserver {
217
208
  oldValue,
218
209
  newValue
219
210
  }) => {
220
- var _this$intersectionObs1;
221
- (_this$intersectionObs1 = this.intersectionObserver) === null || _this$intersectionObs1 === void 0 ? void 0 : _this$intersectionObs1.watchAndTag(target, ({
211
+ var _this$intersectionObs0;
212
+ (_this$intersectionObs0 = this.intersectionObserver) === null || _this$intersectionObs0 === void 0 ? void 0 : _this$intersectionObs0.watchAndTag(target, ({
222
213
  target,
223
214
  rect
224
215
  }) => {
@@ -345,12 +336,12 @@ export default class ViewportObserver {
345
336
  this.isStarted = true;
346
337
  }
347
338
  stop() {
348
- var _this$mutationObserve2, _this$intersectionObs10, _this$performanceObse2;
339
+ var _this$mutationObserve2, _this$intersectionObs1, _this$performanceObse2;
349
340
  if (!this.isStarted) {
350
341
  return;
351
342
  }
352
343
  (_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 ? void 0 : _this$mutationObserve2.disconnect();
353
- (_this$intersectionObs10 = this.intersectionObserver) === null || _this$intersectionObs10 === void 0 ? void 0 : _this$intersectionObs10.disconnect();
344
+ (_this$intersectionObs1 = this.intersectionObserver) === null || _this$intersectionObs1 === void 0 ? void 0 : _this$intersectionObs1.disconnect();
354
345
  (_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 ? void 0 : _this$performanceObse2.disconnect();
355
346
  this.isStarted = false;
356
347
  // Clean up caches when stopping