@atlaskit/react-ufo 4.4.2 → 4.4.4

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 (66) hide show
  1. package/CHANGELOG.md +18 -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 +306 -232
  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/trace-interaction/internal/trace-ufo-interaction.js +3 -8
  11. package/dist/cjs/vc/index.js +4 -3
  12. package/dist/cjs/vc/vc-observer/index.js +3 -46
  13. package/dist/cjs/vc/vc-observer-new/index.js +4 -3
  14. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +3 -3
  15. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +4 -4
  16. package/dist/es2019/create-interaction-extra-metrics-payload/index.js +93 -0
  17. package/dist/es2019/create-payload/index.js +3 -3
  18. package/dist/es2019/create-payload/utils/get-vc-metrics.js +3 -2
  19. package/dist/es2019/interaction-metrics/index.js +310 -233
  20. package/dist/es2019/interaction-metrics/interaction-extra-metrics.js +63 -0
  21. package/dist/es2019/interaction-metrics-init/index.js +29 -2
  22. package/dist/es2019/segment/third-party-segment.js +3 -1
  23. package/dist/es2019/ssr/index.js +3 -2
  24. package/dist/es2019/trace-interaction/internal/trace-ufo-interaction.js +3 -8
  25. package/dist/es2019/vc/index.js +4 -2
  26. package/dist/es2019/vc/vc-observer/index.js +0 -43
  27. package/dist/es2019/vc/vc-observer-new/index.js +4 -2
  28. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +3 -2
  29. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +4 -4
  30. package/dist/esm/create-interaction-extra-metrics-payload/index.js +109 -0
  31. package/dist/esm/create-payload/index.js +3 -3
  32. package/dist/esm/create-payload/utils/get-vc-metrics.js +37 -21
  33. package/dist/esm/interaction-metrics/index.js +305 -231
  34. package/dist/esm/interaction-metrics/interaction-extra-metrics.js +83 -0
  35. package/dist/esm/interaction-metrics-init/index.js +48 -6
  36. package/dist/esm/segment/third-party-segment.js +3 -1
  37. package/dist/esm/ssr/index.js +3 -2
  38. package/dist/esm/trace-interaction/internal/trace-ufo-interaction.js +3 -8
  39. package/dist/esm/vc/index.js +4 -3
  40. package/dist/esm/vc/vc-observer/index.js +3 -46
  41. package/dist/esm/vc/vc-observer-new/index.js +4 -3
  42. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +3 -3
  43. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +4 -4
  44. package/dist/types/common/common/types.d.ts +2 -0
  45. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +45 -0
  46. package/dist/types/create-payload/index.d.ts +1 -0
  47. package/dist/types/create-payload/utils/get-vc-metrics.d.ts +1 -1
  48. package/dist/types/interaction-metrics/index.d.ts +2 -0
  49. package/dist/types/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
  50. package/dist/types/vc/types.d.ts +1 -0
  51. package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +2 -2
  52. package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -1
  53. package/dist/types/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
  54. package/dist/types/vc/vc-observer-new/types.d.ts +1 -0
  55. package/dist/types-ts4.5/common/common/types.d.ts +2 -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-new/metric-calculator/abstract-base-vc-calculator.d.ts +2 -2
  63. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -1
  64. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
  65. package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +1 -0
  66. package/package.json +4 -10
@@ -20,12 +20,14 @@ import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature
20
20
  import { getInteractionId } from '../interaction-id-context';
21
21
  import { newVCObserver } from '../vc';
22
22
  import { interactions } from './common/constants';
23
+ import InteractionExtraMetrics from './interaction-extra-metrics';
23
24
  import PostInteractionLog from './post-interaction-log';
24
25
  var PreviousInteractionLog = {
25
26
  name: undefined,
26
27
  isAborted: undefined
27
28
  };
28
29
  export var postInteractionLog = new PostInteractionLog();
30
+ export var interactionExtraMetrics = new InteractionExtraMetrics();
29
31
  var interactionQueue = [];
