@atlaskit/analytics-next 8.3.5 → 9.0.0

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/components/AnalyticsContext/LegacyAnalyticsContext.js +4 -28
  3. package/dist/cjs/components/AnalyticsContext/ModernAnalyticsContext.js +1 -12
  4. package/dist/cjs/components/AnalyticsContext/index.js +0 -7
  5. package/dist/cjs/components/AnalyticsErrorBoundary.js +19 -68
  6. package/dist/cjs/components/AnalyticsListener/LegacyAnalyticsListener.js +6 -32
  7. package/dist/cjs/components/AnalyticsListener/ModernAnalyticsListener.js +2 -14
  8. package/dist/cjs/components/AnalyticsListener/index.js +0 -7
  9. package/dist/cjs/events/AnalyticsEvent.js +2 -18
  10. package/dist/cjs/events/UIAnalyticsEvent.js +3 -31
  11. package/dist/cjs/hocs/withAnalyticsContext.js +5 -17
  12. package/dist/cjs/hocs/withAnalyticsEvents.js +6 -16
  13. package/dist/cjs/hooks/useAnalyticsContext.js +0 -5
  14. package/dist/cjs/hooks/useAnalyticsEvents.js +0 -5
  15. package/dist/cjs/hooks/useCallbackWithAnalytics.js +1 -7
  16. package/dist/cjs/hooks/usePatchedProps.js +3 -19
  17. package/dist/cjs/hooks/usePlatformLeafEventHandler.js +20 -27
  18. package/dist/cjs/hooks/usePlatformLeafSyntheticEventHandler.js +19 -26
  19. package/dist/cjs/hooks/useTrackedRef.js +0 -3
  20. package/dist/cjs/index.js +0 -18
  21. package/dist/cjs/test-utils/useRenderCounter.js +0 -3
  22. package/dist/cjs/utils/cleanProps.js +1 -5
  23. package/dist/cjs/utils/createAndFireEvent.js +0 -4
  24. package/dist/cjs/version.json +1 -1
  25. package/dist/es2019/components/AnalyticsContext/LegacyAnalyticsContext.js +2 -12
  26. package/dist/es2019/components/AnalyticsContext/ModernAnalyticsContext.js +0 -2
  27. package/dist/es2019/components/AnalyticsContext/index.js +0 -3
  28. package/dist/es2019/components/AnalyticsErrorBoundary.js +8 -37
  29. package/dist/es2019/components/AnalyticsListener/LegacyAnalyticsListener.js +2 -14
  30. package/dist/es2019/components/AnalyticsListener/ModernAnalyticsListener.js +0 -3
  31. package/dist/es2019/components/AnalyticsListener/index.js +0 -3
  32. package/dist/es2019/events/AnalyticsEvent.js +6 -10
  33. package/dist/es2019/events/UIAnalyticsEvent.js +3 -15
  34. package/dist/es2019/hocs/withAnalyticsContext.js +6 -5
  35. package/dist/es2019/hocs/withAnalyticsEvents.js +4 -4
  36. package/dist/es2019/hooks/usePatchedProps.js +6 -9
  37. package/dist/es2019/hooks/usePlatformLeafEventHandler.js +14 -10
  38. package/dist/es2019/hooks/usePlatformLeafSyntheticEventHandler.js +14 -10
  39. package/dist/es2019/index.js +2 -1
  40. package/dist/es2019/test-utils/useRenderCounter.js +2 -1
  41. package/dist/es2019/utils/createAndFireEvent.js +0 -2
  42. package/dist/es2019/version.json +1 -1
  43. package/dist/esm/components/AnalyticsContext/LegacyAnalyticsContext.js +4 -21
  44. package/dist/esm/components/AnalyticsContext/ModernAnalyticsContext.js +1 -3
  45. package/dist/esm/components/AnalyticsContext/index.js +0 -3
  46. package/dist/esm/components/AnalyticsErrorBoundary.js +18 -54
  47. package/dist/esm/components/AnalyticsListener/LegacyAnalyticsListener.js +6 -25
  48. package/dist/esm/components/AnalyticsListener/ModernAnalyticsListener.js +2 -5
  49. package/dist/esm/components/AnalyticsListener/index.js +0 -3
  50. package/dist/esm/events/AnalyticsEvent.js +2 -16
  51. package/dist/esm/events/UIAnalyticsEvent.js +3 -27
  52. package/dist/esm/hocs/withAnalyticsContext.js +5 -9
  53. package/dist/esm/hocs/withAnalyticsEvents.js +6 -8
  54. package/dist/esm/hooks/useCallbackWithAnalytics.js +1 -2
  55. package/dist/esm/hooks/usePatchedProps.js +3 -14
  56. package/dist/esm/hooks/usePlatformLeafEventHandler.js +20 -22
  57. package/dist/esm/hooks/usePlatformLeafSyntheticEventHandler.js +19 -21
  58. package/dist/esm/index.js +2 -1
  59. package/dist/esm/test-utils/useRenderCounter.js +2 -1
  60. package/dist/esm/utils/cleanProps.js +1 -2
  61. package/dist/esm/utils/createAndFireEvent.js +0 -2
  62. package/dist/esm/version.json +1 -1
  63. package/dist/types/components/AnalyticsErrorBoundary.d.ts +7 -12
  64. package/package.json +5 -10
  65. package/report.api.md +137 -7407
  66. package/dist/types-ts4.0/components/AnalyticsContext/LegacyAnalyticsContext.d.ts +0 -29
  67. package/dist/types-ts4.0/components/AnalyticsContext/ModernAnalyticsContext.d.ts +0 -3
  68. package/dist/types-ts4.0/components/AnalyticsContext/index.d.ts +0 -3
  69. package/dist/types-ts4.0/components/AnalyticsContext/types.d.ts +0 -9
  70. package/dist/types-ts4.0/components/AnalyticsErrorBoundary.d.ts +0 -29
  71. package/dist/types-ts4.0/components/AnalyticsListener/LegacyAnalyticsListener.d.ts +0 -33
  72. package/dist/types-ts4.0/components/AnalyticsListener/ModernAnalyticsListener.d.ts +0 -3
  73. package/dist/types-ts4.0/components/AnalyticsListener/index.d.ts +0 -3
  74. package/dist/types-ts4.0/components/AnalyticsListener/types.d.ts +0 -12
  75. package/dist/types-ts4.0/events/AnalyticsEvent.d.ts +0 -15
  76. package/dist/types-ts4.0/events/UIAnalyticsEvent.d.ts +0 -20
  77. package/dist/types-ts4.0/hocs/withAnalyticsContext.d.ts +0 -6
  78. package/dist/types-ts4.0/hocs/withAnalyticsEvents.d.ts +0 -12
  79. package/dist/types-ts4.0/hooks/useAnalyticsContext.d.ts +0 -2
  80. package/dist/types-ts4.0/hooks/useAnalyticsEvents.d.ts +0 -5
  81. package/dist/types-ts4.0/hooks/useCallbackWithAnalytics.d.ts +0 -2
  82. package/dist/types-ts4.0/hooks/usePatchedProps.d.ts +0 -5
  83. package/dist/types-ts4.0/hooks/usePlatformLeafEventHandler.d.ts +0 -12
  84. package/dist/types-ts4.0/hooks/usePlatformLeafSyntheticEventHandler.d.ts +0 -11
  85. package/dist/types-ts4.0/hooks/useTrackedRef.d.ts +0 -2
  86. package/dist/types-ts4.0/index.d.ts +0 -25
  87. package/dist/types-ts4.0/performance/examples.d.ts +0 -5
  88. package/dist/types-ts4.0/test-utils/useRenderCounter.d.ts +0 -1
  89. package/dist/types-ts4.0/types.d.ts +0 -6
  90. package/dist/types-ts4.0/utils/cleanProps.d.ts +0 -3
  91. package/dist/types-ts4.0/utils/createAndFireEvent.d.ts +0 -4
