@atlaskit/react-ufo 2.0.3 → 2.0.5

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,21 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#158480](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158480)
8
+ [`fcbd1c4e6293b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fcbd1c4e6293b) -
9
+ Sending `custom.post-interaction-log` event for certain Perf Push experiences
10
+
11
+ ## 2.0.4
12
+
13
+ ### Patch Changes
14
+
15
+ - [#157826](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157826)
16
+ [`cd0465f950cb6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cd0465f950cb6) -
17
+ Added count of network calls
18
+
3
19
  ## 2.0.3
4
20
 
5
21
  ### Patch Changes
@@ -9,6 +9,7 @@ exports.getConfig = getConfig;
9
9
  exports.getDoNotAbortActivePressInteraction = getDoNotAbortActivePressInteraction;
10
10
  exports.getDoNotAbortActivePressInteractionOnTransition = getDoNotAbortActivePressInteractionOnTransition;
11
11
  exports.getInteractionRate = getInteractionRate;
12
+ exports.getPostInteractionRate = getPostInteractionRate;
12
13
  exports.getRemoveInteractionsUFOPrefixes = getRemoveInteractionsUFOPrefixes;
13
14
  exports.getRemovePageSegmentsUFOPrefixes = getRemovePageSegmentsUFOPrefixes;
14
15
  exports.getTypingPerformanceTracingMethod = getTypingPerformanceTracingMethod;
@@ -80,13 +81,34 @@ function getInteractionRate(name, interactionKind) {
80
81
  return 0;
81
82
  }
82
83
  }
