@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#124988](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/124988)
|
|
8
|
+
[`fa5bc92ae734d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa5bc92ae734d) -
|
|
9
|
+
Deduplicate nth-child(n) selectors produced by TTVC v3 debug info
|
|
10
|
+
|
|
11
|
+
## 3.4.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#124334](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/124334)
|
|
16
|
+
[`419c4451a0c0f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/419c4451a0c0f) -
|
|
17
|
+
Updated assets config to include different types of requests
|
|
18
|
+
|
|
3
19
|
## 3.3.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/assets/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.CHRSummary = exports.CHRReporter = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
10
|
var _defineProperty4 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -21,9 +20,8 @@ var CHRSummary = exports.CHRSummary = /*#__PURE__*/function () {
|
|
|
21
20
|
return (0, _createClass2.default)(CHRSummary, [{
|
|
22
21
|
key: "add",
|
|
23
22
|
value: function add(asset) {
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var type = (0, _utils.calculateTransferType)(asset.type, asset.duration, size);
|
|
23
|
+
var encodedSize = asset.encodedSize || 0;
|
|
24
|
+
var type = (0, _utils.calculateTransferType)(asset.name, asset.initiatorType, asset.duration, asset.transferSize);
|
|
27
25
|
if (type === null) {
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
@@ -54,28 +52,39 @@ var CHRReporter = exports.CHRReporter = /*#__PURE__*/function () {
|
|
|
54
52
|
(0, _defineProperty4.default)(this, "all", new CHRSummary());
|
|
55
53
|
(0, _defineProperty4.default)(this, "allAtlassian", new CHRSummary());
|
|
56
54
|
(0, _defineProperty4.default)(this, "preloaded", new CHRSummary());
|
|
55
|
+
(0, _defineProperty4.default)(this, "defaultAllowedTypes", ['js']);
|
|
57
56
|
}
|
|
58
57
|
return (0, _createClass2.default)(CHRReporter, [{
|
|
59
58
|
key: "get",
|
|
60
|
-
value: function get(resourceTimings,
|
|
59
|
+
value: function get(resourceTimings, assetsConfig, SSRDoneTime) {
|
|
61
60
|
var _this = this;
|
|
62
61
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (
|
|
62
|
+
if (resourceTimings === null) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
resourceTimings.forEach(function (entry) {
|
|
66
|
+
if (!(0, _utils.checkIfTimingsAvailable)(entry)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (entry.encodedSize === entry.decodedSize) {
|
|
70
|
+
// incorrectly reported size
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
var type = (0, _utils.getTypeOfRequest)(entry);
|
|
74
|
+
if (!(assetsConfig.allowedTypes || _this.defaultAllowedTypes).includes(type)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (assetsConfig.classification.all) {
|
|
68
78
|
_this.all.add(entry);
|
|
69
79
|
}
|
|
70
|
-
if (
|
|
71
|
-
label: label,
|
|
80
|
+
if (assetsConfig.classification.allAtlassian({
|
|
72
81
|
entry: entry
|
|
73
82
|
})) {
|
|
74
83
|
_this.allAtlassian.add(entry);
|
|
75
84
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
if (assetsConfig.classification.preloaded({
|
|
86
|
+
entry: entry,
|
|
87
|
+
SSRDoneTime: SSRDoneTime
|
|
79
88
|
})) {
|
|
80
89
|
_this.preloaded.add(entry);
|
|
81
90
|
}
|
|
@@ -83,11 +92,12 @@ var CHRReporter = exports.CHRReporter = /*#__PURE__*/function () {
|
|
|
83
92
|
if (this.all.bundlesCount === 0) {
|
|
84
93
|
return null;
|
|
85
94
|
}
|
|
86
|
-
|
|
95
|
+
var CHRData = {
|
|
87
96
|
all: CHRSummary.makePayload(this.all),
|
|
88
97
|
allAtlassian: CHRSummary.makePayload(this.allAtlassian),
|
|
89
98
|
preloaded: CHRSummary.makePayload(this.preloaded)
|
|
90
99
|
};
|
|
100
|
+
return CHRData;
|
|
91
101
|
} catch (error) {
|
|
92
102
|
return null;
|
|
93
103
|
}
|
package/dist/cjs/assets/utils.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.round = exports.calculateTransferType = exports.cacheableTypes = exports.NETWORK_KEY = exports.MEMORY_KEY = exports.DISK_KEY = void 0;
|
|
6
|
+
exports.round = exports.getTypeOfRequest = exports.checkIfTimingsAvailable = exports.calculateTransferType = exports.cacheableTypes = exports.NETWORK_KEY = exports.MEMORY_KEY = exports.DISK_KEY = void 0;
|
|
7
7
|
/* Borrowed from https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/performance/browser-metrics/src/plugins/timings/resource.ts */
|
|
8
|
-
var cacheableTypes = exports.cacheableTypes = ['script', 'link'];
|
|
8
|
+
var cacheableTypes = exports.cacheableTypes = ['script', 'link', 'other'];
|
|
9
9
|
var MEMORY_KEY = exports.MEMORY_KEY = 'mem';
|
|
10
10
|
var DISK_KEY = exports.DISK_KEY = 'disk';
|
|
11
11
|
var NETWORK_KEY = exports.NETWORK_KEY = 'net';
|
|
12
|
-
var calculateTransferType = exports.calculateTransferType = function calculateTransferType(type, duration, size) {
|
|
13
|
-
if (!cacheableTypes.includes(type)) {
|
|
12
|
+
var calculateTransferType = exports.calculateTransferType = function calculateTransferType(name, type, duration, size) {
|
|
13
|
+
if (!cacheableTypes.includes(type) && !(type === 'other' && name.includes('.js'))) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
if ((size === undefined || size === 0) && duration === 0) {
|
|
@@ -24,6 +24,49 @@ var calculateTransferType = exports.calculateTransferType = function calculateTr
|
|
|
24
24
|
}
|
|
25
25
|
return NETWORK_KEY;
|
|
26
26
|
};
|
|
27
|
+
var getTypeOfRequest = exports.getTypeOfRequest = function getTypeOfRequest(_ref) {
|
|
28
|
+
var name = _ref.name,
|
|
29
|
+
type = _ref.initiatorType;
|
|
30
|
+
var category = 'other';
|
|
31
|
+
var urlWithoutQuery = name.split('?')[0];
|
|
32
|
+
switch (type) {
|
|
33
|
+
case 'script':
|
|
34
|
+
category = 'js';
|
|
35
|
+
break;
|
|
36
|
+
case 'link':
|
|
37
|
+
if (urlWithoutQuery.endsWith('.css')) {
|
|
38
|
+
category = 'css';
|
|
39
|
+
}
|
|
40
|
+
if (urlWithoutQuery.endsWith('.js')) {
|
|
41
|
+
category = 'js';
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case 'img':
|
|
45
|
+
category = 'image';
|
|
46
|
+
break;
|
|
47
|
+
case 'font':
|
|
48
|
+
category = 'font';
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
if (urlWithoutQuery.endsWith('.js')) {
|
|
52
|
+
category = 'js';
|
|
53
|
+
} else if (urlWithoutQuery.endsWith('.css')) {
|
|
54
|
+
category = 'css';
|
|
55
|
+
} else if (urlWithoutQuery.match(/\.(woff|woff2|ttf|otf)$/)) {
|
|
56
|
+
category = 'font';
|
|
57
|
+
} else if (urlWithoutQuery.match(/\.(png|jpg|jpeg|gif|svg)$/)) {
|
|
58
|
+
category = 'image';
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
return category;
|
|
63
|
+
};
|
|
64
|
+
var checkIfTimingsAvailable = exports.checkIfTimingsAvailable = function checkIfTimingsAvailable(entry) {
|
|
65
|
+
if (entry.decodedSize === 0 && entry.encodedSize === 0 && entry.requestStart === 0 && entry.responseStart === 0) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
27
70
|
var round = exports.round = function round(n) {
|
|
28
71
|
if (isNaN(n)) {
|
|
29
72
|
return 0;
|
|
@@ -28,6 +28,7 @@ var _hiddenTiming = require("../hidden-timing");
|
|
|
28
28
|
var initialPageLoadExtraTiming = _interopRequireWildcard(require("../initial-page-load-extra-timing"));
|
|
29
29
|
var _interactionMetrics = require("../interaction-metrics");
|
|
30
30
|
var resourceTiming = _interopRequireWildcard(require("../resource-timing"));
|
|
31
|
+
var _resourceTimingBuffer = require("../resource-timing/common/utils/resource-timing-buffer");
|
|
31
32
|
var _roundNumber = require("../round-number");
|
|
32
33
|
var ssr = _interopRequireWildcard(require("../ssr"));
|
|
33
34
|
var _utils = require("./common/utils");
|
|
@@ -257,18 +258,19 @@ function getSSRProperties(type) {
|
|
|
257
258
|
'ssr:featureFlags': getSSRFeatureFlags(type)
|
|
258
259
|
};
|
|
259
260
|
}
|
|
260
|
-
var getAssetsMetrics = function getAssetsMetrics(interaction,
|
|
261
|
+
var getAssetsMetrics = function getAssetsMetrics(interaction, SSRDoneTime) {
|
|
261
262
|
try {
|
|
262
263
|
var config = (0, _config.getConfig)();
|
|
263
264
|
var type = interaction.type;
|
|
264
265
|
var allowedTypes = ['page_load', 'transition'];
|
|
265
|
-
var
|
|
266
|
-
if (!allowedTypes.includes(type) || !
|
|
266
|
+
var assetsConfig = config === null || config === void 0 ? void 0 : config.assetsConfig;
|
|
267
|
+
if (!allowedTypes.includes(type) || !assetsConfig) {
|
|
267
268
|
// Skip if: type not allowed or assetsClassification isn't configured
|
|
268
269
|
return {};
|
|
269
270
|
}
|
|
270
271
|
var reporter = new _assets.CHRReporter();
|
|
271
|
-
var
|
|
272
|
+
var resourceTimings = (0, _resourceTimingBuffer.filterResourceTimings)(interaction.start, interaction.end);
|
|
273
|
+
var assets = reporter.get(resourceTimings, assetsConfig, SSRDoneTime);
|
|
272
274
|
if (assets) {
|
|
273
275
|
// Only add assets in case it exists
|
|
274
276
|
return {
|
|
@@ -647,7 +649,7 @@ function createInteractionMetricsPayload(_x, _x2, _x3) {
|
|
|
647
649
|
function _createInteractionMetricsPayload() {
|
|
648
650
|
_createInteractionMetricsPayload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interaction, interactionId, experimental) {
|
|
649
651
|
var _window$location, _config$additionalPay;
|
|
650
|
-
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,
|
|
652
|
+
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;
|
|
651
653
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
652
654
|
while (1) switch (_context.prev = _context.next) {
|
|
653
655
|
case 0:
|
|
@@ -674,7 +676,7 @@ function _createInteractionMetricsPayload() {
|
|
|
674
676
|
labelStack = interaction.labelStack ? {
|
|
675
677
|
labelStack: (0, _utils.optimizeLabelStack)(interaction.labelStack, (0, _constants.getReactUFOVersion)(interaction.type))
|
|
676
678
|
} : {}; // Page Load
|
|
677
|
-
|
|
679
|
+
getInitialPageLoadSSRMetrics = function getInitialPageLoadSSRMetrics() {
|
|
678
680
|
var _config$ssr;
|
|
679
681
|
if (!isPageLoad) {
|
|
680
682
|
return {};
|
|
@@ -688,7 +690,8 @@ function _createInteractionMetricsPayload() {
|
|
|
688
690
|
isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
|
|
689
691
|
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
|
|
690
692
|
});
|
|
691
|
-
};
|
|
693
|
+
};
|
|
694
|
+
pageLoadInteractionMetrics = getInitialPageLoadSSRMetrics(); // Detailed payload. Page visibility = visible
|
|
692
695
|
getDetailedInteractionMetrics = function getDetailedInteractionMetrics(resourceTimings) {
|
|
693
696
|
if (experimental || window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
694
697
|
return {};
|
|
@@ -731,9 +734,9 @@ function _createInteractionMetricsPayload() {
|
|
|
731
734
|
}
|
|
732
735
|
newUFOName = (0, _utils.sanitizeUfoName)(ufoName);
|
|
733
736
|
resourceTimings = getResourceTimings(start, end);
|
|
734
|
-
_context.next =
|
|
737
|
+
_context.next = 24;
|
|
735
738
|
return Promise.all([(0, _getVcMetrics.default)(interaction), experimental ? (0, _createExperimentalInteractionMetricsPayload.getExperimentalVCMetrics)(interaction) : Promise.resolve(undefined)]);
|
|
736
|
-
case
|
|
739
|
+
case 24:
|
|
737
740
|
_yield$Promise$all = _context.sent;
|
|
738
741
|
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
|
|
739
742
|
vcMetrics = _yield$Promise$all2[0];
|
|
@@ -758,7 +761,7 @@ function _createInteractionMetricsPayload() {
|
|
|
758
761
|
'event:region': config.region || 'unknown',
|
|
759
762
|
'experience:key': experimental ? 'custom.experimental-interaction-metrics' : 'custom.interaction-metrics',
|
|
760
763
|
'experience:name': newUFOName
|
|
761
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getAssetsMetrics(interaction,
|
|
764
|
+
}, 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)), {}, {
|
|
762
765
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
763
766
|
namePrefix: config.namePrefix || '',
|
|
764
767
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -790,7 +793,7 @@ function _createInteractionMetricsPayload() {
|
|
|
790
793
|
marks: optimizeMarks(interaction.marks, (0, _constants.getReactUFOVersion)(interaction.type)),
|
|
791
794
|
customData: optimizeCustomData(interaction),
|
|
792
795
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start, (0, _constants.getReactUFOVersion)(interaction.type))
|
|
793
|
-
}, labelStack),
|
|
796
|
+
}, labelStack), pageLoadInteractionMetrics), getDetailedInteractionMetrics(resourceTimings)), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)), {}, {
|
|
794
797
|
'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
|
|
795
798
|
'metric:experimental:ttai': expTTAI
|
|
796
799
|
}),
|
|
@@ -804,7 +807,7 @@ function _createInteractionMetricsPayload() {
|
|
|
804
807
|
}
|
|
805
808
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
806
809
|
return _context.abrupt("return", payload);
|
|
807
|
-
case
|
|
810
|
+
case 32:
|
|
808
811
|
case "end":
|
|
809
812
|
return _context.stop();
|
|
810
813
|
}
|
|
@@ -61,8 +61,7 @@ function getUniqueSelector(selectorConfig, element) {
|
|
|
61
61
|
} else if (!isSelectorUnique(potentialSelector)) {
|
|
62
62
|
var parentElement = element.parentElement;
|
|
63
63
|
if (parentElement) {
|
|
64
|
-
|
|
65
|
-
return "".concat(potentialSelector, ":nth-child(").concat(siblingIndex, ")");
|
|
64
|
+
return "".concat(potentialSelector, ":nth-child"); // NOTE: invalid DOM selector, but enough information for VC
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
return potentialSelector;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { calculateTransferType, DISK_KEY, MEMORY_KEY, NETWORK_KEY, round } from './utils';
|
|
2
|
+
import { calculateTransferType, checkIfTimingsAvailable, DISK_KEY, getTypeOfRequest, MEMORY_KEY, NETWORK_KEY, round } from './utils';
|
|
3
3
|
export class CHRSummary {
|
|
4
4
|
constructor() {
|
|
5
5
|
_defineProperty(this, "bundles", {
|
|
@@ -16,9 +16,8 @@ export class CHRSummary {
|
|
|
16
16
|
_defineProperty(this, "sizeTotal", 0);
|
|
17
17
|
}
|
|
18
18
|
add(asset) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const type = calculateTransferType(asset.type, asset.duration, size);
|
|
19
|
+
const encodedSize = asset.encodedSize || 0;
|
|
20
|
+
const type = calculateTransferType(asset.name, asset.initiatorType, asset.duration, asset.transferSize);
|
|
22
21
|
if (type === null) {
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
@@ -47,22 +46,36 @@ export class CHRReporter {
|
|
|
47
46
|
_defineProperty(this, "all", new CHRSummary());
|
|
48
47
|
_defineProperty(this, "allAtlassian", new CHRSummary());
|
|
49
48
|
_defineProperty(this, "preloaded", new CHRSummary());
|
|
49
|
+
_defineProperty(this, "defaultAllowedTypes", ['js']);
|
|
50
50
|
}
|
|
51
|
-
get(resourceTimings,
|
|
51
|
+
get(resourceTimings, assetsConfig, SSRDoneTime) {
|
|
52
52
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
if (resourceTimings === null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
resourceTimings.forEach(entry => {
|
|
57
|
+
if (!checkIfTimingsAvailable(entry)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (entry.encodedSize === entry.decodedSize) {
|
|
61
|
+
// incorrectly reported size
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const type = getTypeOfRequest(entry);
|
|
65
|
+
if (!(assetsConfig.allowedTypes || this.defaultAllowedTypes).includes(type)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (assetsConfig.classification.all) {
|
|
55
69
|
this.all.add(entry);
|
|
56
70
|
}
|
|
57
|
-
if (
|
|
58
|
-
label,
|
|
71
|
+
if (assetsConfig.classification.allAtlassian({
|
|
59
72
|
entry
|
|
60
73
|
})) {
|
|
61
74
|
this.allAtlassian.add(entry);
|
|
62
75
|
}
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
if (assetsConfig.classification.preloaded({
|
|
77
|
+
entry,
|
|
78
|
+
SSRDoneTime
|
|
66
79
|
})) {
|
|
67
80
|
this.preloaded.add(entry);
|
|
68
81
|
}
|
|
@@ -70,11 +83,12 @@ export class CHRReporter {
|
|
|
70
83
|
if (this.all.bundlesCount === 0) {
|
|
71
84
|
return null;
|
|
72
85
|
}
|
|
73
|
-
|
|
86
|
+
const CHRData = {
|
|
74
87
|
all: CHRSummary.makePayload(this.all),
|
|
75
88
|
allAtlassian: CHRSummary.makePayload(this.allAtlassian),
|
|
76
89
|
preloaded: CHRSummary.makePayload(this.preloaded)
|
|
77
90
|
};
|
|
91
|
+
return CHRData;
|
|
78
92
|
} catch (error) {
|
|
79
93
|
return null;
|
|
80
94
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* Borrowed from https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/performance/browser-metrics/src/plugins/timings/resource.ts */
|
|
2
|
-
export const cacheableTypes = ['script', 'link'];
|
|
2
|
+
export const cacheableTypes = ['script', 'link', 'other'];
|
|
3
3
|
export const MEMORY_KEY = 'mem';
|
|
4
4
|
export const DISK_KEY = 'disk';
|
|
5
5
|
export const NETWORK_KEY = 'net';
|
|
6
|
-
export const calculateTransferType = (type, duration, size) => {
|
|
7
|
-
if (!cacheableTypes.includes(type)) {
|
|
6
|
+
export const calculateTransferType = (name, type, duration, size) => {
|
|
7
|
+
if (!cacheableTypes.includes(type) && !(type === 'other' && name.includes('.js'))) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
10
|
if ((size === undefined || size === 0) && duration === 0) {
|
|
@@ -18,6 +18,50 @@ export const calculateTransferType = (type, duration, size) => {
|
|
|
18
18
|
}
|
|
19
19
|
return NETWORK_KEY;
|
|
20
20
|
};
|
|
21
|
+
export const getTypeOfRequest = ({
|
|
22
|
+
name,
|
|
23
|
+
initiatorType: type
|
|
24
|
+
}) => {
|
|
25
|
+
let category = 'other';
|
|
26
|
+
const urlWithoutQuery = name.split('?')[0];
|
|
27
|
+
switch (type) {
|
|
28
|
+
case 'script':
|
|
29
|
+
category = 'js';
|
|
30
|
+
break;
|
|
31
|
+
case 'link':
|
|
32
|
+
if (urlWithoutQuery.endsWith('.css')) {
|
|
33
|
+
category = 'css';
|
|
34
|
+
}
|
|
35
|
+
if (urlWithoutQuery.endsWith('.js')) {
|
|
36
|
+
category = 'js';
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case 'img':
|
|
40
|
+
category = 'image';
|
|
41
|
+
break;
|
|
42
|
+
case 'font':
|
|
43
|
+
category = 'font';
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
if (urlWithoutQuery.endsWith('.js')) {
|
|
47
|
+
category = 'js';
|
|
48
|
+
} else if (urlWithoutQuery.endsWith('.css')) {
|
|
49
|
+
category = 'css';
|
|
50
|
+
} else if (urlWithoutQuery.match(/\.(woff|woff2|ttf|otf)$/)) {
|
|
51
|
+
category = 'font';
|
|
52
|
+
} else if (urlWithoutQuery.match(/\.(png|jpg|jpeg|gif|svg)$/)) {
|
|
53
|
+
category = 'image';
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return category;
|
|
58
|
+
};
|
|
59
|
+
export const checkIfTimingsAvailable = entry => {
|
|
60
|
+
if (entry.decodedSize === 0 && entry.encodedSize === 0 && entry.requestStart === 0 && entry.responseStart === 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
21
65
|
export const round = n => {
|
|
22
66
|
if (isNaN(n)) {
|
|
23
67
|
return 0;
|
|
@@ -13,6 +13,7 @@ import { getPageVisibilityState } from '../hidden-timing';
|
|
|
13
13
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
14
14
|
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
15
15
|
import * as resourceTiming from '../resource-timing';
|
|
16
|
+
import { filterResourceTimings } from '../resource-timing/common/utils/resource-timing-buffer';
|
|
16
17
|
import { roundEpsilon } from '../round-number';
|
|
17
18
|
import * as ssr from '../ssr';
|
|
18
19
|
import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
@@ -234,20 +235,21 @@ function getSSRProperties(type) {
|
|
|
234
235
|
'ssr:featureFlags': getSSRFeatureFlags(type)
|
|
235
236
|
};
|
|
236
237
|
}
|
|
237
|
-
const getAssetsMetrics = (interaction,
|
|
238
|
+
const getAssetsMetrics = (interaction, SSRDoneTime) => {
|
|
238
239
|
try {
|
|
239
240
|
const config = getConfig();
|
|
240
241
|
const {
|
|
241
242
|
type
|
|
242
243
|
} = interaction;
|
|
243
244
|
const allowedTypes = ['page_load', 'transition'];
|
|
244
|
-
const
|
|
245
|
-
if (!allowedTypes.includes(type) || !
|
|
245
|
+
const assetsConfig = config === null || config === void 0 ? void 0 : config.assetsConfig;
|
|
246
|
+
if (!allowedTypes.includes(type) || !assetsConfig) {
|
|
246
247
|
// Skip if: type not allowed or assetsClassification isn't configured
|
|
247
248
|
return {};
|
|
248
249
|
}
|
|
249
250
|
const reporter = new CHRReporter();
|
|
250
|
-
const
|
|
251
|
+
const resourceTimings = filterResourceTimings(interaction.start, interaction.end);
|
|
252
|
+
const assets = reporter.get(resourceTimings, assetsConfig, SSRDoneTime);
|
|
251
253
|
if (assets) {
|
|
252
254
|
// Only add assets in case it exists
|
|
253
255
|
return {
|
|
@@ -664,7 +666,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
664
666
|
labelStack: optimizeLabelStack(interaction.labelStack, getReactUFOVersion(interaction.type))
|
|
665
667
|
} : {};
|
|
666
668
|
// Page Load
|
|
667
|
-
const
|
|
669
|
+
const getInitialPageLoadSSRMetrics = () => {
|
|
668
670
|
var _config$ssr;
|
|
669
671
|
if (!isPageLoad) {
|
|
670
672
|
return {};
|
|
@@ -680,6 +682,8 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
680
682
|
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
|
|
681
683
|
};
|
|
682
684
|
};
|
|
685
|
+
const pageLoadInteractionMetrics = getInitialPageLoadSSRMetrics();
|
|
686
|
+
|
|
683
687
|
// Detailed payload. Page visibility = visible
|
|
684
688
|
const getDetailedInteractionMetrics = resourceTimings => {
|
|
685
689
|
if (experimental || window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
@@ -748,7 +752,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
748
752
|
// root
|
|
749
753
|
...getBrowserMetadata(),
|
|
750
754
|
...getSSRProperties(type),
|
|
751
|
-
...getAssetsMetrics(interaction,
|
|
755
|
+
...getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime),
|
|
752
756
|
...getPPSMetrics(interaction),
|
|
753
757
|
...getPaintMetrics(type),
|
|
754
758
|
...getNavigationMetrics(type),
|
|
@@ -790,7 +794,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
790
794
|
customData: optimizeCustomData(interaction),
|
|
791
795
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start, getReactUFOVersion(interaction.type)),
|
|
792
796
|
...labelStack,
|
|
793
|
-
...
|
|
797
|
+
...pageLoadInteractionMetrics,
|
|
794
798
|
...getDetailedInteractionMetrics(resourceTimings),
|
|
795
799
|
...getPageLoadDetailedInteractionMetrics(),
|
|
796
800
|
...getBm3TrackerTimings(interaction),
|
|
@@ -55,8 +55,7 @@ function getUniqueSelector(selectorConfig, element) {
|
|
|
55
55
|
} else if (!isSelectorUnique(potentialSelector)) {
|
|
56
56
|
const parentElement = element.parentElement;
|
|
57
57
|
if (parentElement) {
|
|
58
|
-
|
|
59
|
-
return `${potentialSelector}:nth-child(${siblingIndex})`;
|
|
58
|
+
return `${potentialSelector}:nth-child`; // NOTE: invalid DOM selector, but enough information for VC
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
return potentialSelector;
|
package/dist/esm/assets/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
import { calculateTransferType, DISK_KEY, MEMORY_KEY, NETWORK_KEY, round } from './utils';
|
|
4
|
+
import { calculateTransferType, checkIfTimingsAvailable, DISK_KEY, getTypeOfRequest, MEMORY_KEY, NETWORK_KEY, round } from './utils';
|
|
6
5
|
export var CHRSummary = /*#__PURE__*/function () {
|
|
7
6
|
function CHRSummary() {
|
|
8
7
|
_classCallCheck(this, CHRSummary);
|
|
@@ -14,9 +13,8 @@ export var CHRSummary = /*#__PURE__*/function () {
|
|
|
14
13
|
return _createClass(CHRSummary, [{
|
|
15
14
|
key: "add",
|
|
16
15
|
value: function add(asset) {
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var type = calculateTransferType(asset.type, asset.duration, size);
|
|
16
|
+
var encodedSize = asset.encodedSize || 0;
|
|
17
|
+
var type = calculateTransferType(asset.name, asset.initiatorType, asset.duration, asset.transferSize);
|
|
20
18
|
if (type === null) {
|
|
21
19
|
return;
|
|
22
20
|
}
|
|
@@ -47,28 +45,39 @@ export var CHRReporter = /*#__PURE__*/function () {
|
|
|
47
45
|
_defineProperty(this, "all", new CHRSummary());
|
|
48
46
|
_defineProperty(this, "allAtlassian", new CHRSummary());
|
|
49
47
|
_defineProperty(this, "preloaded", new CHRSummary());
|
|
48
|
+
_defineProperty(this, "defaultAllowedTypes", ['js']);
|
|
50
49
|
}
|
|
51
50
|
return _createClass(CHRReporter, [{
|
|
52
51
|
key: "get",
|
|
53
|
-
value: function get(resourceTimings,
|
|
52
|
+
value: function get(resourceTimings, assetsConfig, SSRDoneTime) {
|
|
54
53
|
var _this = this;
|
|
55
54
|
try {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
55
|
+
if (resourceTimings === null) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
resourceTimings.forEach(function (entry) {
|
|
59
|
+
if (!checkIfTimingsAvailable(entry)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (entry.encodedSize === entry.decodedSize) {
|
|
63
|
+
// incorrectly reported size
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var type = getTypeOfRequest(entry);
|
|
67
|
+
if (!(assetsConfig.allowedTypes || _this.defaultAllowedTypes).includes(type)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (assetsConfig.classification.all) {
|
|
61
71
|
_this.all.add(entry);
|
|
62
72
|
}
|
|
63
|
-
if (
|
|
64
|
-
label: label,
|
|
73
|
+
if (assetsConfig.classification.allAtlassian({
|
|
65
74
|
entry: entry
|
|
66
75
|
})) {
|
|
67
76
|
_this.allAtlassian.add(entry);
|
|
68
77
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
if (assetsConfig.classification.preloaded({
|
|
79
|
+
entry: entry,
|
|
80
|
+
SSRDoneTime: SSRDoneTime
|
|
72
81
|
})) {
|
|
73
82
|
_this.preloaded.add(entry);
|
|
74
83
|
}
|
|
@@ -76,11 +85,12 @@ export var CHRReporter = /*#__PURE__*/function () {
|
|
|
76
85
|
if (this.all.bundlesCount === 0) {
|
|
77
86
|
return null;
|
|
78
87
|
}
|
|
79
|
-
|
|
88
|
+
var CHRData = {
|
|
80
89
|
all: CHRSummary.makePayload(this.all),
|
|
81
90
|
allAtlassian: CHRSummary.makePayload(this.allAtlassian),
|
|
82
91
|
preloaded: CHRSummary.makePayload(this.preloaded)
|
|
83
92
|
};
|
|
93
|
+
return CHRData;
|
|
84
94
|
} catch (error) {
|
|
85
95
|
return null;
|
|
86
96
|
}
|
package/dist/esm/assets/utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* Borrowed from https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/performance/browser-metrics/src/plugins/timings/resource.ts */
|
|
2
|
-
export var cacheableTypes = ['script', 'link'];
|
|
2
|
+
export var cacheableTypes = ['script', 'link', 'other'];
|
|
3
3
|
export var MEMORY_KEY = 'mem';
|
|
4
4
|
export var DISK_KEY = 'disk';
|
|
5
5
|
export var NETWORK_KEY = 'net';
|
|
6
|
-
export var calculateTransferType = function calculateTransferType(type, duration, size) {
|
|
7
|
-
if (!cacheableTypes.includes(type)) {
|
|
6
|
+
export var calculateTransferType = function calculateTransferType(name, type, duration, size) {
|
|
7
|
+
if (!cacheableTypes.includes(type) && !(type === 'other' && name.includes('.js'))) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
10
|
if ((size === undefined || size === 0) && duration === 0) {
|
|
@@ -18,6 +18,49 @@ export var calculateTransferType = function calculateTransferType(type, duration
|
|
|
18
18
|
}
|
|
19
19
|
return NETWORK_KEY;
|
|
20
20
|
};
|
|
21
|
+
export var getTypeOfRequest = function getTypeOfRequest(_ref) {
|
|
22
|
+
var name = _ref.name,
|
|
23
|
+
type = _ref.initiatorType;
|
|
24
|
+
var category = 'other';
|
|
25
|
+
var urlWithoutQuery = name.split('?')[0];
|
|
26
|
+
switch (type) {
|
|
27
|
+
case 'script':
|
|
28
|
+
category = 'js';
|
|
29
|
+
break;
|
|
30
|
+
case 'link':
|
|
31
|
+
if (urlWithoutQuery.endsWith('.css')) {
|
|
32
|
+
category = 'css';
|
|
33
|
+
}
|
|
34
|
+
if (urlWithoutQuery.endsWith('.js')) {
|
|
35
|
+
category = 'js';
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'img':
|
|
39
|
+
category = 'image';
|
|
40
|
+
break;
|
|
41
|
+
case 'font':
|
|
42
|
+
category = 'font';
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
if (urlWithoutQuery.endsWith('.js')) {
|
|
46
|
+
category = 'js';
|
|
47
|
+
} else if (urlWithoutQuery.endsWith('.css')) {
|
|
48
|
+
category = 'css';
|
|
49
|
+
} else if (urlWithoutQuery.match(/\.(woff|woff2|ttf|otf)$/)) {
|
|
50
|
+
category = 'font';
|
|
51
|
+
} else if (urlWithoutQuery.match(/\.(png|jpg|jpeg|gif|svg)$/)) {
|
|
52
|
+
category = 'image';
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
return category;
|
|
57
|
+
};
|
|
58
|
+
export var checkIfTimingsAvailable = function checkIfTimingsAvailable(entry) {
|
|
59
|
+
if (entry.decodedSize === 0 && entry.encodedSize === 0 && entry.requestStart === 0 && entry.responseStart === 0) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
21
64
|
export var round = function round(n) {
|
|
22
65
|
if (isNaN(n)) {
|
|
23
66
|
return 0;
|