@@ -6,11 +6,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
11
  import React, { Component } from 'react';
15
12
  import PropTypes from 'prop-types';
16
13
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
@@ -18,50 +15,40 @@ var ContextTypes = {
18
15
  getAtlaskitAnalyticsContext: PropTypes.func,
19
16
  getAtlaskitAnalyticsEventHandlers: PropTypes.func
20
17
  };
21
-
22
18
  var noop = function noop() {
23
19
  return [];
24
- }; // eslint-disable-next-line @repo/internal/react/no-class-components
25
-
20
+ };
26
21
 
22
+ // eslint-disable-next-line @repo/internal/react/no-class-components
27
23
  var AnalyticsContext = /*#__PURE__*/function (_Component) {
28
24
  _inherits(AnalyticsContext, _Component);
29
-
30
25
  var _super = _createSuper(AnalyticsContext);
31
-
32
26
  function AnalyticsContext(props) {
33
27
  var _this;
34
-
35
28
  _classCallCheck(this, AnalyticsContext);
36
-
37
29
  _this = _super.call(this, props);
38
-
39
30
  _defineProperty(_assertThisInitialized(_this), "getChildContext", function () {
40
31
  return {
41
32
  getAtlaskitAnalyticsContext: _this.getAnalyticsContext
42
33
  };
43
34
  });
44
-
45
35
  _defineProperty(_assertThisInitialized(_this), "getAnalyticsContext", function () {
46
36
  var data = _this.props.data;
47
37
  var _this$context$getAtla = _this.context.getAtlaskitAnalyticsContext,
48
- getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
38
+ getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
49
39
  return [].concat(_toConsumableArray(getAtlaskitAnalyticsContext()), [data]);
50
40
  });
51
-
52
41
  _defineProperty(_assertThisInitialized(_this), "getAnalyticsEventHandlers", function () {
53
42
  var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsEventHandlers,
54
- getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
43
+ getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
55
44
  return getAtlaskitAnalyticsEventHandlers();
56
45
  });
57
-
58
46
  _this.contextValue = {
59
47
  getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
60
48
  getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
61
49
  };
62
50
  return _this;
63
51
  }
64
-
65
52
  _createClass(AnalyticsContext, [{
66
53
  key: "render",
67
54
  value: function render() {
@@ -71,12 +58,8 @@ var AnalyticsContext = /*#__PURE__*/function (_Component) {
71
58
  }, children);
72
59
  }
73
60
  }]);
