@atlaskit/react-ufo 4.14.2 → 4.14.4
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 +14 -0
- package/dist/cjs/config/index.js +4 -0
- package/dist/cjs/create-payload/index.js +22 -2
- package/dist/cjs/create-payload/utils/get-vc-metrics.js +10 -6
- package/dist/cjs/interaction-metrics/index.js +2 -1
- package/dist/cjs/segment/segment.js +2 -1
- package/dist/cjs/trace-interaction/internal/trace-ufo-interaction.js +3 -0
- package/dist/cjs/trace-pageload/index.js +3 -0
- package/dist/cjs/trace-transition/index.js +3 -0
- package/dist/cjs/typing-performance-tracing/index.js +5 -0
- package/dist/cjs/vc/index.js +4 -3
- package/dist/cjs/vc/vc-observer-new/index.js +31 -7
- package/dist/cjs/vc/vc-observer-new/metric-calculator/vcnext/index.js +7 -1
- package/dist/cjs/vc/vc-observer-new/raw-data-handler/index.js +237 -0
- package/dist/es2019/config/index.js +3 -0
- package/dist/es2019/create-payload/index.js +17 -1
- package/dist/es2019/create-payload/utils/get-vc-metrics.js +5 -2
- package/dist/es2019/interaction-metrics/index.js +2 -0
- package/dist/es2019/segment/segment.js +2 -0
- package/dist/es2019/trace-interaction/internal/trace-ufo-interaction.js +2 -0
- package/dist/es2019/trace-pageload/index.js +2 -0
- package/dist/es2019/trace-transition/index.js +3 -0
- package/dist/es2019/typing-performance-tracing/index.js +4 -0
- package/dist/es2019/vc/index.js +4 -2
- package/dist/es2019/vc/vc-observer-new/index.js +20 -1
- package/dist/es2019/vc/vc-observer-new/metric-calculator/vcnext/index.js +7 -1
- package/dist/es2019/vc/vc-observer-new/raw-data-handler/index.js +173 -0
- package/dist/esm/config/index.js +3 -0
- package/dist/esm/create-payload/index.js +22 -2
- package/dist/esm/create-payload/utils/get-vc-metrics.js +11 -7
- package/dist/esm/interaction-metrics/index.js +2 -0
- package/dist/esm/segment/segment.js +2 -0
- package/dist/esm/trace-interaction/internal/trace-ufo-interaction.js +2 -0
- package/dist/esm/trace-pageload/index.js +2 -0
- package/dist/esm/trace-transition/index.js +3 -0
- package/dist/esm/typing-performance-tracing/index.js +4 -0
- package/dist/esm/vc/index.js +4 -3
- package/dist/esm/vc/vc-observer-new/index.js +31 -7
- package/dist/esm/vc/vc-observer-new/metric-calculator/vcnext/index.js +7 -1
- package/dist/esm/vc/vc-observer-new/raw-data-handler/index.js +231 -0
- package/dist/types/common/vc/types.d.ts +20 -1
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/vc/types.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/raw-data-handler/index.d.ts +20 -0
- package/dist/types/vc/vc-observer-new/types.d.ts +2 -0
- package/dist/types-ts4.5/common/vc/types.d.ts +25 -1
- package/dist/types-ts4.5/config/index.d.ts +6 -0
- package/dist/types-ts4.5/vc/types.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/raw-data-handler/index.d.ts +20 -0
- package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +2 -0
- package/package.json +7 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
var _getViewportHeight = _interopRequireDefault(require("../metric-calculator/utils/get-viewport-height"));
|
|
15
|
+
var _getViewportWidth = _interopRequireDefault(require("../metric-calculator/utils/get-viewport-width"));
|
|
16
|
+
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; } } }; }
|
|
17
|
+
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; } }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
21
|
+
var ABORTING_WINDOW_EVENT = ['wheel', 'scroll', 'keydown', 'resize'];
|
|
22
|
+
var MAX_OBSERVATIONS = 100;
|
|
23
|
+
var RawDataHandler = exports.default = /*#__PURE__*/function () {
|
|
24
|
+
function RawDataHandler() {
|
|
25
|
+
(0, _classCallCheck2.default)(this, RawDataHandler);
|
|
26
|
+
(0, _defineProperty2.default)(this, "revisionNo", 'raw-handler');
|
|
27
|
+
}
|
|
28
|
+
return (0, _createClass2.default)(RawDataHandler, [{
|
|
29
|
+
key: "getVCCleanStatus",
|
|
30
|
+
value: function getVCCleanStatus(filteredEntries) {
|
|
31
|
+
var dirtyReason = '';
|
|
32
|
+
var abortTimestamp = -1;
|
|
33
|
+
var hasAbortEvent = filteredEntries.some(function (entry) {
|
|
34
|
+
if (entry.data.type === 'window:event') {
|
|
35
|
+
var data = entry.data;
|
|
36
|
+
if (ABORTING_WINDOW_EVENT.includes(data.eventType)) {
|
|
37
|
+
dirtyReason = data.eventType === 'keydown' ? 'keypress' : data.eventType;
|
|
38
|
+
abortTimestamp = Math.round(entry.time);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
});
|
|
44
|
+
if (hasAbortEvent && dirtyReason) {
|
|
45
|
+
return {
|
|
46
|
+
isVCClean: false,
|
|
47
|
+
dirtyReason: dirtyReason,
|
|
48
|
+
abortTimestamp: abortTimestamp
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
isVCClean: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "getRawData",
|
|
57
|
+
value: function () {
|
|
58
|
+
var _getRawData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
59
|
+
var entries, startTime, stopTime, isPageVisible, isVCClean, dirtyReason, getVCCleanStatusResult, viewportEntries, targetNameToIdMap, elementMapEntriesMap, nextElementId, typeMap, typeMapEntriesMap, nextTypeId, attributeMap, attributeEntriesMap, nextAttributeId, rawObservations, firstObservation, lastObservations, referencedEids, referencedChgs, referencedAtts, _iterator, _step, observation, _iterator2, _step2, eid, _iterator3, _step3, chg, _iterator4, _step4, att, result;
|
|
60
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
61
|
+
while (1) switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
entries = _ref.entries, startTime = _ref.startTime, stopTime = _ref.stopTime, isPageVisible = _ref.isPageVisible;
|
|
64
|
+
getVCCleanStatusResult = this.getVCCleanStatus(entries);
|
|
65
|
+
isVCClean = getVCCleanStatusResult.isVCClean;
|
|
66
|
+
dirtyReason = getVCCleanStatusResult.dirtyReason;
|
|
67
|
+
if (isPageVisible) {
|
|
68
|
+
_context.next = 6;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return _context.abrupt("return", {
|
|
72
|
+
revision: this.revisionNo,
|
|
73
|
+
clean: false,
|
|
74
|
+
'metric:vc90': null,
|
|
75
|
+
abortReason: 'browser_backgrounded',
|
|
76
|
+
abortTimestamp: -1,
|
|
77
|
+
viewport: {
|
|
78
|
+
w: (0, _getViewportWidth.default)(),
|
|
79
|
+
h: (0, _getViewportHeight.default)()
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
case 6:
|
|
83
|
+
viewportEntries = entries.filter(function (entry) {
|
|
84
|
+
return entry.time >= startTime && entry.time <= stopTime && entry.data && entry.data.visible;
|
|
85
|
+
});
|
|
86
|
+
targetNameToIdMap = new Map();
|
|
87
|
+
elementMapEntriesMap = {};
|
|
88
|
+
nextElementId = 1;
|
|
89
|
+
typeMap = new Map();
|
|
90
|
+
typeMapEntriesMap = {};
|
|
91
|
+
nextTypeId = 1;
|
|
92
|
+
attributeMap = new Map();
|
|
93
|
+
attributeEntriesMap = {};
|
|
94
|
+
nextAttributeId = 1;
|
|
95
|
+
rawObservations = viewportEntries.map(function (entry) {
|
|
96
|
+
var viewportEntry = entry.data;
|
|
97
|
+
var targetName = viewportEntry.elementName || '';
|
|
98
|
+
var type = viewportEntry.type || '';
|
|
99
|
+
var rect = viewportEntry.rect;
|
|
100
|
+
var attributeName = viewportEntry.attributeName || '';
|
|
101
|
+
var eid = targetNameToIdMap.get(viewportEntry.elementName || '') || 0;
|
|
102
|
+
if (eid === 0) {
|
|
103
|
+
eid = nextElementId;
|
|
104
|
+
nextElementId += 1;
|
|
105
|
+
targetNameToIdMap.set(targetName, eid);
|
|
106
|
+
elementMapEntriesMap[eid] = targetName;
|
|
107
|
+
}
|
|
108
|
+
var chg = typeMap.get(type || '') || 0;
|
|
109
|
+
if (chg === 0) {
|
|
110
|
+
chg = nextTypeId;
|
|
111
|
+
nextTypeId += 1;
|
|
112
|
+
typeMap.set(type, chg);
|
|
113
|
+
typeMapEntriesMap[chg] = type;
|
|
114
|
+
}
|
|
115
|
+
var att = 0;
|
|
116
|
+
if (attributeName) {
|
|
117
|
+
att = attributeMap.get(attributeName) || 0;
|
|
118
|
+
if (att === 0) {
|
|
119
|
+
att = nextAttributeId;
|
|
120
|
+
nextAttributeId += 1;
|
|
121
|
+
attributeMap.set(attributeName, att);
|
|
122
|
+
attributeEntriesMap[att] = attributeName;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
var observation = _objectSpread({
|
|
126
|
+
t: Math.round(entry.time),
|
|
127
|
+
r: [Math.round(rect.left * 10) / 10, Math.round(rect.top * 10) / 10, Math.round(rect.right * 10) / 10, Math.round(rect.bottom * 10) / 10],
|
|
128
|
+
chg: chg,
|
|
129
|
+
eid: eid || 0
|
|
130
|
+
}, att > 0 ? {
|
|
131
|
+
att: att
|
|
132
|
+
} : {});
|
|
133
|
+
return observation;
|
|
134
|
+
}); // If the number of observations is greater than the maximum allowed, we need to trim the observations to the maximum allowed.
|
|
135
|
+
// We do this by keeping the first observation and the last MAX_OBSERVATIONS observations.
|
|
136
|
+
// We then collect the referenced IDs from the remaining observations and remove the unreferenced entries from the maps
|
|
137
|
+
if (rawObservations.length > MAX_OBSERVATIONS) {
|
|
138
|
+
firstObservation = rawObservations[0];
|
|
139
|
+
lastObservations = rawObservations.slice(-MAX_OBSERVATIONS);
|
|
140
|
+
rawObservations = [firstObservation].concat((0, _toConsumableArray2.default)(lastObservations));
|
|
141
|
+
|
|
142
|
+
// Collect referenced IDs from remaining observations
|
|
143
|
+
referencedEids = new Set();
|
|
144
|
+
referencedChgs = new Set();
|
|
145
|
+
referencedAtts = new Set();
|
|
146
|
+
_iterator = _createForOfIteratorHelper(rawObservations);
|
|
147
|
+
try {
|
|
148
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
149
|
+
observation = _step.value;
|
|
150
|
+
if (observation.eid > 0) {
|
|
151
|
+
referencedEids.add(observation.eid);
|
|
152
|
+
}
|
|
153
|
+
if (typeof observation.chg === 'number' && observation.chg > 0) {
|
|
154
|
+
referencedChgs.add(observation.chg);
|
|
155
|
+
}
|
|
156
|
+
if (observation.att !== undefined && observation.att > 0) {
|
|
157
|
+
referencedAtts.add(observation.att);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Remove unreferenced entries from maps
|
|
162
|
+
} catch (err) {
|
|
163
|
+
_iterator.e(err);
|
|
164
|
+
} finally {
|
|
165
|
+
_iterator.f();
|
|
166
|
+
}
|
|
167
|
+
_iterator2 = _createForOfIteratorHelper(Object.keys(elementMapEntriesMap).map(Number));
|
|
168
|
+
try {
|
|
169
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
170
|
+
eid = _step2.value;
|
|
171
|
+
if (!referencedEids.has(eid)) {
|
|
172
|
+
delete elementMapEntriesMap[eid];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} catch (err) {
|
|
176
|
+
_iterator2.e(err);
|
|
177
|
+
} finally {
|
|
178
|
+
_iterator2.f();
|
|
179
|
+
}
|
|
180
|
+
_iterator3 = _createForOfIteratorHelper(Object.keys(typeMapEntriesMap).map(Number));
|
|
181
|
+
try {
|
|
182
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
183
|
+
chg = _step3.value;
|
|
184
|
+
if (!referencedChgs.has(chg)) {
|
|
185
|
+
delete typeMapEntriesMap[chg];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} catch (err) {
|
|
189
|
+
_iterator3.e(err);
|
|
190
|
+
} finally {
|
|
191
|
+
_iterator3.f();
|
|
192
|
+
}
|
|
193
|
+
_iterator4 = _createForOfIteratorHelper(Object.keys(attributeEntriesMap).map(Number));
|
|
194
|
+
try {
|
|
195
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
196
|
+
att = _step4.value;
|
|
197
|
+
if (!referencedAtts.has(att)) {
|
|
198
|
+
delete attributeEntriesMap[att];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} catch (err) {
|
|
202
|
+
_iterator4.e(err);
|
|
203
|
+
} finally {
|
|
204
|
+
_iterator4.f();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
result = {
|
|
208
|
+
revision: this.revisionNo,
|
|
209
|
+
clean: isVCClean,
|
|
210
|
+
'metric:vc90': null,
|
|
211
|
+
rawData: {
|
|
212
|
+
obs: rawObservations !== null && rawObservations !== void 0 ? rawObservations : undefined,
|
|
213
|
+
eid: elementMapEntriesMap !== null && elementMapEntriesMap !== void 0 ? elementMapEntriesMap : undefined,
|
|
214
|
+
chg: typeMapEntriesMap !== null && typeMapEntriesMap !== void 0 ? typeMapEntriesMap : undefined,
|
|
215
|
+
att: attributeEntriesMap !== null && attributeEntriesMap !== void 0 ? attributeEntriesMap : undefined
|
|
216
|
+
},
|
|
217
|
+
abortReason: dirtyReason,
|
|
218
|
+
abortTimestamp: getVCCleanStatusResult.abortTimestamp,
|
|
219
|
+
viewport: {
|
|
220
|
+
w: (0, _getViewportWidth.default)(),
|
|
221
|
+
h: (0, _getViewportHeight.default)()
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
return _context.abrupt("return", result);
|
|
225
|
+
case 20:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context.stop();
|
|
228
|
+
}
|
|
229
|
+
}, _callee, this);
|
|
230
|
+
}));
|
|
231
|
+
function getRawData(_x) {
|
|
232
|
+
return _getRawData.apply(this, arguments);
|
|
233
|
+
}
|
|
234
|
+
return getRawData;
|
|
235
|
+
}()
|
|
236
|
+
}]);
|
|
237
|
+
}();
|
|
@@ -170,6 +170,9 @@ export function getExperimentalInteractionRate(name, interactionType) {
|
|
|
170
170
|
return 0;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
+
export function getVCRawDataInteractionRate(name, interactionType) {
|
|
174
|
+
return getConfigRate(name, interactionType, 'enableVCRawDataRates');
|
|
175
|
+
}
|
|
173
176
|
export function getPostInteractionRate(name, interactionType) {
|
|
174
177
|
return getConfigRate(name, interactionType, 'postInteractionLog');
|
|
175
178
|
}
|
|
@@ -43,6 +43,7 @@ import { optimizeMarks } from './utils/optimize-marks';
|
|
|
43
43
|
import { optimizeReactProfilerTimings } from './utils/optimize-react-profiler-timings';
|
|
44
44
|
import { optimizeRequestInfo } from './utils/optimize-request-info';
|
|
45
45
|
import { optimizeSpans } from './utils/optimize-spans';
|
|
46
|
+
const MAX_PAYLOAD_SIZE = 250;
|
|
46
47
|
function getUfoNameOverride(interaction) {
|
|
47
48
|
const {
|
|
48
49
|
ufoName,
|
|
@@ -605,7 +606,22 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
605
606
|
regularTTAI = undefined;
|
|
606
607
|
expTTAI = undefined;
|
|
607
608
|
}
|
|
608
|
-
|
|
609
|
+
if (fg('platform_ufo_enable_vc_raw_data')) {
|
|
610
|
+
const size = getPayloadSize(payload.attributes.properties);
|
|
611
|
+
const vcRev = payload.attributes.properties['ufo:vc:rev'];
|
|
612
|
+
const rawData = vcRev.find(item => item.revision === 'raw-handler');
|
|
613
|
+
if (rawData) {
|
|
614
|
+
const rawDataSize = getPayloadSize(rawData);
|
|
615
|
+
payload.attributes.properties['ufo:vc:raw:size'] = rawDataSize;
|
|
616
|
+
if (size > MAX_PAYLOAD_SIZE && Array.isArray(vcRev) && vcRev.length > 0) {
|
|
617
|
+
payload.attributes.properties['ufo:vc:rev'] = vcRev.filter(item => item.revision !== 'raw-handler');
|
|
618
|
+
payload.attributes.properties['ufo:vc:raw:removed'] = true;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
622
|
+
} else {
|
|
623
|
+
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
624
|
+
}
|
|
609
625
|
return payload;
|
|
610
626
|
}
|
|
611
627
|
export async function createPayloads(interactionId, interaction) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import coinflip from '../../coinflip';
|
|
2
|
+
import { getConfig, getMostRecentVCRevision, getVCRawDataInteractionRate } from '../../config';
|
|
2
3
|
import { interactionExtraMetrics, postInteractionLog } from '../../interaction-metrics';
|
|
3
4
|
import getInteractionStatus from './get-interaction-status';
|
|
4
5
|
import getPageVisibilityUpToTTAI from './get-page-visibility-up-to-ttai';
|
|
@@ -22,6 +23,7 @@ async function getVCMetrics(interaction, include3p = false, excludeSmartAnswersI
|
|
|
22
23
|
if (!observer) {
|
|
23
24
|
return {};
|
|
24
25
|
}
|
|
26
|
+
const includeRawData = coinflip(getVCRawDataInteractionRate(interaction.ufoName, interaction.type));
|
|
25
27
|
const isSSREnabled = interaction.type === 'page_load' && ((config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 ? void 0 : (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName)));
|
|
26
28
|
const ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
27
29
|
ssr: getSSRDoneTimeValue(config)
|
|
@@ -44,7 +46,8 @@ async function getVCMetrics(interaction, include3p = false, excludeSmartAnswersI
|
|
|
44
46
|
include3p,
|
|
45
47
|
excludeSmartAnswersInSearch,
|
|
46
48
|
interactionType: interaction.type,
|
|
47
|
-
isPageVisible
|
|
49
|
+
isPageVisible,
|
|
50
|
+
includeRawData
|
|
48
51
|
});
|
|
49
52
|
observer.stop(interaction.ufoName);
|
|
50
53
|
if (!include3p) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
1
2
|
import { v4 as createUUID } from 'uuid';
|
|
2
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import coinflip from '../coinflip';
|
|
@@ -297,6 +298,7 @@ function removeHoldCriterion(id) {
|
|
|
297
298
|
}
|
|
298
299
|
export function addHold(interactionId, labelStack, name, experimental) {
|
|
299
300
|
const interaction = interactions.get(interactionId);
|
|
301
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
300
302
|
const id = createUUID();
|
|
301
303
|
if (!interaction && fg('platform_ufo_enable_late_holds_post_interaction')) {
|
|
302
304
|
// add hold timestamp to post interaction log if interaction is complete
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Profiler, useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { unstable_NormalPriority as NormalPriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
3
4
|
import { v4 as createUUID } from 'uuid';
|
|
4
5
|
import coinflip from '../coinflip';
|
|
5
6
|
import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions } from '../config';
|
|
@@ -156,6 +157,7 @@ export default function UFOSegment({
|
|
|
156
157
|
const rate = getInteractionRate(name, 'press');
|
|
157
158
|
if (coinflip(rate)) {
|
|
158
159
|
const startTimestamp = timestamp !== null && timestamp !== void 0 ? timestamp : performance.now();
|
|
160
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
159
161
|
const newId = createUUID();
|
|
160
162
|
interactionId.current = newId;
|
|
161
163
|
// covered experiences with tracing instrumentation:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
1
2
|
import { v4 as createUUID } from 'uuid';
|
|
2
3
|
import coinflip from '../../coinflip';
|
|
3
4
|
import { getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions } from '../../config';
|
|
@@ -23,6 +24,7 @@ function traceUFOInteraction(name, interactionType, startTime) {
|
|
|
23
24
|
}
|
|
24
25
|
if (coinflip(rate)) {
|
|
25
26
|
const startTimestamp = startTime !== null && startTime !== void 0 ? startTime : performance.now();
|
|
27
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
26
28
|
const newId = createUUID();
|
|
27
29
|
DefaultInteractionID.current = newId;
|
|
28
30
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
1
2
|
import { v4 as createUUID } from 'uuid';
|
|
2
3
|
import coinflip from '../coinflip';
|
|
3
4
|
import { getInteractionRate } from '../config';
|
|
@@ -15,6 +16,7 @@ function traceUFOPageLoad(ufoName, routeName = ufoName) {
|
|
|
15
16
|
const rate = ufoName ? getInteractionRate(ufoName, 'page_load') : 1;
|
|
16
17
|
const enabledBySamplingRate = coinflip(rate);
|
|
17
18
|
if (enabledBySamplingRate && !activeInteraction) {
|
|
19
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
18
20
|
const newId = createUUID();
|
|
19
21
|
DefaultInteractionID.current = newId;
|
|
20
22
|
addNewInteraction(newId, ufoName || '', 'page_load', 0, rate, null, routeName, getActiveTrace());
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
4
|
import { v4 as createUUID } from 'uuid';
|
|
3
5
|
import coinflip from '../coinflip';
|
|
4
6
|
import { getDoNotAbortActivePressInteractionOnTransition, getInteractionRate } from '../config';
|
|
@@ -20,6 +22,7 @@ function traceUFOTransition(ufoName, routeName = ufoName) {
|
|
|
20
22
|
UFORouteName.current = ufoName;
|
|
21
23
|
const rate = getInteractionRate(ufoName, 'transition');
|
|
22
24
|
if (coinflip(rate)) {
|
|
25
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
23
26
|
const newId = createUUID();
|
|
24
27
|
setInteractionActiveTrace(newId);
|
|
25
28
|
DefaultInteractionID.current = newId;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
3
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
3
4
|
import { v4 as createUUID } from 'uuid';
|
|
4
5
|
import coinflip from '../coinflip';
|
|
5
6
|
import { getInteractionRate, getTypingPerformanceTracingMethod } from '../config';
|
|
@@ -42,6 +43,7 @@ function typingPerformanceTracingTimeout(element, name, rate) {
|
|
|
42
43
|
let isInteractionInitialised = false;
|
|
43
44
|
let id;
|
|
44
45
|
const start = () => {
|
|
46
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
45
47
|
id = createUUID();
|
|
46
48
|
addNewInteraction(id, name, 'typing', performance.now(), rate, null, null);
|
|
47
49
|
isInteractionInitialised = true;
|
|
@@ -95,6 +97,7 @@ function typingPerformanceTracingTimeoutNoAlloc(element, name, rate) {
|
|
|
95
97
|
count = 0;
|
|
96
98
|
};
|
|
97
99
|
const start = () => {
|
|
100
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
98
101
|
id = createUUID();
|
|
99
102
|
addNewInteraction(id, name, 'typing', performance.now(), rate, null, null);
|
|
100
103
|
isInteractionInitialised = true;
|
|
@@ -164,6 +167,7 @@ function typingPerformanceTracingMutationObserver(element, name, rate) {
|
|
|
164
167
|
eventTime = -1;
|
|
165
168
|
};
|
|
166
169
|
const start = () => {
|
|
170
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
167
171
|
id = createUUID();
|
|
168
172
|
addNewInteraction(id, name, 'typing', performance.now(), rate, null, null);
|
|
169
173
|
isInteractionInitialised = true;
|
package/dist/es2019/vc/index.js
CHANGED
|
@@ -97,7 +97,8 @@ export class VCObserverWrapper {
|
|
|
97
97
|
experienceKey,
|
|
98
98
|
include3p,
|
|
99
99
|
excludeSmartAnswersInSearch,
|
|
100
|
-
includeSSRRatio
|
|
100
|
+
includeSSRRatio,
|
|
101
|
+
includeRawData
|
|
101
102
|
} = param;
|
|
102
103
|
const v1v2Result = isVCRevisionEnabled('fy25.01', experienceKey) || isVCRevisionEnabled('fy25.02', experienceKey) ? await ((_this$oldVCObserver4 = this.oldVCObserver) === null || _this$oldVCObserver4 === void 0 ? void 0 : _this$oldVCObserver4.getVCResult(param)) : {};
|
|
103
104
|
const v3Result = isVCRevisionEnabled('fy25.03', experienceKey) ? await ((_this$newVCObserver3 = this.newVCObserver) === null || _this$newVCObserver3 === void 0 ? void 0 : _this$newVCObserver3.getVCResult({
|
|
@@ -110,7 +111,8 @@ export class VCObserverWrapper {
|
|
|
110
111
|
includeSSRRatio,
|
|
111
112
|
interactionType: param.interactionType,
|
|
112
113
|
isPageVisible: param.isPageVisible,
|
|
113
|
-
interactionAbortReason: param.interactionAbortReason
|
|
114
|
+
interactionAbortReason: param.interactionAbortReason,
|
|
115
|
+
includeRawData
|
|
114
116
|
})) : [];
|
|
115
117
|
if (!v3Result) {
|
|
116
118
|
return v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {};
|
|
@@ -7,6 +7,7 @@ import VCCalculator_FY25_03 from './metric-calculator/fy25_03';
|
|
|
7
7
|
import getViewportHeight from './metric-calculator/utils/get-viewport-height';
|
|
8
8
|
import getViewportWidth from './metric-calculator/utils/get-viewport-width';
|
|
9
9
|
import VCNextCalculator from './metric-calculator/vcnext';
|
|
10
|
+
import RawDataHandler from './raw-data-handler';
|
|
10
11
|
import ViewportObserver from './viewport-observer';
|
|
11
12
|
import WindowEventObserver from './window-event-observer';
|
|
12
13
|
const SSRState = {
|
|
@@ -201,10 +202,12 @@ export default class VCObserverNew {
|
|
|
201
202
|
isPageVisible,
|
|
202
203
|
include3p,
|
|
203
204
|
includeSSRRatio,
|
|
204
|
-
excludeSmartAnswersInSearch
|
|
205
|
+
excludeSmartAnswersInSearch,
|
|
206
|
+
includeRawData
|
|
205
207
|
} = param;
|
|
206
208
|
const results = [];
|
|
207
209
|
this.addStartEntry(start);
|
|
210
|
+
const feVCCalculationStartTime = performance.now();
|
|
208
211
|
const calculator_fy25_03 = new VCCalculator_FY25_03();
|
|
209
212
|
if (param.ssr) {
|
|
210
213
|
this.addSSR(param.ssr);
|
|
@@ -247,6 +250,22 @@ export default class VCObserverNew {
|
|
|
247
250
|
if (vcNext) {
|
|
248
251
|
results.push(vcNext);
|
|
249
252
|
}
|
|
253
|
+
const feVCCalculationEndTime = performance.now();
|
|
254
|
+
if (includeRawData && fg('platform_ufo_enable_vc_raw_data')) {
|
|
255
|
+
const rawVCCalculationStartTime = performance.now();
|
|
256
|
+
const rawHandler = new RawDataHandler();
|
|
257
|
+
const raw = await rawHandler.getRawData({
|
|
258
|
+
entries: orderedEntries,
|
|
259
|
+
startTime: start,
|
|
260
|
+
stopTime: stop,
|
|
261
|
+
isPageVisible
|
|
262
|
+
});
|
|
263
|
+
if (raw) {
|
|
264
|
+
raw.rawVCTime = Number((performance.now() - rawVCCalculationStartTime).toFixed(2));
|
|
265
|
+
raw.feVCTime = Number((feVCCalculationEndTime - feVCCalculationStartTime).toFixed(2));
|
|
266
|
+
results.push(raw);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
250
269
|
return results;
|
|
251
270
|
}
|
|
252
271
|
addStartEntry(startTime) {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import VCCalculator_FY25_03 from '../fy25_03';
|
|
2
3
|
|
|
3
4
|
// NOTE: `next` to be renamed `fy26.04` once stable
|
|
4
5
|
const REVISION_NO = 'next';
|
|
5
6
|
const getConsideredEntryTypes = () => {
|
|
7
|
+
const consideredEntryTypes = ['mutation:display-contents-children-element'];
|
|
8
|
+
if (fg('platform_ufo_remove_ssr_placeholder_in_ttvc_v4')) {
|
|
9
|
+
consideredEntryTypes.push('mutation:ssr-placeholder');
|
|
10
|
+
}
|
|
6
11
|
return ['mutation:display-contents-children-element'];
|
|
7
12
|
};
|
|
8
13
|
const getExcludedEntryTypes = () => {
|
|
9
|
-
|
|
14
|
+
const excludedEntryTypes = ['layout-shift:same-rect'];
|
|
15
|
+
return excludedEntryTypes;
|
|
10
16
|
};
|
|
11
17
|
|
|
12
18
|
// NOTE: `VCNext` to be renamed `FY26_04` once stable
|