@atlaskit/analytics-next 8.3.5 → 9.0.1

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 (92) hide show
  1. package/CHANGELOG.md +12 -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 -38
  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 +9 -11
  65. package/report.api.md +152 -7410
  66. package/tmp/api-report-tmp.d.ts +225 -0
  67. package/dist/types-ts4.0/components/AnalyticsContext/LegacyAnalyticsContext.d.ts +0 -29
  68. package/dist/types-ts4.0/components/AnalyticsContext/ModernAnalyticsContext.d.ts +0 -3
  69. package/dist/types-ts4.0/components/AnalyticsContext/index.d.ts +0 -3
  70. package/dist/types-ts4.0/components/AnalyticsContext/types.d.ts +0 -9
  71. package/dist/types-ts4.0/components/AnalyticsErrorBoundary.d.ts +0 -29
  72. package/dist/types-ts4.0/components/AnalyticsListener/LegacyAnalyticsListener.d.ts +0 -33
  73. package/dist/types-ts4.0/components/AnalyticsListener/ModernAnalyticsListener.d.ts +0 -3
  74. package/dist/types-ts4.0/components/AnalyticsListener/index.d.ts +0 -3
  75. package/dist/types-ts4.0/components/AnalyticsListener/types.d.ts +0 -12
  76. package/dist/types-ts4.0/events/AnalyticsEvent.d.ts +0 -15
  77. package/dist/types-ts4.0/events/UIAnalyticsEvent.d.ts +0 -20
  78. package/dist/types-ts4.0/hocs/withAnalyticsContext.d.ts +0 -6
  79. package/dist/types-ts4.0/hocs/withAnalyticsEvents.d.ts +0 -12
  80. package/dist/types-ts4.0/hooks/useAnalyticsContext.d.ts +0 -2
  81. package/dist/types-ts4.0/hooks/useAnalyticsEvents.d.ts +0 -5
  82. package/dist/types-ts4.0/hooks/useCallbackWithAnalytics.d.ts +0 -2
  83. package/dist/types-ts4.0/hooks/usePatchedProps.d.ts +0 -5
  84. package/dist/types-ts4.0/hooks/usePlatformLeafEventHandler.d.ts +0 -12
  85. package/dist/types-ts4.0/hooks/usePlatformLeafSyntheticEventHandler.d.ts +0 -11
  86. package/dist/types-ts4.0/hooks/useTrackedRef.d.ts +0 -2
  87. package/dist/types-ts4.0/index.d.ts +0 -25
  88. package/dist/types-ts4.0/performance/examples.d.ts +0 -5
  89. package/dist/types-ts4.0/test-utils/useRenderCounter.d.ts +0 -1
  90. package/dist/types-ts4.0/types.d.ts +0 -6
  91. package/dist/types-ts4.0/utils/cleanProps.d.ts +0 -3
  92. package/dist/types-ts4.0/utils/createAndFireEvent.d.ts +0 -4
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _default = function _default(channel) {
9
8
  return function (payload) {
10
9
  return function (createAnalyticsEvent) {
11
10
  var consumerEvent = createAnalyticsEvent(payload);
12
11
  var clonedEvent = consumerEvent.clone();
13
-
14
12
  if (clonedEvent) {
15
13
  clonedEvent.fire(channel);
16
14
  }
17
-
18
15
  return consumerEvent;
19
16
  };
20
17
  };
21
18
  };
22
-
23
19
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/analytics-next",
3
- "version": "8.3.5",
3
+ "version": "9.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -6,18 +6,15 @@ const ContextTypes = {
6
6
  getAtlaskitAnalyticsContext: PropTypes.func,
7
7
  getAtlaskitAnalyticsEventHandlers: PropTypes.func
8
8
  };
9
+ const noop = () => [];
9
10
 
