@atlaskit/react-ufo 4.4.3 → 4.4.5

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 (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/create-interaction-extra-metrics-payload/index.js +116 -0
  3. package/dist/cjs/create-payload/index.js +3 -2
  4. package/dist/cjs/create-payload/utils/get-vc-metrics.js +37 -21
  5. package/dist/cjs/interaction-metrics/index.js +313 -259
  6. package/dist/cjs/interaction-metrics/interaction-extra-metrics.js +89 -0
  7. package/dist/cjs/interaction-metrics-init/index.js +51 -7
  8. package/dist/cjs/segment/third-party-segment.js +3 -1
  9. package/dist/cjs/ssr/index.js +3 -2
  10. package/dist/cjs/vc/index.js +4 -3
  11. package/dist/cjs/vc/vc-observer/index.js +31 -51
  12. package/dist/cjs/vc/vc-observer-new/index.js +4 -3
  13. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +7 -5
  14. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +15 -6
  15. package/dist/es2019/create-interaction-extra-metrics-payload/index.js +93 -0
  16. package/dist/es2019/create-payload/index.js +3 -3
  17. package/dist/es2019/create-payload/utils/get-vc-metrics.js +3 -2
  18. package/dist/es2019/interaction-metrics/index.js +317 -260
  19. package/dist/es2019/interaction-metrics/interaction-extra-metrics.js +63 -0
  20. package/dist/es2019/interaction-metrics-init/index.js +29 -2
  21. package/dist/es2019/segment/third-party-segment.js +3 -1
  22. package/dist/es2019/ssr/index.js +3 -2
  23. package/dist/es2019/vc/index.js +4 -2
  24. package/dist/es2019/vc/vc-observer/index.js +41 -61
  25. package/dist/es2019/vc/vc-observer-new/index.js +4 -2
  26. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +7 -3
  27. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +12 -5
  28. package/dist/esm/create-interaction-extra-metrics-payload/index.js +109 -0
  29. package/dist/esm/create-payload/index.js +3 -3
  30. package/dist/esm/create-payload/utils/get-vc-metrics.js +37 -21
  31. package/dist/esm/interaction-metrics/index.js +312 -258
  32. package/dist/esm/interaction-metrics/interaction-extra-metrics.js +83 -0
  33. package/dist/esm/interaction-metrics-init/index.js +48 -6
  34. package/dist/esm/segment/third-party-segment.js +3 -1
  35. package/dist/esm/ssr/index.js +3 -2
  36. package/dist/esm/vc/index.js +4 -3
  37. package/dist/esm/vc/vc-observer/index.js +31 -51
  38. package/dist/esm/vc/vc-observer-new/index.js +4 -3
  39. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +7 -5
  40. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +15 -6
  41. package/dist/types/common/common/types.d.ts +2 -0
  42. package/dist/types/common/vc/types.d.ts +1 -0
  43. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +45 -0
  44. package/dist/types/create-payload/index.d.ts +1 -0
  45. package/dist/types/create-payload/utils/get-vc-metrics.d.ts +1 -1
  46. package/dist/types/interaction-metrics/index.d.ts +2 -0
  47. package/dist/types/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
  48. package/dist/types/vc/types.d.ts +1 -0
  49. package/dist/types/vc/vc-observer/getVCRevisionDebugDetails.d.ts +1 -0
  50. package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +3 -2
  51. package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +2 -2
  52. package/dist/types/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
  53. package/dist/types/vc/vc-observer-new/types.d.ts +1 -0
  54. package/dist/types-ts4.5/common/common/types.d.ts +2 -0
  55. package/dist/types-ts4.5/common/vc/types.d.ts +1 -0
  56. package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +45 -0
  57. package/dist/types-ts4.5/create-payload/index.d.ts +1 -0
  58. package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +1 -1
  59. package/dist/types-ts4.5/interaction-metrics/index.d.ts +2 -0
  60. package/dist/types-ts4.5/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
  61. package/dist/types-ts4.5/vc/types.d.ts +1 -0
  62. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionDebugDetails.d.ts +1 -0
  63. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +3 -2
  64. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +2 -2
  65. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
  66. package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +1 -0
  67. package/package.json +7 -10
@@ -10,12 +10,14 @@ import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature
10
10
  import { getInteractionId } from '../interaction-id-context';
11
11
  import { newVCObserver } from '../vc';
12
12
  import { interactions } from './common/constants';
13
+ import InteractionExtraMetrics from './interaction-extra-metrics';
13
14
  import PostInteractionLog from './post-interaction-log';
14
15
  const PreviousInteractionLog = {
15
16
  name: undefined,
16
17
  isAborted: undefined
17
18
  };
18
19
  export const postInteractionLog = new PostInteractionLog();
20
+ export const interactionExtraMetrics = new InteractionExtraMetrics();
19
21
  const interactionQueue = [];
20
22
  const segmentCache = new Map();
21
23
  export const segmentUnmountCache = new Map(); // Temporarily store segment unmount counts
@@ -158,23 +160,16 @@ export function addCustomTiming(interactionId, labelStack, data) {
158
160
  } = timingData;
159
161
  try {
160
162
  // for Firefox 102 and older
161
- if (fg('ufo_chrome_devtools_uplift')) {
162
- performance.measure(`🛸 ${labelStackToString(labelStack, key)} [custom_timing]`, {
163
- start: startTime,
164
- end: endTime,
165
- detail: {
166
- devtools: {
167
- track: '🛸 reactUFO detailed timings',
168
- color: 'tertiary-light'
169
- }
163
+ performance.measure(`🛸 ${labelStackToString(labelStack, key)} [custom_timing]`, {
164
+ start: startTime,
165
+ end: endTime,
166
+ detail: {
167
+ devtools: {
168
+ track: '🛸 reactUFO detailed timings',
169
+ color: 'tertiary-light'
170
170
  }
171
- });
172
- } else {
173
- performance.measure(`🛸 ${labelStackToString(labelStack, key)} [custom_timing]`, {
174
- start: startTime,
175
- end: endTime
176
- });
177
- }
171
+ }
172
+ });
178
173
  } catch (e) {
179
174
  // do nothing
180
175
  }
@@ -227,23 +222,16 @@ export function addSpan(interactionId, type, name, labelStack, start, end = perf
227
222
  if (isPerformanceTracingEnabled()) {
228
223
  try {
229
224
  // for Firefox 102 and older
230
- if (fg('ufo_chrome_devtools_uplift')) {
231
- performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
232
- start,
233
- end,
234
- detail: {
235
- devtools: {
236
- track: '🛸 reactUFO detailed timings',
237
- color: 'secondary'
238
- }
225
+ performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
226
+ start,
227
+ end,
228
+ detail: {
229
+ devtools: {
230
+ track: '🛸 reactUFO detailed timings',
231
+ color: 'secondary'
239
232
  }
240
- });
241
- } else {
242
- performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
243
- start,
244
- end
245
- });
246
- }
233
+ }
234
+ });
247
235
  } catch (e) {
248
236
  // do nothing
249
237
  }