30
32
  var segmentCache = new Map();
31
33
  export var segmentUnmountCache = new Map(); // Temporarily store segment unmount counts
@@ -192,23 +194,16 @@ export function addCustomTiming(interactionId, labelStack, data) {
192
194
  endTime = timingData.endTime;
193
195
  try {
194
196
  // for Firefox 102 and older
195
- if (fg('ufo_chrome_devtools_uplift')) {
196
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, key), " [custom_timing]"), {
197
- start: startTime,
198
- end: endTime,
199
- detail: {
200
- devtools: {
201
- track: '🛸 reactUFO detailed timings',
202
- color: 'tertiary-light'
203
- }
197
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, key), " [custom_timing]"), {
198
+ start: startTime,
199
+ end: endTime,
200
+ detail: {
201
+ devtools: {
202
+ track: '🛸 reactUFO detailed timings',
203
+ color: 'tertiary-light'
204
204
  }
205
- });
206
- } else {
207
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, key), " [custom_timing]"), {
208
- start: startTime,
209
- end: endTime
210
- });
211
- }
205
+ }
206
+ });
212
207
  } catch (e) {
213
208
  // do nothing
214
209
  }
@@ -265,23 +260,16 @@ export function addSpan(interactionId, type, name, labelStack, start) {
265
260
  if (isPerformanceTracingEnabled()) {
266
261
  try {
267
262
  // for Firefox 102 and older
268
- if (fg('ufo_chrome_devtools_uplift')) {
269
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
270
- start: start,
271
- end: end,
272
- detail: {
273
- devtools: {
274
- track: '🛸 reactUFO detailed timings',
275
- color: 'secondary'
276
- }
263
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
264
+ start: start,
265
+ end: end,
266
+ detail: {
267
+ devtools: {
268
+ track: '🛸 reactUFO detailed timings',
269
+ color: 'secondary'
277
270
  }
278
- });
279
- } else {
280
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
281
- start: start,
282
- end: end
283
- });
284
- }
271
+ }
272
+ });
285
273
  } catch (e) {
286
274
  // do nothing
287
275
  }
@@ -304,23 +292,16 @@ export function addSpanToAll(type, name, labelStack, start) {
304
292
  if (isPerformanceTracingEnabled()) {
305
293
  try {
306
294
  // for Firefox 102 and older
307
- if (fg('ufo_chrome_devtools_uplift')) {
308
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
309
- start: start,
310
- end: end,
311
- detail: {
312
- devtools: {
313
- track: '🛸 reactUFO detailed timings',
314
- color: 'secondary'
315
- }
295
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
296
+ start: start,
297
+ end: end,
298
+ detail: {
299
+ devtools: {
300
+ track: '🛸 reactUFO detailed timings',
301
+ color: 'secondary'
316
302
  }
317
- });
318
- } else {
319
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
320
- start: start,
321
- end: end
322
- });
323
- }
303
+ }
304
+ });
324
305
  } catch (e) {
325
306
  // do nothing
326
307
  }
@@ -358,46 +339,58 @@ export function addHold(interactionId, labelStack, name, experimental) {
358
339
  var interaction = interactions.get(interactionId);
359
340
  var id = createUUID();
360
341
  if (interaction != null) {
361
- var _getConfig2;
362
342
  var start = performance.now();
363
343
  var holdActive = {
364
344
  labelStack: labelStack,
365
345
  name: name,
366
346
  start: start
367
347
  };
368
- if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled && experimental) {
369
- interaction.holdExpActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
370
- start: start
371
- }));
372
- }
373
- if (!experimental) {
374
- interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
375
- start: start
376
- }));
348
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
349
+ var is3pHold = labelStack.some(function (l) {
350
+ return 'type' in l && l.type === 'third-party';
351
+ });
352
+ if (is3pHold) {
353
+ if (!interaction.hold3pActive) {
354
+ interaction.hold3pActive = new Map();
355
+ }
356
+ interaction.hold3pActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
357
+ start: start
358
+ }));
359
+ } else {
360
+ interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
361
+ start: start
362
+ }));
363
+ addHoldCriterion(id, labelStack, name, start);
364
+ }
365
+ } else {
366
+ var _getConfig2;
367
+ if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled && experimental) {
368
+ interaction.holdExpActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
369
+ start: start
370
+ }));
371
+ }
372
+ if (!experimental) {
373
+ interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
374
+ start: start
375
+ }));
376
+ }
377
+ addHoldCriterion(id, labelStack, name, start);
377
378
  }
