@atlaskit/react-ufo 4.1.2 → 4.1.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.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#190712](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/190712)
8
+ [`20c54200a3179`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20c54200a3179) -
9
+ Stop the post interaction observer properly
10
+
3
11
  ## 4.1.2
4
12
 
5
13
  ### Patch Changes
@@ -731,11 +731,14 @@ 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
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(interaction.ufoName, interaction.type))) {
738
+ postInteractionLog.reset();
739
+ postInteractionLog.stopVCObserver();
740
+ }
741
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
739
742
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
740
743
  remove(interactionId);
741
744
  }
@@ -744,12 +747,15 @@ function abort(interactionId, abortReason) {
744
747
  function abortByNewInteraction(interactionId, interactionName) {
745
748
  var interaction = _constants.interactions.get(interactionId);
746
749
  if (interaction != null) {
747
- var _getConfig1;
748
750
  callCancelCallbacks(interaction);
749
751
  interaction.abortReason = 'new_interaction';
750
752
  interaction.abortedByInteractionName = interactionName;
751
753
  finishInteraction(interactionId, interaction);
752
- if ((_getConfig1 = (0, _config.getConfig)()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
754
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(interaction.ufoName, interaction.type))) {
755
+ postInteractionLog.reset();
756
+ postInteractionLog.stopVCObserver();
757
+ }
758
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
753
759
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
754
760
  remove(interactionId);
755
761
  }
@@ -757,7 +763,6 @@ function abortByNewInteraction(interactionId, interactionName) {
757
763
  }
758
764
  function abortAll(abortReason, abortedByInteractionName) {
759
765
  _constants.interactions.forEach(function (interaction, interactionId) {
760
- var _getConfig10;
761
766
  var noMoreHolds = interaction.holdActive.size === 0;
762
767
  if (!noMoreHolds) {
763
768
  callCancelCallbacks(interaction);
@@ -767,7 +772,11 @@ function abortAll(abortReason, abortedByInteractionName) {
767
772
  }
768
773
  }
769
774
  finishInteraction(interactionId, interaction);
770
- if ((_getConfig10 = (0, _config.getConfig)()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
775
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(interaction.ufoName, interaction.type))) {
776
+ postInteractionLog.reset();
777
+ postInteractionLog.stopVCObserver();
778
+ }
779
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
771
780
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
772
781
  remove(interactionId);
773
782
  }
@@ -778,9 +787,8 @@ function addOnCancelCallback(id, cancelCallback) {
778
787
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
779
788
  }
780
789
  function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
781
- var _getConfig11;
782
790
  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) {
791
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(ufoName, type))) {
784
792
  postInteractionLog.reset();
785
793
  }
786
794
  var vcObserver;
@@ -892,20 +900,23 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
892
900
  addHoldByID(interactionId, [], ufoName, ufoName, true);
893
901
  }
894
902
  if (type === 'transition' || type === 'page_load') {
895
- var _getConfig12;
896
903
  // Use per-interaction VC observer if available, otherwise fall back to global
897
904
  var observer = vcObserver || (0, _vc.getVCObserver)();
898
905
  observer.start({
899
906
  startTime: startTime,
900
907
  experienceKey: ufoName
901
908
  });
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
- });
909
+ if (type === 'transition' || (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction')) {
910
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(ufoName, type))) {
911
+ postInteractionLog.startVCObserver({
912
+ startTime: startTime
913
+ });
914
+ }
915
+ if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(ufoName, type))) {
916
+ _createExperimentalInteractionMetricsPayload.experimentalVC.start({
917
+ startTime: startTime
918
+ });
919
+ }
909
920
  }
910
921
  }
911
922
  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,14 @@ 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
+ if (coinflip(getPostInteractionRate(interaction.ufoName, interaction.type))) {
614
+ postInteractionLog.reset();
615
+ postInteractionLog.stopVCObserver();
616
+ }
617
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
615
618
  onExperimentalInteractionComplete(interactionId, interaction);
616
619
  remove(interactionId);
617
620
  }