83
- function getCapabilityRate(capability) {
84
+ function getPostInteractionRate(name, interactionType) {
84
85
  try {
85
86
  if (!config) {
86
87
  return 0;
87
88
  }
88
89
  var _config2 = config,
89
- capabilityRate = _config2.capability;
90
+ postInteractionLog = _config2.postInteractionLog;
91
+ if (!(postInteractionLog !== null && postInteractionLog !== void 0 && postInteractionLog.enabled)) {
92
+ return 0;
93
+ }
94
+ if (postInteractionLog.rates && typeof postInteractionLog.rates[name] === 'number') {
95
+ return postInteractionLog.rates[name];
96
+ }
97
+ if (postInteractionLog.kind && typeof postInteractionLog.kind[interactionType] === 'number') {
98
+ return postInteractionLog.kind[interactionType];
99
+ }
100
+ return 0;
101
+ } catch (e) {
102
+ return 0;
103
+ }
104
+ }
105
+ function getCapabilityRate(capability) {
106
+ try {
107
+ if (!config) {
108
+ return 0;
109
+ }
110
+ var _config3 = config,
111
+ capabilityRate = _config3.capability;
90
112
  if (capabilityRate != null) {
91
113
  var rate = capabilityRate[capability];
92
114
  if (rate != null) {
@@ -105,8 +127,8 @@ function getTypingPerformanceTracingMethod() {
105
127
  if (!config) {
106
128
  return defaultMethod;
107
129
  }
108
- var _config3 = config,
109
- typingMethod = _config3.typingMethod;
130
+ var _config4 = config,
131
+ typingMethod = _config4.typingMethod;
110
132
  if (typingMethod != null && validTypingMethods.find(function (m) {
111
133
  return m === typingMethod;
112
134
  })) {
@@ -125,8 +147,8 @@ function getAwaitBM3TTIList() {
125
147
  if (!config) {
126
148
  return [];
127
149
  }
128
- var _config4 = config,
129
- awaitBM3TTI = _config4.awaitBM3TTI;
150
+ var _config5 = config,
151
+ awaitBM3TTI = _config5.awaitBM3TTI;
130
152
  if (awaitBM3TTI != null) {
131
153
  return awaitBM3TTI;
132
154
  } else {
@@ -143,8 +165,8 @@ function getRemovePageSegmentsUFOPrefixes() {
143
165
  if (!config) {
144
166
  return false;
145
167
  }
146
- var _config5 = config,
147
- removePageSegmentsUFOPrefixes = _config5.removePageSegmentsUFOPrefixes;
168
+ var _config6 = config,
169
+ removePageSegmentsUFOPrefixes = _config6.removePageSegmentsUFOPrefixes;
148
170
  if (removePageSegmentsUFOPrefixes != null) {
149
171
  return removePageSegmentsUFOPrefixes;
150
172
  } else {
@@ -161,8 +183,8 @@ function getRemoveInteractionsUFOPrefixes() {
161
183
  if (!config) {
162
184
  return false;
163
185
  }
164
- var _config6 = config,
165
- removeInteractionsUFOPrefixes = _config6.removeInteractionsUFOPrefixes;
186
+ var _config7 = config,
187
+ removeInteractionsUFOPrefixes = _config7.removeInteractionsUFOPrefixes;
166
188
  if (removeInteractionsUFOPrefixes != null) {
167
189
  return removeInteractionsUFOPrefixes;
168
190
  } else {
@@ -182,8 +204,8 @@ function getUfoNameOverrides() {
182
204
  if (!config) {
183
205
  return undefined;
184
206
  }
185
- var _config7 = config,
186
- ufoNameOverrides = _config7.ufoNameOverrides;
207
+ var _config8 = config,
208
+ ufoNameOverrides = _config8.ufoNameOverrides;
187
209
  if (ufoNameOverrides != null) {
188
210
  return ufoNameOverrides;
189
211
  }
@@ -199,8 +221,8 @@ function getDoNotAbortActivePressInteraction() {
199
221
  if (!config) {
200
222
  return undefined;
201
223
  }
202
- var _config8 = config,
203
- doNotAbortActivePressInteraction = _config8.doNotAbortActivePressInteraction;
224
+ var _config9 = config,
225
+ doNotAbortActivePressInteraction = _config9.doNotAbortActivePressInteraction;
204
226
  return doNotAbortActivePressInteraction;
205
227
  } catch (e) {
206
228
  return undefined;
@@ -213,8 +235,8 @@ function getDoNotAbortActivePressInteractionOnTransition() {
213
235
  if (!config) {
214
236
  return undefined;
215
237
  }
216
- var _config9 = config,
217
- doNotAbortActivePressInteractionOnTransition = _config9.doNotAbortActivePressInteractionOnTransition;
238
+ var _config10 = config,
239
+ doNotAbortActivePressInteractionOnTransition = _config10.doNotAbortActivePressInteractionOnTransition;
218
240
  return doNotAbortActivePressInteractionOnTransition;
219
241
  } catch (e) {
220
242
  return undefined;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = createPostInteractionLogPayload;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _coinflip = _interopRequireDefault(require("../coinflip"));
10
11
  var _constants = require("../common/constants");
11
12
  var _config = require("../config");
12
13
  var _utils = require("../create-payload/common/utils");
@@ -125,6 +126,10 @@ function createPostInteractionLogPayload(_ref2) {
125
126
  throw Error('UFO Configuration not provided');
126
127
  }
127
128
  var ufoName = (0, _utils.sanitizeUfoName)(lastInteractionFinish.ufoName);
129
+ var rate = (0, _config.getPostInteractionRate)(ufoName, lastInteractionFinish.type);
130
+ if (!(0, _coinflip.default)(rate)) {
131
+ return null;
132
+ }
128
133
  var pageVisibilityState = (0, _hiddenTiming.getPageVisibilityState)(lastInteractionFinish.start, lastInteractionFinish.end);
129
134
  if (pageVisibilityState !== 'visible') {
130
135
  return null;
@@ -441,7 +441,7 @@ var addProfilerTimings = exports.addProfilerTimings = function addProfilerTiming
441
441
  startTime: startTime,
442
442
  commitTime: commitTime
443
443
  });
444
- } else if ((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && _getConfig.captureLateReRenders) {
444
+ } else if ((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.postInteractionLog) !== null && _getConfig !== void 0 && _getConfig.enabled) {
445
445
  postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
446
446
  }
447
447
  };
@@ -553,7 +553,7 @@ function tryComplete(interactionId, endTime) {
553
553
  if (noMoreHolds) {
554
554
  var _getConfig3;
555
555
  finishInteraction(interactionId, interaction, endTime);
556
- if ((_getConfig3 = (0, _config.getConfig)()) !== null && _getConfig3 !== void 0 && _getConfig3.captureLateReRenders) {
556
+ if ((_getConfig3 = (0, _config.getConfig)()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.postInteractionLog) !== null && _getConfig3 !== void 0 && _getConfig3.enabled) {
557
557
  postInteractionLog.onInteractionComplete(interaction);
558
558
  }
559
559
  }
@@ -603,7 +603,7 @@ function addOnCancelCallback(id, cancelCallback) {
603
603
  function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
604
604
  var _getConfig4;
605
605
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
606
- if ((_getConfig4 = (0, _config.getConfig)()) !== null && _getConfig4 !== void 0 && _getConfig4.captureLateReRenders) {
606
+ if ((_getConfig4 = (0, _config.getConfig)()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
607
607
  postInteractionLog.reset();
608
608
  }
609
609
  var previousTime = startTime;
@@ -73,15 +73,17 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
73
73
  createPostInteractionLogPayloadPackage = _ref2[2];
74
74
  if (awc.getAnalyticsWebClientPromise) {
75
75
  awc.getAnalyticsWebClientPromise().then(function (client) {
76
+ var _config$postInteracti;
76
77
  var instance = client.getInstance();
77
78
  sinkInteraction(instance, payloadPackage);
78
- if (config.captureLateReRenders) {
79
+ if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
79
80
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
80
81
  }
81
82
  });
82
83
  } else if (awc.sendOperationalEvent) {
84
+ var _config$postInteracti2;
83
85
  sinkInteraction(awc, payloadPackage);
84
- if (config.captureLateReRenders) {
86
+ if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
85
87
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
86
88
  }
87
89
  }
@@ -126,7 +126,11 @@ var getResourceTimings = exports.getResourceTimings = function getResourceTiming
126
126
  return;
127
127
  }
128
128
  var url = resourceTypes.includes(initiatorType) ? sanitiseEndpoints(name) : mapResources(name);
129
- if (!url || resourceTiming[url]) {
129
+ if (!url) {
130
+ return;
131
+ }
132
+ if (resourceTiming[url]) {
133
+ resourceTiming[url].count = (resourceTiming[url].count || 1) + 1;
130
134
  return;
131
135
  }
132
136
  resourceTiming[url] = _objectSpread({
@@ -67,6 +67,28 @@ export function getInteractionRate(name, interactionKind) {
67
67
  return 0;
68
68
  }
69
69
  }
70
+ export function getPostInteractionRate(name, interactionType) {
71
+ try {
72
+ if (!config) {
73
+ return 0;
74
+ }
75
+ const {
76
+ postInteractionLog
77
+ } = config;
78
+ if (!(postInteractionLog !== null && postInteractionLog !== void 0 && postInteractionLog.enabled)) {
79
+ return 0;
80
+ }
81
+ if (postInteractionLog.rates && typeof postInteractionLog.rates[name] === 'number') {
82
+ return postInteractionLog.rates[name];
83
+ }
84
+ if (postInteractionLog.kind && typeof postInteractionLog.kind[interactionType] === 'number') {
85
+ return postInteractionLog.kind[interactionType];
86
+ }
87
+ return 0;
88
+ } catch (e) {
89
+ return 0;
90
+ }
91
+ }
70
92
  export function getCapabilityRate(capability) {
71
93
  try {
72
94
  if (!config) {
@@ -1,5 +1,6 @@
1
+ import coinflip from '../coinflip';
1
2
  import { REACT_UFO_VERSION } from '../common/constants';
2
- import { getConfig } from '../config';
3
+ import { getConfig, getPostInteractionRate } from '../config';
3
4
  import { isSegmentLabel, sanitizeUfoName } from '../create-payload/common/utils';
4
5
  import { getPageVisibilityState } from '../hidden-timing';
5
6
  function getParentStack(labelStack) {
@@ -112,6 +113,10 @@ export default function createPostInteractionLogPayload({
112
113
  throw Error('UFO Configuration not provided');
113
114
  }
114
115
  const ufoName = sanitizeUfoName(lastInteractionFinish.ufoName);
116
+ const rate = getPostInteractionRate(ufoName, lastInteractionFinish.type);
117
+ if (!coinflip(rate)) {
118
+ return null;
119
+ }
115
120
  const pageVisibilityState = getPageVisibilityState(lastInteractionFinish.start, lastInteractionFinish.end);
116
121
  if (pageVisibilityState !== 'visible') {
117
122
  return null;
@@ -349,7 +349,7 @@ export function addErrorToAll(name, labelStack, errorType, errorMessage, errorSt
349
349
  });
350
350
  }
351
351
  export const addProfilerTimings = (interactionId, labelStack, type, actualDuration, baseDuration, startTime, commitTime) => {
352
- var _getConfig;
352
+ var _getConfig, _getConfig$postIntera;
353
353
  if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
354
354
  try {
355
355
  // for Firefox 102 and older
@@ -371,7 +371,7 @@ export const addProfilerTimings = (interactionId, labelStack, type, actualDurati
371
371
  startTime,
372
372
  commitTime
373
373
  });
374
- } else if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && _getConfig.captureLateReRenders) {
374
+ } else if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig$postIntera = _getConfig.postInteractionLog) !== null && _getConfig$postIntera !== void 0 && _getConfig$postIntera.enabled) {
375
375
  postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
376
376
  }
377
377
  };
@@ -471,9 +471,9 @@ export function tryComplete(interactionId, endTime) {
471
471
  if (interaction != null) {
472
472
  const noMoreHolds = interaction.holdActive.size === 0;
473
473
  if (noMoreHolds) {
474
- var _getConfig3;
474
+ var _getConfig3, _getConfig3$postInter;
475
475
  finishInteraction(interactionId, interaction, endTime);
476
- if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && _getConfig3.captureLateReRenders) {
476
+ if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3$postInter = _getConfig3.postInteractionLog) !== null && _getConfig3$postInter !== void 0 && _getConfig3$postInter.enabled) {
477
477
  postInteractionLog.onInteractionComplete(interaction);
478
478
  }
479
479
  }
@@ -521,8 +521,8 @@ export function addOnCancelCallback(id, cancelCallback) {
521
521
  interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
522
522
  }
523
523
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName, trace = null) {
524
- var _getConfig4;
525
- if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && _getConfig4.captureLateReRenders) {
524
+ var _getConfig4, _getConfig4$postInter;
525
+ if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4$postInter = _getConfig4.postInteractionLog) !== null && _getConfig4$postInter !== void 0 && _getConfig4$postInter.enabled) {
526
526
  postInteractionLog.reset();
527
527
  }
528
528
  let previousTime = startTime;
@@ -56,15 +56,17 @@ export const init = (analyticsWebClientAsync, config) => {
56
56
  import( /* webpackChunkName: "create-post-intreaction-log-payload" */'../create-post-interaction-log-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage]) => {
57
57
  if (awc.getAnalyticsWebClientPromise) {
58
58
  awc.getAnalyticsWebClientPromise().then(client => {
59
+ var _config$postInteracti;
59
60
  const instance = client.getInstance();
60
61
  sinkInteraction(instance, payloadPackage);
61
- if (config.captureLateReRenders) {
62
+ if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
62
63
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
63
64
  }
64
65
  });
65
66
  } else if (awc.sendOperationalEvent) {
67
+ var _config$postInteracti2;
66
68
  sinkInteraction(awc, payloadPackage);
67
- if (config.captureLateReRenders) {
69
+ if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
68
70
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
69
71
  }
70
72
  }
@@ -114,7 +114,11 @@ export const getResourceTimings = (interactionStart, interactionEnd) => {
114
114
  return;
115
115
  }
116
116
  const url = resourceTypes.includes(initiatorType) ? sanitiseEndpoints(name) : mapResources(name);
117
- if (!url || resourceTiming[url]) {
117
+ if (!url) {
118
+ return;
119
+ }
120
+ if (resourceTiming[url]) {
121
+ resourceTiming[url].count = (resourceTiming[url].count || 1) + 1;
118
122
  return;
119
123
  }
120
124
  resourceTiming[url] = {
@@ -64,13 +64,34 @@ export function getInteractionRate(name, interactionKind) {
64
64
  return 0;
65
65
  }
66
66
  }
67
- export function getCapabilityRate(capability) {
67
+ export function getPostInteractionRate(name, interactionType) {
68
68
  try {
69
69
  if (!config) {
70
70
  return 0;
71
71
  }
72
72
  var _config2 = config,
73
- capabilityRate = _config2.capability;
73
+ postInteractionLog = _config2.postInteractionLog;
74
+ if (!(postInteractionLog !== null && postInteractionLog !== void 0 && postInteractionLog.enabled)) {
75
+ return 0;
76
+ }
77
+ if (postInteractionLog.rates && typeof postInteractionLog.rates[name] === 'number') {
78
+ return postInteractionLog.rates[name];
79
+ }
80
+ if (postInteractionLog.kind && typeof postInteractionLog.kind[interactionType] === 'number') {
81
+ return postInteractionLog.kind[interactionType];
82
+ }
83
+ return 0;
84
+ } catch (e) {
85
+ return 0;
86
+ }
87
+ }
88
+ export function getCapabilityRate(capability) {
89
+ try {
90
+ if (!config) {
91
+ return 0;
92
+ }
93
+ var _config3 = config,
94
+ capabilityRate = _config3.capability;
74
95
  if (capabilityRate != null) {
75
96
  var rate = capabilityRate[capability];
76
97
  if (rate != null) {
@@ -89,8 +110,8 @@ export function getTypingPerformanceTracingMethod() {
89
110
  if (!config) {
90
111
  return defaultMethod;
91
112
  }
92
- var _config3 = config,
93
- typingMethod = _config3.typingMethod;
113
+ var _config4 = config,
114
+ typingMethod = _config4.typingMethod;
94
115
  if (typingMethod != null && validTypingMethods.find(function (m) {
95
116
  return m === typingMethod;
96
117
  })) {
@@ -109,8 +130,8 @@ export function getAwaitBM3TTIList() {
109
130
  if (!config) {
110
131
  return [];
111
132
  }
112
- var _config4 = config,
113
- awaitBM3TTI = _config4.awaitBM3TTI;
133
+ var _config5 = config,
134
+ awaitBM3TTI = _config5.awaitBM3TTI;
114
135
  if (awaitBM3TTI != null) {
115
136
  return awaitBM3TTI;
116
137
  } else {
@@ -127,8 +148,8 @@ export function getRemovePageSegmentsUFOPrefixes() {
127
148
  if (!config) {
128
149
  return false;
129
150
  }
130
- var _config5 = config,
131
- removePageSegmentsUFOPrefixes = _config5.removePageSegmentsUFOPrefixes;
151
+ var _config6 = config,
152
+ removePageSegmentsUFOPrefixes = _config6.removePageSegmentsUFOPrefixes;
132
153
  if (removePageSegmentsUFOPrefixes != null) {
133
154
  return removePageSegmentsUFOPrefixes;
134
155
  } else {
@@ -145,8 +166,8 @@ export function getRemoveInteractionsUFOPrefixes() {
145
166
  if (!config) {
146
167
  return false;
147
168
  }
148
- var _config6 = config,
149
- removeInteractionsUFOPrefixes = _config6.removeInteractionsUFOPrefixes;
169
+ var _config7 = config,
170
+ removeInteractionsUFOPrefixes = _config7.removeInteractionsUFOPrefixes;
150
171
  if (removeInteractionsUFOPrefixes != null) {
151
172
  return removeInteractionsUFOPrefixes;
152
173
  } else {
@@ -166,8 +187,8 @@ export function getUfoNameOverrides() {
166
187
  if (!config) {
167
188
  return undefined;
168
189
  }
169
- var _config7 = config,
170
- ufoNameOverrides = _config7.ufoNameOverrides;
190
+ var _config8 = config,
191
+ ufoNameOverrides = _config8.ufoNameOverrides;
171
192
  if (ufoNameOverrides != null) {
172
193
  return ufoNameOverrides;
173
194
  }
@@ -183,8 +204,8 @@ export function getDoNotAbortActivePressInteraction() {
183
204
  if (!config) {
184
205
  return undefined;
185
206
  }
186
- var _config8 = config,
187
- doNotAbortActivePressInteraction = _config8.doNotAbortActivePressInteraction;
207
+ var _config9 = config,
208
+ doNotAbortActivePressInteraction = _config9.doNotAbortActivePressInteraction;
188
209
  return doNotAbortActivePressInteraction;
189
210
  } catch (e) {
190
211
  return undefined;
@@ -197,8 +218,8 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
197
218
  if (!config) {
198
219
  return undefined;
199
220
  }
200
- var _config9 = config,
201
- doNotAbortActivePressInteractionOnTransition = _config9.doNotAbortActivePressInteractionOnTransition;
221
+ var _config10 = config,
222
+ doNotAbortActivePressInteractionOnTransition = _config10.doNotAbortActivePressInteractionOnTransition;
202
223
  return doNotAbortActivePressInteractionOnTransition;
203
224
  } catch (e) {
204
225
  return undefined;
@@ -2,8 +2,9 @@ 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 coinflip from '../coinflip';
5
6
  import { REACT_UFO_VERSION } from '../common/constants';
6
- import { getConfig } from '../config';
7
+ import { getConfig, getPostInteractionRate } from '../config';
7
8
  import { isSegmentLabel, sanitizeUfoName } from '../create-payload/common/utils';
8
9
  import { getPageVisibilityState } from '../hidden-timing';
9
10
  function getParentStack(labelStack) {
@@ -118,6 +119,10 @@ export default function createPostInteractionLogPayload(_ref2) {
118
119
  throw Error('UFO Configuration not provided');
119
120
  }
120
121
  var ufoName = sanitizeUfoName(lastInteractionFinish.ufoName);
122
+ var rate = getPostInteractionRate(ufoName, lastInteractionFinish.type);
123
+ if (!coinflip(rate)) {
124
+ return null;
125
+ }
121
126
  var pageVisibilityState = getPageVisibilityState(lastInteractionFinish.start, lastInteractionFinish.end);
122
127
  if (pageVisibilityState !== 'visible') {
123
128
  return null;
@@ -398,7 +398,7 @@ export var addProfilerTimings = function addProfilerTimings(interactionId, label
398
398
  startTime: startTime,
399
399
  commitTime: commitTime
400
400
  });
401
- } else if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && _getConfig.captureLateReRenders) {
401
+ } else if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.postInteractionLog) !== null && _getConfig !== void 0 && _getConfig.enabled) {
402
402
  postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
403
403
  }
404
404
  };
@@ -510,7 +510,7 @@ export function tryComplete(interactionId, endTime) {
510
510
  if (noMoreHolds) {
511
511
  var _getConfig3;
512
512
  finishInteraction(interactionId, interaction, endTime);
513
- if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && _getConfig3.captureLateReRenders) {
513
+ if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.postInteractionLog) !== null && _getConfig3 !== void 0 && _getConfig3.enabled) {
514
514
  postInteractionLog.onInteractionComplete(interaction);
515
515
  }
516
516
  }
@@ -560,7 +560,7 @@ export function addOnCancelCallback(id, cancelCallback) {
560
560
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
561
561
  var _getConfig4;
562
562
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
563
- if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && _getConfig4.captureLateReRenders) {
563
+ if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
564
564
  postInteractionLog.reset();
565
565
  }
566
566
  var previousTime = startTime;
@@ -61,15 +61,17 @@ export var init = function init(analyticsWebClientAsync, config) {
61
61
  createPostInteractionLogPayloadPackage = _ref2[2];
62
62
  if (awc.getAnalyticsWebClientPromise) {
63
63
  awc.getAnalyticsWebClientPromise().then(function (client) {
64
+ var _config$postInteracti;
64
65
  var instance = client.getInstance();
65
66
  sinkInteraction(instance, payloadPackage);
66
- if (config.captureLateReRenders) {
67
+ if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
67
68
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
68
69
  }
69
70
  });
70
71
  } else if (awc.sendOperationalEvent) {
72
+ var _config$postInteracti2;
71
73
  sinkInteraction(awc, payloadPackage);
72
- if (config.captureLateReRenders) {
74
+ if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
73
75
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
74
76
  }
75
77
  }
@@ -119,7 +119,11 @@ export var getResourceTimings = function getResourceTimings(interactionStart, in
119
119
  return;
120
120
  }
121
121
  var url = resourceTypes.includes(initiatorType) ? sanitiseEndpoints(name) : mapResources(name);
122
- if (!url || resourceTiming[url]) {
122
+ if (!url) {
123
+ return;
124
+ }
125
+ if (resourceTiming[url]) {
126
+ resourceTiming[url].count = (resourceTiming[url].count || 1) + 1;
123
127
  return;
124
128
  }
125
129
  resourceTiming[url] = _objectSpread({
@@ -1,4 +1,4 @@
1
- import type { InteractionMetrics } from '../common';
1
+ import type { InteractionMetrics, InteractionType } from '../common';
2
2
  export interface AdditionalData {
3
3
  [key: string]: null | undefined | string | number | boolean | undefined | AdditionalData | Record<string, AdditionalData> | Array<AdditionalData>;
4
4
  }
@@ -24,6 +24,9 @@ type SelectorConfig = {
24
24
  className: boolean;
25
25
  dataVC?: boolean;
26
26
  };
27
+ type Rates = {
28
+ readonly [key: string]: number;
29
+ };
27
30
  export type Config = {
28
31
  readonly enabled?: boolean;
29
32
  readonly doNotAbortActivePressInteraction?: string[];
@@ -32,9 +35,7 @@ export type Config = {
32
35
  readonly ufoNameOverrides?: UFONameOverride;
33
36
  readonly namePrefix?: string;
34
37
  readonly segmentPrefix?: string;
35
- readonly rates?: {
36
- readonly [key: string]: number;
37
- };
38
+ readonly rates?: Rates;
38
39
  readonly rules?: readonly {
39
40
  readonly test?: string;
40
41
  readonly rate?: number;
@@ -66,7 +67,11 @@ export type Config = {
66
67
  readonly ssr?: boolean;
67
68
  readonly stopVCAtInteractionFinish?: boolean;
68
69
  };
69
- readonly captureLateReRenders?: boolean;
70
+ readonly postInteractionLog?: {
71
+ readonly enabled?: boolean;
72
+ readonly rates?: Rates;
73
+ readonly kind?: Record<InteractionType, number>;
74
+ };
70
75
  readonly enableSegmentHighlighting?: boolean;
71
76
  readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
72
77
  readonly timeWindowForLateMutationsInMilliseconds?: number;
@@ -79,6 +84,7 @@ export type Config = {
79
84
  export declare function setUFOConfig(newConfig: Config): void;
80
85
  export declare function getConfig(): Config | undefined;
81
86
  export declare function getInteractionRate(name: string, interactionKind: InteractionKind): number;
87
+ export declare function getPostInteractionRate(name: string, interactionType: InteractionType): number;
82
88
  export declare function getCapabilityRate(capability: Capability): number;
83
89
  declare const validTypingMethods: readonly ["timeout", "timeoutNoAlloc", "mutationObserver"];
84
90
  type ValidTypingMethod = (typeof validTypingMethods)[number];
@@ -25,6 +25,7 @@ interface BasicResourceTiming {
25
25
  type: string;
26
26
  workerStart: number;
27
27
  fetchStart: number;
28
+ count?: number;
28
29
  }
29
30
  interface CacheableResourceTiming extends BasicResourceTiming {
30
31
  transferType: string;
@@ -1,4 +1,4 @@
1
- import type { InteractionMetrics } from '../common';
1
+ import type { InteractionMetrics, InteractionType } from '../common';
2
2
  export interface AdditionalData {
3
3
  [key: string]: null | undefined | string | number | boolean | undefined | AdditionalData | Record<string, AdditionalData> | Array<AdditionalData>;
4
4
  }
@@ -24,6 +24,9 @@ type SelectorConfig = {
24
24
  className: boolean;
25
25
  dataVC?: boolean;
26
26
  };
27
+ type Rates = {
28
+ readonly [key: string]: number;
29
+ };
27
30
  export type Config = {
28
31
  readonly enabled?: boolean;
29
32
  readonly doNotAbortActivePressInteraction?: string[];
@@ -32,9 +35,7 @@ export type Config = {
32
35
  readonly ufoNameOverrides?: UFONameOverride;
33
36
  readonly namePrefix?: string;
34
37
  readonly segmentPrefix?: string;
35
- readonly rates?: {
36
- readonly [key: string]: number;
37
- };
38
+ readonly rates?: Rates;
38
39
  readonly rules?: readonly {
39
40
  readonly test?: string;
40
41
  readonly rate?: number;
@@ -66,7 +67,11 @@ export type Config = {
66
67
  readonly ssr?: boolean;
67
68
  readonly stopVCAtInteractionFinish?: boolean;
68
69
  };
69
- readonly captureLateReRenders?: boolean;
70
+ readonly postInteractionLog?: {
71
+ readonly enabled?: boolean;
72
+ readonly rates?: Rates;
73
+ readonly kind?: Record<InteractionType, number>;
74
+ };
70
75
  readonly enableSegmentHighlighting?: boolean;
71
76
  readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
72
77
  readonly timeWindowForLateMutationsInMilliseconds?: number;
@@ -79,6 +84,7 @@ export type Config = {
79
84
  export declare function setUFOConfig(newConfig: Config): void;
80
85
  export declare function getConfig(): Config | undefined;
81
86
  export declare function getInteractionRate(name: string, interactionKind: InteractionKind): number;
87
+ export declare function getPostInteractionRate(name: string, interactionType: InteractionType): number;
82
88
  export declare function getCapabilityRate(capability: Capability): number;
83
89
  declare const validTypingMethods: readonly [
84
90
  "timeout",
@@ -25,6 +25,7 @@ interface BasicResourceTiming {
25
25
  type: string;
26
26
  workerStart: number;
27
27
  fetchStart: number;
28
+ count?: number;
28
29
  }
29
30
  interface CacheableResourceTiming extends BasicResourceTiming {
30
31
  transferType: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",