@atlaskit/react-ufo 4.1.11 → 4.1.12

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.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#195371](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195371)
8
+ [`928a3cc316c8f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/928a3cc316c8f) -
9
+ Fix post interaction log naming issue
10
+
3
11
  ## 4.1.11
4
12
 
5
13
  ### Patch Changes
@@ -54,6 +54,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
54
54
  var _coinflip = _interopRequireDefault(require("../coinflip"));
55
55
  var _config = require("../config");
56
56
  var _createExperimentalInteractionMetricsPayload = require("../create-experimental-interaction-metrics-payload");
57
+ var _utils = require("../create-payload/common/utils");
57
58
  var _experienceTraceIdContext = require("../experience-trace-id-context");
58
59
  var _featureFlagsAccessed = require("../feature-flags-accessed");
59
60
  var _interactionIdContext = require("../interaction-id-context");
@@ -653,6 +654,18 @@ function finishInteraction(id, data) {
653
654
  data.vc = observer.getVCRawData();
654
655
  }
655
656
  }
657
+
658
+ // By this time, stop the post interaction log observer if coinflip rate is 0
659
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_check_name')) {
660
+ var sanitisedUfoName = (0, _utils.sanitizeUfoName)(data.ufoName);
661
+ if (!(0, _coinflip.default)((0, _config.getPostInteractionRate)(sanitisedUfoName, data.type))) {
662
+ postInteractionLog.stopVCObserver();
663
+ }
664
+ } else {
665
+ if (!(0, _coinflip.default)((0, _config.getPostInteractionRate)(data.routeName || data.ufoName, data.type))) {
666
+ postInteractionLog.stopVCObserver();
667
+ }
668
+ }
656
669
  if (!((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
657
670
  remove(id);
658
671
  }
@@ -875,8 +888,12 @@ function addOnCancelCallback(id, cancelCallback) {
875
888
  }
876
889
  function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
877
890
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
878
- if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
891
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_check_name')) {
879
892
  postInteractionLog.reset();
893
+ } else {
894
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
895
+ postInteractionLog.reset();
896
+ }
880
897
  }
881
898
  var vcObserver;
882
899
  var previousTime = startTime;
@@ -995,10 +1012,21 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
995
1012
  experienceKey: ufoName
996
1013
  });
997
1014
  }
998
- if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
999
- postInteractionLog.startVCObserver({
1000
- startTime: startTime
1001
- });
1015
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_check_name')) {
1016
+ var _getConfig0;
1017
+ // Start post interaction observer for all if config is enabled
1018
+ // in case ufoName is updated at later time
1019
+ if ((_getConfig0 = (0, _config.getConfig)()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.postInteractionLog) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
1020
+ postInteractionLog.startVCObserver({
1021
+ startTime: startTime
1022
+ });
1023
+ }
1024
+ } else {
1025
+ if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
1026
+ postInteractionLog.startVCObserver({
1027
+ startTime: startTime
1028
+ });
1029
+ }
1002
1030
  }
1003
1031
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(ufoName, type))) {
1004
1032
  _createExperimentalInteractionMetricsPayload.experimentalVC.start({
@@ -120,8 +120,8 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
120
120
  key: "sendPostInteractionLog",
121
121
  value: (function () {
122
122
  var _sendPostInteractionLog = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
123
- var _this$vcObserver4, _this$vcObserver5;
124
- var _this$vcObserver3, postInteractionFinishVCResult;
123
+ var _this$vcObserver4, _config$vc, _config$vc2, _this$vcObserver5;
124
+ var _this$vcObserver3, config, postInteractionFinishVCResult;
125
125
  return _regenerator.default.wrap(function _callee$(_context) {
126
126
  while (1) switch (_context.prev = _context.next) {
127
127
  case 0:
@@ -133,18 +133,21 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
133
133
  (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 || _this$vcObserver3.stop();
134
134
  return _context.abrupt("return");
135
135
  case 4:
136
- _context.next = 6;
137
- return (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult(_objectSpread(_objectSpread({
136
+ config = (0, _config.getConfig)();
137
+ _context.next = 7;
138
+ return (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult(_objectSpread({
138
139
  start: this.lastInteractionFinish.start,
139
140
  stop: performance.now(),
140
141
  tti: -1,
141
142
  // no need for TTI value here
142
143
  isEventAborted: !!this.lastInteractionFinish.abortReason,
143
- prefix: 'ufo'
144
- }, this.vcObserverSSRConfig), {}, {
145
- experienceKey: this.lastInteractionFinish.ufoName
146
- }));
147
- case 6:
144
+ prefix: 'ufo',
145
+ experienceKey: this.lastInteractionFinish.ufoName,
146
+ interactionId: this.lastInteractionFinish.id,
147
+ includeSSRInV3: config === null || config === void 0 || (_config$vc = config.vc) === null || _config$vc === void 0 ? void 0 : _config$vc.includeSSRInV3,
148
+ includeSSRRatio: config === null || config === void 0 || (_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.includeSSRRatio
149
+ }, this.vcObserverSSRConfig));
150
+ case 7:
148
151
  postInteractionFinishVCResult = _context.sent;
149
152
  (_this$vcObserver5 = this.vcObserver) === null || _this$vcObserver5 === void 0 || _this$vcObserver5.stop();
150
153
  this.sinkHandlerFn({
@@ -154,7 +157,7 @@ var PostInteractionLog = exports.default = /*#__PURE__*/function () {
154
157
  lastInteractionFinishVCResult: this.lastInteractionFinishVCResult
155
158
  });
156
159
  this.reset();
157
- case 10:
160
+ case 11:
158
161
  case "end":
159
162
  return _context.stop();
160
163
  }
@@ -3,6 +3,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import coinflip from '../coinflip';
4
4
  import { getAwaitBM3TTIList, getCapabilityRate, getConfig, getExperimentalInteractionRate, getInteractionTimeout, getPostInteractionRate } from '../config';
5
5
  import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComplete } from '../create-experimental-interaction-metrics-payload';
6
+ import { sanitizeUfoName } from '../create-payload/common/utils';
6
7
  import { clearActiveTrace } from '../experience-trace-id-context';
7
8
  import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
8
9
  import { getInteractionId } from '../interaction-id-context';
@@ -571,6 +572,18 @@ function finishInteraction(id, data, endTime = performance.now()) {
571
572
  data.vc = observer.getVCRawData();
572
573
  }
573
574
  }
575
+
576
+ // By this time, stop the post interaction log observer if coinflip rate is 0
577
+ if (fg('platform_ufo_post_interaction_check_name')) {
578
+ const sanitisedUfoName = sanitizeUfoName(data.ufoName);
579
+ if (!coinflip(getPostInteractionRate(sanitisedUfoName, data.type))) {
580
+ postInteractionLog.stopVCObserver();
581
+ }
582
+ } else {
583
+ if (!coinflip(getPostInteractionRate(data.routeName || data.ufoName, data.type))) {
584
+ postInteractionLog.stopVCObserver();
585
+ }
586
+ }
574
587
  if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$experimen = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5$experimen !== void 0 && _getConfig5$experimen.enabled)) {
575
588
  remove(id);
576
589
  }
@@ -750,8 +763,12 @@ export function addOnCancelCallback(id, cancelCallback) {
750
763
  interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
751
764
  }
752
765
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName, trace = null) {
753
- if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
766
+ if (fg('platform_ufo_post_interaction_check_name')) {
754
767
  postInteractionLog.reset();
768
+ } else {
769
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
770
+ postInteractionLog.reset();
771
+ }
755
772
  }
756
773
  let vcObserver;
757
774
  let previousTime = startTime;
@@ -870,10 +887,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
870
887
  experienceKey: ufoName
871
888
  });
872
889
  }
873
- if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
874
- postInteractionLog.startVCObserver({
875
- startTime
876
- });
890
+ if (fg('platform_ufo_post_interaction_check_name')) {
891
+ var _getConfig0, _getConfig0$postInter;
892
+ // Start post interaction observer for all if config is enabled
893
+ // in case ufoName is updated at later time
894
+ if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0$postInter = _getConfig0.postInteractionLog) !== null && _getConfig0$postInter !== void 0 && _getConfig0$postInter.enabled) {
895
+ postInteractionLog.startVCObserver({
896
+ startTime
897
+ });
898
+ }
899
+ } else {
900
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
901
+ postInteractionLog.startVCObserver({
902
+ startTime
903
+ });
904
+ }
877
905
  }
878
906
  if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
879
907
  experimentalVC.start({
@@ -88,13 +88,14 @@ export default class PostInteractionLog {
88
88
  * Send the log if there is data
89
89
  */
90
90
  async sendPostInteractionLog() {
91
- var _this$vcObserver4, _this$vcObserver5;
91
+ var _this$vcObserver4, _config$vc, _config$vc2, _this$vcObserver5;
92
92
  if (!this.hasData() || !this.lastInteractionFinish || !this.sinkHandlerFn) {
93
93
  var _this$vcObserver3;
94
94
  this.reset();
95
95
  (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.stop();
96
96
  return;
97
97
  }
98
+ const config = getConfig();
98
99
  const postInteractionFinishVCResult = await ((_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult({
99
100
  start: this.lastInteractionFinish.start,
100
101
  stop: performance.now(),
@@ -102,8 +103,11 @@ export default class PostInteractionLog {
102
103
  // no need for TTI value here
103
104
  isEventAborted: !!this.lastInteractionFinish.abortReason,
104
105
  prefix: 'ufo',
105
- ...this.vcObserverSSRConfig,
106
- experienceKey: this.lastInteractionFinish.ufoName
106
+ experienceKey: this.lastInteractionFinish.ufoName,
107
+ interactionId: this.lastInteractionFinish.id,
108
+ includeSSRInV3: config === null || config === void 0 ? void 0 : (_config$vc = config.vc) === null || _config$vc === void 0 ? void 0 : _config$vc.includeSSRInV3,
109
+ includeSSRRatio: config === null || config === void 0 ? void 0 : (_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.includeSSRRatio,
110
+ ...this.vcObserverSSRConfig
107
111
  }));
108
112
  (_this$vcObserver5 = this.vcObserver) === null || _this$vcObserver5 === void 0 ? void 0 : _this$vcObserver5.stop();
109
113
  this.sinkHandlerFn({
@@ -13,6 +13,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import coinflip from '../coinflip';
14
14
  import { getAwaitBM3TTIList, getCapabilityRate, getConfig, getExperimentalInteractionRate, getInteractionTimeout, getPostInteractionRate } from '../config';
15
15
  import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComplete } from '../create-experimental-interaction-metrics-payload';
16
+ import { sanitizeUfoName } from '../create-payload/common/utils';
16
17
  import { clearActiveTrace } from '../experience-trace-id-context';
17
18
  import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
18
19
  import { getInteractionId } from '../interaction-id-context';
@@ -607,6 +608,18 @@ function finishInteraction(id, data) {
607
608
  data.vc = observer.getVCRawData();
608
609
  }
609
610
  }
611
+
612
+ // By this time, stop the post interaction log observer if coinflip rate is 0
613
+ if (fg('platform_ufo_post_interaction_check_name')) {
614
+ var sanitisedUfoName = sanitizeUfoName(data.ufoName);
615
+ if (!coinflip(getPostInteractionRate(sanitisedUfoName, data.type))) {
616
+ postInteractionLog.stopVCObserver();
617
+ }
618
+ } else {
619
+ if (!coinflip(getPostInteractionRate(data.routeName || data.ufoName, data.type))) {
620
+ postInteractionLog.stopVCObserver();
621
+ }
622
+ }
610
623
  if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
611
624
  remove(id);
612
625
  }
@@ -829,8 +842,12 @@ export function addOnCancelCallback(id, cancelCallback) {
829
842
  }
830
843
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
831
844
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
832
- if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
845
+ if (fg('platform_ufo_post_interaction_check_name')) {
833
846
  postInteractionLog.reset();
847
+ } else {
848
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
849
+ postInteractionLog.reset();
850
+ }
834
851
  }
835
852
  var vcObserver;
836
853
  var previousTime = startTime;
@@ -949,10 +966,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
949
966
  experienceKey: ufoName
950
967
  });
951
968
  }
952
- if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
953
- postInteractionLog.startVCObserver({
954
- startTime: startTime
955
- });
969
+ if (fg('platform_ufo_post_interaction_check_name')) {
970
+ var _getConfig0;
971
+ // Start post interaction observer for all if config is enabled
972
+ // in case ufoName is updated at later time
973
+ if ((_getConfig0 = getConfig()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.postInteractionLog) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
974
+ postInteractionLog.startVCObserver({
975
+ startTime: startTime
976
+ });
977
+ }
978
+ } else {
979
+ if (coinflip(getPostInteractionRate(routeName || ufoName, type))) {
980
+ postInteractionLog.startVCObserver({
981
+ startTime: startTime
982
+ });
983
+ }
956
984
  }
957
985
  if (coinflip(getExperimentalInteractionRate(ufoName, type))) {
958
986
  experimentalVC.start({
@@ -113,8 +113,8 @@ var PostInteractionLog = /*#__PURE__*/function () {
113
113
  key: "sendPostInteractionLog",
114
114
  value: (function () {
115
115
  var _sendPostInteractionLog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
116
- var _this$vcObserver4, _this$vcObserver5;
117
- var _this$vcObserver3, postInteractionFinishVCResult;
116
+ var _this$vcObserver4, _config$vc, _config$vc2, _this$vcObserver5;
117
+ var _this$vcObserver3, config, postInteractionFinishVCResult;
118
118
  return _regeneratorRuntime.wrap(function _callee$(_context) {
119
119
  while (1) switch (_context.prev = _context.next) {
120
120
  case 0:
@@ -126,18 +126,21 @@ var PostInteractionLog = /*#__PURE__*/function () {
126
126
  (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 || _this$vcObserver3.stop();
127
127
  return _context.abrupt("return");
128
128
  case 4:
129
- _context.next = 6;
130
- return (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult(_objectSpread(_objectSpread({
129
+ config = getConfig();
130
+ _context.next = 7;
131
+ return (_this$vcObserver4 = this.vcObserver) === null || _this$vcObserver4 === void 0 ? void 0 : _this$vcObserver4.getVCResult(_objectSpread({
131
132
  start: this.lastInteractionFinish.start,
132
133
  stop: performance.now(),
133
134
  tti: -1,
134
135
  // no need for TTI value here
135
136
  isEventAborted: !!this.lastInteractionFinish.abortReason,
136
- prefix: 'ufo'
137
- }, this.vcObserverSSRConfig), {}, {
138
- experienceKey: this.lastInteractionFinish.ufoName
139
- }));
140
- case 6:
137
+ prefix: 'ufo',
138
+ experienceKey: this.lastInteractionFinish.ufoName,
139
+ interactionId: this.lastInteractionFinish.id,
140
+ includeSSRInV3: config === null || config === void 0 || (_config$vc = config.vc) === null || _config$vc === void 0 ? void 0 : _config$vc.includeSSRInV3,
141
+ includeSSRRatio: config === null || config === void 0 || (_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.includeSSRRatio
142
+ }, this.vcObserverSSRConfig));
143
+ case 7:
141
144
  postInteractionFinishVCResult = _context.sent;
142
145
  (_this$vcObserver5 = this.vcObserver) === null || _this$vcObserver5 === void 0 || _this$vcObserver5.stop();
143
146
  this.sinkHandlerFn({
@@ -147,7 +150,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
147
150
  lastInteractionFinishVCResult: this.lastInteractionFinishVCResult
148
151
  });
149
152
  this.reset();
150
- case 10:
153
+ case 11:
151
154
  case "end":
152
155
  return _context.stop();
153
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.1.11",
3
+ "version": "4.1.12",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -194,6 +194,9 @@
194
194
  },
195
195
  "ufo_chrome_devtools_uplift": {
196
196
  "type": "boolean"
197
+ },
198
+ "platform_ufo_post_interaction_check_name": {
199
+ "type": "boolean"
197
200
  }
198
201
  }
199
202
  }