378
- addHoldCriterion(id, labelStack, name, start);
379
379
  return function () {
380
380
  var end = performance.now();
381
381
  if (isPerformanceTracingEnabled()) {
382
382
  try {
383
383
  // for Firefox 102 and older
384
- if (fg('ufo_chrome_devtools_uplift')) {
385
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
386
- start: start,
387
- end: end,
388
- detail: {
389
- devtools: {
390
- track: '🛸 reactUFO detailed timings',
391
- color: 'secondary-light'
392
- }
384
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
385
+ start: start,
386
+ end: end,
387
+ detail: {
388
+ devtools: {
389
+ track: '🛸 reactUFO detailed timings',
390
+ color: 'secondary-light'
393
391
  }
394
- });
395
- } else {
396
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
397
- start: start,
398
- end: end
399
- });
400
- }
392
+ }
393
+ });
401
394
  } catch (e) {
402
395
  // do nothing
403
396
  }
@@ -419,6 +412,20 @@ export function addHold(interactionId, labelStack, name, experimental) {
419
412
  }));
420
413
  interaction.holdExpActive.delete(id);
421
414
  }
415
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
416
+ if (interaction.hold3pActive) {
417
+ var current3pHold = interaction.hold3pActive.get(id);
418
+ if (current3pHold != null) {
419
+ if (!currentInteraction.hold3pInfo) {
420
+ currentInteraction.hold3pInfo = [];
421
+ }
422
+ currentInteraction.hold3pInfo.push(_objectSpread(_objectSpread({}, current3pHold), {}, {
423
+ end: end
424
+ }));
425
+ interaction.hold3pActive.delete(id);
426
+ }
427
+ }
428
+ }
422
429
  }
423
430
  };
424
431
  }
@@ -428,13 +435,38 @@ export function addHoldByID(interactionId, labelStack, name, id, ignoreOnSubmit)
428
435
  var interaction = interactions.get(interactionId);
429
436
  if (interaction != null) {
430
437
  var start = performance.now();
431
- interaction.holdActive.set(id, {
432
- labelStack: labelStack,
433
- name: name,
434
- start: start,
435
- ignoreOnSubmit: ignoreOnSubmit
436
- });
437
- addHoldCriterion(id, labelStack, name, start);
438
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
439
+ var is3pHold = labelStack.some(function (l) {
440
+ return 'type' in l && l.type === 'third-party';
441
+ });
442
+ if (is3pHold) {
443
+ if (!interaction.hold3pActive) {
444
+ interaction.hold3pActive = new Map();
445
+ }
446
+ interaction.hold3pActive.set(id, {
447
+ labelStack: labelStack,
448
+ name: name,
449
+ start: start,
450
+ ignoreOnSubmit: ignoreOnSubmit
451
+ });
452
+ } else {
453
+ interaction.holdActive.set(id, {
454
+ labelStack: labelStack,
455
+ name: name,
456
+ start: start,
457
+ ignoreOnSubmit: ignoreOnSubmit
458
+ });
459
+ addHoldCriterion(id, labelStack, name, start);
460
+ }
461
+ } else {
462
+ interaction.holdActive.set(id, {
463
+ labelStack: labelStack,
464
+ name: name,
465
+ start: start,
466
+ ignoreOnSubmit: ignoreOnSubmit
467
+ });
468
+ addHoldCriterion(id, labelStack, name, start);
469
+ }
438
470
  }
439
471
  return function () {};
