@atlaskit/react-ufo 2.7.0 → 2.8.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/dist/cjs/config/index.js +18 -40
- package/dist/cjs/create-payload/common/utils/index.js +2 -66
- package/dist/cjs/create-payload/index.js +78 -55
- package/dist/cjs/interaction-metrics/common/constants.js +3 -8
- package/dist/cjs/interaction-metrics/index.js +238 -166
- package/dist/cjs/interaction-metrics-init/index.js +9 -31
- package/dist/cjs/load-hold/UFOLoadHold.js +3 -5
- package/dist/cjs/segment/segment.js +8 -9
- package/dist/es2019/config/index.js +0 -22
- package/dist/es2019/create-payload/common/utils/index.js +1 -68
- package/dist/es2019/create-payload/index.js +77 -48
- package/dist/es2019/interaction-metrics/common/constants.js +2 -7
- package/dist/es2019/interaction-metrics/index.js +131 -91
- package/dist/es2019/interaction-metrics-init/index.js +8 -28
- package/dist/es2019/load-hold/UFOLoadHold.js +3 -5
- package/dist/es2019/segment/segment.js +11 -8
- package/dist/esm/config/index.js +18 -39
- package/dist/esm/create-payload/common/utils/index.js +1 -63
- package/dist/esm/create-payload/index.js +78 -53
- package/dist/esm/interaction-metrics/common/constants.js +2 -7
- package/dist/esm/interaction-metrics/index.js +158 -86
- package/dist/esm/interaction-metrics-init/index.js +8 -28
- package/dist/esm/load-hold/UFOLoadHold.js +3 -5
- package/dist/esm/segment/segment.js +8 -9
- package/dist/types/common/common/types.d.ts +4 -6
- package/dist/types/config/index.d.ts +0 -6
- package/dist/types/create-payload/common/utils/index.d.ts +0 -9
- package/dist/types/create-payload/index.d.ts +5660 -13
- package/dist/types/interaction-context/index.d.ts +0 -1
- package/dist/types/interaction-metrics/common/constants.d.ts +3 -32
- package/dist/types/interaction-metrics/index.d.ts +17 -1
- package/dist/types/load-hold/UFOLoadHold.d.ts +2 -1
- package/dist/types-ts4.5/common/common/types.d.ts +4 -6
- package/dist/types-ts4.5/config/index.d.ts +0 -6
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +0 -9
- package/dist/types-ts4.5/create-payload/index.d.ts +5660 -13
- package/dist/types-ts4.5/interaction-context/index.d.ts +0 -1
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -32
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +17 -1
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +2 -1
- package/package.json +2 -3
- package/create-experimental-interaction-metrics-payload/package.json +0 -15
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +0 -100
- package/dist/cjs/interaction-metrics/common/index.js +0 -151
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +0 -71
- package/dist/es2019/interaction-metrics/common/index.js +0 -103
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +0 -90
- package/dist/esm/interaction-metrics/common/index.js +0 -132
- package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +0 -16
- package/dist/types/interaction-metrics/common/index.d.ts +0 -16
- package/dist/types-ts4.5/create-experimental-interaction-metrics-payload/index.d.ts +0 -16
- package/dist/types-ts4.5/interaction-metrics/common/index.d.ts +0 -16
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { v4 as createUUID } from 'uuid';
|
|
2
2
|
import coinflip from '../coinflip';
|
|
3
3
|
import { getAwaitBM3TTIList, getCapabilityRate, getConfig } from '../config';
|
|
4
|
-
import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComplete } from '../create-experimental-interaction-metrics-payload';
|
|
5
|
-
import { getTTAI, postInteractionLog } from '../create-payload/common/utils';
|
|
6
4
|
import { clearActiveTrace } from '../experience-trace-id-context';
|
|
7
5
|
import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
|
|
8
6
|
import { getInteractionId } from '../interaction-id-context';
|
|
9
7
|
import { getVCObserver } from '../vc';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import interactions from './common/constants';
|
|
9
|
+
import PostInteractionLog from './post-interaction-log';
|
|
12
10
|
const PreviousInteractionLog = {
|
|
13
11
|
name: undefined,
|
|
14
12
|
isAborted: undefined
|
|
15
13
|
};
|
|
14
|
+
export const postInteractionLog = new PostInteractionLog();
|
|
15
|
+
const interactionQueue = [];
|
|
16
|
+
const segmentCache = new Map();
|
|
17
|
+
const CLEANUP_TIMEOUT = 60 * 1000;
|
|
18
|
+
const CLEANUP_TIMEOUT_AFTER_APDEX = 15 * 1000;
|
|
19
|
+
const segmentObservers = [];
|
|
16
20
|
export function getActiveInteraction() {
|
|
17
21
|
const interactionId = getInteractionId();
|
|
18
22
|
if (!interactionId.current) {
|
|
@@ -20,6 +24,36 @@ export function getActiveInteraction() {
|
|
|
20
24
|
}
|
|
21
25
|
return interactions.get(interactionId.current);
|
|
22
26
|
}
|
|
27
|
+
function isPerformanceTracingEnabled() {
|
|
28
|
+
var _getConfig;
|
|
29
|
+
return ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.enableAdditionalPerformanceMarks) || window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production';
|
|
30
|
+
}
|
|
31
|
+
function labelStackToString(labelStack, name) {
|
|
32
|
+
var _stack$map;
|
|
33
|
+
const stack = [...(labelStack !== null && labelStack !== void 0 ? labelStack : [])];
|
|
34
|
+
if (name) {
|
|
35
|
+
stack.push({
|
|
36
|
+
name
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return (_stack$map = stack.map(l => l.name)) === null || _stack$map === void 0 ? void 0 : _stack$map.join('/');
|
|
40
|
+
}
|
|
41
|
+
function labelStackToIdString(labelStack) {
|
|
42
|
+
var _labelStack$map;
|
|
43
|
+
return labelStack === null || labelStack === void 0 ? void 0 : (_labelStack$map = labelStack.map(l => 'segmentId' in l ? `${l.name}:${l.segmentId}` : `${l.name}`)) === null || _labelStack$map === void 0 ? void 0 : _labelStack$map.join('/');
|
|
44
|
+
}
|
|
45
|
+
function addSegmentObserver(observer) {
|
|
46
|
+
segmentObservers.push(observer);
|
|
47
|
+
for (const segmentInfo of segmentCache.values()) {
|
|
48
|
+
observer.onAdd(segmentInfo);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function removeSegmentObserver(observer) {
|
|
52
|
+
const index = segmentObservers.findIndex(obs => obs === observer);
|
|
53
|
+
if (index !== -1) {
|
|
54
|
+
segmentObservers.splice(index, 1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
23
57
|
export function remove(interactionId) {
|
|
24
58
|
interactions.delete(interactionId);
|
|
25
59
|
}
|
|
@@ -162,6 +196,7 @@ export function addPreload(moduleId, timestamp) {
|
|
|
162
196
|
export function addLoad(identifier, start, end) {
|
|
163
197
|
addSpanToAll('bundle_load', identifier, null, start, end - start);
|
|
164
198
|
}
|
|
199
|
+
const moduleLoadingRequests = {};
|
|
165
200
|
export function extractModuleName(input) {
|
|
166
201
|
let result = input !== null && input !== void 0 ? input : '';
|
|
167
202
|
result = result.replace(/^\.\/src\/packages\//, '');
|
|
@@ -169,29 +204,30 @@ export function extractModuleName(input) {
|
|
|
169
204
|
result = result.replace(/(\/src)?\/(index|main)\.(tsx|ts|js|jsx)$/, '');
|
|
170
205
|
return result;
|
|
171
206
|
}
|
|
172
|
-
|
|
207
|
+
function addHoldCriterion(id, labelStack, name, startTime) {
|
|
208
|
+
var _window$__CRITERION__;
|
|
209
|
+
if (!((_window$__CRITERION__ = window.__CRITERION__) !== null && _window$__CRITERION__ !== void 0 && _window$__CRITERION__.addUFOHold)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
window.__CRITERION__.addUFOHold(id, labelStackToString(labelStack), name, startTime);
|
|
213
|
+
}
|
|
214
|
+
function removeHoldCriterion(id) {
|
|
215
|
+
var _window$__CRITERION__2;
|
|
216
|
+
if (!((_window$__CRITERION__2 = window.__CRITERION__) !== null && _window$__CRITERION__2 !== void 0 && _window$__CRITERION__2.removeUFOHold)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
window.__CRITERION__.removeUFOHold(id);
|
|
220
|
+
}
|
|
221
|
+
export function addHold(interactionId, labelStack, name) {
|
|
173
222
|
const interaction = interactions.get(interactionId);
|
|
174
223
|
const id = createUUID();
|
|
175
224
|
if (interaction != null) {
|
|
176
|
-
|
|
177
|
-
|
|
225
|
+
const start = performance.now();
|
|
226
|
+
interaction.holdActive.set(id, {
|
|
178
227
|
labelStack,
|
|
179
228
|
name,
|
|
180
|
-
start
|
|
181
|
-
};
|
|
182
|
-
const start = performance.now();
|
|
183
|
-
if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig$experiment = _getConfig.experimentalInteractionMetrics) !== null && _getConfig$experiment !== void 0 && _getConfig$experiment.enabled && experimental) {
|
|
184
|
-
interaction.holdExpActive.set(id, {
|
|
185
|
-
...holdActive,
|
|
186
|
-
start
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (!experimental) {
|
|
190
|
-
interaction.holdActive.set(id, {
|
|
191
|
-
...holdActive,
|
|
192
|
-
start
|
|
193
|
-
});
|
|
194
|
-
}
|
|
229
|
+
start
|
|
230
|
+
});
|
|
195
231
|
addHoldCriterion(id, labelStack, name, start);
|
|
196
232
|
return () => {
|
|
197
233
|
const end = performance.now();
|
|
@@ -209,22 +245,12 @@ export function addHold(interactionId, labelStack, name, experimental) {
|
|
|
209
245
|
removeHoldCriterion(id);
|
|
210
246
|
const currentInteraction = interactions.get(interactionId);
|
|
211
247
|
const currentHold = interaction.holdActive.get(id);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
interaction.holdActive.delete(id);
|
|
220
|
-
}
|
|
221
|
-
if (expHold != null) {
|
|
222
|
-
currentInteraction.holdExpInfo.push({
|
|
223
|
-
...expHold,
|
|
224
|
-
end
|
|
225
|
-
});
|
|
226
|
-
interaction.holdExpActive.delete(id);
|
|
227
|
-
}
|
|
248
|
+
if (currentInteraction != null && currentHold != null) {
|
|
249
|
+
currentInteraction.holdInfo.push({
|
|
250
|
+
...currentHold,
|
|
251
|
+
end
|
|
252
|
+
});
|
|
253
|
+
interaction.holdActive.delete(id);
|
|
228
254
|
}
|
|
229
255
|
};
|
|
230
256
|
}
|
|
@@ -353,9 +379,21 @@ export const addProfilerTimings = (interactionId, labelStack, type, actualDurati
|
|
|
353
379
|
postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
|
|
354
380
|
}
|
|
355
381
|
};
|
|
382
|
+
const pushToQueue = (id, data) => {
|
|
383
|
+
interactionQueue.push({
|
|
384
|
+
id,
|
|
385
|
+
data
|
|
386
|
+
});
|
|
387
|
+
};
|
|
356
388
|
let handleInteraction = pushToQueue;
|
|
389
|
+
function callCleanUpCallbacks(interaction) {
|
|
390
|
+
interaction.cleanupCallbacks.reverse().forEach(cleanUpCallback => {
|
|
391
|
+
cleanUpCallback();
|
|
392
|
+
});
|
|
393
|
+
}
|
|
357
394
|
const finishInteraction = (id, data, endTime = performance.now()) => {
|
|
358
395
|
var _getConfig3, _getConfig3$vc;
|
|
396
|
+
// eslint-disable-next-line no-param-reassign
|
|
359
397
|
data.end = endTime;
|
|
360
398
|
try {
|
|
361
399
|
// for Firefox 102 and older
|
|
@@ -367,6 +405,7 @@ const finishInteraction = (id, data, endTime = performance.now()) => {
|
|
|
367
405
|
// do nothing
|
|
368
406
|
}
|
|
369
407
|
if (data.featureFlags) {
|
|
408
|
+
// eslint-disable-next-line no-param-reassign
|
|
370
409
|
data.featureFlags.during = Object.fromEntries(currentFeatureFlagsAccessed);
|
|
371
410
|
}
|
|
372
411
|
clearActiveTrace();
|
|
@@ -374,13 +413,41 @@ const finishInteraction = (id, data, endTime = performance.now()) => {
|
|
|
374
413
|
if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3$vc = _getConfig3.vc) !== null && _getConfig3$vc !== void 0 && _getConfig3$vc.stopVCAtInteractionFinish) {
|
|
375
414
|
data.vc = getVCObserver().getVCRawData();
|
|
376
415
|
}
|
|
416
|
+
remove(id);
|
|
377
417
|
PreviousInteractionLog.name = data.ufoName || 'unknown';
|
|
378
418
|
PreviousInteractionLog.isAborted = data.abortReason != null;
|
|
379
419
|
if (data.ufoName) {
|
|
380
420
|
handleInteraction(id, data);
|
|
381
421
|
}
|
|
382
422
|
if (isPerformanceTracingEnabled()) {
|
|
383
|
-
|
|
423
|
+
const profilerTimingMap = new Map();
|
|
424
|
+
data.reactProfilerTimings.forEach(profilerTiming => {
|
|
425
|
+
const labelStackId = labelStackToIdString(profilerTiming.labelStack);
|
|
426
|
+
if (labelStackId) {
|
|
427
|
+
var _profilerTimingMap$ge, _timing$start, _timing$end;
|
|
428
|
+
const timing = (_profilerTimingMap$ge = profilerTimingMap.get(labelStackId)) !== null && _profilerTimingMap$ge !== void 0 ? _profilerTimingMap$ge : {
|
|
429
|
+
labelStack: profilerTiming.labelStack
|
|
430
|
+
};
|
|
431
|
+
timing.start = profilerTiming.startTime < ((_timing$start = timing.start) !== null && _timing$start !== void 0 ? _timing$start : Number.MAX_SAFE_INTEGER) ? profilerTiming.startTime : timing.start;
|
|
432
|
+
timing.end = profilerTiming.commitTime > ((_timing$end = timing.end) !== null && _timing$end !== void 0 ? _timing$end : Number.MIN_SAFE_INTEGER) ? profilerTiming.commitTime : timing.end;
|
|
433
|
+
profilerTimingMap.set(labelStackId, timing);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
try {
|
|
437
|
+
// for Firefox 102 and older
|
|
438
|
+
for (const [, {
|
|
439
|
+
labelStack,
|
|
440
|
+
start,
|
|
441
|
+
end
|
|
442
|
+
}] of profilerTimingMap.entries()) {
|
|
443
|
+
performance.measure(`🛸 ${labelStackToString(labelStack)} [segment_ttai]`, {
|
|
444
|
+
start,
|
|
445
|
+
end
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
} catch (e) {
|
|
449
|
+
// do nothing
|
|
450
|
+
}
|
|
384
451
|
}
|
|
385
452
|
try {
|
|
386
453
|
// dispatch a global window event to notify the measure is completed
|
|
@@ -403,86 +470,54 @@ export const sinkInteractionHandler = sinkFn => {
|
|
|
403
470
|
export const sinkPostInteractionLogHandler = sinkFn => {
|
|
404
471
|
postInteractionLog.sinkHandler(sinkFn);
|
|
405
472
|
};
|
|
406
|
-
|
|
407
|
-
// a flag to prevent multiple submitting
|
|
408
|
-
let activeSubmitted = false;
|
|
409
473
|
export function tryComplete(interactionId, endTime) {
|
|
410
474
|
const interaction = interactions.get(interactionId);
|
|
411
475
|
if (interaction != null) {
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
const postInteraction = () => {
|
|
476
|
+
const noMoreHolds = interaction.holdActive.size === 0;
|
|
477
|
+
if (noMoreHolds) {
|
|
415
478
|
var _getConfig4, _getConfig4$postInter;
|
|
479
|
+
finishInteraction(interactionId, interaction, endTime);
|
|
416
480
|
if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4$postInter = _getConfig4.postInteractionLog) !== null && _getConfig4$postInter !== void 0 && _getConfig4$postInter.enabled) {
|
|
417
|
-
|
|
418
|
-
const experimentalVC90 = (_getExperimentalVCMet = getExperimentalVCMetrics(interaction)) === null || _getExperimentalVCMet === void 0 ? void 0 : _getExperimentalVCMet['metric:experimental:vc90'];
|
|
419
|
-
const experimentalTTAI = getTTAI(interaction);
|
|
420
|
-
postInteractionLog.onInteractionComplete({
|
|
421
|
-
...interaction,
|
|
422
|
-
experimentalTTAI,
|
|
423
|
-
experimentalVC90
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
remove(interactionId);
|
|
427
|
-
};
|
|
428
|
-
if (noMoreActiveHolds) {
|
|
429
|
-
if (!activeSubmitted) {
|
|
430
|
-
finishInteraction(interactionId, interaction, endTime);
|
|
431
|
-
activeSubmitted = true;
|
|
432
|
-
}
|
|
433
|
-
if (noMoreExpHolds) {
|
|
434
|
-
var _getConfig5, _getConfig5$experimen;
|
|
435
|
-
if ((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$experimen = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5$experimen !== void 0 && _getConfig5$experimen.enabled) {
|
|
436
|
-
onExperimentalInteractionComplete(interactionId, interaction, endTime);
|
|
437
|
-
}
|
|
438
|
-
postInteraction();
|
|
481
|
+
postInteractionLog.onInteractionComplete(interaction);
|
|
439
482
|
}
|
|
440
483
|
}
|
|
441
484
|
}
|
|
442
485
|
}
|
|
486
|
+
function callCancelCallbacks(interaction) {
|
|
487
|
+
interaction.cancelCallbacks.reverse().forEach(cancelCallback => {
|
|
488
|
+
cancelCallback();
|
|
489
|
+
});
|
|
490
|
+
}
|
|
443
491
|
export function abort(interactionId, abortReason) {
|
|
444
492
|
const interaction = interactions.get(interactionId);
|
|
445
493
|
if (interaction != null) {
|
|
446
|
-
var _getConfig6, _getConfig6$experimen;
|
|
447
494
|
callCancelCallbacks(interaction);
|
|
448
495
|
interaction.abortReason = abortReason;
|
|
449
496
|
finishInteraction(interactionId, interaction);
|
|
450
|
-
if ((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6$experimen = _getConfig6.experimentalInteractionMetrics) !== null && _getConfig6$experimen !== void 0 && _getConfig6$experimen.enabled) {
|
|
451
|
-
onExperimentalInteractionComplete(interactionId, interaction);
|
|
452
|
-
}
|
|
453
|
-
remove(interactionId);
|
|
454
497
|
}
|
|
455
498
|
}
|
|
456
499
|
export function abortByNewInteraction(interactionId, interactionName) {
|
|
457
500
|
const interaction = interactions.get(interactionId);
|
|
458
501
|
if (interaction != null) {
|
|
459
|
-
var _getConfig7, _getConfig7$experimen;
|
|
460
502
|
callCancelCallbacks(interaction);
|
|
461
503
|
interaction.abortReason = 'new_interaction';
|
|
462
504
|
interaction.abortedByInteractionName = interactionName;
|
|
463
505
|
finishInteraction(interactionId, interaction);
|
|
464
|
-
if ((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7$experimen = _getConfig7.experimentalInteractionMetrics) !== null && _getConfig7$experimen !== void 0 && _getConfig7$experimen.enabled) {
|
|
465
|
-
onExperimentalInteractionComplete(interactionId, interaction);
|
|
466
|
-
}
|
|
467
|
-
remove(interactionId);
|
|
468
506
|
}
|
|
469
507
|
}
|
|
470
508
|
export function abortAll(abortReason, abortedByInteractionName) {
|
|
471
509
|
interactions.forEach((interaction, interactionId) => {
|
|
472
|
-
var _getConfig8, _getConfig8$experimen;
|
|
473
510
|
const noMoreHolds = interaction.holdActive.size === 0;
|
|
474
511
|
if (!noMoreHolds) {
|
|
475
512
|
callCancelCallbacks(interaction);
|
|
513
|
+
// eslint-disable-next-line no-param-reassign
|
|
476
514
|
interaction.abortReason = abortReason;
|
|
477
515
|
if (abortedByInteractionName != null) {
|
|
516
|
+
// eslint-disable-next-line no-param-reassign
|
|
478
517
|
interaction.abortedByInteractionName = abortedByInteractionName;
|
|
479
518
|
}
|
|
480
519
|
}
|
|
481
520
|
finishInteraction(interactionId, interaction);
|
|
482
|
-
if ((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8$experimen = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8$experimen !== void 0 && _getConfig8$experimen.enabled) {
|
|
483
|
-
onExperimentalInteractionComplete(interactionId, interaction);
|
|
484
|
-
}
|
|
485
|
-
remove(interactionId);
|
|
486
521
|
});
|
|
487
522
|
}
|
|
488
523
|
export function addOnCancelCallback(id, cancelCallback) {
|
|
@@ -490,8 +525,8 @@ export function addOnCancelCallback(id, cancelCallback) {
|
|
|
490
525
|
interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
|
|
491
526
|
}
|
|
492
527
|
export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName, trace = null) {
|
|
493
|
-
var
|
|
494
|
-
if ((
|
|
528
|
+
var _getConfig5, _getConfig5$postInter;
|
|
529
|
+
if ((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$postInter = _getConfig5.postInteractionLog) !== null && _getConfig5$postInter !== void 0 && _getConfig5$postInter.enabled) {
|
|
495
530
|
postInteractionLog.reset();
|
|
496
531
|
}
|
|
497
532
|
let previousTime = startTime;
|
|
@@ -531,11 +566,9 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
531
566
|
requestInfo: [],
|
|
532
567
|
reactProfilerTimings: [],
|
|
533
568
|
holdInfo: [],
|
|
534
|
-
holdExpInfo: [],
|
|
535
569
|
holdActive: new Map(),
|
|
536
|
-
holdExpActive: new Map(),
|
|
537
570
|
// measure when we execute this code
|
|
538
|
-
// from this
|
|
571
|
+
// from this we can measure the input delay -
|
|
539
572
|
// how long the browser took to hand execution back to JS)
|
|
540
573
|
measureStart: performance.now(),
|
|
541
574
|
rate,
|
|
@@ -585,10 +618,6 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
585
618
|
postInteractionLog.startVCObserver({
|
|
586
619
|
startTime
|
|
587
620
|
});
|
|
588
|
-
experimentalVC.start({
|
|
589
|
-
startTime
|
|
590
|
-
});
|
|
591
|
-
activeSubmitted = false;
|
|
592
621
|
}
|
|
593
622
|
}
|
|
594
623
|
export function addBrowserMetricEvent(event) {
|
|
@@ -651,6 +680,17 @@ export function addRequestInfo(interactionId, labelStack, requestInfo) {
|
|
|
651
680
|
});
|
|
652
681
|
}
|
|
653
682
|
}
|
|
683
|
+
function isSegmentLabel(obj) {
|
|
684
|
+
return obj && typeof obj.name === 'string' && typeof obj.segmentId === 'string';
|
|
685
|
+
}
|
|
686
|
+
function getSegmentCacheKey(labelStack) {
|
|
687
|
+
return labelStack.map(l => {
|
|
688
|
+
if (isSegmentLabel(l)) {
|
|
689
|
+
return `${l.name}_${l.segmentId}`;
|
|
690
|
+
}
|
|
691
|
+
return l.name;
|
|
692
|
+
}).join('|');
|
|
693
|
+
}
|
|
654
694
|
export function addSegment(labelStack) {
|
|
655
695
|
const key = getSegmentCacheKey(labelStack);
|
|
656
696
|
const existingSegment = segmentCache.get(key);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
2
2
|
import { startLighthouseObserver } from '../additional-payload';
|
|
3
3
|
import { setUFOConfig } from '../config';
|
|
4
|
-
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
5
|
-
import { postInteractionLog } from '../create-payload/common/utils';
|
|
6
4
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
7
|
-
import { sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
5
|
+
import { postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
8
6
|
import { getVCObserver } from '../vc';
|
|
9
7
|
let initialized = false;
|
|
10
8
|
function sinkInteraction(instance, payloadPackage) {
|
|
@@ -17,16 +15,6 @@ function sinkInteraction(instance, payloadPackage) {
|
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
|
-
function sinkExperimentalInteractionMetrics(instance, payloadPackage) {
|
|
21
|
-
sinkExperimentalHandler((interactionId, interaction) => {
|
|
22
|
-
scheduleCallback(idlePriority, () => {
|
|
23
|
-
const payload = payloadPackage.createExperimentalMetricsPayload(interactionId, interaction);
|
|
24
|
-
if (payload) {
|
|
25
|
-
instance.sendOperationalEvent(payload);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
18
|
function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
31
19
|
sinkPostInteractionLogHandler(logOutput => {
|
|
32
20
|
scheduleCallback(idlePriority, () => {
|
|
@@ -44,7 +32,6 @@ export const init = (analyticsWebClientAsync, config) => {
|
|
|
44
32
|
}
|
|
45
33
|
setUFOConfig(config);
|
|
46
34
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
47
|
-
var _config$experimentalI;
|
|
48
35
|
const vcOptions = {
|
|
49
36
|
heatmapSize: config.vc.heatmapSize,
|
|
50
37
|
oldDomUpdates: config.vc.oldDomUpdates,
|
|
@@ -58,34 +45,27 @@ export const init = (analyticsWebClientAsync, config) => {
|
|
|
58
45
|
postInteractionLog.startVCObserver({
|
|
59
46
|
startTime: 0
|
|
60
47
|
});
|
|
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
|
-
}
|
|
66
48
|
}
|
|
67
49
|
setupHiddenTimingCapture();
|
|
68
50
|
startLighthouseObserver();
|
|
69
51
|
initialized = true;
|
|
70
|
-
Promise.all([analyticsWebClientAsync,
|
|
52
|
+
Promise.all([analyticsWebClientAsync,
|
|
53
|
+
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
54
|
+
import( /* webpackChunkName: "create-payloads" */'../create-payload'),
|
|
55
|
+
// eslint-disable-next-line import/dynamic-import-chunkname
|
|
56
|
+
import( /* webpackChunkName: "create-post-intreaction-log-payload" */'../create-post-interaction-log-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage]) => {
|
|
71
57
|
if (awc.getAnalyticsWebClientPromise) {
|
|
72
58
|
awc.getAnalyticsWebClientPromise().then(client => {
|
|
73
|
-
var _config$
|
|
59
|
+
var _config$postInteracti;
|
|
74
60
|
const instance = client.getInstance();
|
|
75
61
|
sinkInteraction(instance, payloadPackage);
|
|
76
|
-
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
77
|
-
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
78
|
-
}
|
|
79
62
|
if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
|
|
80
63
|
sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
|
|
81
64
|
}
|
|
82
65
|
});
|
|
83
66
|
} else if (awc.sendOperationalEvent) {
|
|
84
|
-
var _config$
|
|
67
|
+
var _config$postInteracti2;
|
|
85
68
|
sinkInteraction(awc, payloadPackage);
|
|
86
|
-
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
87
|
-
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
88
|
-
}
|
|
89
69
|
if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
|
|
90
70
|
sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
|
|
91
71
|
}
|
|
@@ -22,7 +22,8 @@ const useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayou
|
|
|
22
22
|
* return (
|
|
23
23
|
* <>
|
|
24
24
|
* <Skeleton />
|
|
25
|
-
* <UFOLoadHold name="card"
|
|
25
|
+
* <UFOLoadHold name="card">
|
|
26
|
+
* </UFOLoadHold>
|
|
26
27
|
* )
|
|
27
28
|
* }
|
|
28
29
|
* ```
|
|
@@ -56,10 +57,7 @@ export default function UFOLoadHold({
|
|
|
56
57
|
// react-18: useId instead
|
|
57
58
|
const context = useContext(UFOInteractionContext);
|
|
58
59
|
useLayoutEffectSAFE(() => {
|
|
59
|
-
if (hold && context != null) {
|
|
60
|
-
if (experimental && context.holdExperimental) {
|
|
61
|
-
return context.holdExperimental(name);
|
|
62
|
-
}
|
|
60
|
+
if (hold && !experimental && context != null) {
|
|
63
61
|
return context.hold(name);
|
|
64
62
|
}
|
|
65
63
|
}, [hold, context, name]);
|
|
@@ -67,13 +67,15 @@ export default function UFOSegment({
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function _internalHold(labelStack, name
|
|
70
|
+
function _internalHold(labelStack, name
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
72
|
+
) {
|
|
71
73
|
if (interactionId.current != null) {
|
|
72
74
|
if (parentContext) {
|
|
73
|
-
return parentContext._internalHold(labelStack, name
|
|
75
|
+
return parentContext._internalHold(labelStack, name);
|
|
74
76
|
} else {
|
|
75
77
|
const capturedInteractionId = interactionId.current;
|
|
76
|
-
const disposeHold = addHold(interactionId.current, labelStack, name
|
|
78
|
+
const disposeHold = addHold(interactionId.current, labelStack, name);
|
|
77
79
|
return () => {
|
|
78
80
|
if (capturedInteractionId === interactionId.current) {
|
|
79
81
|
disposeHold();
|
|
@@ -82,7 +84,9 @@ export default function UFOSegment({
|
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
function _internalHoldByID(labelStack, id, name, remove
|
|
87
|
+
function _internalHoldByID(labelStack, id, name, remove
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
89
|
+
) {
|
|
86
90
|
if (interactionId.current != null) {
|
|
87
91
|
if (parentContext) {
|
|
88
92
|
parentContext._internalHoldByID(labelStack, name, id, remove);
|
|
@@ -104,12 +108,11 @@ export default function UFOSegment({
|
|
|
104
108
|
}
|
|
105
109
|
return {
|
|
106
110
|
labelStack,
|
|
107
|
-
hold(name = 'unknown'
|
|
111
|
+
hold(name = 'unknown'
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
113
|
+
) {
|
|
108
114
|
return this._internalHold(this.labelStack, name);
|
|
109
115
|
},
|
|
110
|
-
holdExperimental(name = 'unknown') {
|
|
111
|
-
return this._internalHold(this.labelStack, name, true);
|
|
112
|
-
},
|
|
113
116
|
addHoldByID(labelStack, id, name = 'unknown') {
|
|
114
117
|
this._internalHoldByID(labelStack, id, name, false);
|
|
115
118
|
},
|
package/dist/esm/config/index.js
CHANGED
|
@@ -64,34 +64,13 @@ export function getInteractionRate(name, interactionKind) {
|
|
|
64
64
|
return 0;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
export function getExperimentalInteractionRate(name, interactionType) {
|
|
68
|
-
try {
|
|
69
|
-
if (!config) {
|
|
70
|
-
return 0;
|
|
71
|
-
}
|
|
72
|
-
var _config2 = config,
|
|
73
|
-
experimentalInteractionMetrics = _config2.experimentalInteractionMetrics;
|
|
74
|
-
if (!(experimentalInteractionMetrics !== null && experimentalInteractionMetrics !== void 0 && experimentalInteractionMetrics.enabled)) {
|
|
75
|
-
return 0;
|
|
76
|
-
}
|
|
77
|
-
if (experimentalInteractionMetrics.rates && typeof experimentalInteractionMetrics.rates[name] === 'number') {
|
|
78
|
-
return experimentalInteractionMetrics.rates[name];
|
|
79
|
-
}
|
|
80
|
-
if (experimentalInteractionMetrics.kind && typeof experimentalInteractionMetrics.kind[interactionType] === 'number') {
|
|
81
|
-
return experimentalInteractionMetrics.kind[interactionType];
|
|
82
|
-
}
|
|
83
|
-
return 0;
|
|
84
|
-
} catch (e) {
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
67
|
export function getPostInteractionRate(name, interactionType) {
|
|
89
68
|
try {
|
|
90
69
|
if (!config) {
|
|
91
70
|
return 0;
|
|
92
71
|
}
|
|
93
|
-
var
|
|
94
|
-
postInteractionLog =
|
|
72
|
+
var _config2 = config,
|
|
73
|
+
postInteractionLog = _config2.postInteractionLog;
|
|
95
74
|
if (!(postInteractionLog !== null && postInteractionLog !== void 0 && postInteractionLog.enabled)) {
|
|
96
75
|
return 0;
|
|
97
76
|
}
|
|
@@ -111,8 +90,8 @@ export function getCapabilityRate(capability) {
|
|
|
111
90
|
if (!config) {
|
|
112
91
|
return 0;
|
|
113
92
|
}
|
|
114
|
-
var
|
|
115
|
-
capabilityRate =
|
|
93
|
+
var _config3 = config,
|
|
94
|
+
capabilityRate = _config3.capability;
|
|
116
95
|
if (capabilityRate != null) {
|
|
117
96
|
var rate = capabilityRate[capability];
|
|
118
97
|
if (rate != null) {
|
|
@@ -131,8 +110,8 @@ export function getTypingPerformanceTracingMethod() {
|
|
|
131
110
|
if (!config) {
|
|
132
111
|
return defaultMethod;
|
|
133
112
|
}
|
|
134
|
-
var
|
|
135
|
-
typingMethod =
|
|
113
|
+
var _config4 = config,
|
|
114
|
+
typingMethod = _config4.typingMethod;
|
|
136
115
|
if (typingMethod != null && validTypingMethods.find(function (m) {
|
|
137
116
|
return m === typingMethod;
|
|
138
117
|
})) {
|
|
@@ -151,8 +130,8 @@ export function getAwaitBM3TTIList() {
|
|
|
151
130
|
if (!config) {
|
|
152
131
|
return [];
|
|
153
132
|
}
|
|
154
|
-
var
|
|
155
|
-
awaitBM3TTI =
|
|
133
|
+
var _config5 = config,
|
|
134
|
+
awaitBM3TTI = _config5.awaitBM3TTI;
|
|
156
135
|
if (awaitBM3TTI != null) {
|
|
157
136
|
return awaitBM3TTI;
|
|
158
137
|
} else {
|
|
@@ -169,8 +148,8 @@ export function getRemovePageSegmentsUFOPrefixes() {
|
|
|
169
148
|
if (!config) {
|
|
170
149
|
return false;
|
|
171
150
|
}
|
|
172
|
-
var
|
|
173
|
-
removePageSegmentsUFOPrefixes =
|
|
151
|
+
var _config6 = config,
|
|
152
|
+
removePageSegmentsUFOPrefixes = _config6.removePageSegmentsUFOPrefixes;
|
|
174
153
|
if (removePageSegmentsUFOPrefixes != null) {
|
|
175
154
|
return removePageSegmentsUFOPrefixes;
|
|
176
155
|
} else {
|
|
@@ -187,8 +166,8 @@ export function getRemoveInteractionsUFOPrefixes() {
|
|
|
187
166
|
if (!config) {
|
|
188
167
|
return false;
|
|
189
168
|
}
|
|
190
|
-
var
|
|
191
|
-
removeInteractionsUFOPrefixes =
|
|
169
|
+
var _config7 = config,
|
|
170
|
+
removeInteractionsUFOPrefixes = _config7.removeInteractionsUFOPrefixes;
|
|
192
171
|
if (removeInteractionsUFOPrefixes != null) {
|
|
193
172
|
return removeInteractionsUFOPrefixes;
|
|
194
173
|
} else {
|
|
@@ -208,8 +187,8 @@ export function getUfoNameOverrides() {
|
|
|
208
187
|
if (!config) {
|
|
209
188
|
return undefined;
|
|
210
189
|
}
|
|
211
|
-
var
|
|
212
|
-
ufoNameOverrides =
|
|
190
|
+
var _config8 = config,
|
|
191
|
+
ufoNameOverrides = _config8.ufoNameOverrides;
|
|
213
192
|
if (ufoNameOverrides != null) {
|
|
214
193
|
return ufoNameOverrides;
|
|
215
194
|
}
|
|
@@ -225,8 +204,8 @@ export function getDoNotAbortActivePressInteraction() {
|
|
|
225
204
|
if (!config) {
|
|
226
205
|
return undefined;
|
|
227
206
|
}
|
|
228
|
-
var
|
|
229
|
-
doNotAbortActivePressInteraction =
|
|
207
|
+
var _config9 = config,
|
|
208
|
+
doNotAbortActivePressInteraction = _config9.doNotAbortActivePressInteraction;
|
|
230
209
|
return doNotAbortActivePressInteraction;
|
|
231
210
|
} catch (e) {
|
|
232
211
|
return undefined;
|
|
@@ -239,8 +218,8 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
|
|
|
239
218
|
if (!config) {
|
|
240
219
|
return undefined;
|
|
241
220
|
}
|
|
242
|
-
var
|
|
243
|
-
doNotAbortActivePressInteractionOnTransition =
|
|
221
|
+
var _config10 = config,
|
|
222
|
+
doNotAbortActivePressInteractionOnTransition = _config10.doNotAbortActivePressInteractionOnTransition;
|
|
244
223
|
return doNotAbortActivePressInteractionOnTransition;
|
|
245
224
|
} catch (e) {
|
|
246
225
|
return undefined;
|