@@ -620,12 +623,15 @@ export function abort(interactionId, abortReason) {
620
623
  export function abortByNewInteraction(interactionId, interactionName) {
621
624
  const interaction = interactions.get(interactionId);
622
625
  if (interaction != null) {
623
- var _getConfig1, _getConfig1$experimen;
624
626
  callCancelCallbacks(interaction);
625
627
  interaction.abortReason = 'new_interaction';
626
628
  interaction.abortedByInteractionName = interactionName;
627
629
  finishInteraction(interactionId, interaction);
628
- if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1$experimen = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1$experimen !== void 0 && _getConfig1$experimen.enabled) {
630
+ if (coinflip(getPostInteractionRate(interaction.ufoName, interaction.type))) {
631
+ postInteractionLog.reset();
632
+ postInteractionLog.stopVCObserver();
633
+ }
634
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
629
635
  onExperimentalInteractionComplete(interactionId, interaction);
630
636
  remove(interactionId);
631
637
  }
@@ -633,7 +639,6 @@ export function abortByNewInteraction(interactionId, interactionName) {
633
639
  }
634
640
  export function abortAll(abortReason, abortedByInteractionName) {
635
641
  interactions.forEach((interaction, interactionId) => {
636
- var _getConfig10, _getConfig10$experime;
637
642
  const noMoreHolds = interaction.holdActive.size === 0;
638
643
  if (!noMoreHolds) {
639
644
  callCancelCallbacks(interaction);
@@ -643,7 +648,11 @@ export function abortAll(abortReason, abortedByInteractionName) {
643
648
  }
644
649
  }
645
650
  finishInteraction(interactionId, interaction);
646
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10$experime = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10$experime !== void 0 && _getConfig10$experime.enabled) {
651
+ if (coinflip(getPostInteractionRate(interaction.ufoName, interaction.type))) {
652
+ postInteractionLog.reset();
653
+ postInteractionLog.stopVCObserver();
654
+ }
655
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
647
656
  onExperimentalInteractionComplete(interactionId, interaction);
648
657
  remove(interactionId);
649
658
  }
@@ -654,8 +663,7 @@ export function addOnCancelCallback(id, cancelCallback) {
654
663
  interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
655
664
  }
656
665
  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) {
666
+ if (coinflip(getPostInteractionRate(ufoName, type))) {
659
667
  postInteractionLog.reset();
660
668
  }
661
669
  let vcObserver;
@@ -767,20 +775,23 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
767
775
  addHoldByID(interactionId, [], ufoName, ufoName, true);
768
776
  }
769
777
  if (type === 'transition' || type === 'page_load') {
770
- var _getConfig12, _getConfig12$experime;
771
778
  // Use per-interaction VC observer if available, otherwise fall back to global
772
779
  const observer = vcObserver || getVCObserver();
773
780
  observer.start({
774
781
  startTime,
775
782
  experienceKey: ufoName
776
783
  });
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
- });
784
+ if (type === 'transition' || fg('platform_ufo_enable_vc_observer_per_interaction')) {
785
+ if (coinflip(getPostInteractionRate(ufoName, type))) {
786
+ postInteractionLog.startVCObserver({
787
+ startTime
788
+ });
789
+ }
790
+ if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
791
+ experimentalVC.start({
792
+ startTime
793
+ });
794
+ }
784
795
  }
785
796
  }
786
797
  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,14 @@ 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
+ if (coinflip(getPostInteractionRate(interaction.ufoName, interaction.type))) {
692
+ postInteractionLog.reset();
693
+ postInteractionLog.stopVCObserver();
694
+ }
695
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
693
696
  onExperimentalInteractionComplete(interactionId, interaction);
694
697
  remove(interactionId);
695
698
  }
@@ -698,12 +701,15 @@ export function abort(interactionId, abortReason) {
698
701
  export function abortByNewInteraction(interactionId, interactionName) {
699
702
  var interaction = interactions.get(interactionId);
700
703
  if (interaction != null) {
701
- var _getConfig1;
702
704
  callCancelCallbacks(interaction);
703
705
  interaction.abortReason = 'new_interaction';
704
706
  interaction.abortedByInteractionName = interactionName;
705
707
  finishInteraction(interactionId, interaction);
706
- if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
708
+ if (coinflip(getPostInteractionRate(interaction.ufoName, interaction.type))) {
709
+ postInteractionLog.reset();
710
+ postInteractionLog.stopVCObserver();
711
+ }
712
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
707
713
  onExperimentalInteractionComplete(interactionId, interaction);
708
714
  remove(interactionId);
709
715
  }
@@ -711,7 +717,6 @@ export function abortByNewInteraction(interactionId, interactionName) {
711
717
  }
712
718
  export function abortAll(abortReason, abortedByInteractionName) {
713
719
  interactions.forEach(function (interaction, interactionId) {
714
- var _getConfig10;
715
720
  var noMoreHolds = interaction.holdActive.size === 0;
716
721
  if (!noMoreHolds) {
717
722
  callCancelCallbacks(interaction);
@@ -721,7 +726,11 @@ export function abortAll(abortReason, abortedByInteractionName) {
721
726
  }
722
727
  }
723
728
  finishInteraction(interactionId, interaction);
724
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
729
+ if (coinflip(getPostInteractionRate(interaction.ufoName, interaction.type))) {
730
+ postInteractionLog.reset();
731
+ postInteractionLog.stopVCObserver();
732
+ }
733
+ if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
725
734
  onExperimentalInteractionComplete(interactionId, interaction);
726
735
  remove(interactionId);
727
736
  }
@@ -732,9 +741,8 @@ export function addOnCancelCallback(id, cancelCallback) {
732
741
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
733
742
  }
734
743
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
735
- var _getConfig11;
736
744
  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) {
745
+ if (coinflip(getPostInteractionRate(ufoName, type))) {
738
746
  postInteractionLog.reset();
739
747
  }
740
748
  var vcObserver;
@@ -846,20 +854,23 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
846
854
  addHoldByID(interactionId, [], ufoName, ufoName, true);
847
855
  }
848
856
  if (type === 'transition' || type === 'page_load') {
849
- var _getConfig12;
850
857
  // Use per-interaction VC observer if available, otherwise fall back to global
851
858
  var observer = vcObserver || getVCObserver();
852
859
  observer.start({
853
860
  startTime: startTime,
854
861
  experienceKey: ufoName
855
862
  });
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
- });
863
+ if (type === 'transition' || fg('platform_ufo_enable_vc_observer_per_interaction')) {
864
+ if (coinflip(getPostInteractionRate(ufoName, type))) {
865
+ postInteractionLog.startVCObserver({
866
+ startTime: startTime
867
+ });
868
+ }
869
+ if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
870
+ experimentalVC.start({
871
+ startTime: startTime
872
+ });
873
+ }
863
874
  }
864
875
  }
865
876
  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.3",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",