@@ -264,23 +252,16 @@ export function addSpanToAll(type, name, labelStack, start, end = performance.no
264
252
  if (isPerformanceTracingEnabled()) {
265
253
  try {
266
254
  // for Firefox 102 and older
267
- if (fg('ufo_chrome_devtools_uplift')) {
268
- performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
269
- start,
270
- end,
271
- detail: {
272
- devtools: {
273
- track: '🛸 reactUFO detailed timings',
274
- color: 'secondary'
275
- }
255
+ performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
256
+ start,
257
+ end,
258
+ detail: {
259
+ devtools: {
260
+ track: '🛸 reactUFO detailed timings',
261
+ color: 'secondary'
276
262
  }
277
- });
278
- } else {
279
- performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
280
- start,
281
- end
282
- });
283
- }
263
+ }
264
+ });
284
265
  } catch (e) {
285
266
  // do nothing
286
267
  }
@@ -318,48 +299,60 @@ export function addHold(interactionId, labelStack, name, experimental) {
318
299
  const interaction = interactions.get(interactionId);
319
300
  const id = createUUID();
320
301
  if (interaction != null) {
321
- var _getConfig2, _getConfig2$experimen;
322
302
  const start = performance.now();
323
303
  const holdActive = {
324
304
  labelStack,
325
305
  name,
326
306
  start
327
307
  };
328
- if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2$experimen = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2$experimen !== void 0 && _getConfig2$experimen.enabled && experimental) {
329
- interaction.holdExpActive.set(id, {
330
- ...holdActive,
331
- start
332
- });
333
- }
334
- if (!experimental) {
335
- interaction.holdActive.set(id, {
336
- ...holdActive,
337
- start
338
- });
308
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
309
+ const is3pHold = labelStack.some(l => 'type' in l && l.type === 'third-party');
310
+ if (is3pHold) {
311
+ if (!interaction.hold3pActive) {
312
+ interaction.hold3pActive = new Map();
313
+ }
314
+ interaction.hold3pActive.set(id, {
315
+ ...holdActive,
316
+ start
317
+ });
318
+ } else {
319
+ interaction.holdActive.set(id, {
320
+ ...holdActive,
321
+ start
322
+ });
323
+ addHoldCriterion(id, labelStack, name, start);
324
+ }
325
+ } else {
326
+ var _getConfig2, _getConfig2$experimen;
327
+ if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2$experimen = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2$experimen !== void 0 && _getConfig2$experimen.enabled && experimental) {
328
+ interaction.holdExpActive.set(id, {
329
+ ...holdActive,
330
+ start
331
+ });
332
+ }
333
+ if (!experimental) {
334
+ interaction.holdActive.set(id, {
335
+ ...holdActive,
336
+ start
337
+ });
338
+ }
339
+ addHoldCriterion(id, labelStack, name, start);
339
340
  }