440
472
  }
@@ -451,6 +483,20 @@ export function removeHoldByID(interactionId, id) {
451
483
  interaction.holdActive.delete(id);
452
484
  removeHoldCriterion(id);
453
485
  }
486
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
487
+ if (interaction.hold3pActive) {
488
+ var current3pHold = interaction.hold3pActive.get(id);
489
+ if (currentInteraction != null && current3pHold != null) {
490
+ if (!currentInteraction.hold3pInfo) {
491
+ currentInteraction.hold3pInfo = [];
492
+ }
493
+ currentInteraction.hold3pInfo.push(_objectSpread(_objectSpread({}, current3pHold), {}, {
494
+ end: end
495
+ }));
496
+ interaction.hold3pActive.delete(id);
497
+ }
498
+ }
499
+ }
454
500
  }
455
501
  }
456
502
  export function getCurrentInteractionType(interactionId) {
@@ -524,23 +570,16 @@ export function addProfilerTimings(interactionId, labelStack, type, actualDurati
524
570
  if (isPerformanceTracingEnabled()) {
525
571
  try {
526
572
  // for Firefox 102 and older
527
- if (fg('ufo_chrome_devtools_uplift')) {
528
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
529
- start: startTime,
530
- duration: actualDuration,
531
- detail: {
532
- devtools: {
533
- track: '🛸 reactUFO detailed timings',
534
- color: 'secondary-dark'
535
- }
573
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
574
+ start: startTime,
575
+ duration: actualDuration,
576
+ detail: {
577
+ devtools: {
578
+ track: '🛸 reactUFO detailed timings',
579
+ color: 'secondary-dark'
536
580
  }
537
- });
538
- } else {
539
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
540
- start: startTime,
541
- duration: actualDuration
542
- });
543
- }
581
+ }
582
+ });
544
583
  } catch (e) {
545
584
  // do nothing
546
585
  }
@@ -572,38 +611,30 @@ function callCleanUpCallbacks(interaction) {
572
611
  });
573
612
  }
574
613
  function finishInteraction(id, data) {
575
- var _getConfig4, _getConfig5;
614
+ var _getConfig4;
576
615
  var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
577
616
  data.end = endTime;
578
617
  try {
579
618
  // for Firefox 102 and older
580
-
581
- if (fg('ufo_chrome_devtools_uplift')) {
582
- performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
583
- start: data.start,
584
- end: data.end,
585
- detail: {
586
- devtools: {
587
- track: 'main metrics',
588
- trackGroup: '🛸 reactUFO metrics',
589
- color: 'tertiary'
590
- }
619
+ performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
620
+ start: data.start,
621
+ end: data.end,
622
+ detail: {
623
+ devtools: {
624
+ track: 'main metrics',
625
+ trackGroup: '🛸 reactUFO metrics',
626
+ color: 'tertiary'
591
627
  }
592
- });
593
- performance.mark("TTAI", {
594
- startTime: data.end,
595
- detail: {
596
- devtools: {
597
- dataType: 'marker'
598
- }
628
+ }
629
+ });
630
+ performance.mark("TTAI", {
631
+ startTime: data.end,
632
+ detail: {
633
+ devtools: {
634
+ dataType: 'marker'
599
635
  }
600
- });
601
- } else {
602
- performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
603
- start: data.start,
604
- end: data.end
605
- });
606
- }
636
+ }
637
+ });
607
638
  } catch (e) {
608
639
  // do nothing
609
640
  }
@@ -632,13 +663,31 @@ function finishInteraction(id, data) {
632
663
  postInteractionLog.stopVCObserver();
633
664
  }
634
665
  }
635
- if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
636
- remove(id);
666
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
667
+ if (!data.hold3pActive || data.hold3pActive.size === 0) {
668
+ var _getConfig5;
669
+ if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
670
+ remove(id);
671
+ }
672
+ interactionExtraMetrics.stopVCObserver();
673
+ }
674
+ } else {
675
+ var _getConfig6;
676
+ if (!((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.experimentalInteractionMetrics) !== null && _getConfig6 !== void 0 && _getConfig6.enabled)) {
677
+ remove(id);
678
+ }
637
679
  }
