@atlaskit/react-ufo 4.1.2 → 4.1.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#191244](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191244)
8
+ [`2d701ec4a7166`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2d701ec4a7166) -
9
+ fix name values used for post-interaction-log rate limiting
10
+
11
+ ## 4.1.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#190712](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/190712)
16
+ [`20c54200a3179`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20c54200a3179) -
17
+ Stop the post interaction observer properly
18
+
3
19
  ## 4.1.2
4
20
 
5
21
  ### Patch Changes
@@ -731,11 +731,12 @@ function callCancelCallbacks(interaction) {
731
731
  function abort(interactionId, abortReason) {
732
732
  var interaction = _constants.interactions.get(interactionId);
733
733
  if (interaction != null) {
734
- var _getConfig0;
735
734
  callCancelCallbacks(interaction);
736
735
  interaction.abortReason = abortReason;
737
736
  finishInteraction(interactionId, interaction);
738
- if ((_getConfig0 = (0, _config.getConfig)()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
737
+ postInteractionLog.reset();
738
+ postInteractionLog.stopVCObserver();
739
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
739
740
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
740
741
  remove(interactionId);
741
742
  }
@@ -744,12 +745,13 @@ function abort(interactionId, abortReason) {
744
745
  function abortByNewInteraction(interactionId, interactionName) {
745
746
  var interaction = _constants.interactions.get(interactionId);
746
747
  if (interaction != null) {
747
- var _getConfig1;
748
748
  callCancelCallbacks(interaction);
749
749
  interaction.abortReason = 'new_interaction';
750
750
  interaction.abortedByInteractionName = interactionName;
751
751
  finishInteraction(interactionId, interaction);
752
- if ((_getConfig1 = (0, _config.getConfig)()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
752
+ postInteractionLog.reset();
753
+ postInteractionLog.stopVCObserver();
754
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
753
755
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
754
756
  remove(interactionId);
755
757
  }
@@ -757,7 +759,6 @@ function abortByNewInteraction(interactionId, interactionName) {
757
759
  }
758
760
  function abortAll(abortReason, abortedByInteractionName) {
759
761
  _constants.interactions.forEach(function (interaction, interactionId) {
760
- var _getConfig10;
761
762
  var noMoreHolds = interaction.holdActive.size === 0;
762
763
  if (!noMoreHolds) {
763
764
  callCancelCallbacks(interaction);
@@ -767,7 +768,9 @@ function abortAll(abortReason, abortedByInteractionName) {
767
768
  }
768
769
  }
769
770
  finishInteraction(interactionId, interaction);
770
- if ((_getConfig10 = (0, _config.getConfig)()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
771
+ postInteractionLog.reset();
772
+ postInteractionLog.stopVCObserver();
773
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
771
774
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
772
775
  remove(interactionId);
773
776
  }
@@ -778,9 +781,8 @@ function addOnCancelCallback(id, cancelCallback) {
778
781
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
779
782
  }
780
783
  function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
781
- var _getConfig11;
782
784
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
783
- if ((_getConfig11 = (0, _config.getConfig)()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
785
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
784
786
  postInteractionLog.reset();
785
787
  }
786
788
  var vcObserver;
@@ -892,20 +894,23 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
892
894
  addHoldByID(interactionId, [], ufoName, ufoName, true);
893
895
  }
894
896
  if (type === 'transition' || type === 'page_load') {
895
- var _getConfig12;
896
897
  // Use per-interaction VC observer if available, otherwise fall back to global
897
898
  var observer = vcObserver || (0, _vc.getVCObserver)();
898
899
  observer.start({
899
900
  startTime: startTime,
900
901
  experienceKey: ufoName
901
902
  });
902
- postInteractionLog.startVCObserver({
903
- startTime: startTime
904
- });
905
- if ((_getConfig12 = (0, _config.getConfig)()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.experimentalInteractionMetrics) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
906
- _createExperimentalInteractionMetricsPayload.experimentalVC.start({
907
- startTime: startTime
908
- });
903
+ if (type === 'transition' || (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction')) {
904
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
905
+ postInteractionLog.startVCObserver({
906
+ startTime: startTime
907
+ });
908
+ }
909
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(ufoName, type))) {
910
+ _createExperimentalInteractionMetricsPayload.experimentalVC.start({
911
+ startTime: startTime
912
+ });
913
+ }
909
914
  }
910
915
  }
911
916
  if (type === 'press' && (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_press_interactions')) {
@@ -56,6 +56,12 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
56
56
  startTime: startTime
57
57
  });
58
58
  }
59
+ }, {
60
+ key: "stopVCObserver",
61
+ value: function stopVCObserver() {
62
+ var _this$vcObserver2;
63
+ (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 || _this$vcObserver2.stop();
64
+ }
59
65
  }, {
60
66
  key: "setVCObserverSSRConfig",
61
67
  value: function setVCObserverSSRConfig(vcObserverSSRConfig) {
@@ -114,8 +120,8 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
114
120
  key: "sendPostInteractionLog",
115
121
  value: (function () {
116
122
  var _sendPostInteractionLog = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
117
- var _this$vcObserver3, _getConfig2;
118
- var _getConfig, _this$vcObserver2, postInteractionFinishVCResult, _this$vcObserver4;
123
+ var _this$vcObserver4, _this$vcObserver5;
124
+ var _this$vcObserver3, postInteractionFinishVCResult;
119
125
  return _regenerator.default.wrap(function _callee$(_context) {
120
126
  while (1) switch (_context.prev = _context.next) {
121
127
  case 0:
@@ -124,13 +130,11 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
124
130
  break;
125
131
  }
126
132
  this.reset();
127
- if ((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.experimentalInteractionMetrics) !== null && _getConfig !== void 0 && _getConfig.enabled) {
128
- (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 || _this$vcObserver2.stop();
129
- }
133
+ (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 || _this$vcObserver3.stop();
130
134
  return _context.abrupt("return");
131
135
  case 4:
132
136
  _context.next = 6;
133
- return (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.getVCResult(_objectSpread(_objectSpread({
137
+ return (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult(_objectSpread(_objectSpread({
134
138
  start: this.lastInteractionFinish.start,
135
139
  stop: performance.now(),
136
140
  tti: -1,
@@ -142,9 +146,7 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
142
146
  }));
143
147
  case 6:
144
148
  postInteractionFinishVCResult = _context.sent;
145
- if ((_getConfig2 = (0, _config.getConfig)()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled) {
146
- (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 || _this$vcObserver4.stop();
147
- }
149
+ (_this$vcObserver5 = this.vcObserver) === null || _this$vcObserver5 === void 0 || _this$vcObserver5.stop();
148
150
  this.sinkHandlerFn({
149
151
  lastInteractionFinish: this.lastInteractionFinish,
150
152
  reactProfilerTimings: this.reactProfilerTimings,
@@ -172,7 +174,7 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
172
174
  }, {
173
175
  key: "onInteractionComplete",
174
176
  value: function onInteractionComplete(_ref2) {
175
- var _getConfig3,
177
+ var _getConfig,
176
178
  _this = this;
177
179
  var ufoName = _ref2.ufoName,
178
180
  start = _ref2.start,
@@ -198,7 +200,7 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
198
200
  experimentalVC90: experimentalVC90,
199
201
  errors: errors
200
202
  };
201
- var timeout = ((_getConfig3 = (0, _config.getConfig)()) === null || _getConfig3 === void 0 ? void 0 : _getConfig3.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
203
+ var timeout = ((_getConfig = (0, _config.getConfig)()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
202
204
  this.sinkTimeoutId = window.setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
203
205
  return _regenerator.default.wrap(function _callee2$(_context2) {
204
206
  while (1) switch (_context2.prev = _context2.next) {
@@ -99,20 +99,23 @@ function init(analyticsWebClientAsync, config) {
99
99
  ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
100
100
  disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
101
101
  };
102
- if (!(0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction')) {
103
- (0, _vc.getVCObserver)(vcOptions).start({
104
- startTime: 0
105
- });
106
- }
107
102
  _interactionMetrics.postInteractionLog.initializeVCObserver(vcOptions);
108
- _interactionMetrics.postInteractionLog.startVCObserver({
109
- startTime: 0
110
- });
111
103
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
112
104
  _createExperimentalInteractionMetricsPayload.experimentalVC.initialize(vcOptions).start({
113
105
  startTime: 0
114
106
  });
115
107
  }
108
+ if (!(0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction')) {
109
+ var _config$postInteracti;
110
+ (0, _vc.getVCObserver)(vcOptions).start({
111
+ startTime: 0
112
+ });
113
+ if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
114
+ _interactionMetrics.postInteractionLog.startVCObserver({
115
+ startTime: 0
116
+ });
117
+ }
118
+ }
116
119
  }
117
120
  (0, _hiddenTiming.setupHiddenTimingCapture)();
118
121
  (0, _additionalPayload.startLighthouseObserver)();
@@ -138,23 +141,23 @@ function init(analyticsWebClientAsync, config) {
138
141
  createPostInteractionLogPayloadPackage = _ref2[2];
139
142
  if (awc.getAnalyticsWebClientPromise) {
140
143
  awc.getAnalyticsWebClientPromise().then(function (client) {
141
- var _config$experimentalI2, _config$postInteracti;
144
+ var _config$experimentalI2, _config$postInteracti2;
142
145
  var instance = client.getInstance();
143
146
  sinkInteraction(instance, payloadPackage);
144
147
  if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
145
148
  sinkExperimentalInteractionMetrics(instance, payloadPackage);
146
149
  }
147
- if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
150
+ if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
148
151
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
149
152
  }
150
153
  });
151
154
  } else if (awc.sendOperationalEvent) {
152
- var _config$experimentalI3, _config$postInteracti2;
155
+ var _config$experimentalI3, _config$postInteracti3;
153
156
  sinkInteraction(awc, payloadPackage);
154
157
  if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
155
158
  sinkExperimentalInteractionMetrics(awc, payloadPackage);
156
159
  }
157
- if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
160
+ if ((_config$postInteracti3 = config.postInteractionLog) !== null && _config$postInteracti3 !== void 0 && _config$postInteracti3.enabled) {
158
161
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
159
162
  }
160
163
  }
@@ -1,7 +1,7 @@
1
1
  import { v4 as createUUID } from 'uuid';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import coinflip from '../coinflip';
4
- import { getAwaitBM3TTIList, getCapabilityRate, getConfig, getInteractionTimeout } from '../config';
4
+ import { getAwaitBM3TTIList, getCapabilityRate, getConfig, getExperimentalInteractionRate, getInteractionTimeout, getPostInteractionRate } from '../config';
5
5
  import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComplete } from '../create-experimental-interaction-metrics-payload';
6
6
  import { clearActiveTrace } from '../experience-trace-id-context';
7
7
  import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
@@ -607,11 +607,12 @@ function callCancelCallbacks(interaction) {
607
607
  export function abort(interactionId, abortReason) {
608
608
  const interaction = interactions.get(interactionId);
609
609
  if (interaction != null) {
610
- var _getConfig0, _getConfig0$experimen;
611
610
  callCancelCallbacks(interaction);
612
611
  interaction.abortReason = abortReason;
613
612
  finishInteraction(interactionId, interaction);
614
- if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0$experimen = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0$experimen !== void 0 && _getConfig0$experimen.enabled) {
613
+ postInteractionLog.reset();
614
+ postInteractionLog.stopVCObserver();
615
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
615
616
  onExperimentalInteractionComplete(interactionId, interaction);
616
617
  remove(interactionId);
617
618
  }
@@ -620,12 +621,13 @@ export function abort(interactionId, abortReason) {
620
621
  export function abortByNewInteraction(interactionId, interactionName) {
621
622
  const interaction = interactions.get(interactionId);
622
623
  if (interaction != null) {
623
- var _getConfig1, _getConfig1$experimen;
624
624
  callCancelCallbacks(interaction);
625
625
  interaction.abortReason = 'new_interaction';
626
626
  interaction.abortedByInteractionName = interactionName;
627
627
  finishInteraction(interactionId, interaction);
628
- if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1$experimen = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1$experimen !== void 0 && _getConfig1$experimen.enabled) {
628
+ postInteractionLog.reset();
629
+ postInteractionLog.stopVCObserver();
630
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
629
631
  onExperimentalInteractionComplete(interactionId, interaction);
630
632
  remove(interactionId);
631
633
  }
@@ -633,7 +635,6 @@ export function abortByNewInteraction(interactionId, interactionName) {
633
635
  }
634
636
  export function abortAll(abortReason, abortedByInteractionName) {
635
637
  interactions.forEach((interaction, interactionId) => {
636
- var _getConfig10, _getConfig10$experime;
637
638
  const noMoreHolds = interaction.holdActive.size === 0;
638
639
  if (!noMoreHolds) {
639
640
  callCancelCallbacks(interaction);
@@ -643,7 +644,9 @@ export function abortAll(abortReason, abortedByInteractionName) {
643
644
  }
644
645
  }
645
646
  finishInteraction(interactionId, interaction);
646
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10$experime = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10$experime !== void 0 && _getConfig10$experime.enabled) {
647
+ postInteractionLog.reset();
648
+ postInteractionLog.stopVCObserver();
649
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
647
650
  onExperimentalInteractionComplete(interactionId, interaction);
648
651
  remove(interactionId);
649
652
  }
@@ -654,8 +657,7 @@ export function addOnCancelCallback(id, cancelCallback) {
654
657
  interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
655
658
  }
656
659
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName, trace = null) {
657
- var _getConfig11, _getConfig11$postInte;
658
- if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11$postInte = _getConfig11.postInteractionLog) !== null && _getConfig11$postInte !== void 0 && _getConfig11$postInte.enabled) {
660
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
659
661
  postInteractionLog.reset();
660
662
  }
661
663
  let vcObserver;
@@ -767,20 +769,23 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
767
769
  addHoldByID(interactionId, [], ufoName, ufoName, true);
768
770
  }
769
771
  if (type === 'transition' || type === 'page_load') {
770
- var _getConfig12, _getConfig12$experime;
771
772
  // Use per-interaction VC observer if available, otherwise fall back to global
772
773
  const observer = vcObserver || getVCObserver();
773
774
  observer.start({
774
775
  startTime,
775
776
  experienceKey: ufoName
776
777
  });
777
- postInteractionLog.startVCObserver({
778
- startTime
779
- });
780
- if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12$experime = _getConfig12.experimentalInteractionMetrics) !== null && _getConfig12$experime !== void 0 && _getConfig12$experime.enabled) {
781
- experimentalVC.start({
782
- startTime
783
- });
778
+ if (type === 'transition' || fg('platform_ufo_enable_vc_observer_per_interaction')) {
779
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
780
+ postInteractionLog.startVCObserver({
781
+ startTime
782
+ });
783
+ }
784
+ if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
785
+ experimentalVC.start({
786
+ startTime
787
+ });
788
+ }
784
789
  }
785
790
  }
786
791
  if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
@@ -40,6 +40,10 @@ export default class PostInteractionLog {
40
40
  startTime
41
41
  });
42
42
  }
43
+ stopVCObserver() {
44
+ var _this$vcObserver2;
45
+ (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 ? void 0 : _this$vcObserver2.stop();
46
+ }
43
47
  setVCObserverSSRConfig(vcObserverSSRConfig) {
44
48
  this.vcObserverSSRConfig = vcObserverSSRConfig;
45
49
  }
@@ -84,17 +88,14 @@ export default class PostInteractionLog {
84
88
  * Send the log if there is data
85
89
  */
86
90
  async sendPostInteractionLog() {
87
- var _this$vcObserver3, _getConfig2, _getConfig2$experimen;
91
+ var _this$vcObserver4, _this$vcObserver5;
88
92
  if (!this.hasData() || !this.lastInteractionFinish || !this.sinkHandlerFn) {
89
- var _getConfig, _getConfig$experiment;
93
+ var _this$vcObserver3;
90
94
  this.reset();
91
- if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig$experiment = _getConfig.experimentalInteractionMetrics) !== null && _getConfig$experiment !== void 0 && _getConfig$experiment.enabled) {
92
- var _this$vcObserver2;
93
- (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 ? void 0 : _this$vcObserver2.stop();
94
- }
95
+ (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.stop();
95
96
  return;
96
97
  }
97
- const postInteractionFinishVCResult = await ((_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.getVCResult({
98
+ const postInteractionFinishVCResult = await ((_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult({
98
99
  start: this.lastInteractionFinish.start,
99
100
  stop: performance.now(),
100
101
  tti: -1,
@@ -104,10 +105,7 @@ export default class PostInteractionLog {
104
105
  ...this.vcObserverSSRConfig,
105
106
  experienceKey: this.lastInteractionFinish.ufoName
106
107
  }));
107
- if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2$experimen = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2$experimen !== void 0 && _getConfig2$experimen.enabled) {
108
- var _this$vcObserver4;
109
- (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.stop();
110
- }
108
+ (_this$vcObserver5 = this.vcObserver) === null || _this$vcObserver5 === void 0 ? void 0 : _this$vcObserver5.stop();
111
109
  this.sinkHandlerFn({
112
110
  lastInteractionFinish: this.lastInteractionFinish,
113
111
  reactProfilerTimings: this.reactProfilerTimings,
@@ -135,7 +133,7 @@ export default class PostInteractionLog {
135
133
  experimentalVC90,
136
134
  errors
137
135
  }) {
138
- var _getConfig3;
136
+ var _getConfig;
139
137
  this.lastInteractionFinish = {
140
138
  ufoName,
141
139
  start,
@@ -149,7 +147,7 @@ export default class PostInteractionLog {
149
147
  experimentalVC90,
150
148
  errors
151
149
  };
152
- const timeout = ((_getConfig3 = getConfig()) === null || _getConfig3 === void 0 ? void 0 : _getConfig3.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
150
+ const timeout = ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
153
151
  this.sinkTimeoutId = window.setTimeout(async () => {
154
152
  await this.sendPostInteractionLog();
155
153
  }, timeout);
@@ -89,20 +89,23 @@ export function init(analyticsWebClientAsync, config) {
89
89
  ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
90
90
  disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
91
91
  };
92
- if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
93
- getVCObserver(vcOptions).start({
94
- startTime: 0
95
- });
96
- }
97
92
  postInteractionLog.initializeVCObserver(vcOptions);
98
- postInteractionLog.startVCObserver({
99
- startTime: 0
100
- });
101
93
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
102
94
  experimentalVC.initialize(vcOptions).start({
103
95
  startTime: 0
104
96
  });
105
97
  }
98
+ if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
99
+ var _config$postInteracti;
100
+ getVCObserver(vcOptions).start({
101
+ startTime: 0
102
+ });
103
+ if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
104
+ postInteractionLog.startVCObserver({
105
+ startTime: 0
106
+ });
107
+ }
108
+ }
106
109
  }
107
110
  setupHiddenTimingCapture();
108
111
  startLighthouseObserver();
@@ -120,23 +123,23 @@ export function init(analyticsWebClientAsync, config) {
120
123
  Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage]) => {
121
124
  if (awc.getAnalyticsWebClientPromise) {
122
125
  awc.getAnalyticsWebClientPromise().then(client => {
123
- var _config$experimentalI2, _config$postInteracti;
126
+ var _config$experimentalI2, _config$postInteracti2;
124
127
  const instance = client.getInstance();
125
128
  sinkInteraction(instance, payloadPackage);
126
129
  if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
127
130
  sinkExperimentalInteractionMetrics(instance, payloadPackage);
128
131
  }
129
- if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
132
+ if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
130
133
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
131
134
  }
132
135
  });
133
136
  } else if (awc.sendOperationalEvent) {
134
- var _config$experimentalI3, _config$postInteracti2;
137
+ var _config$experimentalI3, _config$postInteracti3;
135
138
  sinkInteraction(awc, payloadPackage);
136
139
  if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
137
140
  sinkExperimentalInteractionMetrics(awc, payloadPackage);
138
141
  }
139
- if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
142
+ if ((_config$postInteracti3 = config.postInteractionLog) !== null && _config$postInteracti3 !== void 0 && _config$postInteracti3.enabled) {
140
143
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
141
144
  }
142
145
  }
@@ -11,7 +11,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
11
11
  import { v4 as createUUID } from 'uuid';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import coinflip from '../coinflip';
14
- import { getAwaitBM3TTIList, getCapabilityRate, getConfig, getInteractionTimeout } from '../config';
14
+ import { getAwaitBM3TTIList, getCapabilityRate, getConfig, getExperimentalInteractionRate, getInteractionTimeout, getPostInteractionRate } from '../config';
15
15
  import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComplete } from '../create-experimental-interaction-metrics-payload';
16
16
  import { clearActiveTrace } from '../experience-trace-id-context';
17
17
  import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
@@ -685,11 +685,12 @@ function callCancelCallbacks(interaction) {
685
685
  export function abort(interactionId, abortReason) {
686
686
  var interaction = interactions.get(interactionId);
687
687
  if (interaction != null) {
688
- var _getConfig0;
689
688
  callCancelCallbacks(interaction);
690
689
  interaction.abortReason = abortReason;
691
690
  finishInteraction(interactionId, interaction);
692
- if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
691
+ postInteractionLog.reset();
692
+ postInteractionLog.stopVCObserver();
693
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
693
694
  onExperimentalInteractionComplete(interactionId, interaction);
694
695
  remove(interactionId);
695
696
  }
@@ -698,12 +699,13 @@ export function abort(interactionId, abortReason) {
698
699
  export function abortByNewInteraction(interactionId, interactionName) {
699
700
  var interaction = interactions.get(interactionId);
700
701
  if (interaction != null) {
701
- var _getConfig1;
702
702
  callCancelCallbacks(interaction);
703
703
  interaction.abortReason = 'new_interaction';
704
704
  interaction.abortedByInteractionName = interactionName;
705
705
  finishInteraction(interactionId, interaction);
706
- if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
706
+ postInteractionLog.reset();
707
+ postInteractionLog.stopVCObserver();
708
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
707
709
  onExperimentalInteractionComplete(interactionId, interaction);
708
710
  remove(interactionId);
709
711
  }
@@ -711,7 +713,6 @@ export function abortByNewInteraction(interactionId, interactionName) {
711
713
  }
712
714
  export function abortAll(abortReason, abortedByInteractionName) {
713
715
  interactions.forEach(function (interaction, interactionId) {
714
- var _getConfig10;
715
716
  var noMoreHolds = interaction.holdActive.size === 0;
716
717
  if (!noMoreHolds) {
717
718
  callCancelCallbacks(interaction);
@@ -721,7 +722,9 @@ export function abortAll(abortReason, abortedByInteractionName) {
721
722
  }
722
723
  }
723
724
  finishInteraction(interactionId, interaction);
724
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
725
+ postInteractionLog.reset();
726
+ postInteractionLog.stopVCObserver();
727
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
725
728
  onExperimentalInteractionComplete(interactionId, interaction);
726
729
  remove(interactionId);
727
730
  }
@@ -732,9 +735,8 @@ export function addOnCancelCallback(id, cancelCallback) {
732
735
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
733
736
  }
734
737
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
735
- var _getConfig11;
736
738
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
737
- if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
739
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
738
740
  postInteractionLog.reset();
739
741
  }
740
742
  var vcObserver;
@@ -846,20 +848,23 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
846
848
  addHoldByID(interactionId, [], ufoName, ufoName, true);
847
849
  }
848
850
  if (type === 'transition' || type === 'page_load') {
849
- var _getConfig12;
850
851
  // Use per-interaction VC observer if available, otherwise fall back to global
851
852
  var observer = vcObserver || getVCObserver();
852
853
  observer.start({
853
854
  startTime: startTime,
854
855
  experienceKey: ufoName
855
856
  });
856
- postInteractionLog.startVCObserver({
857
- startTime: startTime
858
- });
859
- if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.experimentalInteractionMetrics) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
860
- experimentalVC.start({
861
- startTime: startTime
862
- });
857
+ if (type === 'transition' || fg('platform_ufo_enable_vc_observer_per_interaction')) {
858
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
859
+ postInteractionLog.startVCObserver({
860
+ startTime: startTime
861
+ });
862
+ }
863
+ if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
864
+ experimentalVC.start({
865
+ startTime: startTime
866
+ });
867
+ }
863
868
  }
864
869
  }
865
870
  if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
@@ -49,6 +49,12 @@ var PostInteractionLog = /*#__PURE__*/function () {
49
49
  startTime: startTime
50
50
  });
51
51
  }
52
+ }, {
53
+ key: "stopVCObserver",
54
+ value: function stopVCObserver() {
55
+ var _this$vcObserver2;
56
+ (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 || _this$vcObserver2.stop();
57
+ }
52
58
  }, {
53
59
  key: "setVCObserverSSRConfig",
54
60
  value: function setVCObserverSSRConfig(vcObserverSSRConfig) {
@@ -107,8 +113,8 @@ var PostInteractionLog = /*#__PURE__*/function () {
107
113
  key: "sendPostInteractionLog",
108
114
  value: (function () {
109
115
  var _sendPostInteractionLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
110
- var _this$vcObserver3, _getConfig2;
111
- var _getConfig, _this$vcObserver2, postInteractionFinishVCResult, _this$vcObserver4;
116
+ var _this$vcObserver4, _this$vcObserver5;
117
+ var _this$vcObserver3, postInteractionFinishVCResult;
112
118
  return _regeneratorRuntime.wrap(function _callee$(_context) {
113
119
  while (1) switch (_context.prev = _context.next) {
114
120
  case 0:
@@ -117,13 +123,11 @@ var PostInteractionLog = /*#__PURE__*/function () {
117
123
  break;
118
124
  }
119
125
  this.reset();
120
- if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.experimentalInteractionMetrics) !== null && _getConfig !== void 0 && _getConfig.enabled) {
121
- (_this$vcObserver2 = this.vcObserver) === null || _this$vcObserver2 === void 0 || _this$vcObserver2.stop();
122
- }
126
+ (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 || _this$vcObserver3.stop();
123
127
  return _context.abrupt("return");
124
128
  case 4:
125
129
  _context.next = 6;
126
- return (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.getVCResult(_objectSpread(_objectSpread({
130
+ return (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult(_objectSpread(_objectSpread({
127
131
  start: this.lastInteractionFinish.start,
128
132
  stop: performance.now(),
129
133
  tti: -1,
@@ -135,9 +139,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
135
139
  }));
136
140
  case 6:
137
141
  postInteractionFinishVCResult = _context.sent;
138
- if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled) {
139
- (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 || _this$vcObserver4.stop();
140
- }
142
+ (_this$vcObserver5 = this.vcObserver) === null || _this$vcObserver5 === void 0 || _this$vcObserver5.stop();
141
143
  this.sinkHandlerFn({
142
144
  lastInteractionFinish: this.lastInteractionFinish,
143
145
  reactProfilerTimings: this.reactProfilerTimings,
@@ -165,7 +167,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
165
167
  }, {
166
168
  key: "onInteractionComplete",
167
169
  value: function onInteractionComplete(_ref2) {
168
- var _getConfig3,
170
+ var _getConfig,
169
171
  _this = this;
170
172
  var ufoName = _ref2.ufoName,
171
173
  start = _ref2.start,
@@ -191,7 +193,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
191
193
  experimentalVC90: experimentalVC90,
192
194
  errors: errors
193
195
  };
194
- var timeout = ((_getConfig3 = getConfig()) === null || _getConfig3 === void 0 ? void 0 : _getConfig3.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
196
+ var timeout = ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.timeWindowForLateMutationsInMilliseconds) || POST_INTERACTION_LOG_SEND_DEFAULT_TIMEOUT;
195
197
  this.sinkTimeoutId = window.setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
196
198
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
197
199
  while (1) switch (_context2.prev = _context2.next) {
@@ -90,20 +90,23 @@ export function init(analyticsWebClientAsync, config) {
90
90
  ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
91
91
  disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
92
92
  };
93
- if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
94
- getVCObserver(vcOptions).start({
95
- startTime: 0
96
- });
97
- }
98
93
  postInteractionLog.initializeVCObserver(vcOptions);
99
- postInteractionLog.startVCObserver({
100
- startTime: 0
101
- });
102
94
  if (config !== null && config !== void 0 && (_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
103
95
  experimentalVC.initialize(vcOptions).start({
104
96
  startTime: 0
105
97
  });
106
98
  }
99
+ if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
100
+ var _config$postInteracti;
101
+ getVCObserver(vcOptions).start({
102
+ startTime: 0
103
+ });
104
+ if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
105
+ postInteractionLog.startVCObserver({
106
+ startTime: 0
107
+ });
108
+ }
109
+ }
107
110
  }
108
111
  setupHiddenTimingCapture();
109
112
  startLighthouseObserver();
@@ -125,23 +128,23 @@ export function init(analyticsWebClientAsync, config) {
125
128
  createPostInteractionLogPayloadPackage = _ref2[2];
126
129
  if (awc.getAnalyticsWebClientPromise) {
127
130
  awc.getAnalyticsWebClientPromise().then(function (client) {
128
- var _config$experimentalI2, _config$postInteracti;
131
+ var _config$experimentalI2, _config$postInteracti2;
129
132
  var instance = client.getInstance();
130
133
  sinkInteraction(instance, payloadPackage);
131
134
  if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
132
135
  sinkExperimentalInteractionMetrics(instance, payloadPackage);
133
136
  }
134
- if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
137
+ if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
135
138
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
136
139
  }
137
140
  });
138
141
  } else if (awc.sendOperationalEvent) {
139
- var _config$experimentalI3, _config$postInteracti2;
142
+ var _config$experimentalI3, _config$postInteracti3;
140
143
  sinkInteraction(awc, payloadPackage);
141
144
  if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
142
145
  sinkExperimentalInteractionMetrics(awc, payloadPackage);
143
146
  }
144
- if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
147
+ if ((_config$postInteracti3 = config.postInteractionLog) !== null && _config$postInteracti3 !== void 0 && _config$postInteracti3.enabled) {
145
148
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
146
149
  }
147
150
  }
@@ -27,6 +27,7 @@ export default class PostInteractionLog {
27
27
  startVCObserver({ startTime }: {
28
28
  startTime: number;
29
29
  }): void;
30
+ stopVCObserver(): void;
30
31
  setVCObserverSSRConfig(vcObserverSSRConfig: {
31
32
  ssr: number | undefined;
32
33
  } | null): void;
@@ -27,6 +27,7 @@ export default class PostInteractionLog {
27
27
  startVCObserver({ startTime }: {
28
28
  startTime: number;
29
29
  }): void;
30
+ stopVCObserver(): void;
30
31
  setVCObserverSSRConfig(vcObserverSSRConfig: {
31
32
  ssr: number | undefined;
32
33
  } | null): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.1.2",
3
+ "version": "4.1.4",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",