@atlaskit/react-ufo 3.0.0 → 3.1.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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#118212](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/118212)
|
|
8
|
+
[`7a1ec3e0fb496`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7a1ec3e0fb496) -
|
|
9
|
+
Updating logic to track resource timings to include 'other' type which includes '.js'
|
|
10
|
+
|
|
3
11
|
## 3.0.0
|
|
4
12
|
|
|
5
13
|
### Major Changes
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getResourceTimings = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
var _config = require("../config");
|
|
10
11
|
var _roundNumber = require("../round-number");
|
|
11
12
|
var _config2 = require("./common/utils/config");
|
|
@@ -17,10 +18,19 @@ var resourceTypes = ['fetch', 'xmlhttprequest'];
|
|
|
17
18
|
var CACHE_NETWORK = 'network';
|
|
18
19
|
var CACHE_MEMORY = 'memory';
|
|
19
20
|
var CACHE_DISK = 'disk';
|
|
21
|
+
var isCacheableType = function isCacheableType(url, type) {
|
|
22
|
+
if (cacheableTypes.includes(type)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (type === 'other' && url.includes('.js') && (0, _platformFeatureFlags.fg)('ufo_support_other_resource_type_js')) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
20
30
|
|
|
21
31
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
22
|
-
var calculateTransferType = function calculateTransferType(type, duration, size) {
|
|
23
|
-
if (!
|
|
32
|
+
var calculateTransferType = function calculateTransferType(name, type, duration, size) {
|
|
33
|
+
if (!isCacheableType(name, type)) {
|
|
24
34
|
return CACHE_NETWORK;
|
|
25
35
|
}
|
|
26
36
|
if ((size === undefined || size === 0) && duration === 0) {
|
|
@@ -38,15 +48,22 @@ var getWindowObject = function getWindowObject() {
|
|
|
38
48
|
return typeof window !== 'undefined' && !!window ? window : undefined;
|
|
39
49
|
};
|
|
40
50
|
var hasAccessToResourceSize = function hasAccessToResourceSize(url, type, entry, hasTimingHeaders) {
|
|
41
|
-
return !
|
|
51
|
+
return !isCacheableType(url, type) || url.includes('localhost') || !!getWindowObject() && url.includes(window.location.hostname) || hasTimingHeaders(url, entry);
|
|
42
52
|
};
|
|
43
53
|
var getReportedInitiatorTypes = function getReportedInitiatorTypes(xhrEnabled) {
|
|
44
54
|
var ufoConfig = (0, _config.getConfig)();
|
|
45
55
|
if (!(ufoConfig !== null && ufoConfig !== void 0 && ufoConfig.allowedResources)) {
|
|
46
|
-
if (
|
|
47
|
-
|
|
56
|
+
if ((0, _platformFeatureFlags.fg)('ufo_support_other_resource_type_js')) {
|
|
57
|
+
if (xhrEnabled) {
|
|
58
|
+
return ['script', 'link', 'fetch', 'other', 'xmlhttprequest'];
|
|
59
|
+
}
|
|
60
|
+
return ['script', 'link', 'fetch', 'other'];
|
|
61
|
+
} else {
|
|
62
|
+
if (xhrEnabled) {
|
|
63
|
+
return ['script', 'link', 'fetch', 'xmlhttprequest'];
|
|
64
|
+
}
|
|
65
|
+
return ['script', 'link', 'fetch'];
|
|
48
66
|
}
|
|
49
|
-
return ['script', 'link', 'fetch'];
|
|
50
67
|
}
|
|
51
68
|
return ufoConfig.allowedResources;
|
|
52
69
|
};
|
|
@@ -77,7 +94,7 @@ var getNetworkData = function getNetworkData(item, eventStart) {
|
|
|
77
94
|
return {};
|
|
78
95
|
}
|
|
79
96
|
if (cacheableTypes.includes(initiatorType)) {
|
|
80
|
-
var transferType = calculateTransferType(initiatorType, duration, transferSize);
|
|
97
|
+
var transferType = calculateTransferType(name, initiatorType, duration, transferSize);
|
|
81
98
|
return _objectSpread({
|
|
82
99
|
ttfb: ttfb,
|
|
83
100
|
transferType: transferType,
|
|
@@ -125,6 +142,9 @@ var getResourceTimings = exports.getResourceTimings = function getResourceTiming
|
|
|
125
142
|
if (initiatorType === 'xmlhttprequest' && (xhrFilter === undefined || xhrFilter(name) === false)) {
|
|
126
143
|
return;
|
|
127
144
|
}
|
|
145
|
+
if (initiatorType === 'other' && !name.includes('.js') && (0, _platformFeatureFlags.fg)('ufo_support_other_resource_type_js')) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
128
148
|
var url = resourceTypes.includes(initiatorType) ? sanitiseEndpoints(name) : mapResources(name);
|
|
129
149
|
if (!url) {
|
|
130
150
|
return;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { getConfig as getConfigUFO } from '../config';
|
|
2
3
|
import { roundEpsilon } from '../round-number';
|
|
3
4
|
import { getConfig } from './common/utils/config';
|
|
@@ -7,10 +8,19 @@ const resourceTypes = ['fetch', 'xmlhttprequest'];
|
|
|
7
8
|
const CACHE_NETWORK = 'network';
|
|
8
9
|
const CACHE_MEMORY = 'memory';
|
|
9
10
|
const CACHE_DISK = 'disk';
|
|
11
|
+
const isCacheableType = (url, type) => {
|
|
12
|
+
if (cacheableTypes.includes(type)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (type === 'other' && url.includes('.js') && fg('ufo_support_other_resource_type_js')) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
10
20
|
|
|
11
21
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
12
|
-
const calculateTransferType = (type, duration, size) => {
|
|
13
|
-
if (!
|
|
22
|
+
const calculateTransferType = (name, type, duration, size) => {
|
|
23
|
+
if (!isCacheableType(name, type)) {
|
|
14
24
|
return CACHE_NETWORK;
|
|
15
25
|
}
|
|
16
26
|
if ((size === undefined || size === 0) && duration === 0) {
|
|
@@ -25,14 +35,21 @@ const calculateTransferType = (type, duration, size) => {
|
|
|
25
35
|
return CACHE_NETWORK;
|
|
26
36
|
};
|
|
27
37
|
const getWindowObject = () => typeof window !== 'undefined' && !!window ? window : undefined;
|
|
28
|
-
const hasAccessToResourceSize = (url, type, entry, hasTimingHeaders) => !
|
|
38
|
+
const hasAccessToResourceSize = (url, type, entry, hasTimingHeaders) => !isCacheableType(url, type) || url.includes('localhost') || !!getWindowObject() && url.includes(window.location.hostname) || hasTimingHeaders(url, entry);
|
|
29
39
|
const getReportedInitiatorTypes = xhrEnabled => {
|
|
30
40
|
const ufoConfig = getConfigUFO();
|
|
31
41
|
if (!(ufoConfig !== null && ufoConfig !== void 0 && ufoConfig.allowedResources)) {
|
|
32
|
-
if (
|
|
33
|
-
|
|
42
|
+
if (fg('ufo_support_other_resource_type_js')) {
|
|
43
|
+
if (xhrEnabled) {
|
|
44
|
+
return ['script', 'link', 'fetch', 'other', 'xmlhttprequest'];
|
|
45
|
+
}
|
|
46
|
+
return ['script', 'link', 'fetch', 'other'];
|
|
47
|
+
} else {
|
|
48
|
+
if (xhrEnabled) {
|
|
49
|
+
return ['script', 'link', 'fetch', 'xmlhttprequest'];
|
|
50
|
+
}
|
|
51
|
+
return ['script', 'link', 'fetch'];
|
|
34
52
|
}
|
|
35
|
-
return ['script', 'link', 'fetch'];
|
|
36
53
|
}
|
|
37
54
|
return ufoConfig.allowedResources;
|
|
38
55
|
};
|
|
@@ -60,7 +77,7 @@ const getNetworkData = (item, eventStart, hasTimingHeaders = evaluateAccessToRes
|
|
|
60
77
|
return {};
|
|
61
78
|
}
|
|
62
79
|
if (cacheableTypes.includes(initiatorType)) {
|
|
63
|
-
const transferType = calculateTransferType(initiatorType, duration, transferSize);
|
|
80
|
+
const transferType = calculateTransferType(name, initiatorType, duration, transferSize);
|
|
64
81
|
return {
|
|
65
82
|
ttfb,
|
|
66
83
|
transferType,
|
|
@@ -113,6 +130,9 @@ export const getResourceTimings = (interactionStart, interactionEnd) => {
|
|
|
113
130
|
if (initiatorType === 'xmlhttprequest' && (xhrFilter === undefined || xhrFilter(name) === false)) {
|
|
114
131
|
return;
|
|
115
132
|
}
|
|
133
|
+
if (initiatorType === 'other' && !name.includes('.js') && fg('ufo_support_other_resource_type_js')) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
116
136
|
const url = resourceTypes.includes(initiatorType) ? sanitiseEndpoints(name) : mapResources(name);
|
|
117
137
|
if (!url) {
|
|
118
138
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { getConfig as getConfigUFO } from '../config';
|
|
5
6
|
import { roundEpsilon } from '../round-number';
|
|
6
7
|
import { getConfig } from './common/utils/config';
|
|
@@ -10,10 +11,19 @@ var resourceTypes = ['fetch', 'xmlhttprequest'];
|
|
|
10
11
|
var CACHE_NETWORK = 'network';
|
|
11
12
|
var CACHE_MEMORY = 'memory';
|
|
12
13
|
var CACHE_DISK = 'disk';
|
|
14
|
+
var isCacheableType = function isCacheableType(url, type) {
|
|
15
|
+
if (cacheableTypes.includes(type)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (type === 'other' && url.includes('.js') && fg('ufo_support_other_resource_type_js')) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
13
23
|
|
|
14
24
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
15
|
-
var calculateTransferType = function calculateTransferType(type, duration, size) {
|
|
16
|
-
if (!
|
|
25
|
+
var calculateTransferType = function calculateTransferType(name, type, duration, size) {
|
|
26
|
+
if (!isCacheableType(name, type)) {
|
|
17
27
|
return CACHE_NETWORK;
|
|
18
28
|
}
|
|
19
29
|
if ((size === undefined || size === 0) && duration === 0) {
|
|
@@ -31,15 +41,22 @@ var getWindowObject = function getWindowObject() {
|
|
|
31
41
|
return typeof window !== 'undefined' && !!window ? window : undefined;
|
|
32
42
|
};
|
|
33
43
|
var hasAccessToResourceSize = function hasAccessToResourceSize(url, type, entry, hasTimingHeaders) {
|
|
34
|
-
return !
|
|
44
|
+
return !isCacheableType(url, type) || url.includes('localhost') || !!getWindowObject() && url.includes(window.location.hostname) || hasTimingHeaders(url, entry);
|
|
35
45
|
};
|
|
36
46
|
var getReportedInitiatorTypes = function getReportedInitiatorTypes(xhrEnabled) {
|
|
37
47
|
var ufoConfig = getConfigUFO();
|
|
38
48
|
if (!(ufoConfig !== null && ufoConfig !== void 0 && ufoConfig.allowedResources)) {
|
|
39
|
-
if (
|
|
40
|
-
|
|
49
|
+
if (fg('ufo_support_other_resource_type_js')) {
|
|
50
|
+
if (xhrEnabled) {
|
|
51
|
+
return ['script', 'link', 'fetch', 'other', 'xmlhttprequest'];
|
|
52
|
+
}
|
|
53
|
+
return ['script', 'link', 'fetch', 'other'];
|
|
54
|
+
} else {
|
|
55
|
+
if (xhrEnabled) {
|
|
56
|
+
return ['script', 'link', 'fetch', 'xmlhttprequest'];
|
|
57
|
+
}
|
|
58
|
+
return ['script', 'link', 'fetch'];
|
|
41
59
|
}
|
|
42
|
-
return ['script', 'link', 'fetch'];
|
|
43
60
|
}
|
|
44
61
|
return ufoConfig.allowedResources;
|
|
45
62
|
};
|
|
@@ -70,7 +87,7 @@ var getNetworkData = function getNetworkData(item, eventStart) {
|
|
|
70
87
|
return {};
|
|
71
88
|
}
|
|
72
89
|
if (cacheableTypes.includes(initiatorType)) {
|
|
73
|
-
var transferType = calculateTransferType(initiatorType, duration, transferSize);
|
|
90
|
+
var transferType = calculateTransferType(name, initiatorType, duration, transferSize);
|
|
74
91
|
return _objectSpread({
|
|
75
92
|
ttfb: ttfb,
|
|
76
93
|
transferType: transferType,
|
|
@@ -118,6 +135,9 @@ export var getResourceTimings = function getResourceTimings(interactionStart, in
|
|
|
118
135
|
if (initiatorType === 'xmlhttprequest' && (xhrFilter === undefined || xhrFilter(name) === false)) {
|
|
119
136
|
return;
|
|
120
137
|
}
|
|
138
|
+
if (initiatorType === 'other' && !name.includes('.js') && fg('ufo_support_other_resource_type_js')) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
121
141
|
var url = resourceTypes.includes(initiatorType) ? sanitiseEndpoints(name) : mapResources(name);
|
|
122
142
|
if (!url) {
|
|
123
143
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -159,6 +159,9 @@
|
|
|
159
159
|
},
|
|
160
160
|
"ufo_chr_config": {
|
|
161
161
|
"type": "boolean"
|
|
162
|
+
},
|
|
163
|
+
"ufo_support_other_resource_type_js": {
|
|
164
|
+
"type": "boolean"
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
}
|