638
680
  PreviousInteractionLog.name = data.ufoName || 'unknown';
639
681
  PreviousInteractionLog.isAborted = data.abortReason != null;
640
682
  if (data.ufoName) {
641
- handleInteraction(id, data);
683
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
684
+ if (interactionExtraMetrics.finishedInteractionId !== id) {
685
+ // If this same interaction was not already handled, handle it
686
+ handleInteraction(id, data);
687
+ }
688
+ } else {
689
+ handleInteraction(id, data);
690
+ }
642
691
  }
643
692
  if (isPerformanceTracingEnabled()) {
644
693
  var profilerTimingMap = new Map();
@@ -665,23 +714,16 @@ function finishInteraction(id, data) {
665
714
  labelStack = _step3$value$.labelStack,
666
715
  start = _step3$value$.start,
667
716
  end = _step3$value$.end;
668
- if (fg('ufo_chrome_devtools_uplift')) {
669
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
670
- start: start,
671
- end: end,
672
- detail: {
673
- devtools: {
674
- track: '🛸 reactUFO detailed timings',
675
- color: 'secondary-dark'
676
- }
717
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
718
+ start: start,
719
+ end: end,
720
+ detail: {
721
+ devtools: {
722
+ track: '🛸 reactUFO detailed timings',
723
+ color: 'secondary-dark'
677
724
  }
678
- });
679
- } else {
680
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
681
- start: start,
682
- end: end
683
- });
684
- }
725
+ }
726
+ });
685
727
  }
