@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.10.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#152686](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/152686)
|
|
8
|
+
[`d4b943e998cff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d4b943e998cff) -
|
|
9
|
+
AFO-3823 improve VCObserverNew perf overhead
|
|
10
|
+
|
|
11
|
+
## 3.10.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#148578](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/148578)
|
|
16
|
+
[`d0ee548642b3e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d0ee548642b3e) -
|
|
17
|
+
Use `ufo:vc:rev` for late mutations post interaction log
|
|
18
|
+
|
|
3
19
|
## 3.10.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -4,7 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getReactUFOPayloadVersion = getReactUFOPayloadVersion;
|
|
7
|
-
function getReactUFOPayloadVersion(interactionType) {
|
|
7
|
+
function getReactUFOPayloadVersion(interactionType, isPostInteractionLog) {
|
|
8
|
+
if (isPostInteractionLog) {
|
|
9
|
+
return '1.0.1';
|
|
10
|
+
}
|
|
8
11
|
if (interactionType !== 'page_load' && interactionType !== 'transition') {
|
|
9
12
|
return '1.0.1';
|
|
10
13
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
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; } } }; }
|
|
8
|
+
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; } }
|
|
9
|
+
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; }
|
|
10
|
+
function getLateMutations(vcDetails, lastInteractionFinish, postInteractionFinishVCRatios) {
|
|
11
|
+
// Map to track which elements are already seen for each timestamp
|
|
12
|
+
var seen = new Map();
|
|
13
|
+
var result = [];
|
|
14
|
+
for (var part in vcDetails) {
|
|
15
|
+
var details = vcDetails[part];
|
|
16
|
+
if (!(details !== null && details !== void 0 && details.t) || details.t <= lastInteractionFinish.end || !details.e) {
|
|
17
|
+
continue; // Skip if not late or no elements
|
|
18
|
+
}
|
|
19
|
+
if (!seen.has(details.t)) {
|
|
20
|
+
seen.set(details.t, new Set());
|
|
21
|
+
}
|
|
22
|
+
var seenElements = seen.get(details.t);
|
|
23
|
+
var _iterator = _createForOfIteratorHelper(details.e),
|
|
24
|
+
_step;
|
|
25
|
+
try {
|
|
26
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
27
|
+
var element = _step.value;
|
|
28
|
+
if (seenElements.has(element)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
seenElements.add(element);
|
|
32
|
+
result.push({
|
|
33
|
+
time: details.t,
|
|
34
|
+
element: element,
|
|
35
|
+
viewportHeatmapPercentage: postInteractionFinishVCRatios[element] || 0
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
_iterator.e(err);
|
|
40
|
+
} finally {
|
|
41
|
+
_iterator.f();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
var _default = exports.default = getLateMutations;
|
|
@@ -7,11 +7,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _coinflip = _interopRequireDefault(require("../coinflip"));
|
|
11
12
|
var _config = require("../config");
|
|
12
13
|
var _utils = require("../create-payload/common/utils");
|
|
13
14
|
var _getReactUfoPayloadVersion = require("../create-payload/utils/get-react-ufo-payload-version");
|
|
14
15
|
var _hiddenTiming = require("../hidden-timing");
|
|
16
|
+
var _getLateMutations = _interopRequireDefault(require("./get-late-mutations"));
|
|
15
17
|
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; }
|
|
16
18
|
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; }
|
|
17
19
|
function getParentStack(labelStack) {
|
|
@@ -141,39 +143,72 @@ function createPostInteractionLogPayload(_ref2) {
|
|
|
141
143
|
var lastInteractionFinishTTAI = Math.round(lastInteractionFinish.end - lastInteractionFinish.start);
|
|
142
144
|
var lastInteractionFinishVC90 = null;
|
|
143
145
|
var lastInteractionFinishVCClean = false;
|
|
144
|
-
if (
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_use_vc_rev')) {
|
|
147
|
+
var lastInteractionFinishVCRev = lastInteractionFinishVCResult === null || lastInteractionFinishVCResult === void 0 ? void 0 : lastInteractionFinishVCResult['ufo:vc:rev'];
|
|
148
|
+
var lastInteractionFinishRevision = lastInteractionFinishVCRev === null || lastInteractionFinishVCRev === void 0 ? void 0 : lastInteractionFinishVCRev.find(function (_ref3) {
|
|
149
|
+
var revision = _ref3.revision;
|
|
150
|
+
return revision === 'fy25.02';
|
|
151
|
+
});
|
|
152
|
+
if (lastInteractionFinishRevision !== null && lastInteractionFinishRevision !== void 0 && lastInteractionFinishRevision.clean) {
|
|
153
|
+
var _lastInteractionFinis;
|
|
154
|
+
lastInteractionFinishVCClean = true;
|
|
155
|
+
lastInteractionFinishVC90 = (_lastInteractionFinis = lastInteractionFinishRevision['metric:vc90']) !== null && _lastInteractionFinis !== void 0 ? _lastInteractionFinis : null;
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
if (lastInteractionFinishVCResult !== null && lastInteractionFinishVCResult !== void 0 && lastInteractionFinishVCResult['ufo:vc:state']) {
|
|
159
|
+
var _lastInteractionFinis2;
|
|
160
|
+
lastInteractionFinishVCClean = true;
|
|
161
|
+
var lastInteractionFinishVCMetrics = lastInteractionFinishVCResult === null || lastInteractionFinishVCResult === void 0 ? void 0 : lastInteractionFinishVCResult['metrics:vc'];
|
|
162
|
+
lastInteractionFinishVC90 = (_lastInteractionFinis2 = lastInteractionFinishVCMetrics[90]) !== null && _lastInteractionFinis2 !== void 0 ? _lastInteractionFinis2 : null;
|
|
163
|
+
}
|
|
149
164
|
}
|
|
150
165
|
var postInteractionFinishVCRatios = {};
|
|
151
|
-
var revisedVC90 = null;
|
|
152
|
-
var postInteractionFinishVCUpdates = [];
|
|
153
166
|
var postInteractionFinishVCClean = false;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
167
|
+
var revisedVC90 = null;
|
|
168
|
+
var lateMutations = [];
|
|
169
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_use_vc_rev')) {
|
|
170
|
+
var postInteractionFinishVCRev = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:rev'];
|
|
171
|
+
var postInteractionFinishRevision = postInteractionFinishVCRev === null || postInteractionFinishVCRev === void 0 ? void 0 : postInteractionFinishVCRev.find(function (_ref4) {
|
|
172
|
+
var revision = _ref4.revision;
|
|
173
|
+
return revision === 'fy25.02';
|
|
174
|
+
});
|
|
175
|
+
if (postInteractionFinishRevision !== null && postInteractionFinishRevision !== void 0 && postInteractionFinishRevision.clean) {
|
|
176
|
+
postInteractionFinishVCClean = true;
|
|
177
|
+
postInteractionFinishVCRatios = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:ratios'];
|
|
178
|
+
if (typeof lastInteractionFinishVC90 === 'number') {
|
|
179
|
+
var _postInteractionFinis;
|
|
180
|
+
revisedVC90 = (_postInteractionFinis = postInteractionFinishRevision['metric:vc90']) !== null && _postInteractionFinis !== void 0 ? _postInteractionFinis : null;
|
|
181
|
+
}
|
|
182
|
+
var vcDetails = postInteractionFinishRevision.vcDetails;
|
|
183
|
+
if (vcDetails) {
|
|
184
|
+
lateMutations = (0, _getLateMutations.default)(vcDetails, lastInteractionFinish, postInteractionFinishVCRatios);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
if (postInteractionFinishVCResult !== null && postInteractionFinishVCResult !== void 0 && postInteractionFinishVCResult['ufo:vc:state']) {
|
|
189
|
+
postInteractionFinishVCClean = true;
|
|
190
|
+
postInteractionFinishVCRatios = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:ratios'];
|
|
191
|
+
var postInteractionFinishVCUpdates = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['ufo:vc:updates'];
|
|
192
|
+
var postInteractionFinishVCMetrics = postInteractionFinishVCResult === null || postInteractionFinishVCResult === void 0 ? void 0 : postInteractionFinishVCResult['metrics:vc'];
|
|
193
|
+
if (typeof lastInteractionFinishVC90 === 'number') {
|
|
194
|
+
var _postInteractionFinis2;
|
|
195
|
+
revisedVC90 = (_postInteractionFinis2 = postInteractionFinishVCMetrics[90]) !== null && _postInteractionFinis2 !== void 0 ? _postInteractionFinis2 : null;
|
|
196
|
+
}
|
|
197
|
+
lateMutations = postInteractionFinishVCUpdates ? postInteractionFinishVCUpdates.filter(function (entry) {
|
|
198
|
+
return entry.time > lastInteractionFinish.end;
|
|
199
|
+
}).flatMap(function (_ref5) {
|
|
200
|
+
var time = _ref5.time,
|
|
201
|
+
elements = _ref5.elements;
|
|
202
|
+
return Array.from(new Set(elements)).map(function (element) {
|
|
203
|
+
return {
|
|
204
|
+
time: time,
|
|
205
|
+
element: element,
|
|
206
|
+
viewportHeatmapPercentage: postInteractionFinishVCRatios[element]
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
}) : [];
|
|
162
210
|
}
|
|
163
211
|
}
|
|
164
|
-
var lateMutations = postInteractionFinishVCUpdates ? postInteractionFinishVCUpdates.filter(function (entry) {
|
|
165
|
-
return entry.time > lastInteractionFinish.end;
|
|
166
|
-
}).flatMap(function (_ref3) {
|
|
167
|
-
var time = _ref3.time,
|
|
168
|
-
elements = _ref3.elements;
|
|
169
|
-
return Array.from(new Set(elements)).map(function (element) {
|
|
170
|
-
return {
|
|
171
|
-
time: time,
|
|
172
|
-
element: element,
|
|
173
|
-
viewportHeatmapPercentage: postInteractionFinishVCRatios[element]
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
}) : [];
|
|
177
212
|
return {
|
|
178
213
|
actionSubject: 'experience',
|
|
179
214
|
action: 'measured',
|
|
@@ -188,7 +223,7 @@ function createPostInteractionLogPayload(_ref2) {
|
|
|
188
223
|
'event:schema': '1.0.0',
|
|
189
224
|
'event:source': {
|
|
190
225
|
name: 'react-ufo/web',
|
|
191
|
-
version: (0, _getReactUfoPayloadVersion.getReactUFOPayloadVersion)(lastInteractionFinish.type)
|
|
226
|
+
version: (0, _getReactUfoPayloadVersion.getReactUFOPayloadVersion)(lastInteractionFinish.type, true) // always 1.0.1 as `reactProfileTimings` has `labelStack` as an array
|
|
192
227
|
},
|
|
193
228
|
'event:region': config.region || 'unknown',
|
|
194
229
|
'experience:key': 'custom.post-interaction-logs',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -127,9 +127,9 @@ var MultiRevisionHeatmap = exports.MultiRevisionHeatmap = /*#__PURE__*/function
|
|
|
127
127
|
});
|
|
128
128
|
return {
|
|
129
129
|
revision: rev.name,
|
|
130
|
-
vcDetails: vcDetails,
|
|
131
130
|
clean: args.clean,
|
|
132
|
-
'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
|
|
131
|
+
'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,
|
|
132
|
+
vcDetails: vcDetails
|
|
133
133
|
};
|
|
134
134
|
});
|
|
135
135
|
return payload;
|
|
@@ -7,13 +7,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
10
|
var EntriesTimeline = exports.default = /*#__PURE__*/function () {
|
|
12
11
|
function EntriesTimeline() {
|
|
13
12
|
(0, _classCallCheck2.default)(this, EntriesTimeline);
|
|
14
|
-
(0, _defineProperty2.default)(this, "unorderedEntries", []);
|
|
15
|
-
(0, _defineProperty2.default)(this, "sortedEntriesCache", new Map());
|
|
16
13
|
this.unorderedEntries = [];
|
|
14
|
+
this.sortedEntriesCache = new Map();
|
|
17
15
|
}
|
|
18
16
|
return (0, _createClass2.default)(EntriesTimeline, [{
|
|
19
17
|
key: "push",
|
|
@@ -78,9 +78,9 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
78
78
|
vcDetails = _context.sent;
|
|
79
79
|
return _context.abrupt("return", {
|
|
80
80
|
revision: this.revisionNo,
|
|
81
|
-
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined,
|
|
82
81
|
clean: true,
|
|
83
|
-
'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
|
|
82
|
+
'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,
|
|
83
|
+
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
|
|
84
84
|
});
|
|
85
85
|
case 15:
|
|
86
86
|
case "end":
|
package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js
CHANGED
|
@@ -11,15 +11,16 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _taskYield = _interopRequireDefault(require("../../utils/task-yield"));
|
|
15
16
|
// 24-bit color value
|
|
16
17
|
/**
|
|
17
18
|
* Class responsible for managing a scaled canvas and tracking pixel drawing operations.
|
|
18
|
-
* It uses an OffscreenCanvas
|
|
19
|
-
* colors and timestamps for pixel counting purposes.
|
|
19
|
+
* It uses either an OffscreenCanvas (if available) or a regular HTML Canvas for better performance
|
|
20
|
+
* and maintains a mapping between colors and timestamps for pixel counting purposes.
|
|
20
21
|
*/
|
|
21
22
|
var ViewportCanvas = exports.ViewportCanvas = /*#__PURE__*/function () {
|
|
22
|
-
/** The underlying
|
|
23
|
+
/** The underlying Canvas instance (either OffscreenCanvas or HTMLCanvasElement) */
|
|
23
24
|
|
|
24
25
|
/** The 2D rendering context of the canvas */
|
|
25
26
|
|
|
@@ -50,10 +51,8 @@ var ViewportCanvas = exports.ViewportCanvas = /*#__PURE__*/function () {
|
|
|
50
51
|
this.scaleX = this.scaledWidth / safeViewportWidth;
|
|
51
52
|
this.scaleY = this.scaledHeight / safeViewportHeight;
|
|
52
53
|
|
|
53
|
-
// Initialize
|
|
54
|
-
this.canvas =
|
|
55
|
-
this.canvas.width = this.scaledWidth;
|
|
56
|
-
this.canvas.height = this.scaledHeight;
|
|
54
|
+
// Initialize canvas with scaled dimensions
|
|
55
|
+
this.canvas = this.createCanvas(this.scaledWidth, this.scaledHeight);
|
|
57
56
|
var ctx = this.canvas.getContext('2d', {
|
|
58
57
|
alpha: false,
|
|
59
58
|
// Disable alpha channel for better performance
|
|
@@ -66,9 +65,28 @@ var ViewportCanvas = exports.ViewportCanvas = /*#__PURE__*/function () {
|
|
|
66
65
|
}
|
|
67
66
|
this.ctx = ctx;
|
|
68
67
|
this.ctx.globalCompositeOperation = 'source-over';
|
|
68
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_use_offscreen_canvas')) {
|
|
69
|
+
this.ctx.imageSmoothingEnabled = false; // Disable image smoothing for better performance
|
|
70
|
+
}
|
|
69
71
|
this.clear();
|
|
70
72
|
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a canvas instance, falling back to HTMLCanvasElement if OffscreenCanvas is not available
|
|
76
|
+
* or if the feature flag is disabled
|
|
77
|
+
*/
|
|
71
78
|
return (0, _createClass2.default)(ViewportCanvas, [{
|
|
79
|
+
key: "createCanvas",
|
|
80
|
+
value: function createCanvas(width, height) {
|
|
81
|
+
if (typeof OffscreenCanvas !== 'undefined' && (0, _platformFeatureFlags.fg)('platform_ufo_use_offscreen_canvas')) {
|
|
82
|
+
return new OffscreenCanvas(width, height);
|
|
83
|
+
}
|
|
84
|
+
var canvas = document.createElement('canvas');
|
|
85
|
+
canvas.width = width;
|
|
86
|
+
canvas.height = height;
|
|
87
|
+
return canvas;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
72
90
|
key: "getScaledDimensions",
|
|
73
91
|
value: function getScaledDimensions() {
|
|
74
92
|
return {
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _vcUtils = require("../../vc-observer/media-wrapper/vc-utils");
|
|
11
12
|
var _isNonVisualStyleMutation = _interopRequireDefault(require("../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation"));
|
|
12
13
|
var _intersectionObserver = require("./intersection-observer");
|
|
@@ -61,139 +62,154 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
61
62
|
var _this = this;
|
|
62
63
|
var onChange = _ref2.onChange;
|
|
63
64
|
(0, _classCallCheck2.default)(this, ViewportObserver);
|
|
64
|
-
this
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!target) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
var visible = isElementVisible(target);
|
|
76
|
-
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
77
|
-
_this.mapVisibleNodeRects.set(target, rect);
|
|
78
|
-
onChange({
|
|
79
|
-
time: time,
|
|
80
|
-
type: type,
|
|
81
|
-
elementRef: new WeakRef(target),
|
|
82
|
-
visible: visible,
|
|
83
|
-
rect: rect,
|
|
84
|
-
previousRect: lastElementRect,
|
|
85
|
-
mutationData: mutationData
|
|
86
|
-
});
|
|
65
|
+
(0, _defineProperty2.default)(this, "handleIntersectionEntry", function (_ref3) {
|
|
66
|
+
var target = _ref3.target,
|
|
67
|
+
rect = _ref3.rect,
|
|
68
|
+
time = _ref3.time,
|
|
69
|
+
type = _ref3.type,
|
|
70
|
+
mutationData = _ref3.mutationData;
|
|
71
|
+
if (!target) {
|
|
72
|
+
return;
|
|
87
73
|
}
|
|
74
|
+
var visible = isElementVisible(target);
|
|
75
|
+
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
76
|
+
_this.mapVisibleNodeRects.set(target, rect);
|
|
77
|
+
_this.onChange({
|
|
78
|
+
time: time,
|
|
79
|
+
type: type,
|
|
80
|
+
elementRef: new WeakRef(target),
|
|
81
|
+
visible: visible,
|
|
82
|
+
rect: rect,
|
|
83
|
+
previousRect: lastElementRect,
|
|
84
|
+
mutationData: mutationData
|
|
85
|
+
});
|
|
88
86
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// for (const elem of addedNode.querySelectorAll('*')) {
|
|
100
|
-
// this.intersectionObserver?.watchAndTag(elem, 'mutation:child-element');
|
|
101
|
-
// }
|
|
102
|
-
|
|
103
|
-
var sameDeletedNode = removedNodes.find(function (n) {
|
|
104
|
-
return n.isEqualNode(addedNode);
|
|
105
|
-
});
|
|
106
|
-
if (sameDeletedNode) {
|
|
107
|
-
var _this$intersectionObs;
|
|
108
|
-
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.watchAndTag(addedNode, 'mutation:remount');
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if ((0, _vcUtils.isContainedWithinMediaWrapper)(addedNode)) {
|
|
112
|
-
var _this$intersectionObs2;
|
|
113
|
-
(_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
(_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
87
|
+
(0, _defineProperty2.default)(this, "handleChildListMutation", function (_ref4) {
|
|
88
|
+
var addedNodes = _ref4.addedNodes,
|
|
89
|
+
removedNodes = _ref4.removedNodes;
|
|
90
|
+
var removedNodeRects = removedNodes.map(function (n) {
|
|
91
|
+
return _this.mapVisibleNodeRects.get(n);
|
|
92
|
+
});
|
|
93
|
+
addedNodes.forEach(function (addedNode) {
|
|
94
|
+
var _this$intersectionObs3;
|
|
95
|
+
var sameDeletedNode = removedNodes.find(function (n) {
|
|
96
|
+
return n.isEqualNode(addedNode);
|
|
117
97
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
type: 'mutation:attribute:non-visual-style',
|
|
141
|
-
mutationData: {
|
|
142
|
-
attributeName: attributeName
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
147
|
-
if (lastElementRect && sameRectSize(rect, lastElementRect)) {
|
|
148
|
-
return {
|
|
149
|
-
type: 'mutation:attribute:no-layout-shift',
|
|
150
|
-
mutationData: {
|
|
151
|
-
attributeName: attributeName
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
98
|
+
if (sameDeletedNode) {
|
|
99
|
+
var _this$intersectionObs;
|
|
100
|
+
(_this$intersectionObs = _this.intersectionObserver) === null || _this$intersectionObs === void 0 || _this$intersectionObs.watchAndTag(addedNode, 'mutation:remount');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if ((0, _vcUtils.isContainedWithinMediaWrapper)(addedNode)) {
|
|
104
|
+
var _this$intersectionObs2;
|
|
105
|
+
(_this$intersectionObs2 = _this.intersectionObserver) === null || _this$intersectionObs2 === void 0 || _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
(_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
(0, _defineProperty2.default)(this, "handleAttributeMutation", function (_ref5) {
|
|
112
|
+
var _this$intersectionObs4;
|
|
113
|
+
var target = _ref5.target,
|
|
114
|
+
attributeName = _ref5.attributeName;
|
|
115
|
+
(_this$intersectionObs4 = _this.intersectionObserver) === null || _this$intersectionObs4 === void 0 || _this$intersectionObs4.watchAndTag(target, function (_ref6) {
|
|
116
|
+
var target = _ref6.target,
|
|
117
|
+
rect = _ref6.rect;
|
|
118
|
+
if ((0, _vcUtils.isContainedWithinMediaWrapper)(target)) {
|
|
155
119
|
return {
|
|
156
|
-
type: 'mutation:
|
|
120
|
+
type: 'mutation:media',
|
|
157
121
|
mutationData: {
|
|
158
122
|
attributeName: attributeName
|
|
159
123
|
}
|
|
160
124
|
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
previousRect: changedRect.previousRect,
|
|
181
|
-
type: 'layout-shift'
|
|
182
|
-
});
|
|
125
|
+
}
|
|
126
|
+
if ((0, _isNonVisualStyleMutation.default)({
|
|
127
|
+
target: target,
|
|
128
|
+
attributeName: attributeName,
|
|
129
|
+
type: 'attributes'
|
|
130
|
+
})) {
|
|
131
|
+
return {
|
|
132
|
+
type: 'mutation:attribute:non-visual-style',
|
|
133
|
+
mutationData: {
|
|
134
|
+
attributeName: attributeName
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var lastElementRect = _this.mapVisibleNodeRects.get(target);
|
|
139
|
+
if (lastElementRect && sameRectSize(rect, lastElementRect)) {
|
|
140
|
+
return {
|
|
141
|
+
type: 'mutation:attribute:no-layout-shift',
|
|
142
|
+
mutationData: {
|
|
143
|
+
attributeName: attributeName
|
|
183
144
|
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
type: 'mutation:attribute',
|
|
149
|
+
mutationData: {
|
|
150
|
+
attributeName: attributeName
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
(0, _defineProperty2.default)(this, "handleLayoutShift", function (_ref7) {
|
|
156
|
+
var time = _ref7.time,
|
|
157
|
+
changedRects = _ref7.changedRects;
|
|
158
|
+
var _iterator = _createForOfIteratorHelper(changedRects),
|
|
159
|
+
_step;
|
|
160
|
+
try {
|
|
161
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
162
|
+
var changedRect = _step.value;
|
|
163
|
+
var target = changedRect.node;
|
|
164
|
+
if (target) {
|
|
165
|
+
_this.onChange({
|
|
166
|
+
time: time,
|
|
167
|
+
elementRef: new WeakRef(target),
|
|
168
|
+
visible: true,
|
|
169
|
+
rect: changedRect.rect,
|
|
170
|
+
previousRect: changedRect.previousRect,
|
|
171
|
+
type: 'layout-shift'
|
|
172
|
+
});
|
|
184
173
|
}
|
|
185
|
-
} catch (err) {
|
|
186
|
-
_iterator.e(err);
|
|
187
|
-
} finally {
|
|
188
|
-
_iterator.f();
|
|
189
174
|
}
|
|
175
|
+
} catch (err) {
|
|
176
|
+
_iterator.e(err);
|
|
177
|
+
} finally {
|
|
178
|
+
_iterator.f();
|
|
190
179
|
}
|
|
191
180
|
});
|
|
181
|
+
this.mapVisibleNodeRects = new WeakMap();
|
|
182
|
+
this.onChange = onChange;
|
|
183
|
+
this.isStarted = false;
|
|
184
|
+
this.intersectionObserver = null;
|
|
185
|
+
this.mutationObserver = null;
|
|
186
|
+
this.performanceObserver = null;
|
|
192
187
|
}
|
|
193
188
|
return (0, _createClass2.default)(ViewportObserver, [{
|
|
189
|
+
key: "initializeObservers",
|
|
190
|
+
value: function initializeObservers() {
|
|
191
|
+
if (this.isStarted) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this.intersectionObserver = (0, _intersectionObserver.createIntersectionObserver)({
|
|
195
|
+
onEntry: this.handleIntersectionEntry
|
|
196
|
+
});
|
|
197
|
+
this.mutationObserver = (0, _mutationObserver.default)({
|
|
198
|
+
onChildListMutation: this.handleChildListMutation,
|
|
199
|
+
onAttributeMutation: this.handleAttributeMutation
|
|
200
|
+
});
|
|
201
|
+
this.performanceObserver = (0, _performanceObserver.default)({
|
|
202
|
+
onLayoutShift: this.handleLayoutShift
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
194
206
|
key: "start",
|
|
195
207
|
value: function start() {
|
|
196
208
|
var _this$mutationObserve, _this$performanceObse;
|
|
209
|
+
if (this.isStarted) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.initializeObservers();
|
|
197
213
|
(_this$mutationObserve = this.mutationObserver) === null || _this$mutationObserve === void 0 || _this$mutationObserve.observe(document.body, {
|
|
198
214
|
attributeOldValue: true,
|
|
199
215
|
attributes: true,
|
|
@@ -206,14 +222,19 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
206
222
|
// @ts-ignore-error
|
|
207
223
|
durationThreshold: 30
|
|
208
224
|
});
|
|
225
|
+
this.isStarted = true;
|
|
209
226
|
}
|
|
210
227
|
}, {
|
|
211
228
|
key: "stop",
|
|
212
229
|
value: function stop() {
|
|
213
230
|
var _this$mutationObserve2, _this$intersectionObs5, _this$performanceObse2;
|
|
231
|
+
if (!this.isStarted) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
214
234
|
(_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
|
|
215
235
|
(_this$intersectionObs5 = this.intersectionObserver) === null || _this$intersectionObs5 === void 0 || _this$intersectionObs5.disconnect();
|
|
216
236
|
(_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
|
|
237
|
+
this.isStarted = false;
|
|
217
238
|
}
|
|
218
239
|
}]);
|
|
219
240
|
}();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export function getReactUFOPayloadVersion(interactionType) {
|
|
1
|
+
export function getReactUFOPayloadVersion(interactionType, isPostInteractionLog) {
|
|
2
|
+
if (isPostInteractionLog) {
|
|
3
|
+
return '1.0.1';
|
|
4
|
+
}
|
|
2
5
|
if (interactionType !== 'page_load' && interactionType !== 'transition') {
|
|
3
6
|
return '1.0.1';
|
|
4
7
|
}
|