@atlaskit/react-ufo 4.0.2 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#186813](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/186813)
8
+ [`b0dd8177f1f10`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b0dd8177f1f10) -
9
+ HOT-119287 only produce critical metrics for root and successful interaction
10
+
3
11
  ## 4.0.2
4
12
 
5
13
  ### Patch Changes
@@ -9,6 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _rootMetrics = require("./root-metrics");
13
14
  var _createSegmentMetrics = require("./segment-metrics/create-segment-metrics");
14
15
  function createCriticalMetricsPayloads(_x, _x2, _x3) {
@@ -21,13 +22,15 @@ function _createCriticalMetricsPayloads() {
21
22
  while (1) switch (_context.prev = _context.next) {
22
23
  case 0:
23
24
  _context.next = 2;
24
- return Promise.all([(0, _rootMetrics.createRootCriticalMetricsPayload)(interactionId, interaction, vcMetrics), (0, _createSegmentMetrics.createSegmentMetricsPayloads)(interactionId, interaction)]);
25
+ return Promise.all([(0, _rootMetrics.createRootCriticalMetricsPayload)(interactionId, interaction, vcMetrics), (0, _platformFeatureFlags.fg)('platform_ufo_segment_critical_metrics') ? (0, _createSegmentMetrics.createSegmentMetricsPayloads)(interactionId, interaction) : []]);
25
26
  case 2:
26
27
  _yield$Promise$all = _context.sent;
27
28
  _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 2);
28
29
  rootPayload = _yield$Promise$all2[0];
29
30
  segmentPayloads = _yield$Promise$all2[1];
30
- return _context.abrupt("return", [rootPayload].concat((0, _toConsumableArray2.default)(segmentPayloads)));
31
+ return _context.abrupt("return", [rootPayload].concat((0, _toConsumableArray2.default)(segmentPayloads)).filter(function (v) {
32
+ return v != null;
33
+ }));
31
34
  case 7:
32
35
  case "end":
33
36
  return _context.stop();
@@ -57,11 +57,17 @@ function _createRootCriticalMetricsPayload() {
57
57
  pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
58
58
  pageVisibilityAtTTAI = (0, _getPageVisibilityUpToTtai.default)(interaction);
59
59
  interactionStatus = (0, _getInteractionStatus.default)(interaction);
60
+ if (!(interactionStatus.originalInteractionStatus !== 'SUCCEEDED')) {
61
+ _context.next = 9;
62
+ break;
63
+ }
64
+ return _context.abrupt("return", null);
65
+ case 9:
60
66
  newUFOName = (0, _utils.sanitizeUfoName)(ufoName); // Get performance metrics
61
67
  ttai = (0, _getTtai.default)(interaction);
62
- _context.next = 11;
68
+ _context.next = 13;
63
69
  return (0, _getPaintMetrics.default)(type, end);
64
- case 11:
70
+ case 13:
65
71
  paintMetrics = _context.sent;
66
72
  navigationMetrics = (0, _getNavigationMetrics.default)(type);
67
73
  ssrSuccess = (0, _getSsrSuccess.default)(type); // Calculate BM3 metrics (TTI and FMP) directly
@@ -74,14 +80,14 @@ function _createRootCriticalMetricsPayload() {
74
80
  }); // Use provided vcMetrics or calculate if not provided
75
81
  _context.t0 = vcMetrics;
76
82
  if (_context.t0) {
77
- _context.next = 23;
83
+ _context.next = 25;
78
84
  break;
79
85
  }
80
- _context.next = 22;
86
+ _context.next = 24;
81
87
  return (0, _getVcMetrics.default)(interaction);
82
- case 22:
88
+ case 24:
83
89
  _context.t0 = _context.sent;
84
- case 23:
90
+ case 25:
85
91
  finalVCMetrics = _context.t0;
86
92
  ttvc = (_finalVCMetrics$ufoV = finalVCMetrics['ufo:vc:rev']) === null || _finalVCMetrics$ufoV === void 0 ? void 0 : _finalVCMetrics$ufoV.map(function (revision) {
87
93
  if (revision['metric:vc90'] === null || revision.clean !== true) {
@@ -170,7 +176,7 @@ function _createRootCriticalMetricsPayload() {
170
176
  }
171
177
  };
172
178
  return _context.abrupt("return", payload);
173
- case 30:
179
+ case 32:
174
180
  case "end":
175
181
  return _context.stop();
176
182
  }
@@ -26,7 +26,7 @@ function createSegmentMetricsPayloads(_x, _x2) {
26
26
  function _createSegmentMetricsPayloads() {
27
27
  _createSegmentMetricsPayloads = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interactionId, interaction) {
28
28
  var _interaction$cohortin;
29
- var config, browserMetadata, cohortingCustomData, pageVisibilityAtTTAI, knownSegments, reactProfilerTimings, rate, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, segmentsByName, _iterator, _step, _loop, _ret, payloads, _iterator2, _step2, _loop2;
29
+ var config, browserMetadata, cohortingCustomData, pageVisibilityAtTTAI, knownSegments, reactProfilerTimings, rate, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, segmentsByName, _iterator, _step, _loop, _ret, payloads, _iterator2, _step2, _loop2, _ret2;
30
30
  return _regenerator.default.wrap(function _callee$(_context3) {
31
31
  while (1) switch (_context3.prev = _context3.next) {
32
32
  case 0:
@@ -148,13 +148,19 @@ function _createSegmentMetricsPayloads() {
148
148
  _context2.next = 8;
149
149
  break;
150
150
  }
151
- return _context2.abrupt("return", 1);
151
+ return _context2.abrupt("return", 0);
152
152
  case 8:
153
153
  lastTiming = segmentProfilerTimings[segmentProfilerTimings.length - 1];
154
154
  startTime = isRootSegment ? interaction.start : firstMountTiming.startTime;
155
155
  endTime = lastTiming.commitTime;
156
156
  ttai = Math.round(endTime - startTime);
157
157
  _getSegmentStatus = (0, _getSegmentStatus2.default)(interaction, segment), status = _getSegmentStatus.status, segmentAbortReason = _getSegmentStatus.abortReason;
158
+ if (!(status !== 'SUCCEEDED')) {
159
+ _context2.next = 15;
160
+ break;
161
+ }
162
+ return _context2.abrupt("return", 0);
163
+ case 15:
158
164
  properties = _objectSpread({
159
165
  // Basic metadata
160
166
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
@@ -206,7 +212,7 @@ function _createSegmentMetricsPayloads() {
206
212
  }
207
213
  };
208
214
  payloads.push(payload);
209
- case 16:
215
+ case 18:
210
216
  case "end":
211
217
  return _context2.stop();
212
218
  }
@@ -215,37 +221,38 @@ function _createSegmentMetricsPayloads() {
215
221
  _iterator2.s();
216
222
  case 32:
217
223
  if ((_step2 = _iterator2.n()).done) {
218
- _context3.next = 38;
224
+ _context3.next = 39;
219
225
  break;
220
226
  }
221
227
  return _context3.delegateYield(_loop2(), "t2", 34);
222
228
  case 34:
223
- if (!_context3.t2) {
224
- _context3.next = 36;
229
+ _ret2 = _context3.t2;
230
+ if (!(_ret2 === 0)) {
231
+ _context3.next = 37;
225
232
  break;
226
233
  }
227
- return _context3.abrupt("continue", 36);
228
- case 36:
234
+ return _context3.abrupt("continue", 37);
235
+ case 37:
229
236
  _context3.next = 32;
230
237
  break;
231
- case 38:
232
- _context3.next = 43;
238
+ case 39:
239
+ _context3.next = 44;
233
240
  break;
234
- case 40:
235
- _context3.prev = 40;
241
+ case 41:
242
+ _context3.prev = 41;
236
243
  _context3.t3 = _context3["catch"](29);
237
244
  _iterator2.e(_context3.t3);
238
- case 43:
239
- _context3.prev = 43;
245
+ case 44:
246
+ _context3.prev = 44;
240
247
  _iterator2.f();
241
- return _context3.finish(43);
242
- case 46:
243
- return _context3.abrupt("return", payloads);
248
+ return _context3.finish(44);
244
249
  case 47:
250
+ return _context3.abrupt("return", payloads);
251
+ case 48:
245
252
  case "end":
246
253
  return _context3.stop();
247
254
  }
248
- }, _callee, null, [[9, 21, 24, 27], [29, 40, 43, 46]]);
255
+ }, _callee, null, [[9, 21, 24, 27], [29, 41, 44, 47]]);
249
256
  }));
250
257
  return _createSegmentMetricsPayloads.apply(this, arguments);
251
258
  }
@@ -1,6 +1,7 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { createRootCriticalMetricsPayload } from './root-metrics';
2
3
  import { createSegmentMetricsPayloads } from './segment-metrics/create-segment-metrics';
3
4
  export async function createCriticalMetricsPayloads(interactionId, interaction, vcMetrics) {
4
- const [rootPayload, segmentPayloads] = await Promise.all([createRootCriticalMetricsPayload(interactionId, interaction, vcMetrics), createSegmentMetricsPayloads(interactionId, interaction)]);
5
- return [rootPayload, ...segmentPayloads];
5
+ const [rootPayload, segmentPayloads] = await Promise.all([createRootCriticalMetricsPayload(interactionId, interaction, vcMetrics), fg('platform_ufo_segment_critical_metrics') ? createSegmentMetricsPayloads(interactionId, interaction) : []]);
6
+ return [rootPayload, ...segmentPayloads].filter(v => v != null);
6
7
  }
@@ -50,6 +50,10 @@ export async function createRootCriticalMetricsPayload(interactionId, interactio
50
50
  const pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
51
51
  const pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
52
52
  const interactionStatus = getInteractionStatus(interaction);
53
+ if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED') {
54
+ // To reduce payload sent from the client, we don't send critical perf metrics for non-success interactions
55
+ return null;
56
+ }
53
57
  const newUFOName = sanitizeUfoName(ufoName);
54
58
 
55
59
  // Get performance metrics
@@ -97,6 +97,10 @@ export async function createSegmentMetricsPayloads(interactionId, interaction) {
97
97
  status,
98
98
  abortReason: segmentAbortReason
99
99
  } = getSegmentStatus(interaction, segment);
100
+ if (status !== 'SUCCEEDED') {
101
+ // To reduce payload sent from the client, we don't send critical perf metrics for non-success interactions
102
+ continue;
103
+ }
100
104
  const properties = {
101
105
  // Basic metadata
102
106
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import { createRootCriticalMetricsPayload } from './root-metrics';
6
7
  import { createSegmentMetricsPayloads } from './segment-metrics/create-segment-metrics';
7
8
  export function createCriticalMetricsPayloads(_x, _x2, _x3) {
@@ -14,13 +15,15 @@ function _createCriticalMetricsPayloads() {
14
15
  while (1) switch (_context.prev = _context.next) {
15
16
  case 0:
16
17
  _context.next = 2;
17
- return Promise.all([createRootCriticalMetricsPayload(interactionId, interaction, vcMetrics), createSegmentMetricsPayloads(interactionId, interaction)]);
18
+ return Promise.all([createRootCriticalMetricsPayload(interactionId, interaction, vcMetrics), fg('platform_ufo_segment_critical_metrics') ? createSegmentMetricsPayloads(interactionId, interaction) : []]);
18
19
  case 2:
19
20
  _yield$Promise$all = _context.sent;
20
21
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
21
22
  rootPayload = _yield$Promise$all2[0];
22
23
  segmentPayloads = _yield$Promise$all2[1];
23
- return _context.abrupt("return", [rootPayload].concat(_toConsumableArray(segmentPayloads)));
24
+ return _context.abrupt("return", [rootPayload].concat(_toConsumableArray(segmentPayloads)).filter(function (v) {
25
+ return v != null;
26
+ }));
24
27
  case 7:
25
28
  case "end":
26
29
  return _context.stop();
@@ -51,11 +51,17 @@ function _createRootCriticalMetricsPayload() {
51
51
  pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
52
52
  pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
53
53
  interactionStatus = getInteractionStatus(interaction);
54
+ if (!(interactionStatus.originalInteractionStatus !== 'SUCCEEDED')) {
55
+ _context.next = 9;
56
+ break;
57
+ }
58
+ return _context.abrupt("return", null);
59
+ case 9:
54
60
  newUFOName = sanitizeUfoName(ufoName); // Get performance metrics
55
61
  ttai = getTTAI(interaction);
56
- _context.next = 11;
62
+ _context.next = 13;
57
63
  return getPaintMetrics(type, end);
58
- case 11:
64
+ case 13:
59
65
  paintMetrics = _context.sent;
60
66
  navigationMetrics = getNavigationMetrics(type);
61
67
  ssrSuccess = getSSRSuccess(type); // Calculate BM3 metrics (TTI and FMP) directly
@@ -68,14 +74,14 @@ function _createRootCriticalMetricsPayload() {
68
74
  }); // Use provided vcMetrics or calculate if not provided
69
75
  _context.t0 = vcMetrics;
70
76
  if (_context.t0) {
71
- _context.next = 23;
77
+ _context.next = 25;
72
78
  break;
73
79
  }
74
- _context.next = 22;
80
+ _context.next = 24;
75
81
  return getVCMetrics(interaction);
76
- case 22:
82
+ case 24:
77
83
  _context.t0 = _context.sent;
78
- case 23:
84
+ case 25:
79
85
  finalVCMetrics = _context.t0;
80
86
  ttvc = (_finalVCMetrics$ufoV = finalVCMetrics['ufo:vc:rev']) === null || _finalVCMetrics$ufoV === void 0 ? void 0 : _finalVCMetrics$ufoV.map(function (revision) {
81
87
  if (revision['metric:vc90'] === null || revision.clean !== true) {
@@ -164,7 +170,7 @@ function _createRootCriticalMetricsPayload() {
164
170
  }
165
171
  };
166
172
  return _context.abrupt("return", payload);
167
- case 30:
173
+ case 32:
168
174
  case "end":
169
175
  return _context.stop();
170
176
  }
@@ -19,7 +19,7 @@ export function createSegmentMetricsPayloads(_x, _x2) {
19
19
  function _createSegmentMetricsPayloads() {
20
20
  _createSegmentMetricsPayloads = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interactionId, interaction) {
21
21
  var _interaction$cohortin;
22
- var config, browserMetadata, cohortingCustomData, pageVisibilityAtTTAI, knownSegments, reactProfilerTimings, rate, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, segmentsByName, _iterator, _step, _loop, _ret, payloads, _iterator2, _step2, _loop2;
22
+ var config, browserMetadata, cohortingCustomData, pageVisibilityAtTTAI, knownSegments, reactProfilerTimings, rate, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, segmentsByName, _iterator, _step, _loop, _ret, payloads, _iterator2, _step2, _loop2, _ret2;
23
23
  return _regeneratorRuntime.wrap(function _callee$(_context3) {
24
24
  while (1) switch (_context3.prev = _context3.next) {
25
25
  case 0:
@@ -141,13 +141,19 @@ function _createSegmentMetricsPayloads() {
141
141
  _context2.next = 8;
142
142
  break;
143
143
  }
144
- return _context2.abrupt("return", 1);
144
+ return _context2.abrupt("return", 0);
145
145
  case 8:
146
146
  lastTiming = segmentProfilerTimings[segmentProfilerTimings.length - 1];
147
147
  startTime = isRootSegment ? interaction.start : firstMountTiming.startTime;
148
148
  endTime = lastTiming.commitTime;
149
149
  ttai = Math.round(endTime - startTime);
150
150
  _getSegmentStatus = getSegmentStatus(interaction, segment), status = _getSegmentStatus.status, segmentAbortReason = _getSegmentStatus.abortReason;
151
+ if (!(status !== 'SUCCEEDED')) {
152
+ _context2.next = 15;
153
+ break;
154
+ }
155
+ return _context2.abrupt("return", 0);
156
+ case 15:
151
157
  properties = _objectSpread({
152
158
  // Basic metadata
153
159
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
@@ -199,7 +205,7 @@ function _createSegmentMetricsPayloads() {
199
205
  }
200
206
  };
201
207
  payloads.push(payload);
202
- case 16:
208
+ case 18:
203
209
  case "end":
204
210
  return _context2.stop();
205
211
  }
@@ -208,37 +214,38 @@ function _createSegmentMetricsPayloads() {
208
214
  _iterator2.s();
209
215
  case 32:
210
216
  if ((_step2 = _iterator2.n()).done) {
211
- _context3.next = 38;
217
+ _context3.next = 39;
212
218
  break;
213
219
  }
214
220
  return _context3.delegateYield(_loop2(), "t2", 34);
215
221
  case 34:
216
- if (!_context3.t2) {
217
- _context3.next = 36;
222
+ _ret2 = _context3.t2;
223
+ if (!(_ret2 === 0)) {
224
+ _context3.next = 37;
218
225
  break;
219
226
  }
220
- return _context3.abrupt("continue", 36);
221
- case 36:
227
+ return _context3.abrupt("continue", 37);
228
+ case 37:
222
229
  _context3.next = 32;
223
230
  break;
224
- case 38:
225
- _context3.next = 43;
231
+ case 39:
232
+ _context3.next = 44;
226
233
  break;
227
- case 40:
228
- _context3.prev = 40;
234
+ case 41:
235
+ _context3.prev = 41;
229
236
  _context3.t3 = _context3["catch"](29);
230
237
  _iterator2.e(_context3.t3);
231
- case 43:
232
- _context3.prev = 43;
238
+ case 44:
239
+ _context3.prev = 44;
233
240
  _iterator2.f();
234
- return _context3.finish(43);
235
- case 46:
236
- return _context3.abrupt("return", payloads);
241
+ return _context3.finish(44);
237
242
  case 47:
243
+ return _context3.abrupt("return", payloads);
244
+ case 48:
238
245
  case "end":
239
246
  return _context3.stop();
240
247
  }
241
- }, _callee, null, [[9, 21, 24, 27], [29, 40, 43, 46]]);
248
+ }, _callee, null, [[9, 21, 24, 27], [29, 41, 44, 47]]);
242
249
  }));
243
250
  return _createSegmentMetricsPayloads.apply(this, arguments);
244
251
  }
@@ -4,4 +4,4 @@ import type { CriticalMetricsPayload } from './types';
4
4
  export type { CriticalMetricsPayload, CriticalMetricsPayloadProperties } from './types';
5
5
  export declare function createRootCriticalMetricsPayload(interactionId: string, interaction: InteractionMetrics, vcMetrics?: VCResult & {
6
6
  'metric:vc90'?: number | null;
7
- }): Promise<CriticalMetricsPayload>;
7
+ }): Promise<CriticalMetricsPayload | null>;
@@ -4,4 +4,4 @@ import type { CriticalMetricsPayload } from './types';
4
4
  export type { CriticalMetricsPayload, CriticalMetricsPayloadProperties } from './types';
5
5
  export declare function createRootCriticalMetricsPayload(interactionId: string, interaction: InteractionMetrics, vcMetrics?: VCResult & {
6
6
  'metric:vc90'?: number | null;
7
- }): Promise<CriticalMetricsPayload>;
7
+ }): Promise<CriticalMetricsPayload | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -214,6 +214,9 @@
214
214
  },
215
215
  "platform_ufo_handle_non_react_element_for_3p": {
216
216
  "type": "boolean"
217
+ },
218
+ "platform_ufo_segment_critical_metrics": {
219
+ "type": "boolean"
217
220
  }
218
221
  }
219
222
  }