686
728
  } catch (err) {
687
729
  _iterator3.e(err);
@@ -723,16 +765,16 @@ export function tryComplete(interactionId, endTime) {
723
765
  var noMoreExpHolds = interaction.holdExpActive.size === 0;
724
766
  var postInteraction = /*#__PURE__*/function () {
725
767
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
726
- var _getConfig6, _getConfig8;
727
- var _getConfig7, experimentalVC90, experimentalTTAI, _yield$getExperimenta, start, end;
768
+ var _getConfig7;
769
+ var _getConfig8, experimentalVC90, experimentalTTAI, _yield$getExperimenta, start, end, _getConfig9, _getConfig0;
728
770
  return _regeneratorRuntime.wrap(function _callee$(_context) {
729
771
  while (1) switch (_context.prev = _context.next) {
730
772
  case 0:
731
- if (!((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.postInteractionLog) !== null && _getConfig6 !== void 0 && _getConfig6.enabled)) {
773
+ if (!((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7 = _getConfig7.postInteractionLog) !== null && _getConfig7 !== void 0 && _getConfig7.enabled)) {
732
774
  _context.next = 17;
733
775
  break;
734
776
  }
735
- if (!((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7 = _getConfig7.experimentalInteractionMetrics) !== null && _getConfig7 !== void 0 && _getConfig7.enabled)) {
777
+ if (!((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8 = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8 !== void 0 && _getConfig8.enabled)) {
736
778
  _context.next = 16;
737
779
  break;
738
780
  }
@@ -766,8 +808,17 @@ export function tryComplete(interactionId, endTime) {
766
808
  experimentalVC90: experimentalVC90
767
809
  }));
768
810
  case 17:
769
- if ((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8 = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8 !== void 0 && _getConfig8.enabled) {
770
- remove(interactionId);
811
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
812
+ if (interactionExtraMetrics.finishedInteractionId !== interactionId) {
813
+ // If interactionExtraMetrics is not waiting for measuring this interaction
814
+ if ((_getConfig9 = getConfig()) !== null && _getConfig9 !== void 0 && (_getConfig9 = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9 !== void 0 && _getConfig9.enabled) {
815
+ remove(interactionId);
816
+ }
817
+ }
818
+ } else {
819
+ if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
820
+ remove(interactionId);
821
+ }
771
822
  }
772
823
  activeSubmitted = false;
773
824
  case 19:
@@ -780,17 +831,42 @@ export function tryComplete(interactionId, endTime) {
780
831
  return _ref.apply(this, arguments);
781
832
  };
782
833
  }();
783
- if (noMoreActiveHolds) {
784
- if (!activeSubmitted) {
785
- finishInteraction(interactionId, interaction, endTime);
786
- activeSubmitted = true;
834
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
835
+ var _interaction$hold3pAc;
836
+ var noMoreActive3pHolds = ((_interaction$hold3pAc = interaction.hold3pActive) === null || _interaction$hold3pAc === void 0 ? void 0 : _interaction$hold3pAc.size) === 0 || interaction.hold3pActive === undefined;
837
+ if (noMoreActiveHolds) {
838
+ if (!activeSubmitted) {
839
+ finishInteraction(interactionId, interaction, endTime);
840
+ interactionExtraMetrics.updateFinishedInteractionId(interactionId);
841
+ activeSubmitted = true;
842
+ }
843
+ if (noMoreExpHolds) {
844
+ var _getConfig1;
845
+ if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
846
+ onExperimentalInteractionComplete(interactionId, interaction, endTime);
847
+ }
848
+ postInteraction();
849
+ }
850
+ if (noMoreActive3pHolds) {
851
+ var data = _objectSpread(_objectSpread({}, interaction), {}, {
852
+ end: endTime
853
+ });
854
+ interactionExtraMetrics.onInteractionComplete(interactionId, data);
855
+ }
787
856
  }
788
- if (noMoreExpHolds) {
789
- var _getConfig9;
790
- if ((_getConfig9 = getConfig()) !== null && _getConfig9 !== void 0 && (_getConfig9 = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9 !== void 0 && _getConfig9.enabled) {
791
- onExperimentalInteractionComplete(interactionId, interaction, endTime);
857
+ } else {
858
+ if (noMoreActiveHolds) {
859
+ if (!activeSubmitted) {
860
+ finishInteraction(interactionId, interaction, endTime);
861
+ activeSubmitted = true;
862
+ }
863
+ if (noMoreExpHolds) {
864
+ var _getConfig10;
865
+ if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
866
+ onExperimentalInteractionComplete(interactionId, interaction, endTime);
867
+ }
868
+ postInteraction();
792
869
  }
793
- postInteraction();
794
870
  }
795
871
  }
796
872
  }
@@ -818,6 +894,11 @@ export function abort(interactionId, abortReason) {
818
894
  finishInteraction(interactionId, interaction);
819
895
  postInteractionLog.reset();
820
896
  postInteractionLog.stopVCObserver();
897
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
898
+ interactionExtraMetrics.stopVCObserver();
899
+ interactionExtraMetrics.reset();
900
+ remove(interactionId);
901
+ }
821
902
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
822
903
  onExperimentalInteractionComplete(interactionId, interaction);
823
904
  remove(interactionId);
@@ -843,6 +924,11 @@ export function abortByNewInteraction(interactionId, interactionName) {
843
924
  finishInteraction(interactionId, interaction);
844
925
  postInteractionLog.reset();
845
926
  postInteractionLog.stopVCObserver();
927
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
928
+ interactionExtraMetrics.stopVCObserver();
929
+ interactionExtraMetrics.reset();
930
+ remove(interactionId);
931
+ }
846
932
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
847
933
  onExperimentalInteractionComplete(interactionId, interaction);
848
934
  remove(interactionId);
@@ -872,6 +958,11 @@ export function abortAll(abortReason, abortedByInteractionName) {
872
958
  finishInteraction(interactionId, interaction);
873
959
  postInteractionLog.reset();
874
960
  postInteractionLog.stopVCObserver();
961
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
962
+ interactionExtraMetrics.stopVCObserver();
963
+ interactionExtraMetrics.reset();
964
+ remove(interactionId);
965
+ }
875
966
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
876
967
  onExperimentalInteractionComplete(interactionId, interaction);
877
968
  remove(interactionId);
@@ -969,7 +1060,9 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
969
1060
  timerID: timerID,
970
1061
  changeTimeout: changeTimeout,
971
1062
  trace: trace,
972
- vcObserver: vcObserver
1063
+ vcObserver: vcObserver,
1064
+ hold3pActive: new Map(),
1065
+ hold3pInfo: []
973
1066
  };
974
1067
  if (addFeatureFlagsToInteraction) {
975
1068
  currentFeatureFlagsAccessed.clear();
@@ -1008,10 +1101,10 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1008
1101
  });
1009
1102
  }
1010
1103
  if (fg('platform_ufo_post_interaction_check_name')) {
1011
- var _getConfig0;
1104
+ var _getConfig11;
1012
1105
  // Start post interaction observer for all if config is enabled
1013
1106
  // in case ufoName is updated at later time
1014
- if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.postInteractionLog) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
1107
+ if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
1015
1108
  postInteractionLog.startVCObserver({
1016
1109
  startTime: startTime
1017
1110
  });
@@ -1028,6 +1121,11 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1028
1121
  startTime: startTime
1029
1122
  });
1030
1123
  }
1124
+ if (fg('platform_ufo_enable_ttai_with_3p')) {
1125
+ interactionExtraMetrics.startVCObserver({
1126
+ startTime: startTime
1127
+ }, interactionId);
1128
+ }
1031
1129
  }
1032
1130
  if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
1033
1131
  // Use per-interaction VC observer if available, otherwise fall back to global
@@ -1055,35 +1153,27 @@ export function addApdexToAll(apdex) {
1055
1153
  interactions.forEach(function (interaction, key) {
1056
1154
  interaction.apdex.push(apdex);
1057
1155
  try {
1156
+ var _apdex$startTime;
1058
1157
  // for Firefox 102 and older
1059
- if (fg('ufo_chrome_devtools_uplift')) {
1060
- var _apdex$startTime;
1061
- performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
1062
- start: (_apdex$startTime = apdex.startTime) !== null && _apdex$startTime !== void 0 ? _apdex$startTime : interaction.start,
1063
- end: apdex.stopTime,
1064
- detail: {
1065
- devtools: {
1066
- track: 'main metrics',
1067
- trackGroup: '🛸 reactUFO metrics',
1068
- color: 'primary-dark'
1069
- }
1158
+ performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
1159
+ start: (_apdex$startTime = apdex.startTime) !== null && _apdex$startTime !== void 0 ? _apdex$startTime : interaction.start,
1160
+ end: apdex.stopTime,
1161
+ detail: {
1162
+ devtools: {
1163
+ track: 'main metrics',
1164
+ trackGroup: '🛸 reactUFO metrics',
1165
+ color: 'primary-dark'
1070
1166
  }
1071
- });
1072
- performance.mark("[bm3] TTI", {
1073
- startTime: apdex.stopTime,
1074
- detail: {
1075
- devtools: {
1076
- dataType: 'marker'
1077
- }
1167
+ }
1168
+ });
1169
+ performance.mark("[bm3] TTI", {
1170
+ startTime: apdex.stopTime,
1171
+ detail: {
1172
+ devtools: {
1173
+ dataType: 'marker'
1078
1174
  }
1079
- });
1080
- } else {
1081
- var _apdex$startTime2;
1082
- performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
1083
- start: (_apdex$startTime2 = apdex.startTime) !== null && _apdex$startTime2 !== void 0 ? _apdex$startTime2 : interaction.start,
1084
- end: apdex.stopTime
1085
- });
1086
- }
1175
+ }
1176
+ });
1087
1177
  } catch (e) {
1088
1178
  // do nothing
1089
1179
  }
