@atlaskit/react-ufo 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 2.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#155785](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155785)
8
+ [`0c6d7f8285d34`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0c6d7f8285d34) -
9
+ moved atlaskit ufo-interaction-ignore to atlaskit/react-ufo
10
+
11
+ ## 2.0.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [#157418](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157418)
16
+ [`e6939ccf435a3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e6939ccf435a3) -
17
+ Add payload size as part of UFO payload
18
+
3
19
  ## 2.0.5
4
20
 
5
21
  ### Patch Changes
@@ -632,6 +632,9 @@ function getSSRDoneTimeValue(config) {
632
632
  var _config$ssr, _config$ssr2;
633
633
  return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
634
634
  }
635
+ function getPayloadSize(payload) {
636
+ return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
637
+ }
635
638
  function createInteractionMetricsPayload(interaction, interactionId) {
636
639
  var _window$location, _config$additionalPay;
637
640
  var interactionPayloadStart = performance.now();
@@ -716,7 +719,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
716
719
  };
717
720
  };
718
721
  var newUFOName = (0, _utils.sanitizeUfoName)(ufoName);
719
- return {
722
+ var payload = {
720
723
  actionSubject: 'experience',
721
724
  action: 'measured',
722
725
  eventType: 'operational',
@@ -728,6 +731,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
728
731
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
729
732
  'event:product': config.product,
730
733
  'event:schema': '1.0.0',
734
+ 'event:sizeInKb': 0,
731
735
  'event:source': {
732
736
  name: 'react-ufo/web',
733
737
  version: _constants.REACT_UFO_VERSION,
@@ -773,6 +777,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
773
777
  })
774
778
  }
775
779
  };
780
+ payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
781
+ return payload;
776
782
  }
777
783
  function createPayloads(interactionId, interaction) {
778
784
  var ufoNameOverride = getUfoNameOverride(interaction);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _ufoInteractionIgnore.default;
11
+ }
12
+ });
13
+ var _ufoInteractionIgnore = _interopRequireDefault(require("./ufo-interaction-ignore"));
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = UFOInteractionIgnore;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _interactionContext = _interopRequireDefault(require("@atlaskit/interaction-context"));
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ /**
17
+ * Prevent a subtree from holding up an interaction
18
+ * Use this when you have a component which loads in late, but
19
+ * isn't considered to be a breach of SLO
20
+ *
21
+ * ```js
22
+ * <App>
23
+ * <Main />
24
+ * <Sidebar>
25
+ * <UFOInteractionIgnore>
26
+ * <InsightsButton />
27
+ * </UFOInteractionIgnore>
28
+ * </Sidebar>
29
+ * </App>
30
+ * ```
31
+ *
32
+ * Has an `ignore` prop, to allow you to use it conditionally
33
+ */
34
+ function UFOInteractionIgnore(_ref) {
35
+ var children = _ref.children,
36
+ _ref$ignore = _ref.ignore,
37
+ ignore = _ref$ignore === void 0 ? true : _ref$ignore;
38
+ var parentContext = (0, _react.useContext)(_interactionContext.default);
39
+ var ignoredInteractionContext = (0, _react.useMemo)(function () {
40
+ if (!parentContext) {
41
+ return null;
42
+ }
43
+ return _objectSpread(_objectSpread({}, parentContext), {}, {
44
+ hold: function hold() {
45
+ if (!ignore) {
46
+ return parentContext.hold.apply(parentContext, arguments);
47
+ }
48
+ }
49
+ });
50
+ }, [parentContext, ignore]);
51
+
52
+ // react-18: Use children directly
53
+ var kids = children != null ? children : null;
54
+ if (!ignoredInteractionContext) {
55
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, kids);
56
+ }
57
+ return /*#__PURE__*/_react.default.createElement(_interactionContext.default.Provider, {
58
+ value: ignoredInteractionContext
59
+ }, kids);
60
+ }
@@ -623,6 +623,9 @@ function getSSRDoneTimeValue(config) {
623
623
  var _config$ssr, _config$ssr2;
624
624
  return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
625
625
  }
626
+ function getPayloadSize(payload) {
627
+ return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
628
+ }
626
629
  function createInteractionMetricsPayload(interaction, interactionId) {
627
630
  var _window$location, _config$additionalPay;
628
631
  const interactionPayloadStart = performance.now();
@@ -710,7 +713,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
710
713
  };
711
714
  };
712
715
  const newUFOName = sanitizeUfoName(ufoName);
713
- return {
716
+ const payload = {
714
717
  actionSubject: 'experience',
715
718
  action: 'measured',
716
719
  eventType: 'operational',
@@ -722,6 +725,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
722
725
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
723
726
  'event:product': config.product,
724
727
  'event:schema': '1.0.0',
728
+ 'event:sizeInKb': 0,
725
729
  'event:source': {
726
730
  name: 'react-ufo/web',
727
731
  version: REACT_UFO_VERSION,
@@ -780,6 +784,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
780
784
  }
781
785
  }
782
786
  };
787
+ payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
788
+ return payload;
783
789
  }
784
790
  export function createPayloads(interactionId, interaction) {
785
791
  const ufoNameOverride = getUfoNameOverride(interaction);
@@ -0,0 +1 @@
1
+ export { default } from './ufo-interaction-ignore';
@@ -0,0 +1,49 @@
1
+ import React, { useContext, useMemo } from 'react';
2
+ import InteractionContext from '@atlaskit/interaction-context';
3
+
4
+ /**
5
+ * Prevent a subtree from holding up an interaction
6
+ * Use this when you have a component which loads in late, but
7
+ * isn't considered to be a breach of SLO
8
+ *
9
+ * ```js
10
+ * <App>
11
+ * <Main />
12
+ * <Sidebar>
13
+ * <UFOInteractionIgnore>
14
+ * <InsightsButton />
15
+ * </UFOInteractionIgnore>
16
+ * </Sidebar>
17
+ * </App>
18
+ * ```
19
+ *
20
+ * Has an `ignore` prop, to allow you to use it conditionally
21
+ */
22
+ export default function UFOInteractionIgnore({
23
+ children,
24
+ ignore = true
25
+ }) {
26
+ const parentContext = useContext(InteractionContext);
27
+ const ignoredInteractionContext = useMemo(() => {
28
+ if (!parentContext) {
29
+ return null;
30
+ }
31
+ return {
32
+ ...parentContext,
33
+ hold(...args) {
34
+ if (!ignore) {
35
+ return parentContext.hold(...args);
36
+ }
37
+ }
38
+ };
39
+ }, [parentContext, ignore]);
40
+
41
+ // react-18: Use children directly
42
+ const kids = children != null ? children : null;
43
+ if (!ignoredInteractionContext) {
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, kids);
45
+ }
46
+ return /*#__PURE__*/React.createElement(InteractionContext.Provider, {
47
+ value: ignoredInteractionContext
48
+ }, kids);
49
+ }
@@ -622,6 +622,9 @@ function getSSRDoneTimeValue(config) {
622
622
  var _config$ssr, _config$ssr2;
623
623
  return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
624
624
  }
625
+ function getPayloadSize(payload) {
626
+ return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
627
+ }
625
628
  function createInteractionMetricsPayload(interaction, interactionId) {
626
629
  var _window$location, _config$additionalPay;
627
630
  var interactionPayloadStart = performance.now();
@@ -706,7 +709,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
706
709
  };
707
710
  };
708
711
  var newUFOName = sanitizeUfoName(ufoName);
709
- return {
712
+ var payload = {
710
713
  actionSubject: 'experience',
711
714
  action: 'measured',
712
715
  eventType: 'operational',
@@ -718,6 +721,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
718
721
  'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
719
722
  'event:product': config.product,
720
723
  'event:schema': '1.0.0',
724
+ 'event:sizeInKb': 0,
721
725
  'event:source': {
722
726
  name: 'react-ufo/web',
723
727
  version: REACT_UFO_VERSION,
@@ -763,6 +767,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
763
767
  })
764
768
  }
765
769
  };
770
+ payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
771
+ return payload;
766
772
  }
767
773
  export function createPayloads(interactionId, interaction) {
768
774
  var ufoNameOverride = getUfoNameOverride(interaction);
@@ -0,0 +1 @@
1
+ export { default } from './ufo-interaction-ignore';
@@ -0,0 +1,51 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import React, { useContext, useMemo } from 'react';
5
+ import InteractionContext from '@atlaskit/interaction-context';
6
+
7
+ /**
8
+ * Prevent a subtree from holding up an interaction
9
+ * Use this when you have a component which loads in late, but
10
+ * isn't considered to be a breach of SLO
11
+ *
12
+ * ```js
13
+ * <App>
14
+ * <Main />
15
+ * <Sidebar>
16
+ * <UFOInteractionIgnore>
17
+ * <InsightsButton />
18
+ * </UFOInteractionIgnore>
19
+ * </Sidebar>
20
+ * </App>
21
+ * ```
22
+ *
23
+ * Has an `ignore` prop, to allow you to use it conditionally
24
+ */
25
+ export default function UFOInteractionIgnore(_ref) {
26
+ var children = _ref.children,
27
+ _ref$ignore = _ref.ignore,
28
+ ignore = _ref$ignore === void 0 ? true : _ref$ignore;
29
+ var parentContext = useContext(InteractionContext);
30
+ var ignoredInteractionContext = useMemo(function () {
31
+ if (!parentContext) {
32
+ return null;
33
+ }
34
+ return _objectSpread(_objectSpread({}, parentContext), {}, {
35
+ hold: function hold() {
36
+ if (!ignore) {
37
+ return parentContext.hold.apply(parentContext, arguments);
38
+ }
39
+ }
40
+ });
41
+ }, [parentContext, ignore]);
42
+
43
+ // react-18: Use children directly
44
+ var kids = children != null ? children : null;
45
+ if (!ignoredInteractionContext) {
46
+ return /*#__PURE__*/React.createElement(React.Fragment, null, kids);
47
+ }
48
+ return /*#__PURE__*/React.createElement(InteractionContext.Provider, {
49
+ value: ignoredInteractionContext
50
+ }, kids);
51
+ }
@@ -727,6 +727,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
727
727
  'event:hostname': string;
728
728
  'event:product': string;
729
729
  'event:schema': string;
730
+ 'event:sizeInKb': number;
730
731
  'event:source': {
731
732
  name: string;
732
733
  version: string;
@@ -1475,6 +1476,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
1475
1476
  'event:hostname': string;
1476
1477
  'event:product': string;
1477
1478
  'event:schema': string;
1479
+ 'event:sizeInKb': number;
1478
1480
  'event:source': {
1479
1481
  name: string;
1480
1482
  version: string;
@@ -2205,6 +2207,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
2205
2207
  'event:hostname': string;
2206
2208
  'event:product': string;
2207
2209
  'event:schema': string;
2210
+ 'event:sizeInKb': number;
2208
2211
  'event:source': {
2209
2212
  name: string;
2210
2213
  version: string;
@@ -2956,6 +2959,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
2956
2959
  'event:hostname': string;
2957
2960
  'event:product': string;
2958
2961
  'event:schema': string;
2962
+ 'event:sizeInKb': number;
2959
2963
  'event:source': {
2960
2964
  name: string;
2961
2965
  version: string;
@@ -0,0 +1 @@
1
+ export { default } from './ufo-interaction-ignore';
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from 'react';
2
+ /**
3
+ * Prevent a subtree from holding up an interaction
4
+ * Use this when you have a component which loads in late, but
5
+ * isn't considered to be a breach of SLO
6
+ *
7
+ * ```js
8
+ * <App>
9
+ * <Main />
10
+ * <Sidebar>
11
+ * <UFOInteractionIgnore>
12
+ * <InsightsButton />
13
+ * </UFOInteractionIgnore>
14
+ * </Sidebar>
15
+ * </App>
16
+ * ```
17
+ *
18
+ * Has an `ignore` prop, to allow you to use it conditionally
19
+ */
20
+ export default function UFOInteractionIgnore({ children, ignore, }: {
21
+ children?: ReactNode;
22
+ ignore?: boolean;
23
+ }): JSX.Element;
@@ -727,6 +727,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
727
727
  'event:hostname': string;
728
728
  'event:product': string;
729
729
  'event:schema': string;
730
+ 'event:sizeInKb': number;
730
731
  'event:source': {
731
732
  name: string;
732
733
  version: string;
@@ -1475,6 +1476,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
1475
1476
  'event:hostname': string;
1476
1477
  'event:product': string;
1477
1478
  'event:schema': string;
1479
+ 'event:sizeInKb': number;
1478
1480
  'event:source': {
1479
1481
  name: string;
1480
1482
  version: string;
@@ -2205,6 +2207,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
2205
2207
  'event:hostname': string;
2206
2208
  'event:product': string;
2207
2209
  'event:schema': string;
2210
+ 'event:sizeInKb': number;
2208
2211
  'event:source': {
2209
2212
  name: string;
2210
2213
  version: string;
@@ -2956,6 +2959,7 @@ export declare function createPayloads(interactionId: string, interaction: Inter
2956
2959
  'event:hostname': string;
2957
2960
  'event:product': string;
2958
2961
  'event:schema': string;
2962
+ 'event:sizeInKb': number;
2959
2963
  'event:source': {
2960
2964
  name: string;
2961
2965
  version: string;
@@ -0,0 +1 @@
1
+ export { default } from './ufo-interaction-ignore';
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from 'react';
2
+ /**
3
+ * Prevent a subtree from holding up an interaction
4
+ * Use this when you have a component which loads in late, but
5
+ * isn't considered to be a breach of SLO
6
+ *
7
+ * ```js
8
+ * <App>
9
+ * <Main />
10
+ * <Sidebar>
11
+ * <UFOInteractionIgnore>
12
+ * <InsightsButton />
13
+ * </UFOInteractionIgnore>
14
+ * </Sidebar>
15
+ * </App>
16
+ * ```
17
+ *
18
+ * Has an `ignore` prop, to allow you to use it conditionally
19
+ */
20
+ export default function UFOInteractionIgnore({ children, ignore, }: {
21
+ children?: ReactNode;
22
+ ignore?: boolean;
23
+ }): JSX.Element;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/react-ufo/interaction-ignore",
3
+ "main": "../dist/cjs/interaction-ignore/index.js",
4
+ "module": "../dist/esm/interaction-ignore/index.js",
5
+ "module:es2019": "../dist/es2019/interaction-ignore/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/interaction-ignore/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.4": {
10
+ "*": [
11
+ "../dist/types-ts4.5/interaction-ignore/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -46,6 +46,7 @@
46
46
  "./initial-page-load-extra-timing": "./src/initial-page-load-extra-timing/index.ts",
47
47
  "./interaction-context": "./src/interaction-context/index.ts",
48
48
  "./interaction-id-context": "./src/interaction-id-context/index.ts",
49
+ "./interaction-ignore": "./src/interaction-ignore/index.ts",
49
50
  "./interaction-metrics": "./src/interaction-metrics/index.ts",
50
51
  "./interaction-metrics-init": "./src/interaction-metrics-init/index.ts",
51
52
  "./label": "./src/label/index.ts",
@@ -72,7 +73,7 @@
72
73
  ".": "./src/index.ts"
73
74
  },
74
75
  "dependencies": {
75
- "@atlaskit/interaction-context": "^2.1.0",
76
+ "@atlaskit/interaction-context": "^2.1.4",
76
77
  "@atlaskit/platform-feature-flags": "^0.3.0",
77
78
  "@babel/runtime": "^7.0.0",
78
79
  "bind-event-listener": "^3.0.0",