340
- addHoldCriterion(id, labelStack, name, start);
341
341
  return () => {
342
342
  const end = performance.now();
343
343
  if (isPerformanceTracingEnabled()) {
344
344
  try {
345
345
  // for Firefox 102 and older
346
- if (fg('ufo_chrome_devtools_uplift')) {
347
- performance.measure(`🛸 ${labelStackToString(labelStack, name)} [hold]`, {
348
- start,
349
- end,
350
- detail: {
351
- devtools: {
352
- track: '🛸 reactUFO detailed timings',
353
- color: 'secondary-light'
354
- }
346
+ performance.measure(`🛸 ${labelStackToString(labelStack, name)} [hold]`, {
347
+ start,
348
+ end,
349
+ detail: {
350
+ devtools: {
351
+ track: '🛸 reactUFO detailed timings',
352
+ color: 'secondary-light'
355
353
  }
356
- });
357
- } else {
358
- performance.measure(`🛸 ${labelStackToString(labelStack, name)} [hold]`, {
359
- start,
360
- end
361
- });
362
- }
354
+ }
355
+ });
363
356
  } catch (e) {
364
357
  // do nothing
365
358
  }
@@ -383,6 +376,21 @@ export function addHold(interactionId, labelStack, name, experimental) {
383
376
  });
384
377
  interaction.holdExpActive.delete(id);
385
378
  }
379
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
380
+ if (interaction.hold3pActive) {
381
+ const current3pHold = interaction.hold3pActive.get(id);
382
+ if (current3pHold != null) {
383
+ if (!currentInteraction.hold3pInfo) {
384
+ currentInteraction.hold3pInfo = [];
385
+ }
386
+ currentInteraction.hold3pInfo.push({
387
+ ...current3pHold,
388
+ end
389
+ });
390
+ interaction.hold3pActive.delete(id);
391
+ }
392
+ }
393
+ }
386
394
  }
387
395
  };
388
396
  }
@@ -392,13 +400,36 @@ export function addHoldByID(interactionId, labelStack, name, id, ignoreOnSubmit)
392
400
  const interaction = interactions.get(interactionId);
393
401
  if (interaction != null) {
394
402
  const start = performance.now();
395
- interaction.holdActive.set(id, {
396
- labelStack,
397
- name,
398
- start,
399
- ignoreOnSubmit
400
- });
401
- addHoldCriterion(id, labelStack, name, start);
403
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
404
+ const is3pHold = labelStack.some(l => 'type' in l && l.type === 'third-party');
405
+ if (is3pHold) {
406
+ if (!interaction.hold3pActive) {
407
+ interaction.hold3pActive = new Map();
408
+ }
409
+ interaction.hold3pActive.set(id, {
410
+ labelStack,
411
+ name,
412
+ start,
413
+ ignoreOnSubmit
414
+ });
415
+ } else {
416
+ interaction.holdActive.set(id, {
417
+ labelStack,
418
+ name,
419
+ start,
420
+ ignoreOnSubmit
421
+ });
422
+ addHoldCriterion(id, labelStack, name, start);
423
+ }
424
+ } else {
425
+ interaction.holdActive.set(id, {
426
+ labelStack,
427
+ name,
428
+ start,
429
+ ignoreOnSubmit
430
+ });
431
+ addHoldCriterion(id, labelStack, name, start);
432
+ }
402
433
  }
403
434
  return () => {};
404
435
  }
@@ -416,6 +447,21 @@ export function removeHoldByID(interactionId, id) {
416
447
  interaction.holdActive.delete(id);
417
448
  removeHoldCriterion(id);
418
449
  }
450
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
451
+ if (interaction.hold3pActive) {
452
+ const current3pHold = interaction.hold3pActive.get(id);
453
+ if (currentInteraction != null && current3pHold != null) {
454
+ if (!currentInteraction.hold3pInfo) {
455
+ currentInteraction.hold3pInfo = [];
456
+ }
457
+ currentInteraction.hold3pInfo.push({
458
+ ...current3pHold,
459
+ end
460
+ });
461
+ interaction.hold3pActive.delete(id);
462
+ }
463
+ }
464
+ }
419
465
  }