74
-
75
61
  return AnalyticsContext;
76
62
  }(Component);
77
-
78
63
  _defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
79
-
80
64
  _defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
81
-
82
65
  export default AnalyticsContext;
@@ -3,10 +3,9 @@ import React, { useCallback, useMemo } from 'react';
3
3
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
4
4
  import { useAnalyticsContext } from '../../hooks/useAnalyticsContext';
5
5
  import { useTrackedRef } from '../../hooks/useTrackedRef';
6
-
7
6
  var AnalyticsContext = function AnalyticsContext(_ref) {
8
7
  var data = _ref.data,
9
- children = _ref.children;
8
+ children = _ref.children;
10
9
  var dataRef = useTrackedRef(data);
11
10
  var analyticsContext = useAnalyticsContext();
12
11
  var getAtlaskitAnalyticsContext = useCallback(function () {
@@ -22,5 +21,4 @@ var AnalyticsContext = function AnalyticsContext(_ref) {
22
21
  value: value
23
22
  }, children);
24
23
  };
25
-
26
24
  export default AnalyticsContext;
@@ -1,13 +1,10 @@
1
1
  var _process$env;
2
-
3
2
  import LegacyAnalyticsContext from './LegacyAnalyticsContext';
4
3
  import ModernAnalyticsContext from './ModernAnalyticsContext';
5
4
  var ExportedAnalyticsContext;
6
-
7
5
  if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
8
6
  ExportedAnalyticsContext = ModernAnalyticsContext;
9
7
  } else {
10
8
  ExportedAnalyticsContext = LegacyAnalyticsContext;
11
9
  }
12
-
13
10
  export default ExportedAnalyticsContext;
@@ -1,64 +1,32 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
3
  import _inherits from "@babel/runtime/helpers/inherits";
5
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
-
13
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
-
17
8
  import React, { Component } from 'react';
18
- import withAnalyticsEvents from '../hocs/withAnalyticsEvents';
19
9
  import AnalyticsContext from './AnalyticsContext/LegacyAnalyticsContext';
10
+ /**
11
+ * @deprecated
12
+ */
20
13
  // eslint-disable-next-line @repo/internal/react/no-class-components
