@atlaskit/react-ufo 2.4.7 → 2.5.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 +15 -0
- package/dist/cjs/common/constants.js +1 -1
- package/dist/cjs/config/index.js +18 -40
- package/dist/cjs/create-payload/common/utils/index.js +1 -85
- package/dist/cjs/create-payload/index.js +77 -37
- package/dist/cjs/interaction-metrics/common/constants.js +1 -7
- package/dist/cjs/interaction-metrics/index.js +205 -140
- package/dist/cjs/interaction-metrics-init/index.js +9 -27
- package/dist/cjs/load-hold/UFOLoadHold.js +4 -3
- package/dist/cjs/segment/segment.js +9 -7
- package/dist/cjs/trace-pageload/index.js +1 -2
- package/dist/cjs/vc/vc-observer/index.js +48 -33
- package/dist/es2019/common/constants.js +1 -1
- package/dist/es2019/config/index.js +0 -22
- package/dist/es2019/create-payload/common/utils/index.js +1 -86
- package/dist/es2019/create-payload/index.js +74 -28
- package/dist/es2019/interaction-metrics/common/constants.js +0 -6
- package/dist/es2019/interaction-metrics/index.js +130 -93
- package/dist/es2019/interaction-metrics-init/index.js +8 -21
- package/dist/es2019/load-hold/UFOLoadHold.js +4 -3
- package/dist/es2019/segment/segment.js +12 -6
- package/dist/es2019/trace-pageload/index.js +1 -1
- package/dist/es2019/vc/vc-observer/index.js +17 -5
- package/dist/esm/common/constants.js +1 -1
- package/dist/esm/config/index.js +18 -39
- package/dist/esm/create-payload/common/utils/index.js +1 -80
- package/dist/esm/create-payload/index.js +75 -33
- package/dist/esm/interaction-metrics/common/constants.js +0 -6
- package/dist/esm/interaction-metrics/index.js +157 -88
- package/dist/esm/interaction-metrics-init/index.js +10 -24
- package/dist/esm/load-hold/UFOLoadHold.js +4 -3
- package/dist/esm/segment/segment.js +9 -7
- package/dist/esm/trace-pageload/index.js +1 -1
- package/dist/esm/vc/vc-observer/index.js +48 -33
- 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 -12
- package/dist/types/create-payload/index.d.ts +5660 -13
- package/dist/types/interaction-metrics/common/constants.d.ts +1 -31
- package/dist/types/interaction-metrics/index.d.ts +15 -4
- package/dist/types/load-hold/UFOLoadHold.d.ts +2 -1
- package/dist/types/trace-pageload/index.d.ts +0 -1
- package/dist/types/vc/vc-observer/index.d.ts +1 -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 -12
- package/dist/types-ts4.5/create-payload/index.d.ts +5660 -13
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +1 -31
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +15 -4
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +2 -1
- package/dist/types-ts4.5/trace-pageload/index.d.ts +0 -1
- package/dist/types-ts4.5/vc/vc-observer/index.d.ts +1 -1
- package/package.json +6 -4
- package/create-experimental-interaction-metrics-payload/package.json +0 -15
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +0 -89
- package/dist/cjs/interaction-metrics/common/index.js +0 -151
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +0 -67
- package/dist/es2019/interaction-metrics/common/index.js +0 -103
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +0 -81
- package/dist/esm/interaction-metrics/common/index.js +0 -132
- package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +0 -31
- 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 -31
- package/dist/types-ts4.5/interaction-metrics/common/index.d.ts +0 -16
|
@@ -18,12 +18,13 @@ import { getBm3Timings } from '../custom-timings';
|
|
|
18
18
|
import { getGlobalErrorCount } from '../global-error-handler';
|
|
19
19
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
20
20
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
21
|
-
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
21
|
+
import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
|
|
22
22
|
import * as resourceTiming from '../resource-timing';
|
|
23
23
|
import { roundEpsilon } from '../round-number';
|
|
24
24
|
import * as ssr from '../ssr';
|
|
25
|
-
import {
|
|
26
|
-
|
|
25
|
+
import { getVCObserver } from '../vc';
|
|
26
|
+
import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
27
|
+
function getUfoNameOverride(interaction) {
|
|
27
28
|
var ufoName = interaction.ufoName,
|
|
28
29
|
apdex = interaction.apdex;
|
|
29
30
|
try {
|
|
@@ -35,6 +36,7 @@ export function getUfoNameOverride(interaction) {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
return ufoName;
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
40
|
} catch (e) {
|
|
39
41
|
return ufoName;
|
|
40
42
|
}
|
|
@@ -69,6 +71,11 @@ var getPageVisibilityUpToTTI = function getPageVisibilityUpToTTI(interaction) {
|
|
|
69
71
|
var bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
|
|
70
72
|
return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
|
|
71
73
|
};
|
|
74
|
+
var getPageVisibilityUpToTTAI = function getPageVisibilityUpToTTAI(interaction) {
|
|
75
|
+
var start = interaction.start,
|
|
76
|
+
end = interaction.end;
|
|
77
|
+
return getPageVisibilityState(start, end);
|
|
78
|
+
};
|
|
72
79
|
var getVisibilityStateFromPerformance = function getVisibilityStateFromPerformance(stop) {
|
|
73
80
|
try {
|
|
74
81
|
var results = performance.getEntriesByType('visibility-state');
|
|
@@ -124,6 +131,15 @@ var getMoreAccuratePageVisibilityUpToTTAI = function getMoreAccuratePageVisibili
|
|
|
124
131
|
}
|
|
125
132
|
return old;
|
|
126
133
|
};
|
|
134
|
+
var getInteractionStatus = function getInteractionStatus(interaction) {
|
|
135
|
+
var originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
|
|
136
|
+
var hasBm3TTI = interaction.apdex.length > 0;
|
|
137
|
+
var overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
|
|
138
|
+
return {
|
|
139
|
+
originalInteractionStatus: originalInteractionStatus,
|
|
140
|
+
overrideStatus: overrideStatus
|
|
141
|
+
};
|
|
142
|
+
};
|
|
127
143
|
var getResourceTimings = function getResourceTimings(start, end) {
|
|
128
144
|
var _resourceTiming$getRe;
|
|
129
145
|
return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
|
|
@@ -152,6 +168,42 @@ var getPaintMetrics = function getPaintMetrics(type) {
|
|
|
152
168
|
});
|
|
153
169
|
return metrics;
|
|
154
170
|
};
|
|
171
|
+
var getVCMetrics = function getVCMetrics(interaction) {
|
|
172
|
+
var _config$vc, _interaction$apdex;
|
|
173
|
+
var config = getConfig();
|
|
174
|
+
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
177
|
+
if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
var ssr = interaction.type === 'page_load' && config !== null && config !== void 0 && config.ssr ? {
|
|
181
|
+
ssr: getSSRDoneTimeValue(config)
|
|
182
|
+
} : null;
|
|
183
|
+
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
184
|
+
var tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime;
|
|
185
|
+
var prefix = 'ufo';
|
|
186
|
+
var result = getVCObserver().getVCResult(_objectSpread({
|
|
187
|
+
start: interaction.start,
|
|
188
|
+
stop: interaction.end,
|
|
189
|
+
tti: tti,
|
|
190
|
+
prefix: prefix,
|
|
191
|
+
vc: interaction.vc
|
|
192
|
+
}, ssr));
|
|
193
|
+
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
194
|
+
var VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
195
|
+
if (!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")])) {
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
var interactionStatus = getInteractionStatus(interaction);
|
|
199
|
+
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
200
|
+
if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
204
|
+
'metric:vc90': VC['90']
|
|
205
|
+
});
|
|
206
|
+
};
|
|
155
207
|
var getNavigationMetrics = function getNavigationMetrics(type) {
|
|
156
208
|
if (type !== 'page_load') {
|
|
157
209
|
return {};
|
|
@@ -199,13 +251,13 @@ var getNavigationMetrics = function getNavigationMetrics(type) {
|
|
|
199
251
|
};
|
|
200
252
|
};
|
|
201
253
|
var getPPSMetrics = function getPPSMetrics(interaction) {
|
|
202
|
-
var _interaction$
|
|
254
|
+
var _interaction$apdex2;
|
|
203
255
|
var start = interaction.start,
|
|
204
256
|
end = interaction.end;
|
|
205
257
|
var config = getConfig();
|
|
206
258
|
var interactionStatus = getInteractionStatus(interaction);
|
|
207
259
|
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
208
|
-
var tti = (_interaction$
|
|
260
|
+
var tti = (_interaction$apdex2 = interaction.apdex) === null || _interaction$apdex2 === void 0 || (_interaction$apdex2 = _interaction$apdex2[0]) === null || _interaction$apdex2 === void 0 ? void 0 : _interaction$apdex2.stopTime;
|
|
209
261
|
var ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
210
262
|
var PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
|
|
211
263
|
start: start,
|
|
@@ -296,13 +348,13 @@ function optimizeCustomData(interaction) {
|
|
|
296
348
|
for (var _i = 0, _Object$entries = Object.entries(currentValue.custom || {}); _i < _Object$entries.length; _i++) {
|
|
297
349
|
var _result$get$data2, _result$get2;
|
|
298
350
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
299
|
-
|
|
351
|
+
_key = _Object$entries$_i[0],
|
|
300
352
|
value = _Object$entries$_i[1];
|
|
301
353
|
var label = stringifyLabelStackFully([]);
|
|
302
354
|
var labelValue = (_result$get$data2 = (_result$get2 = result.get(label)) === null || _result$get2 === void 0 ? void 0 : _result$get2.data) !== null && _result$get$data2 !== void 0 ? _result$get$data2 : {};
|
|
303
355
|
result.set(label, {
|
|
304
356
|
labelStack: optimizeLabelStack([]),
|
|
305
|
-
data: Object.assign(labelValue, _defineProperty({},
|
|
357
|
+
data: Object.assign(labelValue, _defineProperty({}, _key, value))
|
|
306
358
|
});
|
|
307
359
|
}
|
|
308
360
|
return result;
|
|
@@ -540,6 +592,10 @@ function getBm3TrackerTimings(interaction) {
|
|
|
540
592
|
legacyMetrics: legacyMetrics
|
|
541
593
|
};
|
|
542
594
|
}
|
|
595
|
+
function getSSRDoneTimeValue(config) {
|
|
596
|
+
var _config$ssr, _config$ssr2;
|
|
597
|
+
return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
|
|
598
|
+
}
|
|
543
599
|
function getPayloadSize(payload) {
|
|
544
600
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
545
601
|
}
|
|
@@ -582,15 +638,13 @@ function getStylesheetMetrics() {
|
|
|
582
638
|
return {};
|
|
583
639
|
}
|
|
584
640
|
}
|
|
585
|
-
var regularTTAI;
|
|
586
|
-
var expTTAI;
|
|
587
641
|
function getErrorCounts(interaction) {
|
|
588
642
|
return {
|
|
589
643
|
'ufo:errors:globalCount': getGlobalErrorCount(),
|
|
590
644
|
'ufo:errors:count': interaction.errors.length
|
|
591
645
|
};
|
|
592
646
|
}
|
|
593
|
-
|
|
647
|
+
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
594
648
|
var _window$location, _config$additionalPay;
|
|
595
649
|
var interactionPayloadStart = performance.now();
|
|
596
650
|
var config = getConfig();
|
|
@@ -625,7 +679,7 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
625
679
|
} : {};
|
|
626
680
|
// Page Load
|
|
627
681
|
var getPageLoadInteractionMetrics = function getPageLoadInteractionMetrics() {
|
|
628
|
-
var _config$
|
|
682
|
+
var _config$ssr3;
|
|
629
683
|
if (!isPageLoad) {
|
|
630
684
|
return {};
|
|
631
685
|
}
|
|
@@ -636,12 +690,12 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
636
690
|
} : {};
|
|
637
691
|
return _objectSpread(_objectSpread({}, SSRDoneTime), {}, {
|
|
638
692
|
isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
|
|
639
|
-
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$
|
|
693
|
+
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr3 = config.ssr) !== null && _config$ssr3 !== void 0 && _config$ssr3.getSSRDoneTime)
|
|
640
694
|
});
|
|
641
695
|
};
|
|
642
696
|
// Detailed payload. Page visibility = visible
|
|
643
697
|
var getDetailedInteractionMetrics = function getDetailedInteractionMetrics() {
|
|
644
|
-
if (
|
|
698
|
+
if (window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
645
699
|
return {};
|
|
646
700
|
}
|
|
647
701
|
var spans = [].concat(_toConsumableArray(interaction.spans), _toConsumableArray(atlaskitInteractionSpans));
|
|
@@ -656,7 +710,7 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
656
710
|
}),
|
|
657
711
|
holdActive: _toConsumableArray(interaction.holdActive.values()),
|
|
658
712
|
redirects: optimizeRedirects(interaction.redirects, start),
|
|
659
|
-
holdInfo: optimizeHoldInfo(
|
|
713
|
+
holdInfo: optimizeHoldInfo(interaction.holdInfo, start),
|
|
660
714
|
spans: optimizeSpans(spans, start),
|
|
661
715
|
requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
|
|
662
716
|
customTimings: optimizeCustomTimings(interaction.customTimings, start),
|
|
@@ -666,21 +720,16 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
666
720
|
};
|
|
667
721
|
// Page load & detailed payload
|
|
668
722
|
var getPageLoadDetailedInteractionMetrics = function getPageLoadDetailedInteractionMetrics() {
|
|
669
|
-
var _config$
|
|
723
|
+
var _config$ssr4;
|
|
670
724
|
if (!isPageLoad || !isDetailedPayload) {
|
|
671
725
|
return {};
|
|
672
726
|
}
|
|
673
727
|
var config = getConfig();
|
|
674
728
|
return {
|
|
675
729
|
initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
|
|
676
|
-
SSRTimings: config !== null && config !== void 0 && (_config$
|
|
730
|
+
SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
|
|
677
731
|
};
|
|
678
732
|
};
|
|
679
|
-
if (experimental) {
|
|
680
|
-
expTTAI = getTTAI(interaction);
|
|
681
|
-
} else {
|
|
682
|
-
regularTTAI = getTTAI(interaction);
|
|
683
|
-
}
|
|
684
733
|
var newUFOName = sanitizeUfoName(ufoName);
|
|
685
734
|
var payload = {
|
|
686
735
|
actionSubject: 'experience',
|
|
@@ -689,7 +738,7 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
689
738
|
source: 'measured',
|
|
690
739
|
tags: ['observability'],
|
|
691
740
|
attributes: {
|
|
692
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
741
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
693
742
|
// basic
|
|
694
743
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
695
744
|
'event:product': config.product,
|
|
@@ -701,10 +750,10 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
701
750
|
payloadSource: 'platform'
|
|
702
751
|
},
|
|
703
752
|
'event:region': config.region || 'unknown',
|
|
704
|
-
'experience:key':
|
|
753
|
+
'experience:key': 'custom.interaction-metrics',
|
|
705
754
|
'experience:name': newUFOName
|
|
706
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)),
|
|
707
|
-
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
755
|
+
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
|
|
756
|
+
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
708
757
|
namePrefix: config.namePrefix || '',
|
|
709
758
|
segmentPrefix: config.segmentPrefix || '',
|
|
710
759
|
interactionId: interactionId,
|
|
@@ -735,18 +784,11 @@ export function createInteractionMetricsPayload(interaction, interactionId, expe
|
|
|
735
784
|
marks: optimizeMarks(interaction.marks),
|
|
736
785
|
customData: optimizeCustomData(interaction),
|
|
737
786
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
|
|
738
|
-
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
739
|
-
'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
|
|
740
|
-
'metric:experimental:ttai': experimental ? expTTAI : undefined
|
|
741
|
-
}),
|
|
787
|
+
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
742
788
|
'ufo:payloadTime': roundEpsilon(performance.now() - interactionPayloadStart)
|
|
743
789
|
})
|
|
744
790
|
}
|
|
745
791
|
};
|
|
746
|
-
if (experimental) {
|
|
747
|
-
regularTTAI = undefined;
|
|
748
|
-
expTTAI = undefined;
|
|
749
|
-
}
|
|
750
792
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
751
793
|
return payload;
|
|
752
794
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
var interactions = new Map();
|
|
2
|
-
export var CLEANUP_TIMEOUT = 60 * 1000;
|
|
3
|
-
export var CLEANUP_TIMEOUT_AFTER_APDEX = 15 * 1000;
|
|
4
|
-
export var interactionQueue = [];
|
|
5
|
-
export var segmentCache = new Map();
|
|
6
|
-
export var segmentObservers = [];
|
|
7
|
-
export var moduleLoadingRequests = {};
|
|
8
2
|
export default interactions;
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
9
|
import { v4 as createUUID } from 'uuid';
|
|
6
10
|
import coinflip from '../coinflip';
|
|
7
11
|
import { getAwaitBM3TTIList, getCapabilityRate, getConfig } from '../config';
|
|
8
|
-
import { ExperimentalInteractionMetrics } from '../create-experimental-interaction-metrics-payload';
|
|
9
|
-
import { getExperimentalVCMetrics, getTTAI } from '../create-payload/common/utils';
|
|
10
12
|
import { clearActiveTrace } from '../experience-trace-id-context';
|
|
11
13
|
import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
|
|
12
14
|
import { getInteractionId } from '../interaction-id-context';
|
|
13
15
|
import { getVCObserver } from '../vc';
|
|
14
|
-
import
|
|
15
|
-
import interactions, { CLEANUP_TIMEOUT, CLEANUP_TIMEOUT_AFTER_APDEX, interactionQueue, moduleLoadingRequests, segmentCache, segmentObservers } from './common/constants';
|
|
16
|
+
import interactions from './common/constants';
|
|
16
17
|
import PostInteractionLog from './post-interaction-log';
|
|
17
18
|
var PreviousInteractionLog = {
|
|
18
19
|
name: undefined,
|
|
19
20
|
isAborted: undefined
|
|
20
21
|
};
|
|
21
22
|
export var postInteractionLog = new PostInteractionLog();
|
|
22
|
-
|
|
23
|
+
var interactionQueue = [];
|
|
24
|
+
var segmentCache = new Map();
|
|
25
|
+
var CLEANUP_TIMEOUT = 60 * 1000;
|
|
26
|
+
var CLEANUP_TIMEOUT_AFTER_APDEX = 15 * 1000;
|
|
27
|
+
var segmentObservers = [];
|
|
23
28
|
export function getActiveInteraction() {
|
|
24
29
|
var interactionId = getInteractionId();
|
|
25
30
|
if (!interactionId.current) {
|
|
@@ -27,6 +32,51 @@ export function getActiveInteraction() {
|
|
|
27
32
|
}
|
|
28
33
|
return interactions.get(interactionId.current);
|
|
29
34
|
}
|
|
35
|
+
function isPerformanceTracingEnabled() {
|
|
36
|
+
var _getConfig;
|
|
37
|
+
return ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.enableAdditionalPerformanceMarks) || window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production';
|
|
38
|
+
}
|
|
39
|
+
function labelStackToString(labelStack, name) {
|
|
40
|
+
var _stack$map;
|
|
41
|
+
var stack = _toConsumableArray(labelStack !== null && labelStack !== void 0 ? labelStack : []);
|
|
42
|
+
if (name) {
|
|
43
|
+
stack.push({
|
|
44
|
+
name: name
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return (_stack$map = stack.map(function (l) {
|
|
48
|
+
return l.name;
|
|
49
|
+
})) === null || _stack$map === void 0 ? void 0 : _stack$map.join('/');
|
|
50
|
+
}
|
|
51
|
+
function labelStackToIdString(labelStack) {
|
|
52
|
+
var _labelStack$map;
|
|
53
|
+
return labelStack === null || labelStack === void 0 || (_labelStack$map = labelStack.map(function (l) {
|
|
54
|
+
return 'segmentId' in l ? "".concat(l.name, ":").concat(l.segmentId) : "".concat(l.name);
|
|
55
|
+
})) === null || _labelStack$map === void 0 ? void 0 : _labelStack$map.join('/');
|
|
56
|
+
}
|
|
57
|
+
function addSegmentObserver(observer) {
|
|
58
|
+
segmentObservers.push(observer);
|
|
59
|
+
var _iterator = _createForOfIteratorHelper(segmentCache.values()),
|
|
60
|
+
_step;
|
|
61
|
+
try {
|
|
62
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
63
|
+
var segmentInfo = _step.value;
|
|
64
|
+
observer.onAdd(segmentInfo);
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
_iterator.e(err);
|
|
68
|
+
} finally {
|
|
69
|
+
_iterator.f();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function removeSegmentObserver(observer) {
|
|
73
|
+
var index = segmentObservers.findIndex(function (obs) {
|
|
74
|
+
return obs === observer;
|
|
75
|
+
});
|
|
76
|
+
if (index !== -1) {
|
|
77
|
+
segmentObservers.splice(index, 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
30
80
|
export function remove(interactionId) {
|
|
31
81
|
interactions.delete(interactionId);
|
|
32
82
|
}
|
|
@@ -175,6 +225,7 @@ export function addPreload(moduleId, timestamp) {
|
|
|
175
225
|
export function addLoad(identifier, start, end) {
|
|
176
226
|
addSpanToAll('bundle_load', identifier, null, start, end - start);
|
|
177
227
|
}
|
|
228
|
+
var moduleLoadingRequests = {};
|
|
178
229
|
export function extractModuleName(input) {
|
|
179
230
|
var result = input !== null && input !== void 0 ? input : '';
|
|
180
231
|
result = result.replace(/^\.\/src\/packages\//, '');
|
|
@@ -182,27 +233,30 @@ export function extractModuleName(input) {
|
|
|
182
233
|
result = result.replace(/(\/src)?\/(index|main)\.(tsx|ts|js|jsx)$/, '');
|
|
183
234
|
return result;
|
|
184
235
|
}
|
|
185
|
-
|
|
236
|
+
function addHoldCriterion(id, labelStack, name, startTime) {
|
|
237
|
+
var _window$__CRITERION__;
|
|
238
|
+
if (!((_window$__CRITERION__ = window.__CRITERION__) !== null && _window$__CRITERION__ !== void 0 && _window$__CRITERION__.addUFOHold)) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
window.__CRITERION__.addUFOHold(id, labelStackToString(labelStack), name, startTime);
|
|
242
|
+
}
|
|
243
|
+
function removeHoldCriterion(id) {
|
|
244
|
+
var _window$__CRITERION__2;
|
|
245
|
+
if (!((_window$__CRITERION__2 = window.__CRITERION__) !== null && _window$__CRITERION__2 !== void 0 && _window$__CRITERION__2.removeUFOHold)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
window.__CRITERION__.removeUFOHold(id);
|
|
249
|
+
}
|
|
250
|
+
export function addHold(interactionId, labelStack, name) {
|
|
186
251
|
var interaction = interactions.get(interactionId);
|
|
187
252
|
var id = createUUID();
|
|
188
253
|
if (interaction != null) {
|
|
189
|
-
var
|
|
190
|
-
|
|
254
|
+
var start = performance.now();
|
|
255
|
+
interaction.holdActive.set(id, {
|
|
191
256
|
labelStack: labelStack,
|
|
192
257
|
name: name,
|
|
193
|
-
start:
|
|
194
|
-
};
|
|
195
|
-
var start = performance.now();
|
|
196
|
-
if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.experimentalInteractionMetrics) !== null && _getConfig !== void 0 && _getConfig.enabled && experimental) {
|
|
197
|
-
interaction.holdExpActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
|
|
198
|
-
start: start
|
|
199
|
-
}));
|
|
200
|
-
}
|
|
201
|
-
if (!experimental) {
|
|
202
|
-
interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
|
|
203
|
-
start: start
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
258
|
+
start: start
|
|
259
|
+
});
|
|
206
260
|
addHoldCriterion(id, labelStack, name, start);
|
|
207
261
|
return function () {
|
|
208
262
|
var end = performance.now();
|
|
@@ -220,20 +274,11 @@ export function addHold(interactionId, labelStack, name, experimental) {
|
|
|
220
274
|
removeHoldCriterion(id);
|
|
221
275
|
var currentInteraction = interactions.get(interactionId);
|
|
222
276
|
var currentHold = interaction.holdActive.get(id);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}));
|
|
229
|
-
interaction.holdActive.delete(id);
|
|
230
|
-
}
|
|
231
|
-
if (expHold != null) {
|
|
232
|
-
currentInteraction.holdExpInfo.push(_objectSpread(_objectSpread({}, expHold), {}, {
|
|
233
|
-
end: end
|
|
234
|
-
}));
|
|
235
|
-
interaction.holdExpActive.delete(id);
|
|
236
|
-
}
|
|
277
|
+
if (currentInteraction != null && currentHold != null) {
|
|
278
|
+
currentInteraction.holdInfo.push(_objectSpread(_objectSpread({}, currentHold), {}, {
|
|
279
|
+
end: end
|
|
280
|
+
}));
|
|
281
|
+
interaction.holdActive.delete(id);
|
|
237
282
|
}
|
|
238
283
|
};
|
|
239
284
|
}
|
|
@@ -361,10 +406,22 @@ export var addProfilerTimings = function addProfilerTimings(interactionId, label
|
|
|
361
406
|
postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
|
|
362
407
|
}
|
|
363
408
|
};
|
|
409
|
+
var pushToQueue = function pushToQueue(id, data) {
|
|
410
|
+
interactionQueue.push({
|
|
411
|
+
id: id,
|
|
412
|
+
data: data
|
|
413
|
+
});
|
|
414
|
+
};
|
|
364
415
|
var handleInteraction = pushToQueue;
|
|
416
|
+
function callCleanUpCallbacks(interaction) {
|
|
417
|
+
interaction.cleanupCallbacks.reverse().forEach(function (cleanUpCallback) {
|
|
418
|
+
cleanUpCallback();
|
|
419
|
+
});
|
|
420
|
+
}
|
|
365
421
|
var finishInteraction = function finishInteraction(id, data) {
|
|
366
422
|
var _getConfig3;
|
|
367
423
|
var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
|
|
424
|
+
// eslint-disable-next-line no-param-reassign
|
|
368
425
|
data.end = endTime;
|
|
369
426
|
try {
|
|
370
427
|
// for Firefox 102 and older
|
|
@@ -376,20 +433,58 @@ var finishInteraction = function finishInteraction(id, data) {
|
|
|
376
433
|
// do nothing
|
|
377
434
|
}
|
|
378
435
|
if (data.featureFlags) {
|
|
436
|
+
// eslint-disable-next-line no-param-reassign
|
|
379
437
|
data.featureFlags.during = Object.fromEntries(currentFeatureFlagsAccessed);
|
|
380
438
|
}
|
|
381
439
|
clearActiveTrace();
|
|
382
440
|
callCleanUpCallbacks(data);
|
|
383
441
|
if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && _getConfig3.stopVCAtInteractionFinish) {
|
|
384
|
-
data.vc = getVCObserver().getVCRawData();
|
|
442
|
+
data.vc = getVCObserver().getVCRawData(data.end);
|
|
385
443
|
}
|
|
444
|
+
remove(id);
|
|
386
445
|
PreviousInteractionLog.name = data.ufoName || 'unknown';
|
|
387
446
|
PreviousInteractionLog.isAborted = data.abortReason != null;
|
|
388
447
|
if (data.ufoName) {
|
|
389
448
|
handleInteraction(id, data);
|
|
390
449
|
}
|
|
391
450
|
if (isPerformanceTracingEnabled()) {
|
|
392
|
-
|
|
451
|
+
var profilerTimingMap = new Map();
|
|
452
|
+
data.reactProfilerTimings.forEach(function (profilerTiming) {
|
|
453
|
+
var labelStackId = labelStackToIdString(profilerTiming.labelStack);
|
|
454
|
+
if (labelStackId) {
|
|
455
|
+
var _profilerTimingMap$ge, _timing$start, _timing$end;
|
|
456
|
+
var timing = (_profilerTimingMap$ge = profilerTimingMap.get(labelStackId)) !== null && _profilerTimingMap$ge !== void 0 ? _profilerTimingMap$ge : {
|
|
457
|
+
labelStack: profilerTiming.labelStack
|
|
458
|
+
};
|
|
459
|
+
timing.start = profilerTiming.startTime < ((_timing$start = timing.start) !== null && _timing$start !== void 0 ? _timing$start : Number.MAX_SAFE_INTEGER) ? profilerTiming.startTime : timing.start;
|
|
460
|
+
timing.end = profilerTiming.commitTime > ((_timing$end = timing.end) !== null && _timing$end !== void 0 ? _timing$end : Number.MIN_SAFE_INTEGER) ? profilerTiming.commitTime : timing.end;
|
|
461
|
+
profilerTimingMap.set(labelStackId, timing);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
try {
|
|
465
|
+
// for Firefox 102 and older
|
|
466
|
+
var _iterator2 = _createForOfIteratorHelper(profilerTimingMap.entries()),
|
|
467
|
+
_step2;
|
|
468
|
+
try {
|
|
469
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
470
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
471
|
+
_step2$value$ = _step2$value[1],
|
|
472
|
+
labelStack = _step2$value$.labelStack,
|
|
473
|
+
start = _step2$value$.start,
|
|
474
|
+
end = _step2$value$.end;
|
|
475
|
+
performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
|
|
476
|
+
start: start,
|
|
477
|
+
end: end
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
} catch (err) {
|
|
481
|
+
_iterator2.e(err);
|
|
482
|
+
} finally {
|
|
483
|
+
_iterator2.f();
|
|
484
|
+
}
|
|
485
|
+
} catch (e) {
|
|
486
|
+
// do nothing
|
|
487
|
+
}
|
|
393
488
|
}
|
|
394
489
|
try {
|
|
395
490
|
// dispatch a global window event to notify the measure is completed
|
|
@@ -409,92 +504,57 @@ export var sinkInteractionHandler = function sinkInteractionHandler(sinkFn) {
|
|
|
409
504
|
interactionQueue.length = 0;
|
|
410
505
|
}
|
|
411
506
|
};
|
|
412
|
-
export var sinkExperimentalHandler = function sinkExperimentalHandler(sinkFn) {
|
|
413
|
-
experimentalInteractionLog.sinkHandler(sinkFn);
|
|
414
|
-
};
|
|
415
507
|
export var sinkPostInteractionLogHandler = function sinkPostInteractionLogHandler(sinkFn) {
|
|
416
508
|
postInteractionLog.sinkHandler(sinkFn);
|
|
417
509
|
};
|
|
418
|
-
|
|
419
|
-
// a flag to prevent mutliple submittions
|
|
420
|
-
var activeSubmitted = false;
|
|
421
510
|
export function tryComplete(interactionId, endTime) {
|
|
422
511
|
var interaction = interactions.get(interactionId);
|
|
423
512
|
if (interaction != null) {
|
|
424
|
-
var
|
|
425
|
-
|
|
426
|
-
var postInteraction = function postInteraction() {
|
|
513
|
+
var noMoreHolds = interaction.holdActive.size === 0;
|
|
514
|
+
if (noMoreHolds) {
|
|
427
515
|
var _getConfig4;
|
|
516
|
+
finishInteraction(interactionId, interaction, endTime);
|
|
428
517
|
if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
|
|
429
|
-
|
|
430
|
-
var experimentalVC90 = (_getExperimentalVCMet = getExperimentalVCMetrics(interaction)) === null || _getExperimentalVCMet === void 0 ? void 0 : _getExperimentalVCMet['metric:experimental:vc90'];
|
|
431
|
-
var experimentalTTAI = getTTAI(interaction);
|
|
432
|
-
postInteractionLog.onInteractionComplete(_objectSpread(_objectSpread({}, interaction), {}, {
|
|
433
|
-
experimentalTTAI: experimentalTTAI,
|
|
434
|
-
experimentalVC90: experimentalVC90
|
|
435
|
-
}));
|
|
436
|
-
}
|
|
437
|
-
remove(interactionId);
|
|
438
|
-
activeSubmitted = false;
|
|
439
|
-
};
|
|
440
|
-
if (noMoreActiveHolds) {
|
|
441
|
-
if (!activeSubmitted) {
|
|
442
|
-
finishInteraction(interactionId, interaction, endTime);
|
|
443
|
-
activeSubmitted = true;
|
|
444
|
-
}
|
|
445
|
-
if (noMoreExpHolds) {
|
|
446
|
-
var _getConfig5;
|
|
447
|
-
if ((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled) {
|
|
448
|
-
experimentalInteractionLog.onInteractionComplete(interactionId, interaction, endTime);
|
|
449
|
-
}
|
|
450
|
-
postInteraction();
|
|
518
|
+
postInteractionLog.onInteractionComplete(interaction);
|
|
451
519
|
}
|
|
452
520
|
}
|
|
453
521
|
}
|
|
454
522
|
}
|
|
523
|
+
function callCancelCallbacks(interaction) {
|
|
524
|
+
interaction.cancelCallbacks.reverse().forEach(function (cancelCallback) {
|
|
525
|
+
cancelCallback();
|
|
526
|
+
});
|
|
527
|
+
}
|
|
455
528
|
export function abort(interactionId, abortReason) {
|
|
456
529
|
var interaction = interactions.get(interactionId);
|
|
457
530
|
if (interaction != null) {
|
|
458
|
-
var _getConfig6;
|
|
459
531
|
callCancelCallbacks(interaction);
|
|
460
532
|
interaction.abortReason = abortReason;
|
|
461
533
|
finishInteraction(interactionId, interaction);
|
|
462
|
-
if ((_getConfig6 = getConfig()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.experimentalInteractionMetrics) !== null && _getConfig6 !== void 0 && _getConfig6.enabled) {
|
|
463
|
-
experimentalInteractionLog.onInteractionComplete(interactionId, interaction);
|
|
464
|
-
}
|
|
465
|
-
remove(interactionId);
|
|
466
534
|
}
|
|
467
535
|
}
|
|
468
536
|
export function abortByNewInteraction(interactionId, interactionName) {
|
|
469
537
|
var interaction = interactions.get(interactionId);
|
|
470
538
|
if (interaction != null) {
|
|
471
|
-
var _getConfig7;
|
|
472
539
|
callCancelCallbacks(interaction);
|
|
473
540
|
interaction.abortReason = 'new_interaction';
|
|
474
541
|
interaction.abortedByInteractionName = interactionName;
|
|
475
542
|
finishInteraction(interactionId, interaction);
|
|
476
|
-
if ((_getConfig7 = getConfig()) !== null && _getConfig7 !== void 0 && (_getConfig7 = _getConfig7.experimentalInteractionMetrics) !== null && _getConfig7 !== void 0 && _getConfig7.enabled) {
|
|
477
|
-
experimentalInteractionLog.onInteractionComplete(interactionId, interaction);
|
|
478
|
-
}
|
|
479
|
-
remove(interactionId);
|
|
480
543
|
}
|
|
481
544
|
}
|
|
482
545
|
export function abortAll(abortReason, abortedByInteractionName) {
|
|
483
546
|
interactions.forEach(function (interaction, interactionId) {
|
|
484
|
-
var _getConfig8;
|
|
485
547
|
var noMoreHolds = interaction.holdActive.size === 0;
|
|
486
548
|
if (!noMoreHolds) {
|
|
487
549
|
callCancelCallbacks(interaction);
|
|
550
|
+
// eslint-disable-next-line no-param-reassign
|
|
488
551
|
interaction.abortReason = abortReason;
|
|
489
552
|
if (abortedByInteractionName != null) {
|
|
553
|
+
// eslint-disable-next-line no-param-reassign
|
|
490
554
|
interaction.abortedByInteractionName = abortedByInteractionName;
|
|
491
555
|
}
|
|
492
556
|
}
|
|
493
557
|
finishInteraction(interactionId, interaction);
|
|
494
|
-
if ((_getConfig8 = getConfig()) !== null && _getConfig8 !== void 0 && (_getConfig8 = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8 !== void 0 && _getConfig8.enabled) {
|
|
495
|
-
experimentalInteractionLog.onInteractionComplete(interactionId, interaction);
|
|
496
|
-
}
|
|
497
|
-
remove(interactionId);
|
|
498
558
|
});
|
|
499
559
|
}
|
|
500
560
|
export function addOnCancelCallback(id, cancelCallback) {
|
|
@@ -502,9 +562,9 @@ export function addOnCancelCallback(id, cancelCallback) {
|
|
|
502
562
|
interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
|
|
503
563
|
}
|
|
504
564
|
export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
|
|
505
|
-
var
|
|
565
|
+
var _getConfig5;
|
|
506
566
|
var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
507
|
-
if ((
|
|
567
|
+
if ((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.postInteractionLog) !== null && _getConfig5 !== void 0 && _getConfig5.enabled) {
|
|
508
568
|
postInteractionLog.reset();
|
|
509
569
|
}
|
|
510
570
|
var previousTime = startTime;
|
|
@@ -544,11 +604,9 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
544
604
|
requestInfo: [],
|
|
545
605
|
reactProfilerTimings: [],
|
|
546
606
|
holdInfo: [],
|
|
547
|
-
holdExpInfo: [],
|
|
548
607
|
holdActive: new Map(),
|
|
549
|
-
holdExpActive: new Map(),
|
|
550
608
|
// measure when we execute this code
|
|
551
|
-
// from this
|
|
609
|
+
// from this we can measure the input delay -
|
|
552
610
|
// how long the browser took to hand execution back to JS)
|
|
553
611
|
measureStart: performance.now(),
|
|
554
612
|
rate: rate,
|
|
@@ -659,6 +717,17 @@ export function addRequestInfo(interactionId, labelStack, requestInfo) {
|
|
|
659
717
|
}, requestInfo));
|
|
660
718
|
}
|
|
661
719
|
}
|
|
720
|
+
function isSegmentLabel(obj) {
|
|
721
|
+
return obj && typeof obj.name === 'string' && typeof obj.segmentId === 'string';
|
|
722
|
+
}
|
|
723
|
+
function getSegmentCacheKey(labelStack) {
|
|
724
|
+
return labelStack.map(function (l) {
|
|
725
|
+
if (isSegmentLabel(l)) {
|
|
726
|
+
return "".concat(l.name, "_").concat(l.segmentId);
|
|
727
|
+
}
|
|
728
|
+
return l.name;
|
|
729
|
+
}).join('|');
|
|
730
|
+
}
|
|
662
731
|
export function addSegment(labelStack) {
|
|
663
732
|
var key = getSegmentCacheKey(labelStack);
|
|
664
733
|
var existingSegment = segmentCache.get(key);
|