@atlaskit/react-ufo 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/create-experimental-interaction-metrics-payload/package.json +15 -0
- package/dist/cjs/config/index.js +42 -20
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +114 -0
- package/dist/cjs/create-payload/index.js +51 -10
- package/dist/cjs/interaction-metrics/common/constants.js +2 -3
- package/dist/cjs/interaction-metrics/index.js +130 -55
- package/dist/cjs/interaction-metrics/post-interaction-log.js +20 -10
- package/dist/cjs/interaction-metrics-init/index.js +28 -7
- package/dist/cjs/load-hold/UFOLoadHold.js +5 -3
- package/dist/cjs/segment/segment.js +9 -8
- package/dist/es2019/config/index.js +22 -0
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +85 -0
- package/dist/es2019/create-payload/index.js +50 -8
- package/dist/es2019/interaction-metrics/common/constants.js +1 -2
- package/dist/es2019/interaction-metrics/index.js +109 -28
- package/dist/es2019/interaction-metrics/post-interaction-log.js +21 -11
- package/dist/es2019/interaction-metrics-init/index.js +26 -7
- package/dist/es2019/load-hold/UFOLoadHold.js +5 -3
- package/dist/es2019/segment/segment.js +8 -11
- package/dist/esm/config/index.js +41 -20
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +104 -0
- package/dist/esm/create-payload/index.js +51 -11
- package/dist/esm/interaction-metrics/common/constants.js +1 -2
- package/dist/esm/interaction-metrics/index.js +102 -27
- package/dist/esm/interaction-metrics/post-interaction-log.js +20 -10
- package/dist/esm/interaction-metrics-init/index.js +26 -7
- package/dist/esm/load-hold/UFOLoadHold.js +5 -3
- package/dist/esm/segment/segment.js +9 -8
- package/dist/types/common/common/types.d.ts +6 -4
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +16 -0
- package/dist/types/create-payload/index.d.ts +5922 -0
- package/dist/types/interaction-context/index.d.ts +1 -0
- package/dist/types/interaction-metrics/common/constants.d.ts +1 -2
- package/dist/types/interaction-metrics/index.d.ts +1 -1
- package/dist/types/load-hold/UFOLoadHold.d.ts +1 -2
- package/dist/types-ts4.5/common/common/types.d.ts +6 -4
- package/dist/types-ts4.5/config/index.d.ts +6 -0
- package/dist/types-ts4.5/create-experimental-interaction-metrics-payload/index.d.ts +16 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +5922 -0
- package/dist/types-ts4.5/interaction-context/index.d.ts +1 -0
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +1 -2
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +1 -1
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +1 -2
- package/package.json +3 -2
|
@@ -9,11 +9,12 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
9
9
|
import { v4 as createUUID } from 'uuid';
|
|
10
10
|
import coinflip from '../coinflip';
|
|
11
11
|
import { getAwaitBM3TTIList, getCapabilityRate, getConfig } from '../config';
|
|
12
|
+
import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComplete } from '../create-experimental-interaction-metrics-payload';
|
|
12
13
|
import { clearActiveTrace } from '../experience-trace-id-context';
|
|
13
14
|
import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
|
|
14
15
|
import { getInteractionId } from '../interaction-id-context';
|
|
15
16
|
import { getVCObserver } from '../vc';
|
|
16
|
-
import interactions from './common/constants';
|
|
17
|
+
import { interactions } from './common/constants';
|
|
17
18
|
import PostInteractionLog from './post-interaction-log';
|
|
18
19
|
var PreviousInteractionLog = {
|
|
19
20
|
name: undefined,
|
|
@@ -247,16 +248,27 @@ function removeHoldCriterion(id) {
|
|
|
247
248
|
}
|
|
248
249
|
window.__CRITERION__.removeUFOHold(id);
|
|
249
250
|
}
|
|
250
|
-
export function addHold(interactionId, labelStack, name) {
|
|
251
|
+
export function addHold(interactionId, labelStack, name, experimental) {
|
|
251
252
|
var interaction = interactions.get(interactionId);
|
|
252
253
|
var id = createUUID();
|
|
253
254
|
if (interaction != null) {
|
|
255
|
+
var _getConfig2;
|
|
254
256
|
var start = performance.now();
|
|
255
|
-
|
|
257
|
+
var holdActive = {
|
|
256
258
|
labelStack: labelStack,
|
|
257
259
|
name: name,
|
|
258
260
|
start: start
|
|
259
|
-
}
|
|
261
|
+
};
|
|
262
|
+
if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled && experimental) {
|
|
263
|
+
interaction.holdExpActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
|
|
264
|
+
start: start
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
if (!experimental) {
|
|
268
|
+
interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
|
|
269
|
+
start: start
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
260
272
|
addHoldCriterion(id, labelStack, name, start);
|
|
261
273
|
return function () {
|
|
262
274
|
var end = performance.now();
|
|
@@ -274,11 +286,20 @@ export function addHold(interactionId, labelStack, name) {
|
|
|
274
286
|
removeHoldCriterion(id);
|
|
275
287
|
var currentInteraction = interactions.get(interactionId);
|
|
276
288
|
var currentHold = interaction.holdActive.get(id);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
289
|
+
var expHold = interaction.holdExpActive.get(id);
|
|
290
|
+
if (currentInteraction != null) {
|
|
291
|
+
if (currentHold != null) {
|
|
292
|
+
currentInteraction.holdInfo.push(_objectSpread(_objectSpread({}, currentHold), {}, {
|
|
293
|
+
end: end
|
|
294
|
+
}));
|
|
295
|
+
interaction.holdActive.delete(id);
|
|
296
|
+
}
|
|
297
|
+
if (expHold != null) {
|
|
298
|
+
currentInteraction.holdExpInfo.push(_objectSpread(_objectSpread({}, expHold), {}, {
|
|
299
|
+
end: end
|
|
300
|
+
}));
|
|
301
|
+
interaction.holdExpActive.delete(id);
|
|
302
|
+
}
|
|
282
303
|
}
|
|
283
304
|
};
|
|
284
305
|
}
|
|
@@ -380,7 +401,7 @@ export function addErrorToAll(name, labelStack, errorType, errorMessage, errorSt
|
|
|
380
401
|
});
|
|
381
402
|
}
|
|
382
403
|
export var addProfilerTimings = function addProfilerTimings(interactionId, labelStack, type, actualDuration, baseDuration, startTime, commitTime) {
|
|
383
|
-
var
|
|
404
|
+
var _getConfig3;
|
|
384
405
|
if (isPerformanceTracingEnabled()) {
|
|
385
406
|
try {
|
|
386
407
|
// for Firefox 102 and older
|
|
@@ -402,7 +423,7 @@ export var addProfilerTimings = function addProfilerTimings(interactionId, label
|
|
|
402
423
|
startTime: startTime,
|
|
403
424
|
commitTime: commitTime
|
|
404
425
|
});
|
|
405
|
-
} else if ((
|
|
426
|
+
} else if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.postInteractionLog) !== null && _getConfig3 !== void 0 && _getConfig3.enabled) {
|
|
406
427
|
postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
|
|
407
428
|
}
|
|
408
429
|
};
|
|
@@ -419,9 +440,8 @@ function callCleanUpCallbacks(interaction) {
|
|
|
419
440
|
});
|
|
420
441
|
}
|
|
421
442
|
var finishInteraction = function finishInteraction(id, data) {
|
|
422
|
-
var
|
|
443
|
+
var _getConfig4, _getConfig5;
|
|
423
444
|
var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
|
|
424
|
-
// eslint-disable-next-line no-param-reassign
|
|
425
445
|
data.end = endTime;
|
|
426
446
|
try {
|
|
427
447
|
// for Firefox 102 and older
|
|
@@ -433,15 +453,16 @@ var finishInteraction = function finishInteraction(id, data) {
|
|
|
433
453
|
// do nothing
|
|
434
454
|
}
|
|
435
455
|
if (data.featureFlags) {
|
|
436
|
-
// eslint-disable-next-line no-param-reassign
|
|
437
456
|
data.featureFlags.during = Object.fromEntries(currentFeatureFlagsAccessed);
|
|
438
457
|
}
|
|
439
458
|
clearActiveTrace();
|
|
440
459
|
callCleanUpCallbacks(data);
|
|
441
|
-
if ((
|
|
460
|
+
if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.vc) !== null && _getConfig4 !== void 0 && _getConfig4.stopVCAtInteractionFinish) {
|
|
442
461
|
data.vc = getVCObserver().getVCRawData();
|
|
443
462
|
}
|
|
444
|
-
|
|
463
|
+
if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
|
|
464
|
+
remove(id);
|
|
465
|
+
}
|
|
445
466
|
PreviousInteractionLog.name = data.ufoName || 'unknown';
|
|
446
467
|
PreviousInteractionLog.isAborted = data.abortReason != null;
|
|
447
468
|
if (data.ufoName) {
|
|
@@ -507,15 +528,48 @@ export var sinkInteractionHandler = function sinkInteractionHandler(sinkFn) {
|
|
|
507
528
|
export var sinkPostInteractionLogHandler = function sinkPostInteractionLogHandler(sinkFn) {
|
|
508
529
|
postInteractionLog.sinkHandler(sinkFn);
|
|
509
530
|
};
|
|
531
|
+
|
|
532
|
+
// a flag to prevent multiple submitting
|
|
533
|
+
var activeSubmitted = false;
|
|
510
534
|
export function tryComplete(interactionId, endTime) {
|
|
511
535
|
var interaction = interactions.get(interactionId);
|
|
512
536
|
if (interaction != null) {
|
|
513
|
-
var
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
if ((
|
|
518
|
-
|
|
537
|
+
var noMoreActiveHolds = interaction.holdActive.size === 0;
|
|
538
|
+
var noMoreExpHolds = interaction.holdExpActive.size === 0;
|
|
539
|
+
var postInteraction = function postInteraction() {
|
|
540
|
+
var _getConfig6, _getConfig8;
|
|
541
|
+
if ((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.postInteractionLog) !== null && _getConfig6 !== void 0 && _getConfig6.enabled) {
|
|
542
|
+
var _getConfig7;
|
|
543
|
+
var experimentalVC90;
|
|
544
|
+
var experimentalTTAI;
|
|
545
|
+
if ((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7 = _getConfig7.experimentalInteractionMetrics) !== null && _getConfig7 !== void 0 && _getConfig7.enabled) {
|
|
546
|
+
var _getExperimentalVCMet;
|
|
547
|
+
experimentalVC90 = (_getExperimentalVCMet = getExperimentalVCMetrics(interaction)) === null || _getExperimentalVCMet === void 0 ? void 0 : _getExperimentalVCMet['metric:experimental:vc90'];
|
|
548
|
+
var start = interaction.start,
|
|
549
|
+
end = interaction.end;
|
|
550
|
+
experimentalTTAI = !interaction.abortReason ? Math.round(end - start) : undefined;
|
|
551
|
+
}
|
|
552
|
+
postInteractionLog.onInteractionComplete(_objectSpread(_objectSpread({}, interaction), {}, {
|
|
553
|
+
experimentalTTAI: experimentalTTAI,
|
|
554
|
+
experimentalVC90: experimentalVC90
|
|
555
|
+
}));
|
|
556
|
+
}
|
|
557
|
+
if ((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8 = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8 !== void 0 && _getConfig8.enabled) {
|
|
558
|
+
remove(interactionId);
|
|
559
|
+
}
|
|
560
|
+
activeSubmitted = false;
|
|
561
|
+
};
|
|
562
|
+
if (noMoreActiveHolds) {
|
|
563
|
+
if (!activeSubmitted) {
|
|
564
|
+
finishInteraction(interactionId, interaction, endTime);
|
|
565
|
+
activeSubmitted = true;
|
|
566
|
+
}
|
|
567
|
+
if (noMoreExpHolds) {
|
|
568
|
+
var _getConfig9;
|
|
569
|
+
if ((_getConfig9 = getConfig()) !== null && _getConfig9 !== void 0 && (_getConfig9 = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9 !== void 0 && _getConfig9.enabled) {
|
|
570
|
+
onExperimentalInteractionComplete(interactionId, interaction, endTime);
|
|
571
|
+
}
|
|
572
|
+
postInteraction();
|
|
519
573
|
}
|
|
520
574
|
}
|
|
521
575
|
}
|
|
@@ -528,33 +582,46 @@ function callCancelCallbacks(interaction) {
|
|
|
528
582
|
export function abort(interactionId, abortReason) {
|
|
529
583
|
var interaction = interactions.get(interactionId);
|
|
530
584
|
if (interaction != null) {
|
|
585
|
+
var _getConfig10;
|
|
531
586
|
callCancelCallbacks(interaction);
|
|
532
587
|
interaction.abortReason = abortReason;
|
|
533
588
|
finishInteraction(interactionId, interaction);
|
|
589
|
+
if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
|
|
590
|
+
onExperimentalInteractionComplete(interactionId, interaction);
|
|
591
|
+
remove(interactionId);
|
|
592
|
+
}
|
|
534
593
|
}
|
|
535
594
|
}
|
|
536
595
|
export function abortByNewInteraction(interactionId, interactionName) {
|
|
537
596
|
var interaction = interactions.get(interactionId);
|
|
538
597
|
if (interaction != null) {
|
|
598
|
+
var _getConfig11;
|
|
539
599
|
callCancelCallbacks(interaction);
|
|
540
600
|
interaction.abortReason = 'new_interaction';
|
|
541
601
|
interaction.abortedByInteractionName = interactionName;
|
|
542
602
|
finishInteraction(interactionId, interaction);
|
|
603
|
+
if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.experimentalInteractionMetrics) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
|
|
604
|
+
onExperimentalInteractionComplete(interactionId, interaction);
|
|
605
|
+
remove(interactionId);
|
|
606
|
+
}
|
|
543
607
|
}
|
|
544
608
|
}
|
|
545
609
|
export function abortAll(abortReason, abortedByInteractionName) {
|
|
546
610
|
interactions.forEach(function (interaction, interactionId) {
|
|
611
|
+
var _getConfig12;
|
|
547
612
|
var noMoreHolds = interaction.holdActive.size === 0;
|
|
548
613
|
if (!noMoreHolds) {
|
|
549
614
|
callCancelCallbacks(interaction);
|
|
550
|
-
// eslint-disable-next-line no-param-reassign
|
|
551
615
|
interaction.abortReason = abortReason;
|
|
552
616
|
if (abortedByInteractionName != null) {
|
|
553
|
-
// eslint-disable-next-line no-param-reassign
|
|
554
617
|
interaction.abortedByInteractionName = abortedByInteractionName;
|
|
555
618
|
}
|
|
556
619
|
}
|
|
557
620
|
finishInteraction(interactionId, interaction);
|
|
621
|
+
if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.experimentalInteractionMetrics) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
|
|
622
|
+
onExperimentalInteractionComplete(interactionId, interaction);
|
|
623
|
+
remove(interactionId);
|
|
624
|
+
}
|
|
558
625
|
});
|
|
559
626
|
}
|
|
560
627
|
export function addOnCancelCallback(id, cancelCallback) {
|
|
@@ -562,9 +629,9 @@ export function addOnCancelCallback(id, cancelCallback) {
|
|
|
562
629
|
interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
|
|
563
630
|
}
|
|
564
631
|
export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
|
|
565
|
-
var
|
|
632
|
+
var _getConfig13;
|
|
566
633
|
var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
567
|
-
if ((
|
|
634
|
+
if ((_getConfig13 = getConfig()) !== null && _getConfig13 !== void 0 && (_getConfig13 = _getConfig13.postInteractionLog) !== null && _getConfig13 !== void 0 && _getConfig13.enabled) {
|
|
568
635
|
postInteractionLog.reset();
|
|
569
636
|
}
|
|
570
637
|
var previousTime = startTime;
|
|
@@ -604,9 +671,11 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
604
671
|
requestInfo: [],
|
|
605
672
|
reactProfilerTimings: [],
|
|
606
673
|
holdInfo: [],
|
|
674
|
+
holdExpInfo: [],
|
|
607
675
|
holdActive: new Map(),
|
|
676
|
+
holdExpActive: new Map(),
|
|
608
677
|
// measure when we execute this code
|
|
609
|
-
// from this we can measure the input delay -
|
|
678
|
+
// from this, we can measure the input delay -
|
|
610
679
|
// how long the browser took to hand execution back to JS)
|
|
611
680
|
measureStart: performance.now(),
|
|
612
681
|
rate: rate,
|
|
@@ -650,12 +719,18 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
650
719
|
addHoldByID(interactionId, [], ufoName, ufoName, true);
|
|
651
720
|
}
|
|
652
721
|
if (type === 'transition') {
|
|
722
|
+
var _getConfig14;
|
|
653
723
|
getVCObserver().start({
|
|
654
724
|
startTime: startTime
|
|
655
725
|
});
|
|
656
726
|
postInteractionLog.startVCObserver({
|
|
657
727
|
startTime: startTime
|
|
658
728
|
});
|
|
729
|
+
if ((_getConfig14 = getConfig()) !== null && _getConfig14 !== void 0 && (_getConfig14 = _getConfig14.experimentalInteractionMetrics) !== null && _getConfig14 !== void 0 && _getConfig14.enabled) {
|
|
730
|
+
experimentalVC.start({
|
|
731
|
+
startTime: startTime
|
|
732
|
+
});
|
|
733
|
+
}
|
|
659
734
|
}
|
|
660
735
|
}
|
|
661
736
|
export function addBrowserMetricEvent(event) {
|
|
@@ -106,22 +106,32 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
106
106
|
}, {
|
|
107
107
|
key: "sendPostInteractionLog",
|
|
108
108
|
value: function sendPostInteractionLog() {
|
|
109
|
-
var _this$
|
|
109
|
+
var _this$vcObserver3, _getConfig2;
|
|
110
110
|
if (!this.hasData() || !this.lastInteractionFinish || !this.sinkHandlerFn) {
|
|
111
|
+
var _getConfig;
|
|
111
112
|
this.reset();
|
|
113
|
+
if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.experimentalInteractionMetrics) !== null && _getConfig !== void 0 && _getConfig.enabled) {
|
|
114
|
+
var _this$vcObserver2;
|
|
115
|
+
(_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 || _this$vcObserver2.stop();
|
|
116
|
+
}
|
|
112
117
|
return;
|
|
113
118
|
}
|
|
119
|
+
var postInteractionFinishVCResult = (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.getVCResult(_objectSpread({
|
|
120
|
+
start: this.lastInteractionFinish.start,
|
|
121
|
+
stop: performance.now(),
|
|
122
|
+
tti: -1,
|
|
123
|
+
// no need for TTI value here
|
|
124
|
+
prefix: 'ufo'
|
|
125
|
+
}, this.vcObserverSSRConfig));
|
|
126
|
+
if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled) {
|
|
127
|
+
var _this$vcObserver4;
|
|
128
|
+
(_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 || _this$vcObserver4.stop();
|
|
129
|
+
}
|
|
114
130
|
this.sinkHandlerFn({
|
|
115
131
|
lastInteractionFinish: this.lastInteractionFinish,
|
|
116
132
|
reactProfilerTimings: this.reactProfilerTimings,
|
|
117
133
|
// NOTE: invoking `getVCResult` at latest possible point in time here (not earlier) to get the most accurate result (from performance.now())
|
|
118
|
-
postInteractionFinishVCResult:
|
|
119
|
-
start: this.lastInteractionFinish.start,
|
|
120
|
-
stop: performance.now(),
|
|
121
|
-
tti: -1,
|
|
122
|
-
// no need for TTI value here
|
|
123
|
-
prefix: 'ufo'
|
|
124
|
-
}, this.vcObserverSSRConfig)),
|
|
134
|
+
postInteractionFinishVCResult: postInteractionFinishVCResult,
|
|
125
135
|
lastInteractionFinishVCResult: this.lastInteractionFinishVCResult
|
|
126
136
|
});
|
|
127
137
|
this.reset();
|
|
@@ -135,7 +145,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
135
145
|
}, {
|
|
136
146
|
key: "onInteractionComplete",
|
|
137
147
|
value: function onInteractionComplete(_ref2) {
|
|
138
|
-
var
|
|
148
|
+
var _getConfig3,
|
|
139
149
|
_this = this;
|
|
140
150
|
var ufoName = _ref2.ufoName,
|
|
141
151
|
start = _ref2.start,
|
|
@@ -159,7 +169,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
159
169
|
experimentalTTAI: experimentalTTAI,
|
|
160
170
|
experimentalVC90: experimentalVC90
|
|
161
171
|
};
|
|
162
|
-
var timeout = ((
|
|
172
|
+
var timeout = ((_getConfig3 = getConfig()) === null || _getConfig3 === void 0 ? void 0 : _getConfig3.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
|
|
163
173
|
this.sinkTimeoutId = window.setTimeout(function () {
|
|
164
174
|
_this.sendPostInteractionLog();
|
|
165
175
|
}, timeout);
|
|
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
3
3
|
import { startLighthouseObserver } from '../additional-payload';
|
|
4
4
|
import { setUFOConfig } from '../config';
|
|
5
|
+
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
5
6
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
6
7
|
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
7
8
|
import { getVCObserver } from '../vc';
|
|
@@ -16,6 +17,16 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
}
|
|
20
|
+
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
21
|
+
sinkExperimentalHandler(function (interactionId, interaction) {
|
|
22
|
+
scheduleCallback(idlePriority, function () {
|
|
23
|
+
var payload = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
24
|
+
if (payload) {
|
|
25
|
+
instance.sendOperationalEvent(payload);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
19
30
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
20
31
|
sinkPostInteractionLogHandler(function (logOutput) {
|
|
21
32
|
scheduleCallback(idlePriority, function () {
|
|
@@ -33,6 +44,7 @@ export var init = function init(analyticsWebClientAsync, config) {
|
|
|
33
44
|
}
|
|
34
45
|
setUFOConfig(config);
|
|
35
46
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
47
|
+
var _config$experimentalI;
|
|
36
48
|
var vcOptions = {
|
|
37
49
|
heatmapSize: config.vc.heatmapSize,
|
|
38
50
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
@@ -46,31 +58,38 @@ export var init = function init(analyticsWebClientAsync, config) {
|
|
|
46
58
|
postInteractionLog.startVCObserver({
|
|
47
59
|
startTime: 0
|
|
48
60
|
});
|
|
61
|
+
if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
62
|
+
experimentalVC.initialize(vcOptions).start({
|
|
63
|
+
startTime: 0
|
|
64
|
+
});
|
|
65
|
+
}
|
|
49
66
|
}
|
|
50
67
|
setupHiddenTimingCapture();
|
|
51
68
|
startLighthouseObserver();
|
|
52
69
|
initialized = true;
|
|
53
|
-
Promise.all([analyticsWebClientAsync,
|
|
54
|
-
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
55
|
-
import( /* webpackChunkName: "create-payloads" */'../create-payload'),
|
|
56
|
-
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
57
|
-
import( /* webpackChunkName: "create-post-intreaction-log-payload" */'../create-post-interaction-log-payload')]).then(function (_ref) {
|
|
70
|
+
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload')]).then(function (_ref) {
|
|
58
71
|
var _ref2 = _slicedToArray(_ref, 3),
|
|
59
72
|
awc = _ref2[0],
|
|
60
73
|
payloadPackage = _ref2[1],
|
|
61
74
|
createPostInteractionLogPayloadPackage = _ref2[2];
|
|
62
75
|
if (awc.getAnalyticsWebClientPromise) {
|
|
63
76
|
awc.getAnalyticsWebClientPromise().then(function (client) {
|
|
64
|
-
var _config$postInteracti;
|
|
77
|
+
var _config$experimentalI2, _config$postInteracti;
|
|
65
78
|
var instance = client.getInstance();
|
|
66
79
|
sinkInteraction(instance, payloadPackage);
|
|
80
|
+
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
81
|
+
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
82
|
+
}
|
|
67
83
|
if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
|
|
68
84
|
sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
|
|
69
85
|
}
|
|
70
86
|
});
|
|
71
87
|
} else if (awc.sendOperationalEvent) {
|
|
72
|
-
var _config$postInteracti2;
|
|
88
|
+
var _config$experimentalI3, _config$postInteracti2;
|
|
73
89
|
sinkInteraction(awc, payloadPackage);
|
|
90
|
+
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
91
|
+
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
92
|
+
}
|
|
74
93
|
if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
|
|
75
94
|
sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
|
|
76
95
|
}
|
|
@@ -22,8 +22,7 @@ var useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayoutE
|
|
|
22
22
|
* return (
|
|
23
23
|
* <>
|
|
24
24
|
* <Skeleton />
|
|
25
|
-
* <UFOLoadHold name="card"
|
|
26
|
-
* </UFOLoadHold>
|
|
25
|
+
* <UFOLoadHold name="card" />
|
|
27
26
|
* )
|
|
28
27
|
* }
|
|
29
28
|
* ```
|
|
@@ -58,7 +57,10 @@ export default function UFOLoadHold(_ref) {
|
|
|
58
57
|
// react-18: useId instead
|
|
59
58
|
var context = useContext(UFOInteractionContext);
|
|
60
59
|
useLayoutEffectSAFE(function () {
|
|
61
|
-
if (hold &&
|
|
60
|
+
if (hold && context != null) {
|
|
61
|
+
if (experimental && context.holdExperimental) {
|
|
62
|
+
return context.holdExperimental(name);
|
|
63
|
+
}
|
|
62
64
|
return context.hold(name);
|
|
63
65
|
}
|
|
64
66
|
}, [hold, context, name]);
|
|
@@ -79,15 +79,14 @@ export default function UFOSegment(_ref) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
function _internalHold(labelStack, name
|
|
83
|
-
|
|
84
|
-
) {
|
|
82
|
+
function _internalHold(labelStack, name) {
|
|
83
|
+
var experimental = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
85
84
|
if (interactionId.current != null) {
|
|
86
85
|
if (parentContext) {
|
|
87
|
-
return parentContext._internalHold(labelStack, name);
|
|
86
|
+
return parentContext._internalHold(labelStack, name, experimental);
|
|
88
87
|
} else {
|
|
89
88
|
var capturedInteractionId = interactionId.current;
|
|
90
|
-
var disposeHold = addHold(interactionId.current, labelStack, name);
|
|
89
|
+
var disposeHold = addHold(interactionId.current, labelStack, name, experimental);
|
|
91
90
|
return function () {
|
|
92
91
|
if (capturedInteractionId === interactionId.current) {
|
|
93
92
|
disposeHold();
|
|
@@ -96,9 +95,7 @@ export default function UFOSegment(_ref) {
|
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
|
-
function _internalHoldByID(labelStack, id, name, remove
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
101
|
-
) {
|
|
98
|
+
function _internalHoldByID(labelStack, id, name, remove) {
|
|
102
99
|
if (interactionId.current != null) {
|
|
103
100
|
if (parentContext) {
|
|
104
101
|
parentContext._internalHoldByID(labelStack, name, id, remove);
|
|
@@ -123,6 +120,10 @@ export default function UFOSegment(_ref) {
|
|
|
123
120
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
124
121
|
return this._internalHold(this.labelStack, name);
|
|
125
122
|
},
|
|
123
|
+
holdExperimental: function holdExperimental() {
|
|
124
|
+
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
125
|
+
return this._internalHold(this.labelStack, name, true);
|
|
126
|
+
},
|
|
126
127
|
addHoldByID: function addHoldByID(labelStack, id) {
|
|
127
128
|
var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unknown';
|
|
128
129
|
this._internalHoldByID(labelStack, id, name, false);
|
|
@@ -63,7 +63,7 @@ export interface SegmentInfo {
|
|
|
63
63
|
labelStack: LabelStack;
|
|
64
64
|
}
|
|
65
65
|
export interface CustomData {
|
|
66
|
-
[key: string]: null |
|
|
66
|
+
[key: string]: null | string | number | boolean | undefined | CustomData | Record<string, CustomData>;
|
|
67
67
|
}
|
|
68
68
|
export type CustomTiming = Record<string, {
|
|
69
69
|
startTime: number;
|
|
@@ -104,7 +104,9 @@ export interface InteractionMetrics {
|
|
|
104
104
|
labelStack: LabelStack;
|
|
105
105
|
})[];
|
|
106
106
|
holdInfo: HoldInfo[];
|
|
107
|
+
holdExpInfo: HoldInfo[];
|
|
107
108
|
holdActive: Map<string, HoldActive>;
|
|
109
|
+
holdExpActive: Map<string, HoldActive>;
|
|
108
110
|
reactProfilerTimings: ReactProfilerTiming[];
|
|
109
111
|
measureStart: number;
|
|
110
112
|
rate: number;
|
|
@@ -115,11 +117,11 @@ export interface InteractionMetrics {
|
|
|
115
117
|
abortReason?: AbortReasonType;
|
|
116
118
|
abortedByInteractionName?: string;
|
|
117
119
|
/**
|
|
118
|
-
* Apdex is legacy performance measurement where it is
|
|
120
|
+
* Apdex is a legacy performance measurement where it is
|
|
119
121
|
* capturing TTI at arbitrary point in the code (bm3/UFOv1)
|
|
120
122
|
*
|
|
121
123
|
* We are intercepting its values now just so we can use it for
|
|
122
|
-
* topline metric, but should encourage teams adopt TTAI
|
|
124
|
+
* topline metric, but should encourage teams to adopt TTAI
|
|
123
125
|
*
|
|
124
126
|
* This field might be ignored/dropped in the future.
|
|
125
127
|
*/
|
|
@@ -164,7 +166,7 @@ export interface LazyLoadProfilerContext {
|
|
|
164
166
|
addLoad(identifier: string, start: number, end: number): void;
|
|
165
167
|
}
|
|
166
168
|
export interface EnhancedUFOInteractionContextType extends UFOInteractionContextType, RelayMetricsRecorder, LazyLoadProfilerContext {
|
|
167
|
-
_internalHold(labelStack: LabelStack, name: string): void | (() => void);
|
|
169
|
+
_internalHold(labelStack: LabelStack, name: string, experimental?: boolean): void | (() => void);
|
|
168
170
|
_internalHoldByID(labelStack: LabelStack, id: string, name: string, remove: boolean): void | (() => void);
|
|
169
171
|
addHoldByID(labelStack: LabelStack, id: string, name?: string): void;
|
|
170
172
|
removeHoldByID(labelStack: LabelStack, id: string, name?: string): void;
|
|
@@ -73,6 +73,11 @@ export type Config = {
|
|
|
73
73
|
readonly rates?: Rates;
|
|
74
74
|
readonly kind?: Record<InteractionType, number>;
|
|
75
75
|
};
|
|
76
|
+
readonly experimentalInteractionMetrics?: {
|
|
77
|
+
readonly enabled?: boolean;
|
|
78
|
+
readonly rates?: Rates;
|
|
79
|
+
readonly kind?: Record<InteractionType, number>;
|
|
80
|
+
};
|
|
76
81
|
readonly enableSegmentHighlighting?: boolean;
|
|
77
82
|
readonly enableAdditionalPerformanceMarks?: boolean;
|
|
78
83
|
readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
|
|
@@ -87,6 +92,7 @@ export type Config = {
|
|
|
87
92
|
export declare function setUFOConfig(newConfig: Config): void;
|
|
88
93
|
export declare function getConfig(): Config | undefined;
|
|
89
94
|
export declare function getInteractionRate(name: string, interactionKind: InteractionKind): number;
|
|
95
|
+
export declare function getExperimentalInteractionRate(name: string, interactionType: InteractionType): number;
|
|
90
96
|
export declare function getPostInteractionRate(name: string, interactionType: InteractionType): number;
|
|
91
97
|
export declare function getCapabilityRate(capability: Capability): number;
|
|
92
98
|
declare const validTypingMethods: readonly ["timeout", "timeoutNoAlloc", "mutationObserver"];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { InteractionMetrics } from '../common';
|
|
2
|
+
import { VCObserver, type VCObserverOptions } from '../vc/vc-observer';
|
|
3
|
+
type InteractionMetricsHandler = (interactionId: string, interaction: InteractionMetrics) => void | Promise<void>;
|
|
4
|
+
export declare function installInteractionSink(handler: InteractionMetricsHandler): void;
|
|
5
|
+
export declare function sinkExperimentalHandler(sinkFn: (interactionId: string, interaction: InteractionMetrics) => void | Promise<void>): void;
|
|
6
|
+
export declare function onExperimentalInteractionComplete(interactionId: string, data: InteractionMetrics, endTime?: number): void;
|
|
7
|
+
export declare class ExperimentalVCMetrics {
|
|
8
|
+
vcObserver: VCObserver | null;
|
|
9
|
+
initialize(options: VCObserverOptions): this;
|
|
10
|
+
start({ startTime }: {
|
|
11
|
+
startTime: number;
|
|
12
|
+
}): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const experimentalVC: ExperimentalVCMetrics;
|
|
15
|
+
export declare const getExperimentalVCMetrics: (interaction: InteractionMetrics) => import("../common/vc/types").VCResult | null;
|
|
16
|
+
export {};
|