21
- export var BaseAnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
22
- _inherits(BaseAnalyticsErrorBoundary, _Component);
23
-
24
- var _super = _createSuper(BaseAnalyticsErrorBoundary);
25
-
26
- function BaseAnalyticsErrorBoundary(props) {
14
+ var AnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
15
+ _inherits(AnalyticsErrorBoundary, _Component);
16
+ var _super = _createSuper(AnalyticsErrorBoundary);
17
+ function AnalyticsErrorBoundary(props) {
27
18
  var _this;
28
-
29
- _classCallCheck(this, BaseAnalyticsErrorBoundary);
30
-
19
+ _classCallCheck(this, AnalyticsErrorBoundary);
31
20
  _this = _super.call(this, props);
32
-
33
- _defineProperty(_assertThisInitialized(_this), "fireAnalytics", function (analyticsErrorPayload) {
34
- var _this$props = _this.props,
35
- createAnalyticsEvent = _this$props.createAnalyticsEvent,
36
- channel = _this$props.channel,
37
- data = _this$props.data;
38
- createAnalyticsEvent({
39
- action: 'UnhandledError',
40
- eventType: 'ui',
41
- attributes: _objectSpread(_objectSpread({
42
- browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown'
43
- }, data), analyticsErrorPayload)
44
- }).fire(channel);
45
- });
46
-
47
21
  _this.state = {
48
22
  hasError: false
49
23
  };
50
24
  return _this;
51
25
  }
52
-
53
- _createClass(BaseAnalyticsErrorBoundary, [{
26
+ _createClass(AnalyticsErrorBoundary, [{
54
27
  key: "componentDidCatch",
55
28
  value: function componentDidCatch(error, info) {
56
29
  var onError = this.props.onError;
57
- var payload = {
58
- error: error,
59
- info: info
60
- };
61
- this.fireAnalytics(payload);
62
30
  onError && onError(error, info);
63
31
  this.setState({
64
32
  hasError: true
@@ -67,25 +35,21 @@ export var BaseAnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
67
35
  }, {
68
36
  key: "render",
69
37
  value: function render() {
70
- var _this$props2 = this.props,
71
- data = _this$props2.data,
72
- children = _this$props2.children,
73
- ErrorComponent = _this$props2.ErrorComponent;
38
+ var _this$props = this.props,
39
+ data = _this$props.data,
40
+ children = _this$props.children,
41
+ ErrorComponent = _this$props.ErrorComponent;
74
42
  var hasError = this.state.hasError;
75
-
76
- if (hasError && ErrorComponent) {
77
- return /*#__PURE__*/React.createElement(AnalyticsContext, {
43
+ if (hasError) {
44
+ return ErrorComponent ? /*#__PURE__*/React.createElement(AnalyticsContext, {
78
45
  data: data
79
- }, /*#__PURE__*/React.createElement(ErrorComponent, null));
46
+ }, /*#__PURE__*/React.createElement(ErrorComponent, null)) : null;
80
47
  }
81
-
82
48
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
83
49
  data: data
84
50
  }, children);
85
51
  }
86
52
  }]);
87
-
88
- return BaseAnalyticsErrorBoundary;
53
+ return AnalyticsErrorBoundary;
89
54
  }(Component);
90
- var AnalyticsErrorBoundary = withAnalyticsEvents()(BaseAnalyticsErrorBoundary);
91
- export default AnalyticsErrorBoundary;
55
+ export { AnalyticsErrorBoundary as default };
@@ -6,11 +6,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
11
  import React, { Component } from 'react';
15
12
  import PropTypes from 'prop-types';
16
13
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
@@ -18,60 +15,48 @@ var ContextTypes = {
18
15
  getAtlaskitAnalyticsEventHandlers: PropTypes.func,
19
16
  getAtlaskitAnalyticsContext: PropTypes.func
20
17
  };
21
-
22
18
  var noop = function noop() {
23
19
  return [];
24
- }; // eslint-disable-next-line @repo/internal/react/no-class-components
25
-
20
+ };
26
21
 
22
+ // eslint-disable-next-line @repo/internal/react/no-class-components
27
23
  var AnalyticsListener = /*#__PURE__*/function (_Component) {
28
24
  _inherits(AnalyticsListener, _Component);
29
-
30
25
  var _super = _createSuper(AnalyticsListener);
31
-
32
26
  function AnalyticsListener(props) {
33
27
  var _this;
34
-
35
28
  _classCallCheck(this, AnalyticsListener);
36
-
37
29
  _this = _super.call(this, props);
38
-
39
30
  _defineProperty(_assertThisInitialized(_this), "getChildContext", function () {
40
31
  return {
41
32
  getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
42
33
  getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext
43
34
  };
44
35
  });
45
-
46
36
  _defineProperty(_assertThisInitialized(_this), "getAnalyticsEventHandlers", function () {
47
37
  var _this$props = _this.props,
48
- channel = _this$props.channel,
49
- onEvent = _this$props.onEvent;
38
+ channel = _this$props.channel,
39
+ onEvent = _this$props.onEvent;
50
40
  var _this$context$getAtla = _this.context.getAtlaskitAnalyticsEventHandlers,
51
- getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
52
-
41
+ getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
53
42
  var handler = function handler(event, eventChannel) {
54
43
  if (channel === '*' || channel === eventChannel) {
55
44
  onEvent(event, eventChannel);
56
45
  }
57
46
  };
58
-
59
47
  return [handler].concat(_toConsumableArray(getAtlaskitAnalyticsEventHandlers()));
60
48
  });
61
-
62
49
  _defineProperty(_assertThisInitialized(_this), "getAtlaskitAnalyticsContext", function () {
63
50
  var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsContext,
64
- getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
51
+ getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
65
52
  return getAtlaskitAnalyticsContext();
66
53
  });
67
-
68
54
  _this.contextValue = {
69
55
  getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
70
56
  getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
71
57
  };
72
58
  return _this;
73
59
  }
74
-
75
60
  _createClass(AnalyticsListener, [{
76
61
  key: "render",
77
62
  value: function render() {
@@ -81,12 +66,8 @@ var AnalyticsListener = /*#__PURE__*/function (_Component) {
81
66
  }, children);
82
67
  }
83
68
  }]);
84
-
85
69
  return AnalyticsListener;
86
70
  }(Component);
87
-
88
71
  _defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
89
-
90
72
  _defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
91
-
92
73
  export default AnalyticsListener;
@@ -3,11 +3,10 @@ import React, { useCallback, useMemo } from 'react';
3
3
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
4
4
  import { useAnalyticsContext } from '../../hooks/useAnalyticsContext';
5
5
  import { useTrackedRef } from '../../hooks/useTrackedRef';
6
-
7
6
  var AnalyticsListener = function AnalyticsListener(_ref) {
8
7
  var children = _ref.children,
9
- channel = _ref.channel,
10
- onEvent = _ref.onEvent;
8
+ channel = _ref.channel,
9
+ onEvent = _ref.onEvent;
11
10
  var analyticsContext = useAnalyticsContext();
12
11
  var onEventRef = useTrackedRef(onEvent);
13
12
  var channelRef = useTrackedRef(channel);
@@ -17,7 +16,6 @@ var AnalyticsListener = function AnalyticsListener(_ref) {
17
16
  onEventRef.current(event, eventChannel);
18
17
  }
19
18
  };
20
-
21
19
  return [].concat(_toConsumableArray(analyticsContext.getAtlaskitAnalyticsEventHandlers()), [thisHandler]);
22
20
  }, [analyticsContext, channelRef, onEventRef]);
23
21
  var value = useMemo(function () {
@@ -30,5 +28,4 @@ var AnalyticsListener = function AnalyticsListener(_ref) {
30
28
  value: value
31
29
  }, children);
32
30
  };
33
-
34
31
  export default AnalyticsListener;
@@ -1,13 +1,10 @@
1
1
  var _process$env;
2
-
3
2
  import LegacyAnalyticsListener from './LegacyAnalyticsListener';
4
3
  import ModernAnalyticsListener from './ModernAnalyticsListener';
5
4
  var ExportedAnalyticsListener;
6
-
7
5
  if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
8
6
  ExportedAnalyticsListener = ModernAnalyticsListener;
9
7
  } else {
10
8
  ExportedAnalyticsListener = LegacyAnalyticsListener;
11
9
  }