420
466
  }
421
467
  export function getCurrentInteractionType(interactionId) {
@@ -489,23 +535,16 @@ export function addProfilerTimings(interactionId, labelStack, type, actualDurati
489
535
  if (isPerformanceTracingEnabled()) {
490
536
  try {
491
537
  // for Firefox 102 and older
492
- if (fg('ufo_chrome_devtools_uplift')) {
493
- performance.measure(`🛸 ${labelStackToString(labelStack)} [react-profiler] ${type}`, {
494
- start: startTime,
495
- duration: actualDuration,
496
- detail: {
497
- devtools: {
498
- track: '🛸 reactUFO detailed timings',
499
- color: 'secondary-dark'
500
- }
538
+ performance.measure(`🛸 ${labelStackToString(labelStack)} [react-profiler] ${type}`, {
539
+ start: startTime,
540
+ duration: actualDuration,
541
+ detail: {
542
+ devtools: {
543
+ track: '🛸 reactUFO detailed timings',
544
+ color: 'secondary-dark'
501
545
  }
502
- });
503
- } else {
504
- performance.measure(`🛸 ${labelStackToString(labelStack)} [react-profiler] ${type}`, {
505
- start: startTime,
506
- duration: actualDuration
507
- });
508
- }
546
+ }
547
+ });
509
548
  } catch (e) {
510
549
  // do nothing
511
550
  }
@@ -537,37 +576,29 @@ function callCleanUpCallbacks(interaction) {
537
576
  });
538
577
  }
539
578
  function finishInteraction(id, data, endTime = performance.now()) {
540
- var _getConfig4, _getConfig4$vc, _getConfig5, _getConfig5$experimen;
579
+ var _getConfig4, _getConfig4$vc;
541
580
  data.end = endTime;
542
581
  try {
543
582
  // for Firefox 102 and older
544
-
545
- if (fg('ufo_chrome_devtools_uplift')) {
546
- performance.measure(`🛸 [${data.type}] ${data.ufoName} [ttai]`, {
547
- start: data.start,
548
- end: data.end,
549
- detail: {
550
- devtools: {
551
- track: 'main metrics',
552
- trackGroup: '🛸 reactUFO metrics',
553
- color: 'tertiary'
554
- }
583
+ performance.measure(`🛸 [${data.type}] ${data.ufoName} [ttai]`, {
584
+ start: data.start,
585
+ end: data.end,
586
+ detail: {
587
+ devtools: {
588
+ track: 'main metrics',
589
+ trackGroup: '🛸 reactUFO metrics',
590
+ color: 'tertiary'
555
591
  }
556
- });
557
- performance.mark(`TTAI`, {
558
- startTime: data.end,
559
- detail: {
560
- devtools: {
561
- dataType: 'marker'
562
- }
592
+ }
593
+ });
594
+ performance.mark(`TTAI`, {
595
+ startTime: data.end,
596
+ detail: {
597
+ devtools: {
598
+ dataType: 'marker'
563
599
  }
564
- });
565
- } else {
566
- performance.measure(`🛸 [${data.type}] ${data.ufoName} [ttai]`, {
567
- start: data.start,
568
- end: data.end
569
- });
570
- }
600
+ }
601
+ });
571
602
  } catch (e) {
572
603
  // do nothing
573
604
  }
@@ -586,23 +617,35 @@ function finishInteraction(id, data, endTime = performance.now()) {
586
617
  data.hydration = getReactHydrationStats();
587
618
 
588
619
  // By this time, stop the post interaction log observer if coinflip rate is 0
589
- if (fg('platform_ufo_post_interaction_check_name')) {
590
- const sanitisedUfoName = sanitizeUfoName(data.ufoName);
591
- if (!coinflip(getPostInteractionRate(sanitisedUfoName, data.type))) {
592
- postInteractionLog.stopVCObserver();
620
+ const sanitisedUfoName = sanitizeUfoName(data.ufoName);
621
+ if (!coinflip(getPostInteractionRate(sanitisedUfoName, data.type))) {
622
+ postInteractionLog.stopVCObserver();
623
+ }
624
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
625
+ if (!data.hold3pActive || data.hold3pActive.size === 0) {
626
+ var _getConfig5, _getConfig5$experimen;
627
+ if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$experimen = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5$experimen !== void 0 && _getConfig5$experimen.enabled)) {
628
+ remove(id);
629
+ }
630
+ interactionExtraMetrics.stopVCObserver();
593
631
  }
594
632
  } else {
595
- if (!coinflip(getPostInteractionRate(data.routeName || data.ufoName, data.type))) {
596
- postInteractionLog.stopVCObserver();
633
+ var _getConfig6, _getConfig6$experimen;
634
+ if (!((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6$experimen = _getConfig6.experimentalInteractionMetrics) !== null && _getConfig6$experimen !== void 0 && _getConfig6$experimen.enabled)) {
635
+ remove(id);
597
636
  }
598
637
  }
599
- if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$experimen = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5$experimen !== void 0 && _getConfig5$experimen.enabled)) {
600
- remove(id);
601
- }
602
638
  PreviousInteractionLog.name = data.ufoName || 'unknown';
603
639
  PreviousInteractionLog.isAborted = data.abortReason != null;
604
640
  if (data.ufoName) {
605
- handleInteraction(id, data);
641
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
642
+ if (interactionExtraMetrics.finishedInteractionId !== id) {
643
+ // If this same interaction was not already handled, handle it
644
+ handleInteraction(id, data);
645
+ }
646
+ } else {
647
+ handleInteraction(id, data);
648
+ }
606
649
  }
607
650
  if (isPerformanceTracingEnabled()) {
608
651
  const profilerTimingMap = new Map();
@@ -625,23 +668,16 @@ function finishInteraction(id, data, endTime = performance.now()) {
625
668
  start,
626
669
  end
627
670
  }] of profilerTimingMap.entries()) {
628
- if (fg('ufo_chrome_devtools_uplift')) {
629
- performance.measure(`🛸 ${labelStackToString(labelStack)} [segment_ttai]`, {
630
- start,
631
- end,
632
- detail: {
633
- devtools: {
634
- track: '🛸 reactUFO detailed timings',
635
- color: 'secondary-dark'
636
- }
671
+ performance.measure(`🛸 ${labelStackToString(labelStack)} [segment_ttai]`, {
672
+ start,
673
+ end,
674
+ detail: {
675
+ devtools: {
676
+ track: '🛸 reactUFO detailed timings',
677
+ color: 'secondary-dark'
637
678
  }
638
- });
639
- } else {
640
- performance.measure(`🛸 ${labelStackToString(labelStack)} [segment_ttai]`, {
641
- start,
642
- end
643
- });
644
- }
679
+ }
680
+ });
645
681
  }
646
682
  } catch (e) {
647
683
  // do nothing
@@ -677,12 +713,12 @@ export function tryComplete(interactionId, endTime) {
677
713
  const noMoreActiveHolds = interaction.holdActive.size === 0;
678
714
  const noMoreExpHolds = interaction.holdExpActive.size === 0;
679
715
  const postInteraction = async () => {
680
- var _getConfig6, _getConfig6$postInter, _getConfig8, _getConfig8$experimen;
681
- if ((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6$postInter = _getConfig6.postInteractionLog) !== null && _getConfig6$postInter !== void 0 && _getConfig6$postInter.enabled) {
682
- var _getConfig7, _getConfig7$experimen;
716
+ var _getConfig7, _getConfig7$postInter;
717
+ if ((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7$postInter = _getConfig7.postInteractionLog) !== null && _getConfig7$postInter !== void 0 && _getConfig7$postInter.enabled) {
718
+ var _getConfig8, _getConfig8$experimen;
683
719
  let experimentalVC90;
684
720
  let experimentalTTAI;
685
- if ((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7$experimen = _getConfig7.experimentalInteractionMetrics) !== null && _getConfig7$experimen !== void 0 && _getConfig7$experimen.enabled) {
721
+ if ((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8$experimen = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8$experimen !== void 0 && _getConfig8$experimen.enabled) {
686
722
  var _await$getExperimenta;
687
723
  experimentalVC90 = (_await$getExperimenta = await getExperimentalVCMetrics(interaction)) === null || _await$getExperimenta === void 0 ? void 0 : _await$getExperimenta['metric:experimental:vc90'];
688
724
  const {
@@ -697,22 +733,59 @@ export function tryComplete(interactionId, endTime) {
697
733
  experimentalVC90
698
734
  });
699
735
  }
700
- if ((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8$experimen = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8$experimen !== void 0 && _getConfig8$experimen.enabled) {
701
- remove(interactionId);
736
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
737
+ if (interactionExtraMetrics.finishedInteractionId !== interactionId) {
738
+ var _getConfig9, _getConfig9$experimen;
739
+ // If interactionExtraMetrics is not waiting for measuring this interaction
740
+ if ((_getConfig9 = getConfig()) !== null && _getConfig9 !== void 0 && (_getConfig9$experimen = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9$experimen !== void 0 && _getConfig9$experimen.enabled) {
741
+ remove(interactionId);
742
+ }
743
+ }
744
+ } else {
745
+ var _getConfig0, _getConfig0$experimen;
746
+ if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0$experimen = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0$experimen !== void 0 && _getConfig0$experimen.enabled) {
747
+ remove(interactionId);
748
+ }
702
749
  }
703
750
  activeSubmitted = false;
704
751
  };
705
- if (noMoreActiveHolds) {
706
- if (!activeSubmitted) {
707
- finishInteraction(interactionId, interaction, endTime);
708
- activeSubmitted = true;
752
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
753
+ var _interaction$hold3pAc;
754
+ const noMoreActive3pHolds = ((_interaction$hold3pAc = interaction.hold3pActive) === null || _interaction$hold3pAc === void 0 ? void 0 : _interaction$hold3pAc.size) === 0 || interaction.hold3pActive === undefined;
755
+ if (noMoreActiveHolds) {
756
+ if (!activeSubmitted) {
757
+ finishInteraction(interactionId, interaction, endTime);
758
+ interactionExtraMetrics.updateFinishedInteractionId(interactionId);
759
+ activeSubmitted = true;
760
+ }
761
+ if (noMoreExpHolds) {
762
+ var _getConfig1, _getConfig1$experimen;
763
+ if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1$experimen = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1$experimen !== void 0 && _getConfig1$experimen.enabled) {
764
+ onExperimentalInteractionComplete(interactionId, interaction, endTime);
765
+ }
766
+ postInteraction();
767
+ }
768
+ if (noMoreActive3pHolds) {
769
+ const data = {
770
+ ...interaction,
771
+ end: endTime
772
+ };
773
+ interactionExtraMetrics.onInteractionComplete(interactionId, data);
774
+ }
709
775
  }
710
- if (noMoreExpHolds) {
711
- var _getConfig9, _getConfig9$experimen;
712
- if ((_getConfig9 = getConfig()) !== null && _getConfig9 !== void 0 && (_getConfig9$experimen = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9$experimen !== void 0 && _getConfig9$experimen.enabled) {
713
- onExperimentalInteractionComplete(interactionId, interaction, endTime);
776
+ } else {
777
+ if (noMoreActiveHolds) {
778
+ if (!activeSubmitted) {
779
+ finishInteraction(interactionId, interaction, endTime);
780
+ activeSubmitted = true;
781
+ }
782
+ if (noMoreExpHolds) {
783
+ var _getConfig10, _getConfig10$experime;
784
+ if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10$experime = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10$experime !== void 0 && _getConfig10$experime.enabled) {
785
+ onExperimentalInteractionComplete(interactionId, interaction, endTime);
786
+ }
787
+ postInteraction();
714
788
  }
715
- postInteraction();
716
789
  }
717
790
  }
718
791
  }
@@ -740,6 +813,11 @@ export function abort(interactionId, abortReason) {
740
813
  finishInteraction(interactionId, interaction);
741
814
  postInteractionLog.reset();
742
815
  postInteractionLog.stopVCObserver();
816
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
817
+ interactionExtraMetrics.stopVCObserver();
818
+ interactionExtraMetrics.reset();
819
+ remove(interactionId);
820
+ }
743
821
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
744
822
  onExperimentalInteractionComplete(interactionId, interaction);
745
823
  remove(interactionId);
@@ -765,6 +843,11 @@ export function abortByNewInteraction(interactionId, interactionName) {
765
843
  finishInteraction(interactionId, interaction);
766
844
  postInteractionLog.reset();
767
845
  postInteractionLog.stopVCObserver();
846
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
847
+ interactionExtraMetrics.stopVCObserver();
848
+ interactionExtraMetrics.reset();
849
+ remove(interactionId);
850
+ }
768
851
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
769
852
  onExperimentalInteractionComplete(interactionId, interaction);
770
853
  remove(interactionId);
@@ -794,6 +877,11 @@ export function abortAll(abortReason, abortedByInteractionName) {
794
877
  finishInteraction(interactionId, interaction);
795
878
  postInteractionLog.reset();
796
879
  postInteractionLog.stopVCObserver();
880
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
881
+ interactionExtraMetrics.stopVCObserver();
882
+ interactionExtraMetrics.reset();
883
+ remove(interactionId);
884
+ }
797
885
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
798
886
  onExperimentalInteractionComplete(interactionId, interaction);
799
887
  remove(interactionId);
@@ -805,13 +893,7 @@ export function addOnCancelCallback(id, cancelCallback) {
805
893
  interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
806
894
  }
807
895
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName, trace = null) {
808
- if (fg('platform_ufo_post_interaction_check_name')) {
809
- postInteractionLog.reset();
810
- } else {
811
- if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
812
- postInteractionLog.reset();
813
- }
814
- }
896
+ postInteractionLog.reset();
815
897
  let vcObserver;
816
898
  let previousTime = startTime;
817
899
  let timeoutTime = fg('platform_ufo_enable_timeout_config') ? getInteractionTimeout(ufoName) : CLEANUP_TIMEOUT;
@@ -890,7 +972,9 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
890
972
  timerID,
891
973
  changeTimeout,
892
974
  trace,
893
- vcObserver
975
+ vcObserver,
976
+ hold3pActive: new Map(),
977
+ hold3pInfo: []
894
978
  };
895
979
  if (addFeatureFlagsToInteraction) {
896
980
  currentFeatureFlagsAccessed.clear();
@@ -920,6 +1004,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
920
1004
  addHoldByID(interactionId, [], ufoName, ufoName, true);
921
1005
  }
922
1006
  if (type === 'transition' || type === 'page_load') {
1007
+ var _getConfig11, _getConfig11$postInte;
923
1008
  // Use per-interaction VC observer if available, otherwise fall back to global
924
1009
  const observer = vcObserver;
925
1010
  if (observer) {
@@ -928,27 +1013,23 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
928
1013
  experienceKey: ufoName
929
1014
  });
930
1015
  }
931
- if (fg('platform_ufo_post_interaction_check_name')) {
932
- var _getConfig0, _getConfig0$postInter;
933
- // Start post interaction observer for all if config is enabled
934
- // in case ufoName is updated at later time
935
- if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0$postInter = _getConfig0.postInteractionLog) !== null && _getConfig0$postInter !== void 0 && _getConfig0$postInter.enabled) {
936
- postInteractionLog.startVCObserver({
937
- startTime
938
- });
939
- }
940
- } else {
941
- if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
942
- postInteractionLog.startVCObserver({
943
- startTime
944
- });
945
- }
1016
+ // Start post interaction observer for all if config is enabled
1017
+ // in case ufoName is updated at later time
1018
+ if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11$postInte = _getConfig11.postInteractionLog) !== null && _getConfig11$postInte !== void 0 && _getConfig11$postInte.enabled) {
1019
+ postInteractionLog.startVCObserver({
1020
+ startTime
1021
+ });
946
1022
  }
947
1023
  if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
948
1024
  experimentalVC.start({
949
1025
  startTime
950
1026
  });
951
1027
  }
1028
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
1029
+ interactionExtraMetrics.startVCObserver({
1030
+ startTime
1031
+ }, interactionId);
1032
+ }
952
1033
  }
