@atlaskit/react-ufo 3.3.3 → 3.4.1
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 +16 -0
- package/dist/cjs/assets/index.js +26 -16
- package/dist/cjs/assets/utils.js +47 -4
- package/dist/cjs/create-payload/index.js +15 -12
- package/dist/cjs/vc/vc-observer-new/get-element-name.js +1 -2
- package/dist/es2019/assets/index.js +27 -13
- package/dist/es2019/assets/utils.js +47 -3
- package/dist/es2019/create-payload/index.js +11 -7
- package/dist/es2019/vc/vc-observer-new/get-element-name.js +1 -2
- package/dist/esm/assets/index.js +27 -17
- package/dist/esm/assets/utils.js +46 -3
- package/dist/esm/create-payload/index.js +15 -12
- package/dist/esm/vc/vc-observer-new/get-element-name.js +1 -2
- package/dist/types/assets/index.d.ts +5 -5
- package/dist/types/assets/utils.d.ts +4 -1
- package/dist/types/common/assets/types.d.ts +14 -8
- package/dist/types/common/index.d.ts +11 -1
- package/dist/types/config/index.d.ts +5 -0
- package/dist/types/create-payload/index.d.ts +768 -0
- package/dist/types/resource-timing/common/types.d.ts +1 -1
- package/dist/types-ts4.5/assets/index.d.ts +5 -5
- package/dist/types-ts4.5/assets/utils.d.ts +4 -1
- package/dist/types-ts4.5/common/assets/types.d.ts +14 -8
- package/dist/types-ts4.5/common/index.d.ts +11 -1
- package/dist/types-ts4.5/config/index.d.ts +5 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +768 -0
- package/dist/types-ts4.5/resource-timing/common/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ import { getPageVisibilityState } from '../hidden-timing';
|
|
|
25
25
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
26
26
|
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
27
27
|
import * as resourceTiming from '../resource-timing';
|
|
28
|
+
import { filterResourceTimings } from '../resource-timing/common/utils/resource-timing-buffer';
|
|
28
29
|
import { roundEpsilon } from '../round-number';
|
|
29
30
|
import * as ssr from '../ssr';
|
|
30
31
|
import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
@@ -246,18 +247,19 @@ function getSSRProperties(type) {
|
|
|
246
247
|
'ssr:featureFlags': getSSRFeatureFlags(type)
|
|
247
248
|
};
|
|
248
249
|
}
|
|
249
|
-
var getAssetsMetrics = function getAssetsMetrics(interaction,
|
|
250
|
+
var getAssetsMetrics = function getAssetsMetrics(interaction, SSRDoneTime) {
|
|
250
251
|
try {
|
|
251
252
|
var config = getConfig();
|
|
252
253
|
var type = interaction.type;
|
|
253
254
|
var allowedTypes = ['page_load', 'transition'];
|
|
254
|
-
var
|
|
255
|
-
if (!allowedTypes.includes(type) || !
|
|
255
|
+
var assetsConfig = config === null || config === void 0 ? void 0 : config.assetsConfig;
|
|
256
|
+
if (!allowedTypes.includes(type) || !assetsConfig) {
|
|
256
257
|
// Skip if: type not allowed or assetsClassification isn't configured
|
|
257
258
|
return {};
|
|
258
259
|
}
|
|
259
260
|
var reporter = new CHRReporter();
|
|
260
|
-
var
|
|
261
|
+
var resourceTimings = filterResourceTimings(interaction.start, interaction.end);
|
|
262
|
+
var assets = reporter.get(resourceTimings, assetsConfig, SSRDoneTime);
|
|
261
263
|
if (assets) {
|
|
262
264
|
// Only add assets in case it exists
|
|
263
265
|
return {
|
|
@@ -636,7 +638,7 @@ function createInteractionMetricsPayload(_x, _x2, _x3) {
|
|
|
636
638
|
function _createInteractionMetricsPayload() {
|
|
637
639
|
_createInteractionMetricsPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction, interactionId, experimental) {
|
|
638
640
|
var _window$location, _config$additionalPay;
|
|
639
|
-
var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack,
|
|
641
|
+
var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getInitialPageLoadSSRMetrics, pageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, vcMetrics, experimentalMetrics, payload;
|
|
640
642
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
641
643
|
while (1) switch (_context.prev = _context.next) {
|
|
642
644
|
case 0:
|
|
@@ -663,7 +665,7 @@ function _createInteractionMetricsPayload() {
|
|
|
663
665
|
labelStack = interaction.labelStack ? {
|
|
664
666
|
labelStack: optimizeLabelStack(interaction.labelStack, getReactUFOVersion(interaction.type))
|
|
665
667
|
} : {}; // Page Load
|
|
666
|
-
|
|
668
|
+
getInitialPageLoadSSRMetrics = function getInitialPageLoadSSRMetrics() {
|
|
667
669
|
var _config$ssr;
|
|
668
670
|
if (!isPageLoad) {
|
|
669
671
|
return {};
|
|
@@ -677,7 +679,8 @@ function _createInteractionMetricsPayload() {
|
|
|
677
679
|
isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
|
|
678
680
|
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
|
|
679
681
|
});
|
|
680
|
-
};
|
|
682
|
+
};
|
|
683
|
+
pageLoadInteractionMetrics = getInitialPageLoadSSRMetrics(); // Detailed payload. Page visibility = visible
|
|
681
684
|
getDetailedInteractionMetrics = function getDetailedInteractionMetrics(resourceTimings) {
|
|
682
685
|
if (experimental || window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
683
686
|
return {};
|
|
@@ -720,9 +723,9 @@ function _createInteractionMetricsPayload() {
|
|
|
720
723
|
}
|
|
721
724
|
newUFOName = sanitizeUfoName(ufoName);
|
|
722
725
|
resourceTimings = getResourceTimings(start, end);
|
|
723
|
-
_context.next =
|
|
726
|
+
_context.next = 24;
|
|
724
727
|
return Promise.all([getVCMetrics(interaction), experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined)]);
|
|
725
|
-
case
|
|
728
|
+
case 24:
|
|
726
729
|
_yield$Promise$all = _context.sent;
|
|
727
730
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
728
731
|
vcMetrics = _yield$Promise$all2[0];
|
|
@@ -747,7 +750,7 @@ function _createInteractionMetricsPayload() {
|
|
|
747
750
|
'event:region': config.region || 'unknown',
|
|
748
751
|
'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
|
|
749
752
|
'experience:name': newUFOName
|
|
750
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getAssetsMetrics(interaction,
|
|
753
|
+
}, getBrowserMetadata()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), vcMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), {}, {
|
|
751
754
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
752
755
|
namePrefix: config.namePrefix || '',
|
|
753
756
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -779,7 +782,7 @@ function _createInteractionMetricsPayload() {
|
|
|
779
782
|
marks: optimizeMarks(interaction.marks, getReactUFOVersion(interaction.type)),
|
|
780
783
|
customData: optimizeCustomData(interaction),
|
|
781
784
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start, getReactUFOVersion(interaction.type))
|
|
782
|
-
}, labelStack),
|
|
785
|
+
}, labelStack), pageLoadInteractionMetrics), getDetailedInteractionMetrics(resourceTimings)), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)), {}, {
|
|
783
786
|
'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
|
|
784
787
|
'metric:experimental:ttai': expTTAI
|
|
785
788
|
}),
|
|
@@ -793,7 +796,7 @@ function _createInteractionMetricsPayload() {
|
|
|
793
796
|
}
|
|
794
797
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
795
798
|
return _context.abrupt("return", payload);
|
|
796
|
-
case
|
|
799
|
+
case 32:
|
|
797
800
|
case "end":
|
|
798
801
|
return _context.stop();
|
|
799
802
|
}
|
|
@@ -55,8 +55,7 @@ function getUniqueSelector(selectorConfig, element) {
|
|
|
55
55
|
} else if (!isSelectorUnique(potentialSelector)) {
|
|
56
56
|
var parentElement = element.parentElement;
|
|
57
57
|
if (parentElement) {
|
|
58
|
-
|
|
59
|
-
return "".concat(potentialSelector, ":nth-child(").concat(siblingIndex, ")");
|
|
58
|
+
return "".concat(potentialSelector, ":nth-child"); // NOTE: invalid DOM selector, but enough information for VC
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
return potentialSelector;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AssetsConfig, AssetsData, AssetsReporter } from '../common';
|
|
2
|
+
import type { ResourceEntry } from '../resource-timing/common/types';
|
|
3
3
|
export declare class CHRSummary {
|
|
4
4
|
bundles: {
|
|
5
5
|
mem: number;
|
|
@@ -13,13 +13,13 @@ export declare class CHRSummary {
|
|
|
13
13
|
net: number;
|
|
14
14
|
};
|
|
15
15
|
sizeTotal: number;
|
|
16
|
-
add(asset:
|
|
16
|
+
add(asset: ResourceEntry): void;
|
|
17
17
|
static makePayload(summary: CHRSummary): AssetsReporter;
|
|
18
18
|
}
|
|
19
19
|
export declare class CHRReporter {
|
|
20
20
|
all: CHRSummary;
|
|
21
21
|
allAtlassian: CHRSummary;
|
|
22
22
|
preloaded: CHRSummary;
|
|
23
|
-
|
|
24
|
-
get(resourceTimings:
|
|
23
|
+
defaultAllowedTypes: string[];
|
|
24
|
+
get(resourceTimings: ResourceEntry[] | null, assetsConfig: AssetsConfig, SSRDoneTime: number | undefined): AssetsData | null;
|
|
25
25
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { ResourceEntry } from '../resource-timing/common/types';
|
|
1
2
|
export declare const cacheableTypes: string[];
|
|
2
3
|
export declare const MEMORY_KEY = "mem";
|
|
3
4
|
export declare const DISK_KEY = "disk";
|
|
4
5
|
export declare const NETWORK_KEY = "net";
|
|
5
|
-
export declare const calculateTransferType: (type: string, duration: number, size: number | undefined) => "disk" | "mem" | "net" | null;
|
|
6
|
+
export declare const calculateTransferType: (name: string, type: string, duration: number, size: number | undefined) => "disk" | "mem" | "net" | null;
|
|
7
|
+
export declare const getTypeOfRequest: ({ name, initiatorType: type }: ResourceEntry) => string;
|
|
8
|
+
export declare const checkIfTimingsAvailable: (entry: ResourceEntry) => boolean;
|
|
6
9
|
export declare const round: (n: number) => number;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
entry: ResourceTiming;
|
|
1
|
+
import type { ResourceEntry } from '../../resource-timing/common/types';
|
|
2
|
+
export type AssetsConfigAllAtlassianArgs = {
|
|
3
|
+
entry: ResourceEntry;
|
|
5
4
|
};
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export type AssetsConfigPreloadedArgs = {
|
|
6
|
+
entry: ResourceEntry;
|
|
7
|
+
SSRDoneTime?: number;
|
|
8
|
+
};
|
|
9
|
+
export type AssetsConfig = {
|
|
10
|
+
allowedTypes: string[];
|
|
11
|
+
classification: {
|
|
12
|
+
all: boolean;
|
|
13
|
+
allAtlassian: (args: AssetsConfigAllAtlassianArgs) => boolean;
|
|
14
|
+
preloaded: (args: AssetsConfigPreloadedArgs) => boolean;
|
|
15
|
+
};
|
|
10
16
|
};
|
|
11
17
|
export type AssetsReporter = {
|
|
12
18
|
size: number | null;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @private
|
|
3
|
+
* @deprecated API - clean up with next reactUFO major version
|
|
4
|
+
*/
|
|
5
|
+
export type AssetResourceEntry = any;
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated API - clean up with next reactUFO major version
|
|
9
|
+
*/
|
|
10
|
+
export type AssetsClassification = any;
|
|
11
|
+
export type { AssetsConfig, AssetsData, AssetsReporter, AssetsConfigAllAtlassianArgs, AssetsConfigPreloadedArgs, } from './assets/types';
|
|
2
12
|
export type { LifecycleMarkType, MarkType, SpanType, InteractionType, AbortReasonType, CustomTiming, HoldInfo, LoadProfilerEventInfo, ReactProfilerTiming, Span, Mark, InteractionError, RequestInfo, ApdexType, SegmentInfo, CustomData, HoldActive, Redirect, InteractionMetrics, EnhancedUFOInteractionContextType, BM3Event, PostInteractionLogOutput, LastInteractionFinishInfo, } from './common/types';
|
|
3
13
|
export type { MultiHeatmapPayload } from './vc/types';
|
|
4
14
|
/**
|
|
@@ -57,7 +57,12 @@ export type Config = {
|
|
|
57
57
|
readonly getSSRTimings?: () => SSRTiming[];
|
|
58
58
|
readonly getSSRDoneTime?: () => number | undefined;
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* @private
|
|
62
|
+
* @deprecated remove me with next major release
|
|
63
|
+
*/
|
|
60
64
|
readonly assetsClassification?: AssetsClassification;
|
|
65
|
+
readonly assetsConfig?: AssetsClassification;
|
|
61
66
|
readonly enableBetterPageVisibilityApi?: boolean;
|
|
62
67
|
readonly vc?: {
|
|
63
68
|
readonly enabled?: boolean;
|