12
-
13
10
  export default ExportedAnalyticsListener;
@@ -2,55 +2,41 @@ import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
-
6
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
-
8
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
-
10
7
  export var isAnalyticsEvent = function isAnalyticsEvent(obj) {
11
8
  var _obj$constructor;
12
-
13
- return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
9
+ return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) ||
10
+ // Backwards compatibility with older analytics-next packages
14
11
  (obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'AnalyticsEvent';
15
12
  };
16
-
17
13
  var AnalyticsEvent = /*#__PURE__*/function () {
18
14
  function AnalyticsEvent(props) {
19
15
  var _this = this;
20
-
21
16
  _classCallCheck(this, AnalyticsEvent);
22
-
23
17
  _defineProperty(this, "_isAnalyticsEvent", true);
24
-
25
18
  _defineProperty(this, "clone", function () {
26
19
  // just a shallow clone, don't change sub refs unless you want to
27
20
  // affect the original's too
28
21
  var payload = _objectSpread({}, _this.payload);
29
-
30
22
  return new AnalyticsEvent({
31
23
  payload: payload
32
24
  });
33
25
  });
34
-
35
26
  this.payload = props.payload;
36
27
  }
37
-
38
28
  _createClass(AnalyticsEvent, [{
39
29
  key: "update",
40
30
  value: function update(updater) {
41
31
  if (typeof updater === 'function') {
42
32
  this.payload = updater(this.payload);
43
33
  }
44
-
45
34
  if (_typeof(updater) === 'object') {
46
35
  this.payload = _objectSpread(_objectSpread({}, this.payload), updater);
47
36
  }
48
-
49
37
  return this;
50
38
  }
51
39
  }]);
52
-
53
40
  return AnalyticsEvent;
54
41
  }();