@@ -1097,35 +1187,27 @@ export function addApdex(interactionId, apdexInfo) {
1097
1187
  if (interaction != null) {
1098
1188
  interaction.apdex.push(apdexInfo);
1099
1189
  try {
1190
+ var _apdexInfo$startTime;
1100
1191
  // for Firefox 102 and older
1101
- if (fg('ufo_chrome_devtools_uplift')) {
1102
- var _apdexInfo$startTime;
1103
- performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
1104
- start: (_apdexInfo$startTime = apdexInfo.startTime) !== null && _apdexInfo$startTime !== void 0 ? _apdexInfo$startTime : interaction.start,
1105
- end: apdexInfo.stopTime,
1106
- detail: {
1107
- devtools: {
1108
- track: 'main metrics',
1109
- trackGroup: '🛸 reactUFO metrics',
1110
- color: 'primary-dark'
1111
- }
1192
+ performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
1193
+ start: (_apdexInfo$startTime = apdexInfo.startTime) !== null && _apdexInfo$startTime !== void 0 ? _apdexInfo$startTime : interaction.start,
1194
+ end: apdexInfo.stopTime,
1195
+ detail: {
1196
+ devtools: {
1197
+ track: 'main metrics',
1198
+ trackGroup: '🛸 reactUFO metrics',
1199
+ color: 'primary-dark'
1112
1200
  }
1113
- });
1114
- performance.mark("[bm3] TTI", {
1115
- startTime: apdexInfo.stopTime,
1116
- detail: {
1117
- devtools: {
1118
- dataType: 'marker'
1119
- }
1201
+ }
1202
+ });
1203
+ performance.mark("[bm3] TTI", {
1204
+ startTime: apdexInfo.stopTime,
1205
+ detail: {
1206
+ devtools: {
1207
+ dataType: 'marker'
1120
1208
  }
1121
- });
1122
- } else {
1123
- var _apdexInfo$startTime2;
1124
- performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
1125
- start: (_apdexInfo$startTime2 = apdexInfo.startTime) !== null && _apdexInfo$startTime2 !== void 0 ? _apdexInfo$startTime2 : interaction.start,
1126
- end: apdexInfo.stopTime
1127
- });
1128
- }
1209
+ }
1210
+ });
1129
1211
  } catch (e) {
1130
1212
  // do nothing
1131
1213
  }