953
1034
  if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
954
1035
  // Use per-interaction VC observer if available, otherwise fall back to global
@@ -976,35 +1057,27 @@ export function addApdexToAll(apdex) {
976
1057
  interactions.forEach((interaction, key) => {
977
1058
  interaction.apdex.push(apdex);
978
1059
  try {
1060
+ var _apdex$startTime;
979
1061
  // for Firefox 102 and older
980
- if (fg('ufo_chrome_devtools_uplift')) {
981
- var _apdex$startTime;
982
- performance.measure(`🛸 ${apdex.key} [bm3_tti]`, {
983
- start: (_apdex$startTime = apdex.startTime) !== null && _apdex$startTime !== void 0 ? _apdex$startTime : interaction.start,
984
- end: apdex.stopTime,
985
- detail: {
986
- devtools: {
987
- track: 'main metrics',
988
- trackGroup: '🛸 reactUFO metrics',
989
- color: 'primary-dark'
990
- }
1062
+ performance.measure(`🛸 ${apdex.key} [bm3_tti]`, {
1063
+ start: (_apdex$startTime = apdex.startTime) !== null && _apdex$startTime !== void 0 ? _apdex$startTime : interaction.start,
1064
+ end: apdex.stopTime,
1065
+ detail: {
1066
+ devtools: {
1067
+ track: 'main metrics',
1068
+ trackGroup: '🛸 reactUFO metrics',
1069
+ color: 'primary-dark'
991
1070
  }
992
- });
993
- performance.mark(`[bm3] TTI`, {
994
- startTime: apdex.stopTime,
995
- detail: {
996
- devtools: {
997
- dataType: 'marker'
998
- }
1071
+ }
1072
+ });
1073
+ performance.mark(`[bm3] TTI`, {
1074
+ startTime: apdex.stopTime,
1075
+ detail: {
1076
+ devtools: {
1077
+ dataType: 'marker'
999
1078
  }
1000
- });
1001
- } else {
1002
- var _apdex$startTime2;
1003
- performance.measure(`🛸 ${apdex.key} [bm3_tti]`, {
1004
- start: (_apdex$startTime2 = apdex.startTime) !== null && _apdex$startTime2 !== void 0 ? _apdex$startTime2 : interaction.start,
1005
- end: apdex.stopTime
1006
- });
1007
- }
1079
+ }
1080
+ });
1008
1081
  } catch (e) {
1009
1082
  // do nothing
1010
1083
  }
@@ -1018,35 +1091,27 @@ export function addApdex(interactionId, apdexInfo) {
1018
1091
  if (interaction != null) {
1019
1092
  interaction.apdex.push(apdexInfo);
1020
1093
  try {
1094
+ var _apdexInfo$startTime;
1021
1095
  // for Firefox 102 and older
1022
- if (fg('ufo_chrome_devtools_uplift')) {
1023
- var _apdexInfo$startTime;
1024
- performance.measure(`🛸 ${apdexInfo.key} [bm3_tti]`, {
1025
- start: (_apdexInfo$startTime = apdexInfo.startTime) !== null && _apdexInfo$startTime !== void 0 ? _apdexInfo$startTime : interaction.start,
1026
- end: apdexInfo.stopTime,
1027
- detail: {
1028
- devtools: {
1029
- track: 'main metrics',
1030
- trackGroup: '🛸 reactUFO metrics',
1031
- color: 'primary-dark'
1032
- }
1096
+ performance.measure(`🛸 ${apdexInfo.key} [bm3_tti]`, {
1097
+ start: (_apdexInfo$startTime = apdexInfo.startTime) !== null && _apdexInfo$startTime !== void 0 ? _apdexInfo$startTime : interaction.start,
1098
+ end: apdexInfo.stopTime,
1099
+ detail: {
1100
+ devtools: {
1101
+ track: 'main metrics',
1102
+ trackGroup: '🛸 reactUFO metrics',
1103
+ color: 'primary-dark'
1033
1104
  }
1034
- });
1035
- performance.mark(`[bm3] TTI`, {
1036
- startTime: apdexInfo.stopTime,
1037
- detail: {
1038
- devtools: {
1039
- dataType: 'marker'
1040
- }
1105
+ }
1106
+ });
1107
+ performance.mark(`[bm3] TTI`, {
1108
+ startTime: apdexInfo.stopTime,
1109
+ detail: {
1110
+ devtools: {
1111
+ dataType: 'marker'
1041
1112
  }
1042
- });
1043
- } else {
1044
- var _apdexInfo$startTime2;
1045
- performance.measure(`🛸 ${apdexInfo.key} [bm3_tti]`, {
1046
- start: (_apdexInfo$startTime2 = apdexInfo.startTime) !== null && _apdexInfo$startTime2 !== void 0 ? _apdexInfo$startTime2 : interaction.start,
1047
- end: apdexInfo.stopTime
1048
- });
1049
- }
1113
+ }
1114
+ });
1050
1115
  } catch (e) {
1051
1116
  // do nothing
1052
1117
  }
@@ -1114,26 +1179,18 @@ export function addRedirect(interactionId, fromUfoName, nextUfoName, nextRouteNa
1114
1179
  if (isPerformanceTracingEnabled()) {
1115
1180
  const prevRedirect = interaction.redirects.at(-2);
1116
1181
  try {
1182
+ var _prevRedirect$time;
1117
1183
  // for Firefox 102 and older
1118
- if (fg('ufo_chrome_devtools_uplift')) {
1119
- var _prevRedirect$time;
1120
- performance.measure(`🛸 ${nextUfoName} [redirect]`, {
1121
- start: (_prevRedirect$time = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time !== void 0 ? _prevRedirect$time : interaction.start,
1122
- end: time,
1123
- detail: {
1124
- devtools: {
1125
- track: '🛸 reactUFO detailed timings',
1126
- color: 'tertiary'
1127
- }
1184
+ performance.measure(`🛸 ${nextUfoName} [redirect]`, {
1185
+ start: (_prevRedirect$time = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time !== void 0 ? _prevRedirect$time : interaction.start,
1186
+ end: time,
1187
+ detail: {
1188
+ devtools: {
1189
+ track: '🛸 reactUFO detailed timings',
1190
+ color: 'tertiary'
1128
1191
  }
1129
- });
1130
- } else {
1131
- var _prevRedirect$time2;
1132
- performance.measure(`🛸 ${nextUfoName} [redirect]`, {
1133
- start: (_prevRedirect$time2 = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time2 !== void 0 ? _prevRedirect$time2 : interaction.start,
1134
- end: time
1135
- });
1136
- }
1192
+ }
1193
+ });
1137
1194
  } catch (e) {
1138
1195
  // do nothing
1139
1196
  }