55
-
56
42
  export { AnalyticsEvent as default };
@@ -7,53 +7,39 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
-
11
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
-
13
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
-
15
12
  import AnalyticsEvent from './AnalyticsEvent';
16
13
  export var isUIAnalyticsEvent = function isUIAnalyticsEvent(obj) {
17
14
  var _obj$constructor;
18
-
19
- return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
15
+ return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) ||
16
+ // Backwards compatibility with older analytics-next packages
20
17
  (obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'UIAnalyticsEvent';
21
18
  };
22
-
23
19
  var UIAnalyticsEvent = /*#__PURE__*/function (_AnalyticsEvent) {
24
20
  _inherits(UIAnalyticsEvent, _AnalyticsEvent);
25
-
26
21
  var _super = _createSuper(UIAnalyticsEvent);
27
-
28
22
  function UIAnalyticsEvent(props) {
29
23
  var _this;
30
-
31
24
  _classCallCheck(this, UIAnalyticsEvent);
32
-
33
25
  _this = _super.call(this, props);
34
-
35
26
  _defineProperty(_assertThisInitialized(_this), "_isUIAnalyticsEvent", true);
36
-
37
27
  _defineProperty(_assertThisInitialized(_this), "clone", function () {
38
28
  if (_this.hasFired) {
39
29
  if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
40
30
  // eslint-disable-next-line no-console
41
31
  console.warn("Cannot clone an event after it's been fired.");
42
32
  }
43
-
44
33
  return null;
45
34
  }
46
-
47
35
  var context = _toConsumableArray(_this.context);
48
-
49
36
  var handlers = _toConsumableArray(_this.handlers);
37
+
50
38
  /**
51
39
  * A hacky "deep clone" of the object. This is limited in that it wont
52
40
  * support functions, regexs, Maps, Sets, etc, but none of those need to
53
41
  * be represented in our payload.
54
42
  */
55
-
56
-
57
43
  var payload = JSON.parse(JSON.stringify(_this.payload));
58
44
  return new UIAnalyticsEvent({
59
45
  context: context,
@@ -61,30 +47,24 @@ var UIAnalyticsEvent = /*#__PURE__*/function (_AnalyticsEvent) {
61
47
  payload: payload
62
48
  });
63
49
  });
64
-
65
50
  _defineProperty(_assertThisInitialized(_this), "fire", function (channel) {
66
51
  if (_this.hasFired) {
67
52
  if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
68
53
  // eslint-disable-next-line no-console
69
54
  console.warn('Cannot fire an event twice.');
70
55
  }
71
-
72
56
  return;
73
57
  }
74
-
75
58
  _this.handlers.forEach(function (handler) {
76
59
  return handler(_assertThisInitialized(_this), channel);
77
60
  });
78
-
79
61
  _this.hasFired = true;
80
62
  });
81
-
82
63
  _this.context = props.context || [];
83
64
  _this.handlers = props.handlers || [];
84
65
  _this.hasFired = false;
85
66
  return _this;
86
67
  }
