@atlaskit/react-ufo 3.10.2 → 3.10.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 +16 -0
- package/dist/cjs/create-payload/utils/get-react-ufo-payload-version.js +4 -1
- package/dist/cjs/create-post-interaction-log-payload/get-late-mutations.js +46 -0
- package/dist/cjs/create-post-interaction-log-payload/index.js +64 -29
- package/dist/cjs/create-post-interaction-log-payload/types.js +1 -0
- package/dist/cjs/vc/vc-observer/heatmap/heatmap.js +2 -2
- package/dist/cjs/vc/vc-observer-new/entries-timeline/index.js +1 -3
- package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +2 -2
- package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +25 -7
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +136 -115
- package/dist/es2019/create-payload/utils/get-react-ufo-payload-version.js +4 -1
- package/dist/es2019/create-post-interaction-log-payload/get-late-mutations.js +28 -0
- package/dist/es2019/create-post-interaction-log-payload/index.js +57 -24
- package/dist/es2019/create-post-interaction-log-payload/types.js +0 -0
- package/dist/es2019/vc/vc-observer/heatmap/heatmap.js +2 -2
- package/dist/es2019/vc/vc-observer-new/entries-timeline/index.js +1 -3
- package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +2 -2
- package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +23 -7
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +122 -103
- package/dist/esm/create-payload/utils/get-react-ufo-payload-version.js +4 -1
- package/dist/esm/create-post-interaction-log-payload/get-late-mutations.js +40 -0
- package/dist/esm/create-post-interaction-log-payload/index.js +64 -29
- package/dist/esm/create-post-interaction-log-payload/types.js +0 -0
- package/dist/esm/vc/vc-observer/heatmap/heatmap.js +2 -2
- package/dist/esm/vc/vc-observer-new/entries-timeline/index.js +1 -3
- package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +2 -2
- package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +25 -7
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +136 -115
- package/dist/types/create-payload/utils/get-react-ufo-payload-version.d.ts +1 -1
- package/dist/types/create-post-interaction-log-payload/get-late-mutations.d.ts +5 -0
- package/dist/types/create-post-interaction-log-payload/index.d.ts +2 -5
- package/dist/types/create-post-interaction-log-payload/types.d.ts +5 -0
- package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +8 -3
- package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +8 -1
- package/dist/types-ts4.5/create-payload/utils/get-react-ufo-payload-version.d.ts +1 -1
- package/dist/types-ts4.5/create-post-interaction-log-payload/get-late-mutations.d.ts +5 -0
- package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +2 -5
- package/dist/types-ts4.5/create-post-interaction-log-payload/types.d.ts +5 -0
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +8 -3
- package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +8 -1
- package/package.json +7 -1
|
@@ -2,11 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
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
4
|
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; }
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import coinflip from '../coinflip';
|
|
6
7
|
import { getConfig, getPostInteractionRate } from '../config';
|
|
7
8
|
import { isSegmentLabel, sanitizeUfoName } from '../create-payload/common/utils';
|
|
8
9
|
import { getReactUFOPayloadVersion } from '../create-payload/utils/get-react-ufo-payload-version';
|
|
9
10
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
11
|
+
import getLateMutations from './get-late-mutations';
|
|
10
12
|
function getParentStack(labelStack) {
|
|
11
13
|
if (!labelStack || labelStack.length <= 1) {
|
|
12
14
|
return null;
|
|
@@ -134,39 +136,72 @@ function createPostInteractionLogPayload(_ref2) {
|
|
|
134
136
|
var lastInteractionFinishTTAI = Math.round(lastInteractionFinish.end - lastInteractionFinish.start);
|
|
135
137
|
var lastInteractionFinishVC90 = null;
|
|
136
138
|
var lastInteractionFinishVCClean = false;
|
|
137
|
-
if (
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
if (fg('platform_ufo_post_interaction_use_vc_rev')) {
|
|
140
|
+
var lastInteractionFinishVCRev = lastInteractionFinishVCResult === null || lastInteractionFinishVCResult === void 0 ? void 0 : lastInteractionFinishVCResult['ufo:vc:rev'];
|
|
141
|
+
var lastInteractionFinishRevision = lastInteractionFinishVCRev === null || lastInteractionFinishVCRev === void 0 ? void 0 : lastInteractionFinishVCRev.find(function (_ref3) {
|
|
142
|
+
var revision = _ref3.revision;
|
|
143
|
+
return revision === 'fy25.02';
|
|
144
|
+
});
|
|
145
|
+
if (lastInteractionFinishRevision !== null && lastInteractionFinishRevision !== void 0 && lastInteractionFinishRevision.clean) {
|
|
146
|
+
var _lastInteractionFinis;
|
|
147
|
+
lastInteractionFinishVCClean = true;
|
|
148
|
+
lastInteractionFinishVC90 = (_lastInteractionFinis = lastInteractionFinishRevision['metric:vc90']) !== null && _lastInteractionFinis !== void 0 ? _lastInteractionFinis : null;
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
if (lastInteractionFinishVCResult !== null && lastInteractionFinishVCResult !== void 0 && lastInteractionFinishVCResult['ufo:vc:state']) {
|
|
152
|
+
var _lastInteractionFinis2;
|
|
153
|
+
lastInteractionFinishVCClean = true;
|
|
154
|
+
var lastInteractionFinishVCMetrics = lastInteractionFinishVCResult === null || lastInteractionFinishVCResult === void 0 ? void 0 : lastInteractionFinishVCResult['metrics:vc'];
|
|
155
|
+
lastInteractionFinishVC90 = (_lastInteractionFinis2 = lastInteractionFinishVCMetrics[90]) !== null && _lastInteractionFinis2 !== void 0 ? _lastInteractionFinis2 : null;
|
|
156
|
+
}
|
|
142
157
|
}
|
|
143
158
|
var postInteractionFinishVCRatios = {};
|
|
144
|
-
var revisedVC90 = null;
|
|
145
|
-
var postInteractionFinishVCUpdates = [];
|
|
146
159
|
var postInteractionFinishVCClean = false;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
var revisedVC90 = null;
|
|
161
|
+
var lateMutations = [];
|
|
162
|
+
if (fg('platform_ufo_post_interaction_use_vc_rev')) {
|
|
163
|
+
var postInteractionFinishVCRev = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:rev'];
|
|
164
|
+
var postInteractionFinishRevision = postInteractionFinishVCRev === null || postInteractionFinishVCRev === void 0 ? void 0 : postInteractionFinishVCRev.find(function (_ref4) {
|
|
165
|
+
var revision = _ref4.revision;
|
|
166
|
+
return revision === 'fy25.02';
|
|
167
|
+
});
|
|
168
|
+
if (postInteractionFinishRevision !== null && postInteractionFinishRevision !== void 0 && postInteractionFinishRevision.clean) {
|
|
169
|
+
postInteractionFinishVCClean = true;
|
|
170
|
+
postInteractionFinishVCRatios = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:ratios'];
|
|
171
|
+
if (typeof lastInteractionFinishVC90 === 'number') {
|
|
172
|
+
var _postInteractionFinis;
|
|
173
|
+
revisedVC90 = (_postInteractionFinis = postInteractionFinishRevision['metric:vc90']) !== null && _postInteractionFinis !== void 0 ? _postInteractionFinis : null;
|
|
174
|
+
}
|
|
175
|
+
var vcDetails = postInteractionFinishRevision.vcDetails;
|
|
176
|
+
if (vcDetails) {
|
|
177
|
+
lateMutations = getLateMutations(vcDetails, lastInteractionFinish, postInteractionFinishVCRatios);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
if (postInteractionFinishVCResult !== null && postInteractionFinishVCResult !== void 0 && postInteractionFinishVCResult['ufo:vc:state']) {
|
|
182
|
+
postInteractionFinishVCClean = true;
|
|
183
|
+
postInteractionFinishVCRatios = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:ratios'];
|
|
184
|
+
var postInteractionFinishVCUpdates = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:updates'];
|
|
185
|
+
var postInteractionFinishVCMetrics = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['metrics:vc'];
|
|
186
|
+
if (typeof lastInteractionFinishVC90 === 'number') {
|
|
187
|
+
var _postInteractionFinis2;
|
|
188
|
+
revisedVC90 = (_postInteractionFinis2 = postInteractionFinishVCMetrics[90]) !== null && _postInteractionFinis2 !== void 0 ? _postInteractionFinis2 : null;
|
|
189
|
+
}
|
|
190
|
+
lateMutations = postInteractionFinishVCUpdates ? postInteractionFinishVCUpdates.filter(function (entry) {
|
|
191
|
+
return entry.time > lastInteractionFinish.end;
|
|
192
|
+
}).flatMap(function (_ref5) {
|
|
193
|
+
var time = _ref5.time,
|
|
194
|
+
elements = _ref5.elements;
|
|
195
|
+
return Array.from(new Set(elements)).map(function (element) {
|
|
196
|
+
return {
|
|
197
|
+
time: time,
|
|
198
|
+
element: element,
|
|
199
|
+
viewportHeatmapPercentage: postInteractionFinishVCRatios[element]
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}) : [];
|
|
155
203
|
}
|
|
156
204
|
}
|
|
157
|
-
var lateMutations = postInteractionFinishVCUpdates ? postInteractionFinishVCUpdates.filter(function (entry) {
|
|
158
|
-
return entry.time > lastInteractionFinish.end;
|
|
159
|
-
}).flatMap(function (_ref3) {
|
|
160
|
-
var time = _ref3.time,
|
|
161
|
-
elements = _ref3.elements;
|
|
162
|
-
return Array.from(new Set(elements)).map(function (element) {
|
|
163
|
-
return {
|
|
164
|
-
time: time,
|
|
165
|
-
element: element,
|
|
166
|
-
viewportHeatmapPercentage: postInteractionFinishVCRatios[element]
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
}) : [];
|
|
170
205
|
return {
|
|
171
206
|
actionSubject: 'experience',
|
|
172
207
|
action: 'measured',
|
|
@@ -181,7 +216,7 @@ function createPostInteractionLogPayload(_ref2) {
|
|
|
181
216
|
'event:schema': '1.0.0',
|
|
182
217
|
'event:source': {
|
|
183
218
|
name: 'react-ufo/web',
|
|
184
|
-
version: getReactUFOPayloadVersion(lastInteractionFinish.type)
|
|
219
|
+
version: getReactUFOPayloadVersion(lastInteractionFinish.type, true) // always 1.0.1 as `reactProfileTimings` has `labelStack` as an array
|
|
185
220
|
},
|
|
186
221
|
'event:region': config.region || 'unknown',
|
|
187
222
|
'experience:key': 'custom.post-interaction-logs',
|
|
File without changes
|
|
@@ -120,9 +120,9 @@ export var MultiRevisionHeatmap = /*#__PURE__*/function () {
|
|
|
120
120
|
});
|
|
121
121
|
return {
|
|
122
122
|
revision: rev.name,
|
|
123
|
-
vcDetails: vcDetails,
|
|
124
123
|
clean: args.clean,
|
|
125
|
-
'metric:vc90': args.clean && !args.isEventAborted && pageVisibilityUpToTTAI === 'visible' ? vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t : null
|
|
124
|
+
'metric:vc90': args.clean && !args.isEventAborted && pageVisibilityUpToTTAI === 'visible' ? vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t : null,
|
|
125
|
+
vcDetails: vcDetails
|
|
126
126
|
};
|
|
127
127
|
});
|
|
128
128
|
return payload;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
3
|
var EntriesTimeline = /*#__PURE__*/function () {
|
|
5
4
|
function EntriesTimeline() {
|
|
6
5
|
_classCallCheck(this, EntriesTimeline);
|
|
7
|
-
_defineProperty(this, "unorderedEntries", []);
|
|
8
|
-
_defineProperty(this, "sortedEntriesCache", new Map());
|
|
9
6
|
this.unorderedEntries = [];
|
|
7
|
+
this.sortedEntriesCache = new Map();
|
|
10
8
|
}
|
|
11
9
|
return _createClass(EntriesTimeline, [{
|
|
12
10
|
key: "push",
|
|
@@ -71,9 +71,9 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
71
71
|
vcDetails = _context.sent;
|
|
72
72
|
return _context.abrupt("return", {
|
|
73
73
|
revision: this.revisionNo,
|
|
74
|
-
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined,
|
|
75
74
|
clean: true,
|
|
76
|
-
'metric:vc90': (_vcDetails$90$t = vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t) !== null && _vcDetails$90$t !== void 0 ? _vcDetails$90$t : null
|
|
75
|
+
'metric:vc90': (_vcDetails$90$t = vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t) !== null && _vcDetails$90$t !== void 0 ? _vcDetails$90$t : null,
|
|
76
|
+
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
|
|
77
77
|
});
|
|
78
78
|
case 15:
|
|
79
79
|
case "end":
|
package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js
CHANGED
|
@@ -2,17 +2,18 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import taskYield from '../../utils/task-yield';
|
|
6
7
|
|
|
7
8
|
// 24-bit color value
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Class responsible for managing a scaled canvas and tracking pixel drawing operations.
|
|
11
|
-
* It uses an OffscreenCanvas
|
|
12
|
-
* colors and timestamps for pixel counting purposes.
|
|
12
|
+
* It uses either an OffscreenCanvas (if available) or a regular HTML Canvas for better performance
|
|
13
|
+
* and maintains a mapping between colors and timestamps for pixel counting purposes.
|
|
13
14
|
*/
|
|
14
15
|
export var ViewportCanvas = /*#__PURE__*/function () {
|
|
15
|
-
/** The underlying
|
|
16
|
+
/** The underlying Canvas instance (either OffscreenCanvas or HTMLCanvasElement) */
|
|
16
17
|
|
|
17
18
|
/** The 2D rendering context of the canvas */
|
|
18
19
|
|
|
@@ -43,10 +44,8 @@ export var ViewportCanvas = /*#__PURE__*/function () {
|
|
|
43
44
|
this.scaleX = this.scaledWidth / safeViewportWidth;
|
|
44
45
|
this.scaleY = this.scaledHeight / safeViewportHeight;
|
|
45
46
|
|
|
46
|
-
// Initialize
|
|
47
|
-
this.canvas =
|
|
48
|
-
this.canvas.width = this.scaledWidth;
|
|
49
|
-
this.canvas.height = this.scaledHeight;
|
|
47
|
+
// Initialize canvas with scaled dimensions
|
|
48
|
+
this.canvas = this.createCanvas(this.scaledWidth, this.scaledHeight);
|
|
50
49
|
var ctx = this.canvas.getContext('2d', {
|
|
51
50
|
alpha: false,
|
|
52
51
|
// Disable alpha channel for better performance
|
|
@@ -59,9 +58,28 @@ export var ViewportCanvas = /*#__PURE__*/function () {
|
|
|
59
58
|
}
|
|
60
59
|
this.ctx = ctx;
|
|
61
60
|
this.ctx.globalCompositeOperation = 'source-over';
|
|
61
|
+
if (fg('platform_ufo_use_offscreen_canvas')) {
|
|
62
|
+
this.ctx.imageSmoothingEnabled = false; // Disable image smoothing for better performance
|
|
63
|
+
}
|
|
62
64
|
this.clear();
|
|
63
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a canvas instance, falling back to HTMLCanvasElement if OffscreenCanvas is not available
|
|
69
|
+
* or if the feature flag is disabled
|
|
70
|
+
*/
|
|
64
71
|
return _createClass(ViewportCanvas, [{
|
|
72
|
+
key: "createCanvas",
|
|
73
|
+
value: function createCanvas(width, height) {
|
|
74
|
+
if (typeof OffscreenCanvas !== 'undefined' && fg('platform_ufo_use_offscreen_canvas')) {
|
|
75
|
+
return new OffscreenCanvas(width, height);
|
|
76
|
+
}
|
|
77
|
+
var canvas = document.createElement('canvas');
|
|
78
|
+
canvas.width = width;
|
|
79
|
+
canvas.height = height;
|
|
80
|
+
return canvas;
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
65
83
|
key: "getScaledDimensions",
|
|
66
84
|
value: function getScaledDimensions() {
|
|
67
85
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
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; } } }; }
|
|
4
5
|
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; } }
|
|
5
6
|
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; }
|
|
@@ -54,139 +55,154 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
54
55
|
var _this = this;
|
|
55
56
|
var onChange = _ref2.onChange;
|
|
56
57
|
_classCallCheck(this, ViewportObserver);
|
|
57
|
-
this
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!target) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
var visible = isElementVisible(target);
|
|
69
|
-
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
70
|
-
_this.mapVisibleNodeRects.set(target, rect);
|
|
71
|
-
onChange({
|
|
72
|
-
time: time,
|
|
73
|
-
type: type,
|
|
74
|
-
elementRef: new WeakRef(target),
|
|
75
|
-
visible: visible,
|
|
76
|
-
rect: rect,
|
|
77
|
-
previousRect: lastElementRect,
|
|
78
|
-
mutationData: mutationData
|
|
79
|
-
});
|
|
58
|
+
_defineProperty(this, "handleIntersectionEntry", function (_ref3) {
|
|
59
|
+
var target = _ref3.target,
|
|
60
|
+
rect = _ref3.rect,
|
|
61
|
+
time = _ref3.time,
|
|
62
|
+
type = _ref3.type,
|
|
63
|
+
mutationData = _ref3.mutationData;
|
|
64
|
+
if (!target) {
|
|
65
|
+
return;
|
|
80
66
|
}
|
|
67
|
+
var visible = isElementVisible(target);
|
|
68
|
+
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
69
|
+
_this.mapVisibleNodeRects.set(target, rect);
|
|
70
|
+
_this.onChange({
|
|
71
|
+
time: time,
|
|
72
|
+
type: type,
|
|
73
|
+
elementRef: new WeakRef(target),
|
|
74
|
+
visible: visible,
|
|
75
|
+
rect: rect,
|
|
76
|
+
previousRect: lastElementRect,
|
|
77
|
+
mutationData: mutationData
|
|
78
|
+
});
|
|
81
79
|
});
|
|
82
|
-
this
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// for (const elem of addedNode.querySelectorAll('*')) {
|
|
93
|
-
// this.intersectionObserver?.watchAndTag(elem, 'mutation:child-element');
|
|
94
|
-
// }
|
|
95
|
-
|
|
96
|
-
var sameDeletedNode = removedNodes.find(function (n) {
|
|
97
|
-
return n.isEqualNode(addedNode);
|
|
98
|
-
});
|
|
99
|
-
if (sameDeletedNode) {
|
|
100
|
-
var _this$intersectionObs;
|
|
101
|
-
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.watchAndTag(addedNode, 'mutation:remount');
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (isContainedWithinMediaWrapper(addedNode)) {
|
|
105
|
-
var _this$intersectionObs2;
|
|
106
|
-
(_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
(_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
80
|
+
_defineProperty(this, "handleChildListMutation", function (_ref4) {
|
|
81
|
+
var addedNodes = _ref4.addedNodes,
|
|
82
|
+
removedNodes = _ref4.removedNodes;
|
|
83
|
+
var removedNodeRects = removedNodes.map(function (n) {
|
|
84
|
+
return _this.mapVisibleNodeRects.get(n);
|
|
85
|
+
});
|
|
86
|
+
addedNodes.forEach(function (addedNode) {
|
|
87
|
+
var _this$intersectionObs3;
|
|
88
|
+
var sameDeletedNode = removedNodes.find(function (n) {
|
|
89
|
+
return n.isEqualNode(addedNode);
|
|
110
90
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
type: 'mutation:attribute:non-visual-style',
|
|
134
|
-
mutationData: {
|
|
135
|
-
attributeName: attributeName
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
140
|
-
if (lastElementRect && sameRectSize(rect, lastElementRect)) {
|
|
141
|
-
return {
|
|
142
|
-
type: 'mutation:attribute:no-layout-shift',
|
|
143
|
-
mutationData: {
|
|
144
|
-
attributeName: attributeName
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
91
|
+
if (sameDeletedNode) {
|
|
92
|
+
var _this$intersectionObs;
|
|
93
|
+
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.watchAndTag(addedNode, 'mutation:remount');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (isContainedWithinMediaWrapper(addedNode)) {
|
|
97
|
+
var _this$intersectionObs2;
|
|
98
|
+
(_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
(_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
_defineProperty(this, "handleAttributeMutation", function (_ref5) {
|
|
105
|
+
var _this$intersectionObs4;
|
|
106
|
+
var target = _ref5.target,
|
|
107
|
+
attributeName = _ref5.attributeName;
|
|
108
|
+
(_this$intersectionObs4 = _this.intersectionObserver) === null || _this$intersectionObs4 === void 0 || _this$intersectionObs4.watchAndTag(target, function (_ref6) {
|
|
109
|
+
var target = _ref6.target,
|
|
110
|
+
rect = _ref6.rect;
|
|
111
|
+
if (isContainedWithinMediaWrapper(target)) {
|
|
148
112
|
return {
|
|
149
|
-
type: 'mutation:
|
|
113
|
+
type: 'mutation:media',
|
|
150
114
|
mutationData: {
|
|
151
115
|
attributeName: attributeName
|
|
152
116
|
}
|
|
153
117
|
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
previousRect: changedRect.previousRect,
|
|
174
|
-
type: 'layout-shift'
|
|
175
|
-
});
|
|
118
|
+
}
|
|
119
|
+
if (isNonVisualStyleMutation({
|
|
120
|
+
target: target,
|
|
121
|
+
attributeName: attributeName,
|
|
122
|
+
type: 'attributes'
|
|
123
|
+
})) {
|
|
124
|
+
return {
|
|
125
|
+
type: 'mutation:attribute:non-visual-style',
|
|
126
|
+
mutationData: {
|
|
127
|
+
attributeName: attributeName
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
132
|
+
if (lastElementRect && sameRectSize(rect, lastElementRect)) {
|
|
133
|
+
return {
|
|
134
|
+
type: 'mutation:attribute:no-layout-shift',
|
|
135
|
+
mutationData: {
|
|
136
|
+
attributeName: attributeName
|
|
176
137
|
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
type: 'mutation:attribute',
|
|
142
|
+
mutationData: {
|
|
143
|
+
attributeName: attributeName
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
_defineProperty(this, "handleLayoutShift", function (_ref7) {
|
|
149
|
+
var time = _ref7.time,
|
|
150
|
+
changedRects = _ref7.changedRects;
|
|
151
|
+
var _iterator = _createForOfIteratorHelper(changedRects),
|
|
152
|
+
_step;
|
|
153
|
+
try {
|
|
154
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
155
|
+
var changedRect = _step.value;
|
|
156
|
+
var target = changedRect.node;
|
|
157
|
+
if (target) {
|
|
158
|
+
_this.onChange({
|
|
159
|
+
time: time,
|
|
160
|
+
elementRef: new WeakRef(target),
|
|
161
|
+
visible: true,
|
|
162
|
+
rect: changedRect.rect,
|
|
163
|
+
previousRect: changedRect.previousRect,
|
|
164
|
+
type: 'layout-shift'
|
|
165
|
+
});
|
|
177
166
|
}
|
|
178
|
-
} catch (err) {
|
|
179
|
-
_iterator.e(err);
|
|
180
|
-
} finally {
|
|
181
|
-
_iterator.f();
|
|
182
167
|
}
|
|
168
|
+
} catch (err) {
|
|
169
|
+
_iterator.e(err);
|
|
170
|
+
} finally {
|
|
171
|
+
_iterator.f();
|
|
183
172
|
}
|
|
184
173
|
});
|
|
174
|
+
this.mapVisibleNodeRects = new WeakMap();
|
|
175
|
+
this.onChange = onChange;
|
|
176
|
+
this.isStarted = false;
|
|
177
|
+
this.intersectionObserver = null;
|
|
178
|
+
this.mutationObserver = null;
|
|
179
|
+
this.performanceObserver = null;
|
|
185
180
|
}
|
|
186
181
|
return _createClass(ViewportObserver, [{
|
|
182
|
+
key: "initializeObservers",
|
|
183
|
+
value: function initializeObservers() {
|
|
184
|
+
if (this.isStarted) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.intersectionObserver = createIntersectionObserver({
|
|
188
|
+
onEntry: this.handleIntersectionEntry
|
|
189
|
+
});
|
|
190
|
+
this.mutationObserver = createMutationObserver({
|
|
191
|
+
onChildListMutation: this.handleChildListMutation,
|
|
192
|
+
onAttributeMutation: this.handleAttributeMutation
|
|
193
|
+
});
|
|
194
|
+
this.performanceObserver = createPerformanceObserver({
|
|
195
|
+
onLayoutShift: this.handleLayoutShift
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
187
199
|
key: "start",
|
|
188
200
|
value: function start() {
|
|
189
201
|
var _this$mutationObserve, _this$performanceObse;
|
|
202
|
+
if (this.isStarted) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
this.initializeObservers();
|
|
190
206
|
(_this$mutationObserve = this.mutationObserver) === null || _this$mutationObserve === void 0 || _this$mutationObserve.observe(document.body, {
|
|
191
207
|
attributeOldValue: true,
|
|
192
208
|
attributes: true,
|
|
@@ -199,14 +215,19 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
199
215
|
// @ts-ignore-error
|
|
200
216
|
durationThreshold: 30
|
|
201
217
|
});
|
|
218
|
+
this.isStarted = true;
|
|
202
219
|
}
|
|
203
220
|
}, {
|
|
204
221
|
key: "stop",
|
|
205
222
|
value: function stop() {
|
|
206
223
|
var _this$mutationObserve2, _this$intersectionObs5, _this$performanceObse2;
|
|
224
|
+
if (!this.isStarted) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
207
227
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
208
228
|
(_this$intersectionObs5 = this.intersectionObserver) === null || _this$intersectionObs5 === void 0 || _this$intersectionObs5.disconnect();
|
|
209
229
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
|
|
230
|
+
this.isStarted = false;
|
|
210
231
|
}
|
|
211
232
|
}]);
|
|
212
233
|
}();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { InteractionType } from '../../interaction-metrics';
|
|
2
|
-
export declare function getReactUFOPayloadVersion(interactionType: InteractionType): "1.0.1" | "2.0.0";
|
|
2
|
+
export declare function getReactUFOPayloadVersion(interactionType: InteractionType, isPostInteractionLog?: boolean): "1.0.1" | "2.0.0";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LastInteractionFinishInfo } from '../common';
|
|
2
|
+
import { RevisionPayloadVCDetails } from '../common/vc/types';
|
|
3
|
+
import { LateMutation } from './types';
|
|
4
|
+
declare function getLateMutations(vcDetails: RevisionPayloadVCDetails, lastInteractionFinish: LastInteractionFinishInfo, postInteractionFinishVCRatios: Record<string, number>): LateMutation[];
|
|
5
|
+
export default getLateMutations;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PostInteractionLogOutput } from '../common';
|
|
2
|
+
import { LateMutation } from './types';
|
|
2
3
|
declare function createPostInteractionLogPayload({ lastInteractionFinish, reactProfilerTimings, lastInteractionFinishVCResult, postInteractionFinishVCResult, }: PostInteractionLogOutput): {
|
|
3
4
|
actionSubject: string;
|
|
4
5
|
action: string;
|
|
@@ -36,11 +37,7 @@ declare function createPostInteractionLogPayload({ lastInteractionFinish, reactP
|
|
|
36
37
|
revisedTtai: number;
|
|
37
38
|
revisedVC90: number | null;
|
|
38
39
|
vcClean: boolean;
|
|
39
|
-
lateMutations:
|
|
40
|
-
time: number;
|
|
41
|
-
element: string;
|
|
42
|
-
viewportHeatmapPercentage: number;
|
|
43
|
-
}[];
|
|
40
|
+
lateMutations: LateMutation[];
|
|
44
41
|
reactProfilerTimings: any[];
|
|
45
42
|
};
|
|
46
43
|
};
|
|
@@ -5,11 +5,11 @@ type Viewport = {
|
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* Class responsible for managing a scaled canvas and tracking pixel drawing operations.
|
|
8
|
-
* It uses an OffscreenCanvas
|
|
9
|
-
* colors and timestamps for pixel counting purposes.
|
|
8
|
+
* It uses either an OffscreenCanvas (if available) or a regular HTML Canvas for better performance
|
|
9
|
+
* and maintains a mapping between colors and timestamps for pixel counting purposes.
|
|
10
10
|
*/
|
|
11
11
|
export declare class ViewportCanvas {
|
|
12
|
-
/** The underlying
|
|
12
|
+
/** The underlying Canvas instance (either OffscreenCanvas or HTMLCanvasElement) */
|
|
13
13
|
private readonly canvas;
|
|
14
14
|
/** The 2D rendering context of the canvas */
|
|
15
15
|
private readonly ctx;
|
|
@@ -30,6 +30,11 @@ export declare class ViewportCanvas {
|
|
|
30
30
|
* @throws {Error} If canvas context cannot be obtained
|
|
31
31
|
*/
|
|
32
32
|
constructor(viewport: Viewport, scaleFactor?: number);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a canvas instance, falling back to HTMLCanvasElement if OffscreenCanvas is not available
|
|
35
|
+
* or if the feature flag is disabled
|
|
36
|
+
*/
|
|
37
|
+
private createCanvas;
|
|
33
38
|
getScaledDimensions(): {
|
|
34
39
|
width: number;
|
|
35
40
|
height: number;
|
|
@@ -16,7 +16,14 @@ export default class ViewportObserver {
|
|
|
16
16
|
private mutationObserver;
|
|
17
17
|
private performanceObserver;
|
|
18
18
|
private mapVisibleNodeRects;
|
|
19
|
-
|
|
19
|
+
private onChange;
|
|
20
|
+
private isStarted;
|
|
21
|
+
constructor({ onChange }: ViewPortObserverConstructorArgs);
|
|
22
|
+
private handleIntersectionEntry;
|
|
23
|
+
private handleChildListMutation;
|
|
24
|
+
private handleAttributeMutation;
|
|
25
|
+
private handleLayoutShift;
|
|
26
|
+
private initializeObservers;
|
|
20
27
|
start(): void;
|
|
21
28
|
stop(): void;
|
|
22
29
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { InteractionType } from '../../interaction-metrics';
|
|
2
|
-
export declare function getReactUFOPayloadVersion(interactionType: InteractionType): "1.0.1" | "2.0.0";
|
|
2
|
+
export declare function getReactUFOPayloadVersion(interactionType: InteractionType, isPostInteractionLog?: boolean): "1.0.1" | "2.0.0";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LastInteractionFinishInfo } from '../common';
|
|
2
|
+
import { RevisionPayloadVCDetails } from '../common/vc/types';
|
|
3
|
+
import { LateMutation } from './types';
|
|
4
|
+
declare function getLateMutations(vcDetails: RevisionPayloadVCDetails, lastInteractionFinish: LastInteractionFinishInfo, postInteractionFinishVCRatios: Record<string, number>): LateMutation[];
|
|
5
|
+
export default getLateMutations;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PostInteractionLogOutput } from '../common';
|
|
2
|
+
import { LateMutation } from './types';
|
|
2
3
|
declare function createPostInteractionLogPayload({ lastInteractionFinish, reactProfilerTimings, lastInteractionFinishVCResult, postInteractionFinishVCResult, }: PostInteractionLogOutput): {
|
|
3
4
|
actionSubject: string;
|
|
4
5
|
action: string;
|
|
@@ -36,11 +37,7 @@ declare function createPostInteractionLogPayload({ lastInteractionFinish, reactP
|
|
|
36
37
|
revisedTtai: number;
|
|
37
38
|
revisedVC90: number | null;
|
|
38
39
|
vcClean: boolean;
|
|
39
|
-
lateMutations:
|
|
40
|
-
time: number;
|
|
41
|
-
element: string;
|
|
42
|
-
viewportHeatmapPercentage: number;
|
|
43
|
-
}[];
|
|
40
|
+
lateMutations: LateMutation[];
|
|
44
41
|
reactProfilerTimings: any[];
|
|
45
42
|
};
|
|
46
43
|
};
|