10
- const noop = () => []; // eslint-disable-next-line @repo/internal/react/no-class-components
11
-
12
-
11
+ // eslint-disable-next-line @repo/internal/react/no-class-components
13
12
  class AnalyticsContext extends Component {
14
13
  constructor(props) {
15
14
  super(props);
16
-
17
15
  _defineProperty(this, "getChildContext", () => ({
18
16
  getAtlaskitAnalyticsContext: this.getAnalyticsContext
19
17
  }));
20
-
21
18
  _defineProperty(this, "getAnalyticsContext", () => {
22
19
  const {
23
20
  data
@@ -27,20 +24,17 @@ class AnalyticsContext extends Component {
27
24
  } = this.context;
28
25
  return [...getAtlaskitAnalyticsContext(), data];
29
26
  });
30
-
31
27
  _defineProperty(this, "getAnalyticsEventHandlers", () => {
32
28
  const {
33
29
  getAtlaskitAnalyticsEventHandlers = noop
34
30
  } = this.context;
35
31
  return getAtlaskitAnalyticsEventHandlers();
36
32
  });
37
-
38
33
  this.contextValue = {
39
34
  getAtlaskitAnalyticsContext: this.getAnalyticsContext,
40
35
  getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers
41
36
  };
42
37
  }
43
-
44
38
  render() {
45
39
  const {
46
40
  children
@@ -49,11 +43,7 @@ class AnalyticsContext extends Component {
49
43
  value: this.contextValue
50
44
  }, children);
51
45
  }
52
-
53
46
  }
54
-
55
47
  _defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
56
-
57
48
  _defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
58
-
59
49
  export default AnalyticsContext;
@@ -2,7 +2,6 @@ import React, { useCallback, useMemo } from 'react';
2
2
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
3
3
  import { useAnalyticsContext } from '../../hooks/useAnalyticsContext';
4
4
  import { useTrackedRef } from '../../hooks/useTrackedRef';
5
-
6
5
  const AnalyticsContext = ({
7
6
  data,
8
7
  children
@@ -20,5 +19,4 @@ const AnalyticsContext = ({
20
19
  value: value
21
20
  }, children);
22
21
  };
23
-
24
22
  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
  let 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,49 +1,24 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import React, { Component } from 'react';
3
- import withAnalyticsEvents from '../hocs/withAnalyticsEvents';
4
2
  import AnalyticsContext from './AnalyticsContext/LegacyAnalyticsContext';
5
- // eslint-disable-next-line @repo/internal/react/no-class-components
6
- export class BaseAnalyticsErrorBoundary extends Component {
3
+ /**
4
+ * @deprecated
5
+ */ // eslint-disable-next-line @repo/internal/react/no-class-components
6
+ export default class AnalyticsErrorBoundary extends Component {
7
7
  constructor(props) {
8
8
  super(props);
9
-
10
- _defineProperty(this, "fireAnalytics", analyticsErrorPayload => {
11
- const {
12
- createAnalyticsEvent,
13
- channel,
14
- data
15
- } = this.props;
16
- createAnalyticsEvent({
17
- action: 'UnhandledError',
18
- eventType: 'ui',
19
- attributes: {
20
- browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown',
21
- ...data,
22
- ...analyticsErrorPayload
23
- }
24
- }).fire(channel);
25
- });
26
-
27
9
  this.state = {
28
10
  hasError: false
29
11
  };
30
12
  }
31
-
32
13
  componentDidCatch(error, info) {
33
14
  const {
34
15
  onError
35
16
  } = this.props;
36
- const payload = {
37
- error,
38
- info
39
- };
40
- this.fireAnalytics(payload);
41
17
  onError && onError(error, info);
42
18
  this.setState({
43
19
  hasError: true
44
20
  });
45
21
  }
46
-
47
22
  render() {
48
23
  const {
49
24
  data,
@@ -53,18 +28,13 @@ export class BaseAnalyticsErrorBoundary extends Component {
53
28
  const {
54
29
  hasError
55
30
  } = this.state;
56
-
57
- if (hasError && ErrorComponent) {
58
- return /*#__PURE__*/React.createElement(AnalyticsContext, {
31
+ if (hasError) {
32
+ return ErrorComponent ? /*#__PURE__*/React.createElement(AnalyticsContext, {
59
33
  data: data
60
- }, /*#__PURE__*/React.createElement(ErrorComponent, null));
34
+ }, /*#__PURE__*/React.createElement(ErrorComponent, null)) : null;
61
35
  }
62
-
63
36
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
64
37
  data: data
65
38
  }, children);
66
39
  }
67
-
68
- }
69
- const AnalyticsErrorBoundary = withAnalyticsEvents()(BaseAnalyticsErrorBoundary);
70
- export default AnalyticsErrorBoundary;
40
+ }
@@ -6,19 +6,16 @@ const ContextTypes = {
6
6
  getAtlaskitAnalyticsEventHandlers: PropTypes.func,
7
7
  getAtlaskitAnalyticsContext: PropTypes.func
8
8
  };
9
+ const noop = () => [];
9
10
 
10
- const noop = () => []; // eslint-disable-next-line @repo/internal/react/no-class-components
11
-
12
-
11
+ // eslint-disable-next-line @repo/internal/react/no-class-components
13
12
  class AnalyticsListener extends Component {
14
13
  constructor(props) {
15
14
  super(props);
16
-
17
15
  _defineProperty(this, "getChildContext", () => ({
18
16
  getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,
19
17
  getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext
20
18
  }));
21
-
22
19
  _defineProperty(this, "getAnalyticsEventHandlers", () => {
23
20
  const {
24
21
  channel,
@@ -27,29 +24,24 @@ class AnalyticsListener extends Component {
27
24
  const {
28
25
  getAtlaskitAnalyticsEventHandlers = noop
29
26
  } = this.context;
30
-
31
27
  const handler = (event, eventChannel) => {
32
28
  if (channel === '*' || channel === eventChannel) {
33
29
  onEvent(event, eventChannel);
34
30
  }
35
31
  };
36
-
37
32
  return [handler, ...getAtlaskitAnalyticsEventHandlers()];
38
33
  });
39
-
40
34
  _defineProperty(this, "getAtlaskitAnalyticsContext", () => {
41
35
  const {
42
36
  getAtlaskitAnalyticsContext = noop
43
37
  } = this.context;
44
38
  return getAtlaskitAnalyticsContext();
45
39
  });
46
-
47
40
  this.contextValue = {
48
41
  getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext,
49
42
  getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers
50
43
  };
51
44
  }
52
-
53
45
  render() {
54
46
  const {
55
47
  children
@@ -58,11 +50,7 @@ class AnalyticsListener extends Component {
58
50
  value: this.contextValue
59
51
  }, children);
60
52
  }
61
-
62
53
  }
63
-
64
54
  _defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
65
-
66
55
  _defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
67
-
68
56
  export default AnalyticsListener;
@@ -2,7 +2,6 @@ import React, { useCallback, useMemo } from 'react';
2
2
  import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
3
3
  import { useAnalyticsContext } from '../../hooks/useAnalyticsContext';
4
4
  import { useTrackedRef } from '../../hooks/useTrackedRef';
5
-
6
5
  const AnalyticsListener = ({
7
6
  children,
8
7
  channel,
@@ -17,7 +16,6 @@ const AnalyticsListener = ({
17
16
  onEventRef.current(event, eventChannel);
18
17
  }
19
18
  };
20
-
21
19
  return [...analyticsContext.getAtlaskitAnalyticsEventHandlers(), thisHandler];
22
20
  }, [analyticsContext, channelRef, onEventRef]);
23
21
  const value = useMemo(() => {
@@ -30,5 +28,4 @@ const AnalyticsListener = ({
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
  let 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;
@@ -1,39 +1,35 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  export const isAnalyticsEvent = obj => {
3
3
  var _obj$constructor;
4
-
5
- return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
4
+ return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) ||
5
+ // Backwards compatibility with older analytics-next packages
6
6
  (obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'AnalyticsEvent';
7
7
  };
8
8
  export default class AnalyticsEvent {
9
9
  constructor(props) {
10
10
  _defineProperty(this, "_isAnalyticsEvent", true);
11
-
12
11
  _defineProperty(this, "clone", () => {
13
12
  // just a shallow clone, don't change sub refs unless you want to
14
13
  // affect the original's too
15
- const payload = { ...this.payload
14
+ const payload = {
15
+ ...this.payload
16
16
  };
17
17
  return new AnalyticsEvent({
18
18
  payload
19
19
  });
20
20
  });
21
-
22
21
  this.payload = props.payload;
23
22
  }
24
-
25
23
  update(updater) {
26
24
  if (typeof updater === 'function') {
27
25
  this.payload = updater(this.payload);
28
26
  }
29
-
30
27
  if (typeof updater === 'object') {
31
- this.payload = { ...this.payload,
28
+ this.payload = {
29
+ ...this.payload,
32
30
  ...updater
33
31
  };
34
32
  }
35
-
36
33
  return this;
37
34
  }
38
-
39
35
  }
@@ -2,34 +2,30 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import AnalyticsEvent from './AnalyticsEvent';
3
3
  export const isUIAnalyticsEvent = obj => {
4
4
  var _obj$constructor;
5
-
6
- return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
5
+ return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) ||
6
+ // Backwards compatibility with older analytics-next packages
7
7
  (obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'UIAnalyticsEvent';
8
8
  };
9
9
  export default class UIAnalyticsEvent extends AnalyticsEvent {
10
10
  constructor(props) {
11
11
  super(props);
12
-
13
12
  _defineProperty(this, "_isUIAnalyticsEvent", true);
14
-
15
13
  _defineProperty(this, "clone", () => {
16
14
  if (this.hasFired) {
17
15
  if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
18
16
  // eslint-disable-next-line no-console
19
17
  console.warn("Cannot clone an event after it's been fired.");
20
18
  }
21
-
22
19
  return null;
23
20
  }
24
-
25
21
  const context = [...this.context];
26
22
  const handlers = [...this.handlers];
23
+
27
24
  /**
28
25
  * A hacky "deep clone" of the object. This is limited in that it wont
29
26
  * support functions, regexs, Maps, Sets, etc, but none of those need to
30
27
  * be represented in our payload.
31
28
  */
32
-
33
29
  const payload = JSON.parse(JSON.stringify(this.payload));
34
30
  return new UIAnalyticsEvent({
35
31
  context,
@@ -37,37 +33,29 @@ export default class UIAnalyticsEvent extends AnalyticsEvent {
37
33
  payload
38
34
  });
39
35
  });
40
-
41
36
  _defineProperty(this, "fire", channel => {
42
37
  if (this.hasFired) {
43
38
  if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
44
39
  // eslint-disable-next-line no-console
45
40
  console.warn('Cannot fire an event twice.');
46
41
  }
47
-
48
42
  return;
49
43
  }
50
-
51
44
  this.handlers.forEach(handler => handler(this, channel));
52
45
  this.hasFired = true;
53
46
  });
54
-
55
47
  this.context = props.context || [];
56
48
  this.handlers = props.handlers || [];
57
49
  this.hasFired = false;
58
50
  }
59
-
60
51
  update(updater) {
61
52
  if (this.hasFired) {
62
53
  if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
63
54
  // eslint-disable-next-line no-console
64
55
  console.warn("Cannot update an event after it's been fired.");
65
56
  }
66
-
67
57
  return this;
68
58
  }
69
-
70
59
  return super.update(updater);
71
60
  }
72
-
73
61
  }
@@ -1,13 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef, useMemo } from 'react';
3
3
  import AnalyticsContext from '../components/AnalyticsContext';
4
-
5
4
  const withAnalyticsContext = defaultData => WrappedComponent => {
6
5
  const WithAnalyticsContext = /*#__PURE__*/forwardRef(({
7
6
  analyticsContext,
8
7
  ...rest
9
8
  }, ref) => {
10
- const analyticsData = useMemo(() => ({ ...defaultData,
9
+ const analyticsData = useMemo(() => ({
10
+ ...defaultData,
11
11
  ...analyticsContext
12
12
  }), [analyticsContext]);
13
13
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
@@ -15,11 +15,12 @@ const withAnalyticsContext = defaultData => WrappedComponent => {
15
15
  }, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, rest, {
16
16
  ref: ref
17
17
  })));
18
- }); // @ts-ignore
18
+ });
19
19
 
20
- WithAnalyticsContext.displayName = `WithAnalyticsContext(${// @ts-ignore disneyName doesn't exist on type
20
+ // @ts-ignore
21
+ WithAnalyticsContext.displayName = `WithAnalyticsContext(${
22
+ // @ts-ignore disneyName doesn't exist on type
21
23
  WrappedComponent.displayName || WrappedComponent.name})`;
22
24
  return WithAnalyticsContext;
23
25
  };
24
-
25
26
  export default withAnalyticsContext;
@@ -2,7 +2,6 @@ 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
  const withAnalyticsEvents = (createEventMap = {}) => WrappedComponent => {
7
6
  const WithAnalyticsEvents = /*#__PURE__*/forwardRef((props, ref) => {
8
7
  const {
@@ -15,11 +14,12 @@ const withAnalyticsEvents = (createEventMap = {}) => WrappedComponent => {
15
14
  createAnalyticsEvent: createAnalyticsEvent,
16
15
  ref: ref
17
16
  }));
18
- }); // @ts-ignore
17
+ });
19
18
 
20
- WithAnalyticsEvents.displayName = `WithAnalyticsEvents(${// @ts-ignore disneyName doesn't exist on type
19
+ // @ts-ignore
20
+ WithAnalyticsEvents.displayName = `WithAnalyticsEvents(${
21
+ // @ts-ignore disneyName doesn't exist on type
21
22
  WrappedComponent.displayName || WrappedComponent.name})`;
22
23
  return WithAnalyticsEvents;
23
24
  };
24
-
25
25
  export default withAnalyticsEvents;
@@ -6,38 +6,35 @@ export function usePatchedProps(createEventMap = {}, wrappedComponentProps) {
6
6
  } = useAnalyticsEvents();
7
7
  const handlerCache = useRef({});
8
8
  const patchedProps = useMemo(() => {
9
- const cache = handlerCache.current; // Clean up no longer used handlers in cache
9
+ const cache = handlerCache.current;
10
10
 
11
+ // Clean up no longer used handlers in cache
11
12
  Object.keys(cache).filter(key => !(key in createEventMap)).forEach(key => delete cache[key]);
12
13
  return Object.keys(createEventMap).reduce((p, k) => {
13
14
  const eventCreator = createEventMap[k];
14
-
15
15
  if (!['object', 'function'].includes(typeof eventCreator)) {
16
16
  return p;
17
17
  }
18
-
19
18
  const propValue = wrappedComponentProps[k];
20
-
21
19
  if (k in cache && cache[k].eventCreator === eventCreator && cache[k].propValue === propValue) {
22
- return { ...p,
20
+ return {
21
+ ...p,
23
22
  [k]: cache[k].wrappedCallback
24
23
  };
25
24
  }
26
-
27
25
  const wrappedCallback = (...args) => {
28
26
  const analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
29
-
30
27
  if (propValue && typeof propValue === 'function') {
31
28
  propValue(...args, analyticsEvent);
32
29
  }
33
30
  };
34
-
35
31
  cache[k] = {
36
32
  eventCreator,
37
33
  wrappedCallback,
38
34
  propValue
39
35
  };
40
- return { ...p,
36
+ return {
37
+ ...p,
41
38
  [k]: wrappedCallback
42
39
  };
43
40
  }, {});
@@ -18,11 +18,12 @@ export function usePlatformLeafEventHandler({
18
18
  }) {
19
19
  const {
20
20
  createAnalyticsEvent
21
- } = useAnalyticsEvents(); // We put analyticsData and fn in a ref so that we don't need to break
21
+ } = useAnalyticsEvents();
22
+
23
+ // We put analyticsData and fn in a ref so that we don't need to break
22
24
  // memoization.
23
25
  // Generally these could be defined by consumers inline
24
26
  // and so we do this to avoid breaking memoization of useCallback
25
-
26
27
  const dataRef = useTrackedRef(analyticsData);
27
28
  const fnRef = useTrackedRef(fn);
28
29
  const handler = useCallback(value => {
@@ -34,28 +35,31 @@ export function usePlatformLeafEventHandler({
34
35
  packageName,
35
36
  packageVersion
36
37
  }
37
- }); // To avoid wrapping this component in AnalyticsContext we manually
38
+ });
39
+
40
+ // To avoid wrapping this component in AnalyticsContext we manually
38
41
  // push the parent context's meta data into the context.
39
42
  // Note: this new 'context'
40
-
41
43
  const context = {
42
44
  componentName,
43
45
  packageName,
44
46
  packageVersion,
45
47
  ...dataRef.current
46
48
  };
47
- analyticsEvent.context.push(context); // fire an event on the atlaskit channel
49
+ analyticsEvent.context.push(context);
48
50
 
51
+ // fire an event on the atlaskit channel
49
52
  const clone = analyticsEvent.clone();
50
-
51
53
  if (clone) {
52
54
  clone.fire('atlaskit');
53
55
  }
54
-
55
56
  fnRef.current(value, analyticsEvent);
56
- }, [// These are strings and won't change
57
- action, componentName, actionSubject, packageName, packageVersion, // This function is memoized in the context
58
- createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
57
+ }, [
58
+ // These are strings and won't change
59
+ action, componentName, actionSubject, packageName, packageVersion,
60
+ // This function is memoized in the context
61
+ createAnalyticsEvent,
62
+ // these are a stable ref because of the useTrackedRef hook
59
63
  dataRef, fnRef]);
60
64
  return handler;
61
65
  }
@@ -17,11 +17,12 @@ export function usePlatformLeafSyntheticEventHandler({
17
17
  }) {
18
18
  const {
19
19
  createAnalyticsEvent
20
- } = useAnalyticsEvents(); // We put analyticsData and fn in a ref so that we don't need to break
20
+ } = useAnalyticsEvents();
21
+
22
+ // We put analyticsData and fn in a ref so that we don't need to break
21
23
  // memoization.
22
24
  // Generally these could be defined by consumers inline
23
25
  // and so we do this to avoid breaking memoization of useCallback
24
-
25
26
  const dataRef = useTrackedRef(analyticsData);
26
27
  const fnRef = useTrackedRef(fn);
27
28
  const handler = useCallback(() => {
@@ -33,28 +34,31 @@ export function usePlatformLeafSyntheticEventHandler({
33
34
  packageName,
34
35
  packageVersion
35
36
  }
36
- }); // To avoid wrapping this component in AnalyticsContext we manually
37
+ });
38
+
39
+ // To avoid wrapping this component in AnalyticsContext we manually
37
40
  // push the parent context's meta data into the context.
38
41
  // Note: this new 'context'
39
-
40
42
  const context = {
41
43
  componentName,
42
44
  packageName,
43
45
  packageVersion,
44
46
  ...dataRef.current
45
47
  };
46
- analyticsEvent.context.push(context); // fire an event on the atlaskit channel
48
+ analyticsEvent.context.push(context);
47
49
 
50
+ // fire an event on the atlaskit channel
48
51
  const clone = analyticsEvent.clone();
49
-
50
52
  if (clone) {
51
53
  clone.fire('atlaskit');
52
54
  }
53
-
54
55
  fnRef.current(analyticsEvent);
55
- }, [// These are strings and won't change
56
- action, componentName, packageName, packageVersion, // This function is memoized in the context
57
- createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
56
+ }, [
57
+ // These are strings and won't change
58
+ action, componentName, packageName, packageVersion,
59
+ // This function is memoized in the context
60
+ createAnalyticsEvent,
61
+ // these are a stable ref because of the useTrackedRef hook
58
62
  dataRef, fnRef]);
59
63
  return handler;
60
64
  }
@@ -2,8 +2,9 @@
2
2
  export { default as AnalyticsEvent, isAnalyticsEvent } from './events/AnalyticsEvent';
3
3
  export { default as UIAnalyticsEvent, isUIAnalyticsEvent } from './events/UIAnalyticsEvent';
4
4
  // AnalyticsListener component
5
- export { default as AnalyticsListener } from './components/AnalyticsListener/index'; // AnalyticsContext component and HOC
5
+ export { default as AnalyticsListener } from './components/AnalyticsListener/index';
6
6
 
7
+ // AnalyticsContext component and HOC
7
8
  export { default as AnalyticsContext } from './components/AnalyticsContext/index';
8
9
  export { default as withAnalyticsContext } from './hocs/withAnalyticsContext';
9
10
  // AnalyticsErrorBoundary component
@@ -1,5 +1,6 @@
1
- import { useEffect, useRef } from 'react'; // Hook to track the number of renders in tests
1
+ import { useEffect, useRef } from 'react';
2
2
 
3
+ // Hook to track the number of renders in tests
3
4
  export const useRenderCounter = () => {
4
5
  const ref = useRef(1);
5
6
  useEffect(() => {
@@ -1,10 +1,8 @@
1
1
  export default (channel => payload => createAnalyticsEvent => {
2
2
  const consumerEvent = createAnalyticsEvent(payload);
3
3
  const clonedEvent = consumerEvent.clone();
4
-
5
4
  if (clonedEvent) {
6
5
  clonedEvent.fire(channel);
7
6
  }
8
-
9
7
  return consumerEvent;
10
8
  });
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/analytics-next",
3
- "version": "8.3.5",
3
+ "version": "9.0.1",
4
4
  "sideEffects": false
5
5
  }