@atlaskit/react-ufo 2.4.3 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 2.4.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#172240](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/172240)
8
+ [`db973dafd5ae2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/db973dafd5ae2) -
9
+ correctly feature flag and optimise buildSegmentTree function
10
+ - [#172231](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/172231)
11
+ [`de6f706c54af6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/de6f706c54af6) -
12
+ [ED-25937] Skip TTVC calculation from changes that comes from the Editor container
13
+
14
+ ## 2.4.4
15
+
16
+ ### Patch Changes
17
+
18
+ - [`a03da52505965`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a03da52505965) -
19
+ Remove the flag from test files as well as its not present on LD or Statsig
20
+
3
21
  ## 2.4.3
4
22
 
5
23
  ### Patch Changes
@@ -27,20 +27,19 @@ function buildSegmentTree(labelStacks) {
27
27
  };
28
28
  labelStacks.forEach(function (labelStack) {
29
29
  var currentNode = r;
30
- labelStack.forEach(function (label, index) {
31
- var _currentNode$c;
30
+ labelStack.forEach(function (label) {
32
31
  var name = label.name;
33
32
  var id = isSegmentLabel(label) ? label.segmentId : undefined;
34
- var key = id !== undefined ? id.toString() : name;
35
- if (currentNode.c && !currentNode.c[key]) {
33
+ var key = id !== undefined ? id : name;
34
+ if (!currentNode.c) {
35
+ currentNode.c = {};
36
+ }
37
+ if (!currentNode.c[key]) {
36
38
  currentNode.c[key] = {
37
39
  n: name
38
40
  };
39
41
  }
40
- currentNode = (_currentNode$c = currentNode.c) === null || _currentNode$c === void 0 ? void 0 : _currentNode$c[key];
41
- if (index < labelStack.length - 1) {
42
- currentNode.c = _objectSpread({}, currentNode.c || {});
43
- }
42
+ currentNode = currentNode.c[key];
44
43
  });
45
44
  });
46
45
  return {
@@ -670,9 +670,9 @@ function createInteractionMetricsPayload(interaction, interactionId) {
670
670
  var pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
671
671
  var pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
672
672
  var segments = config.killswitchNestedSegments ? [] : knownSegments;
673
- var segmentTree = (0, _utils.buildSegmentTree)(segments.map(function (segment) {
673
+ var segmentTree = _constants.REACT_UFO_VERSION === '2.0.0' ? (0, _utils.buildSegmentTree)(segments.map(function (segment) {
674
674
  return segment.labelStack;
675
- }));
675
+ })) : {};
676
676
  var isDetailedPayload = pageVisibilityAtTTAI === 'visible';
677
677
  var isPageLoad = type === 'page_load';
678
678
  var calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
@@ -23,6 +23,12 @@ var state = {
23
23
  waitingForFirstRender: 2,
24
24
  ignoring: 3
25
25
  };
26
+ function isInsideEditorContainer(target) {
27
+ if (!target || typeof target.closest !== 'function') {
28
+ return false;
29
+ }
30
+ return Boolean(target.closest('.ProseMirror'));
31
+ }
26
32
  var Observers = exports.Observers = /*#__PURE__*/function () {
27
33
  function Observers(opts) {
28
34
  var _this = this;
@@ -297,6 +303,11 @@ var Observers = exports.Observers = /*#__PURE__*/function () {
297
303
  data.ignoreReason = 'not-visible';
298
304
  }
299
305
  }
306
+ if ((0, _platformFeatureFlags.fg)('platform_editor_ed-25937_ignore_mutations_for_ttvc')) {
307
+ if (isInsideEditorContainer(target)) {
308
+ data.ignoreReason = 'editor-container-mutation';
309
+ }
310
+ }
300
311
  _this3.callbacks.forEach(function (callback) {
301
312
  var elementName;
302
313
  try {
@@ -13,22 +13,19 @@ export function buildSegmentTree(labelStacks) {
13
13
  };
14
14
  labelStacks.forEach(labelStack => {
15
15
  let currentNode = r;
16
- labelStack.forEach((label, index) => {
17
- var _currentNode$c;
16
+ labelStack.forEach(label => {
18
17
  const name = label.name;
19
18
  const id = isSegmentLabel(label) ? label.segmentId : undefined;
20
- const key = id !== undefined ? id.toString() : name;
21
- if (currentNode.c && !currentNode.c[key]) {
19
+ const key = id !== undefined ? id : name;
20
+ if (!currentNode.c) {
21
+ currentNode.c = {};
22
+ }
23
+ if (!currentNode.c[key]) {
22
24
  currentNode.c[key] = {
23
25
  n: name
24
26
  };
25
27
  }
26
- currentNode = (_currentNode$c = currentNode.c) === null || _currentNode$c === void 0 ? void 0 : _currentNode$c[key];
27
- if (index < labelStack.length - 1) {
28
- currentNode.c = {
29
- ...(currentNode.c || {})
30
- };
31
- }
28
+ currentNode = currentNode.c[key];
32
29
  });
33
30
  });
34
31
  return {
@@ -664,7 +664,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
664
664
  const pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
665
665
  const pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
666
666
  const segments = config.killswitchNestedSegments ? [] : knownSegments;
667
- const segmentTree = buildSegmentTree(segments.map(segment => segment.labelStack));
667
+ const segmentTree = REACT_UFO_VERSION === '2.0.0' ? buildSegmentTree(segments.map(segment => segment.labelStack)) : {};
668
668
  const isDetailedPayload = pageVisibilityAtTTAI === 'visible';
669
669
  const isPageLoad = type === 'page_load';
670
670
  const calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
@@ -8,6 +8,12 @@ const state = {
8
8
  waitingForFirstRender: 2,
9
9
  ignoring: 3
10
10
  };
11
+ function isInsideEditorContainer(target) {
12
+ if (!target || typeof target.closest !== 'function') {
13
+ return false;
14
+ }
15
+ return Boolean(target.closest('.ProseMirror'));
16
+ }
11
17
  export class Observers {
12
18
  constructor(opts) {
13
19
  _defineProperty(this, "observedMutations", new WeakMap());
@@ -245,6 +251,11 @@ export class Observers {
245
251
  data.ignoreReason = 'not-visible';
246
252
  }
247
253
  }
254
+ if (fg('platform_editor_ed-25937_ignore_mutations_for_ttvc')) {
255
+ if (isInsideEditorContainer(target)) {
256
+ data.ignoreReason = 'editor-container-mutation';
257
+ }
258
+ }
248
259
  this.callbacks.forEach(callback => {
249
260
  let elementName;
250
261
  try {
@@ -16,20 +16,19 @@ export function buildSegmentTree(labelStacks) {
16
16
  };
17
17
  labelStacks.forEach(function (labelStack) {
18
18
  var currentNode = r;
19
- labelStack.forEach(function (label, index) {
20
- var _currentNode$c;
19
+ labelStack.forEach(function (label) {
21
20
  var name = label.name;
22
21
  var id = isSegmentLabel(label) ? label.segmentId : undefined;
23
- var key = id !== undefined ? id.toString() : name;
24
- if (currentNode.c && !currentNode.c[key]) {
22
+ var key = id !== undefined ? id : name;
23
+ if (!currentNode.c) {
24
+ currentNode.c = {};
25
+ }
26
+ if (!currentNode.c[key]) {
25
27
  currentNode.c[key] = {
26
28
  n: name
27
29
  };
28
30
  }
29
- currentNode = (_currentNode$c = currentNode.c) === null || _currentNode$c === void 0 ? void 0 : _currentNode$c[key];
30
- if (index < labelStack.length - 1) {
31
- currentNode.c = _objectSpread({}, currentNode.c || {});
32
- }
31
+ currentNode = currentNode.c[key];
33
32
  });
34
33
  });
35
34
  return {
@@ -660,9 +660,9 @@ function createInteractionMetricsPayload(interaction, interactionId) {
660
660
  var pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
661
661
  var pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
662
662
  var segments = config.killswitchNestedSegments ? [] : knownSegments;
663
- var segmentTree = buildSegmentTree(segments.map(function (segment) {
663
+ var segmentTree = REACT_UFO_VERSION === '2.0.0' ? buildSegmentTree(segments.map(function (segment) {
664
664
  return segment.labelStack;
665
- }));
665
+ })) : {};
666
666
  var isDetailedPayload = pageVisibilityAtTTAI === 'visible';
667
667
  var isPageLoad = type === 'page_load';
668
668
  var calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
@@ -16,6 +16,12 @@ var state = {
16
16
  waitingForFirstRender: 2,
17
17
  ignoring: 3
18
18
  };
19
+ function isInsideEditorContainer(target) {
20
+ if (!target || typeof target.closest !== 'function') {
21
+ return false;
22
+ }
23
+ return Boolean(target.closest('.ProseMirror'));
24
+ }
19
25
  export var Observers = /*#__PURE__*/function () {
20
26
  function Observers(opts) {
21
27
  var _this = this;
@@ -290,6 +296,11 @@ export var Observers = /*#__PURE__*/function () {
290
296
  data.ignoreReason = 'not-visible';
291
297
  }
292
298
  }
299
+ if (fg('platform_editor_ed-25937_ignore_mutations_for_ttvc')) {
300
+ if (isInsideEditorContainer(target)) {
301
+ data.ignoreReason = 'editor-container-mutation';
302
+ }
303
+ }
293
304
  _this3.callbacks.forEach(function (callback) {
294
305
  var elementName;
295
306
  try {
@@ -35,7 +35,7 @@ export type VCEntryType = {
35
35
  vc: number;
36
36
  elements: string[];
37
37
  };
38
- export type VCIgnoreReason = 'image' | 'ssr-hydration' | 'editor-lazy-node-view' | 'not-visible' | '';
38
+ export type VCIgnoreReason = 'image' | 'ssr-hydration' | 'editor-lazy-node-view' | 'not-visible' | 'editor-container-mutation' | '';
39
39
  export type ComponentsLogEntry = {
40
40
  targetName: string;
41
41
  __debug__element: WeakRef<Element> | null;