87
-
88
68
  _createClass(UIAnalyticsEvent, [{
89
69
  key: "update",
90
70
  value: function update(updater) {
@@ -93,15 +73,11 @@ var UIAnalyticsEvent = /*#__PURE__*/function (_AnalyticsEvent) {
93
73
  // eslint-disable-next-line no-console
94
74
  console.warn("Cannot update an event after it's been fired.");
95
75
  }
96
-
97
76
  return this;
98
77
  }
99
-
100
78
  return _get(_getPrototypeOf(UIAnalyticsEvent.prototype), "update", this).call(this, updater);
101
79
  }
102
80
  }]);
103
-
104
81
  return UIAnalyticsEvent;
105
82
  }(AnalyticsEvent);
106
-
107
83
  export { UIAnalyticsEvent as default };
@@ -2,20 +2,15 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["analyticsContext"];
5
-
6
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
-
8
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
-
10
7
  import React, { forwardRef, useMemo } from 'react';
11
8
  import AnalyticsContext from '../components/AnalyticsContext';
12
-
13
9
  var withAnalyticsContext = function withAnalyticsContext(defaultData) {
14
10
  return function (WrappedComponent) {
15
11
  var WithAnalyticsContext = /*#__PURE__*/forwardRef(function (_ref, ref) {
16
12
  var analyticsContext = _ref.analyticsContext,
17
- rest = _objectWithoutProperties(_ref, _excluded);
18
-
13
+ rest = _objectWithoutProperties(_ref, _excluded);
19
14
  var analyticsData = useMemo(function () {
20
15
  return _objectSpread(_objectSpread({}, defaultData), analyticsContext);
21
16
  }, [analyticsContext]);
@@ -24,12 +19,13 @@ var withAnalyticsContext = function withAnalyticsContext(defaultData) {
24
19
  }, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, rest, {
25
20
  ref: ref
26
21
  })));
27
- }); // @ts-ignore
22
+ });
28
23
 
29
- WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat( // @ts-ignore disneyName doesn't exist on type
24
+ // @ts-ignore
25
+ WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat(
26
+ // @ts-ignore disneyName doesn't exist on type
30
27
  WrappedComponent.displayName || WrappedComponent.name, ")");
31
28
  return WithAnalyticsContext;
32
29
  };
33
30
  };
34
-
35
31
  export default withAnalyticsContext;
@@ -2,27 +2,25 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef } from 'react';
3
3
  import { useAnalyticsEvents } from '../hooks/useAnalyticsEvents';
4
4
  import { usePatchedProps } from '../hooks/usePatchedProps';
5
-
6
5
  var withAnalyticsEvents = function withAnalyticsEvents() {
7
6
  var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8
7
  return function (WrappedComponent) {
9
8
  var WithAnalyticsEvents = /*#__PURE__*/forwardRef(function (props, ref) {
10
9
  var _usePatchedProps = usePatchedProps(createEventMap, props),
11
- patchedEventProps = _usePatchedProps.patchedEventProps;
12
-
10
+ patchedEventProps = _usePatchedProps.patchedEventProps;
13
11
  var _useAnalyticsEvents = useAnalyticsEvents(),
14
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
15
-
12
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
16
13
  return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, patchedEventProps, {
17
14
  createAnalyticsEvent: createAnalyticsEvent,
18
15
  ref: ref
19
16
  }));
20
- }); // @ts-ignore
17
+ });
21
18
 
22
- WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat( // @ts-ignore disneyName doesn't exist on type
19
+ // @ts-ignore
20
+ WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat(
21
+ // @ts-ignore disneyName doesn't exist on type
23
22
  WrappedComponent.displayName || WrappedComponent.name, ")");
24
23
  return WithAnalyticsEvents;
25
24
  };
26
25
  };
27
-
28
26
  export default withAnalyticsEvents;
@@ -3,8 +3,7 @@ import { useAnalyticsEvents } from './useAnalyticsEvents';
3
3
  import { useTrackedRef } from './useTrackedRef';
4
4
  export var useCallbackWithAnalytics = function useCallbackWithAnalytics(method, payload, channel) {
5
5
  var _useAnalyticsEvents = useAnalyticsEvents(),
6
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
7
-
6
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
8
7
  var methodRef = useTrackedRef(method);
9
8
  var payloadRef = useTrackedRef(payload);
10
9
  return useCallback(function () {