@@ -1192,26 +1274,18 @@ export function addRedirect(interactionId, fromUfoName, nextUfoName, nextRouteNa
1192
1274
  if (isPerformanceTracingEnabled()) {
1193
1275
  var prevRedirect = interaction.redirects.at(-2);
1194
1276
  try {
1277
+ var _prevRedirect$time;
1195
1278
  // for Firefox 102 and older
1196
- if (fg('ufo_chrome_devtools_uplift')) {
1197
- var _prevRedirect$time;
1198
- performance.measure("\uD83D\uDEF8 ".concat(nextUfoName, " [redirect]"), {
1199
- start: (_prevRedirect$time = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time !== void 0 ? _prevRedirect$time : interaction.start,
1200
- end: time,
1201
- detail: {
1202
- devtools: {
1203
- track: '🛸 reactUFO detailed timings',
1204
- color: 'tertiary'
1205
- }
1279
+ performance.measure("\uD83D\uDEF8 ".concat(nextUfoName, " [redirect]"), {
1280
+ start: (_prevRedirect$time = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time !== void 0 ? _prevRedirect$time : interaction.start,
1281
+ end: time,
1282
+ detail: {
1283
+ devtools: {
1284
+ track: '🛸 reactUFO detailed timings',
1285
+ color: 'tertiary'
1206
1286
  }
1207
- });
1208
- } else {
1209
- var _prevRedirect$time2;
1210
- performance.measure("\uD83D\uDEF8 ".concat(nextUfoName, " [redirect]"), {
1211
- start: (_prevRedirect$time2 = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time2 !== void 0 ? _prevRedirect$time2 : interaction.start,
1212
- end: time
1213
- });
1214
- }
1287
+ }
1288
+ });
1215
1289
  } catch (e) {
1216
1290
  // do nothing
1217
1291
  }