@atlaskit/analytics-next 11.1.3 → 11.2.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.
- package/AnalyticsReactContext/package.json +15 -0
- package/CHANGELOG.md +14 -20
- package/afm-cc/tsconfig.json +3 -3
- package/afm-jira/tsconfig.json +6 -8
- package/{afm-adminhub → afm-products}/tsconfig.json +5 -5
- package/cleanProps/package.json +15 -0
- package/dist/cjs/components/AnalyticsContext/LegacyAnalyticsContext.js +71 -0
- package/dist/cjs/components/AnalyticsContext/index.js +9 -1
- package/dist/cjs/components/AnalyticsErrorBoundary.js +16 -2
- package/dist/cjs/components/AnalyticsListener/LegacyAnalyticsListener.js +79 -0
- package/dist/cjs/components/AnalyticsListener/index.js +9 -1
- package/dist/cjs/components/AnalyticsReactContext.js +13 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/utils/isModernContextEnabledEnv.js +10 -0
- package/dist/es2019/components/AnalyticsContext/LegacyAnalyticsContext.js +49 -0
- package/dist/es2019/components/AnalyticsContext/index.js +9 -1
- package/dist/es2019/components/AnalyticsErrorBoundary.js +16 -2
- package/dist/es2019/components/AnalyticsListener/LegacyAnalyticsListener.js +56 -0
- package/dist/es2019/components/AnalyticsListener/index.js +9 -1
- package/dist/es2019/components/AnalyticsReactContext.js +1 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/utils/isModernContextEnabledEnv.js +4 -0
- package/dist/esm/components/AnalyticsContext/LegacyAnalyticsContext.js +62 -0
- package/dist/esm/components/AnalyticsContext/index.js +9 -1
- package/dist/esm/components/AnalyticsErrorBoundary.js +16 -2
- package/dist/esm/components/AnalyticsListener/LegacyAnalyticsListener.js +70 -0
- package/dist/esm/components/AnalyticsListener/index.js +9 -1
- package/dist/esm/components/AnalyticsReactContext.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/isModernContextEnabledEnv.js +4 -0
- package/dist/types/components/AnalyticsContext/LegacyAnalyticsContext.d.ts +30 -0
- package/dist/types/components/AnalyticsContext/index.d.ts +3 -2
- package/dist/types/components/AnalyticsContext/types.d.ts +1 -1
- package/dist/types/components/AnalyticsListener/LegacyAnalyticsListener.d.ts +34 -0
- package/dist/types/components/AnalyticsListener/index.d.ts +3 -2
- package/dist/types/components/AnalyticsListener/types.d.ts +1 -1
- package/dist/types/components/AnalyticsReactContext.d.ts +2 -0
- package/dist/types/hocs/withAnalyticsEvents.d.ts +1 -1
- package/dist/types/hooks/useAnalyticsEvents.d.ts +1 -1
- package/dist/types/hooks/usePatchedProps.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils/createAndFireEvent.d.ts +4 -3
- package/dist/types/utils/isModernContextEnabledEnv.d.ts +2 -0
- package/dist/types-ts4.5/components/AnalyticsContext/LegacyAnalyticsContext.d.ts +30 -0
- package/dist/types-ts4.5/components/AnalyticsContext/index.d.ts +3 -2
- package/dist/types-ts4.5/components/AnalyticsContext/types.d.ts +1 -1
- package/dist/types-ts4.5/components/AnalyticsListener/LegacyAnalyticsListener.d.ts +34 -0
- package/dist/types-ts4.5/components/AnalyticsListener/index.d.ts +3 -2
- package/dist/types-ts4.5/components/AnalyticsListener/types.d.ts +1 -1
- package/dist/types-ts4.5/components/AnalyticsReactContext.d.ts +2 -0
- package/dist/types-ts4.5/hocs/withAnalyticsEvents.d.ts +1 -1
- package/dist/types-ts4.5/hooks/useAnalyticsEvents.d.ts +1 -1
- package/dist/types-ts4.5/hooks/usePatchedProps.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/dist/types-ts4.5/utils/createAndFireEvent.d.ts +4 -3
- package/dist/types-ts4.5/utils/isModernContextEnabledEnv.d.ts +2 -0
- package/docs/0-intro.tsx +2 -1
- package/docs/10-concepts.tsx +2 -1
- package/docs/20-usage-with-presentational-components.tsx +2 -1
- package/docs/30-usage-for-container-components.tsx +2 -1
- package/docs/40-listeners.tsx +2 -1
- package/docs/50-error-boundary.tsx +2 -1
- package/docs/60-events.tsx +2 -1
- package/docs/70-advanced-usage.tsx +2 -1
- package/docs/80-upgrade-guide.tsx +2 -1
- package/package.json +9 -5
- package/tsconfig.json +1 -2
- package/usePlatformLeafSyntheticEventHandler/package.json +15 -0
- package/afm-dev-agents/tsconfig.json +0 -32
- package/afm-passionfruit/tsconfig.json +0 -32
- package/afm-post-office/tsconfig.json +0 -32
- package/afm-rovo-extension/tsconfig.json +0 -32
- package/afm-townsquare/tsconfig.json +0 -32
- package/afm-volt/tsconfig.json +0 -32
- package/build/tsconfig.json +0 -25
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
|
|
5
|
+
const ContextTypes = {
|
|
6
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
|
|
7
|
+
getAtlaskitAnalyticsContext: PropTypes.func
|
|
8
|
+
};
|
|
9
|
+
const noop = () => [];
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
12
|
+
class AnalyticsListener extends Component {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
_defineProperty(this, "getChildContext", () => ({
|
|
16
|
+
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,
|
|
17
|
+
getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext
|
|
18
|
+
}));
|
|
19
|
+
_defineProperty(this, "getAnalyticsEventHandlers", () => {
|
|
20
|
+
const {
|
|
21
|
+
channel,
|
|
22
|
+
onEvent
|
|
23
|
+
} = this.props;
|
|
24
|
+
const {
|
|
25
|
+
getAtlaskitAnalyticsEventHandlers = noop
|
|
26
|
+
} = this.context;
|
|
27
|
+
const handler = (event, eventChannel) => {
|
|
28
|
+
if (channel === '*' || channel === eventChannel) {
|
|
29
|
+
onEvent(event, eventChannel);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return [handler, ...getAtlaskitAnalyticsEventHandlers()];
|
|
33
|
+
});
|
|
34
|
+
_defineProperty(this, "getAtlaskitAnalyticsContext", () => {
|
|
35
|
+
const {
|
|
36
|
+
getAtlaskitAnalyticsContext = noop
|
|
37
|
+
} = this.context;
|
|
38
|
+
return getAtlaskitAnalyticsContext();
|
|
39
|
+
});
|
|
40
|
+
this.contextValue = {
|
|
41
|
+
getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext,
|
|
42
|
+
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
const {
|
|
47
|
+
children
|
|
48
|
+
} = this.props;
|
|
49
|
+
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
|
|
50
|
+
value: this.contextValue
|
|
51
|
+
}, children);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
|
|
55
|
+
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
|
|
56
|
+
export default AnalyticsListener;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import isModernContextEnabledEnv from '../../utils/isModernContextEnabledEnv';
|
|
4
|
+
import LegacyAnalyticsListener from './LegacyAnalyticsListener';
|
|
1
5
|
import ModernAnalyticsListener from './ModernAnalyticsListener';
|
|
2
|
-
|
|
6
|
+
const AnalyticsListener = props => {
|
|
7
|
+
const isModernContext = isModernContextEnabledEnv || fg('analytics-next-use-legacy-context') === false;
|
|
8
|
+
return isModernContext ? /*#__PURE__*/React.createElement(ModernAnalyticsListener, props) : /*#__PURE__*/React.createElement(LegacyAnalyticsListener, props);
|
|
9
|
+
};
|
|
10
|
+
export default AnalyticsListener;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@atlaskit/analytics-next-stable-react-context';
|
package/dist/es2019/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { default as AnalyticsErrorBoundary } from './components/AnalyticsErrorBo
|
|
|
12
12
|
// createAnalyticsEvent HOC
|
|
13
13
|
export { default as withAnalyticsEvents } from './hocs/withAnalyticsEvents';
|
|
14
14
|
// React context
|
|
15
|
-
export { default as AnalyticsReactContext } from '
|
|
15
|
+
export { default as AnalyticsReactContext } from './components/AnalyticsReactContext';
|
|
16
16
|
// Hook for creating and firing analytics events
|
|
17
17
|
export { useAnalyticsEvents } from './hooks/useAnalyticsEvents';
|
|
18
18
|
export { useCallbackWithAnalytics } from './hooks/useCallbackWithAnalytics';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var _process$env;
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
const _default_1 = typeof process !== 'undefined' && process !== null && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']);
|
|
4
|
+
export default _default_1;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
|
+
import React, { Component } from 'react';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
|
|
13
|
+
var ContextTypes = {
|
|
14
|
+
getAtlaskitAnalyticsContext: PropTypes.func,
|
|
15
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.func
|
|
16
|
+
};
|
|
17
|
+
var noop = function noop() {
|
|
18
|
+
return [];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
22
|
+
var AnalyticsContext = /*#__PURE__*/function (_Component) {
|
|
23
|
+
function AnalyticsContext(props) {
|
|
24
|
+
var _this;
|
|
25
|
+
_classCallCheck(this, AnalyticsContext);
|
|
26
|
+
_this = _callSuper(this, AnalyticsContext, [props]);
|
|
27
|
+
_defineProperty(_this, "getChildContext", function () {
|
|
28
|
+
return {
|
|
29
|
+
getAtlaskitAnalyticsContext: _this.getAnalyticsContext
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(_this, "getAnalyticsContext", function () {
|
|
33
|
+
var data = _this.props.data;
|
|
34
|
+
var _this$context$getAtla = _this.context.getAtlaskitAnalyticsContext,
|
|
35
|
+
getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
|
|
36
|
+
return [].concat(_toConsumableArray(getAtlaskitAnalyticsContext()), [data]);
|
|
37
|
+
});
|
|
38
|
+
_defineProperty(_this, "getAnalyticsEventHandlers", function () {
|
|
39
|
+
var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsEventHandlers,
|
|
40
|
+
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
|
|
41
|
+
return getAtlaskitAnalyticsEventHandlers();
|
|
42
|
+
});
|
|
43
|
+
_this.contextValue = {
|
|
44
|
+
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
|
|
45
|
+
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
|
|
46
|
+
};
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
_inherits(AnalyticsContext, _Component);
|
|
50
|
+
return _createClass(AnalyticsContext, [{
|
|
51
|
+
key: "render",
|
|
52
|
+
value: function render() {
|
|
53
|
+
var children = this.props.children;
|
|
54
|
+
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
|
|
55
|
+
value: this.contextValue
|
|
56
|
+
}, children);
|
|
57
|
+
}
|
|
58
|
+
}]);
|
|
59
|
+
}(Component);
|
|
60
|
+
_defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
|
|
61
|
+
_defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
|
|
62
|
+
export default AnalyticsContext;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import isModernContextEnabledEnv from '../../utils/isModernContextEnabledEnv';
|
|
4
|
+
import LegacyAnalyticsContext from './LegacyAnalyticsContext';
|
|
1
5
|
import ModernAnalyticsContext from './ModernAnalyticsContext';
|
|
2
|
-
|
|
6
|
+
var AnalyticsContext = function AnalyticsContext(props) {
|
|
7
|
+
var isModernContext = isModernContextEnabledEnv || fg('analytics-next-use-legacy-context') === false;
|
|
8
|
+
return isModernContext ? /*#__PURE__*/React.createElement(ModernAnalyticsContext, props) : /*#__PURE__*/React.createElement(LegacyAnalyticsContext, props);
|
|
9
|
+
};
|
|
10
|
+
export default AnalyticsContext;
|
|
@@ -6,6 +6,9 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
7
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import React, { Component } from 'react';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
import isModernContextEnabledEnv from '../utils/isModernContextEnabledEnv';
|
|
11
|
+
import LegacyAnalyticsContext from './AnalyticsContext/LegacyAnalyticsContext';
|
|
9
12
|
import ModernAnalyticsContext from './AnalyticsContext/ModernAnalyticsContext';
|
|
10
13
|
/**
|
|
11
14
|
* @private https://product-fabric.atlassian.net/browse/AFO-815
|
|
@@ -40,15 +43,26 @@ var AnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
40
43
|
children = _this$props.children,
|
|
41
44
|
ErrorComponent = _this$props.ErrorComponent;
|
|
42
45
|
var hasError = this.state.hasError;
|
|
46
|
+
var isModernContext = isModernContextEnabledEnv || fg('analytics-next-use-legacy-context') === false;
|
|
43
47
|
if (hasError) {
|
|
44
48
|
if (ErrorComponent) {
|
|
45
|
-
|
|
49
|
+
if (isModernContext) {
|
|
50
|
+
return /*#__PURE__*/React.createElement(ModernAnalyticsContext, {
|
|
51
|
+
data: data
|
|
52
|
+
}, /*#__PURE__*/React.createElement(ErrorComponent, null));
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/React.createElement(LegacyAnalyticsContext, {
|
|
46
55
|
data: data
|
|
47
56
|
}, /*#__PURE__*/React.createElement(ErrorComponent, null));
|
|
48
57
|
}
|
|
49
58
|
return null;
|
|
50
59
|
}
|
|
51
|
-
|
|
60
|
+
if (isModernContext) {
|
|
61
|
+
return /*#__PURE__*/React.createElement(ModernAnalyticsContext, {
|
|
62
|
+
data: data
|
|
63
|
+
}, children);
|
|
64
|
+
}
|
|
65
|
+
return /*#__PURE__*/React.createElement(LegacyAnalyticsContext, {
|
|
52
66
|
data: data
|
|
53
67
|
}, children);
|
|
54
68
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
9
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
|
+
import React, { Component } from 'react';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
|
|
13
|
+
var ContextTypes = {
|
|
14
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
|
|
15
|
+
getAtlaskitAnalyticsContext: PropTypes.func
|
|
16
|
+
};
|
|
17
|
+
var noop = function noop() {
|
|
18
|
+
return [];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
22
|
+
var AnalyticsListener = /*#__PURE__*/function (_Component) {
|
|
23
|
+
function AnalyticsListener(props) {
|
|
24
|
+
var _this;
|
|
25
|
+
_classCallCheck(this, AnalyticsListener);
|
|
26
|
+
_this = _callSuper(this, AnalyticsListener, [props]);
|
|
27
|
+
_defineProperty(_this, "getChildContext", function () {
|
|
28
|
+
return {
|
|
29
|
+
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
|
|
30
|
+
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(_this, "getAnalyticsEventHandlers", function () {
|
|
34
|
+
var _this$props = _this.props,
|
|
35
|
+
channel = _this$props.channel,
|
|
36
|
+
onEvent = _this$props.onEvent;
|
|
37
|
+
var _this$context$getAtla = _this.context.getAtlaskitAnalyticsEventHandlers,
|
|
38
|
+
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
|
|
39
|
+
var handler = function handler(event, eventChannel) {
|
|
40
|
+
if (channel === '*' || channel === eventChannel) {
|
|
41
|
+
onEvent(event, eventChannel);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return [handler].concat(_toConsumableArray(getAtlaskitAnalyticsEventHandlers()));
|
|
45
|
+
});
|
|
46
|
+
_defineProperty(_this, "getAtlaskitAnalyticsContext", function () {
|
|
47
|
+
var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsContext,
|
|
48
|
+
getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
|
|
49
|
+
return getAtlaskitAnalyticsContext();
|
|
50
|
+
});
|
|
51
|
+
_this.contextValue = {
|
|
52
|
+
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
|
|
53
|
+
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
|
|
54
|
+
};
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
_inherits(AnalyticsListener, _Component);
|
|
58
|
+
return _createClass(AnalyticsListener, [{
|
|
59
|
+
key: "render",
|
|
60
|
+
value: function render() {
|
|
61
|
+
var children = this.props.children;
|
|
62
|
+
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
|
|
63
|
+
value: this.contextValue
|
|
64
|
+
}, children);
|
|
65
|
+
}
|
|
66
|
+
}]);
|
|
67
|
+
}(Component);
|
|
68
|
+
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
|
|
69
|
+
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
|
|
70
|
+
export default AnalyticsListener;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import isModernContextEnabledEnv from '../../utils/isModernContextEnabledEnv';
|
|
4
|
+
import LegacyAnalyticsListener from './LegacyAnalyticsListener';
|
|
1
5
|
import ModernAnalyticsListener from './ModernAnalyticsListener';
|
|
2
|
-
|
|
6
|
+
var AnalyticsListener = function AnalyticsListener(props) {
|
|
7
|
+
var isModernContext = isModernContextEnabledEnv || fg('analytics-next-use-legacy-context') === false;
|
|
8
|
+
return isModernContext ? /*#__PURE__*/React.createElement(ModernAnalyticsListener, props) : /*#__PURE__*/React.createElement(LegacyAnalyticsListener, props);
|
|
9
|
+
};
|
|
10
|
+
export default AnalyticsListener;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@atlaskit/analytics-next-stable-react-context';
|
package/dist/esm/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { default as AnalyticsErrorBoundary } from './components/AnalyticsErrorBo
|
|
|
12
12
|
// createAnalyticsEvent HOC
|
|
13
13
|
export { default as withAnalyticsEvents } from './hocs/withAnalyticsEvents';
|
|
14
14
|
// React context
|
|
15
|
-
export { default as AnalyticsReactContext } from '
|
|
15
|
+
export { default as AnalyticsReactContext } from './components/AnalyticsReactContext';
|
|
16
16
|
// Hook for creating and firing analytics events
|
|
17
17
|
export { useAnalyticsEvents } from './hooks/useAnalyticsEvents';
|
|
18
18
|
export { useCallbackWithAnalytics } from './hooks/useCallbackWithAnalytics';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var _process$env;
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
var _default_1 = typeof process !== 'undefined' && process !== null && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']);
|
|
4
|
+
export default _default_1;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { type AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
4
|
+
interface Props {
|
|
5
|
+
/** Children! */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Arbitrary data. Any events created below this component in the tree will
|
|
8
|
+
* have this added as an item in their context array. */
|
|
9
|
+
data: Object;
|
|
10
|
+
}
|
|
11
|
+
declare class AnalyticsContext extends Component<Props, AnalyticsReactContextInterface> {
|
|
12
|
+
context: any;
|
|
13
|
+
static contextTypes: {
|
|
14
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
+
};
|
|
17
|
+
static childContextTypes: {
|
|
18
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
};
|
|
21
|
+
contextValue: AnalyticsReactContextInterface;
|
|
22
|
+
constructor(props: Props);
|
|
23
|
+
getChildContext: () => {
|
|
24
|
+
getAtlaskitAnalyticsContext: () => any[];
|
|
25
|
+
};
|
|
26
|
+
getAnalyticsContext: () => any[];
|
|
27
|
+
getAnalyticsEventHandlers: () => any;
|
|
28
|
+
render(): React.JSX.Element;
|
|
29
|
+
}
|
|
30
|
+
export default AnalyticsContext;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { AnalyticsContextFunction } from './types';
|
|
2
|
+
declare const AnalyticsContext: AnalyticsContextFunction;
|
|
3
|
+
export default AnalyticsContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
2
2
|
export type AnalyticsContextFunction = (props: {
|
|
3
3
|
/** Children! */
|
|
4
4
|
children: React.ReactNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { type AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
4
|
+
import type { default as UIAnalyticsEvent } from '../../events/UIAnalyticsEvent';
|
|
5
|
+
type Props = {
|
|
6
|
+
/** The channel to listen for events on. */
|
|
7
|
+
channel?: string;
|
|
8
|
+
/** Children! */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** A function which will be called when an event is fired on this Listener's
|
|
11
|
+
* channel. It is passed the event and the channel as arguments. */
|
|
12
|
+
onEvent: (event: UIAnalyticsEvent, channel?: string) => void;
|
|
13
|
+
};
|
|
14
|
+
declare class AnalyticsListener extends Component<Props> {
|
|
15
|
+
context: any;
|
|
16
|
+
static contextTypes: {
|
|
17
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
};
|
|
20
|
+
static childContextTypes: {
|
|
21
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
+
};
|
|
24
|
+
contextValue: AnalyticsReactContextInterface;
|
|
25
|
+
constructor(props: Props);
|
|
26
|
+
getChildContext: () => {
|
|
27
|
+
getAtlaskitAnalyticsContext: () => any;
|
|
28
|
+
getAtlaskitAnalyticsEventHandlers: () => any[];
|
|
29
|
+
};
|
|
30
|
+
getAnalyticsEventHandlers: () => any[];
|
|
31
|
+
getAtlaskitAnalyticsContext: () => any;
|
|
32
|
+
render(): React.JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
export default AnalyticsListener;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { AnalyticsListenerFunction } from './types';
|
|
2
|
+
declare const AnalyticsListener: AnalyticsListenerFunction;
|
|
3
|
+
export default AnalyticsListener;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
2
2
|
import type UIAnalyticsEvent from '../../events/UIAnalyticsEvent';
|
|
3
3
|
export type AnalyticsListenerFunction = (props: {
|
|
4
4
|
/** The channel to listen for events on. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { CreateEventMap, CreateUIAnalyticsEvent } from '../types';
|
|
3
3
|
export interface WithAnalyticsEventsProps {
|
|
4
4
|
/**
|
|
5
5
|
* You should not be accessing this prop under any circumstances.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export { default as AnalyticsErrorBoundary } from './components/AnalyticsErrorBo
|
|
|
11
11
|
export type { AnalyticsErrorBoundaryProps } from './components/AnalyticsErrorBoundary';
|
|
12
12
|
export { default as withAnalyticsEvents } from './hocs/withAnalyticsEvents';
|
|
13
13
|
export type { WithAnalyticsEventsProps } from './hocs/withAnalyticsEvents';
|
|
14
|
-
export { default as AnalyticsReactContext } from '
|
|
15
|
-
export type { AnalyticsReactContextInterface } from '
|
|
14
|
+
export { default as AnalyticsReactContext } from './components/AnalyticsReactContext';
|
|
15
|
+
export type { AnalyticsReactContextInterface } from './components/AnalyticsReactContext';
|
|
16
16
|
export { useAnalyticsEvents } from './hooks/useAnalyticsEvents';
|
|
17
17
|
export type { UseAnalyticsEventsHook } from './hooks/useAnalyticsEvents';
|
|
18
18
|
export { useCallbackWithAnalytics } from './hooks/useCallbackWithAnalytics';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnalyticsEventPayload } from './events/AnalyticsEvent';
|
|
2
2
|
import type UIAnalyticsEvent from './events/UIAnalyticsEvent';
|
|
3
3
|
export type CreateUIAnalyticsEvent = (payload: AnalyticsEventPayload) => UIAnalyticsEvent;
|
|
4
4
|
export type AnalyticsEventCreator = (create: CreateUIAnalyticsEvent, props: Record<string, any>) => UIAnalyticsEvent | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import type { AnalyticsEventPayload } from '../events/AnalyticsEvent';
|
|
2
|
+
import type UIAnalyticsEvent from '../events/UIAnalyticsEvent';
|
|
3
|
+
import type { CreateUIAnalyticsEvent } from '../types';
|
|
4
|
+
declare const _default: (channel?: string) => (payload: AnalyticsEventPayload) => (createAnalyticsEvent: CreateUIAnalyticsEvent) => UIAnalyticsEvent;
|
|
4
5
|
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { type AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
4
|
+
interface Props {
|
|
5
|
+
/** Children! */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Arbitrary data. Any events created below this component in the tree will
|
|
8
|
+
* have this added as an item in their context array. */
|
|
9
|
+
data: Object;
|
|
10
|
+
}
|
|
11
|
+
declare class AnalyticsContext extends Component<Props, AnalyticsReactContextInterface> {
|
|
12
|
+
context: any;
|
|
13
|
+
static contextTypes: {
|
|
14
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
15
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
+
};
|
|
17
|
+
static childContextTypes: {
|
|
18
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
};
|
|
21
|
+
contextValue: AnalyticsReactContextInterface;
|
|
22
|
+
constructor(props: Props);
|
|
23
|
+
getChildContext: () => {
|
|
24
|
+
getAtlaskitAnalyticsContext: () => any[];
|
|
25
|
+
};
|
|
26
|
+
getAnalyticsContext: () => any[];
|
|
27
|
+
getAnalyticsEventHandlers: () => any;
|
|
28
|
+
render(): React.JSX.Element;
|
|
29
|
+
}
|
|
30
|
+
export default AnalyticsContext;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { AnalyticsContextFunction } from './types';
|
|
2
|
+
declare const AnalyticsContext: AnalyticsContextFunction;
|
|
3
|
+
export default AnalyticsContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
2
2
|
export type AnalyticsContextFunction = (props: {
|
|
3
3
|
/** Children! */
|
|
4
4
|
children: React.ReactNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { type AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
4
|
+
import type { default as UIAnalyticsEvent } from '../../events/UIAnalyticsEvent';
|
|
5
|
+
type Props = {
|
|
6
|
+
/** The channel to listen for events on. */
|
|
7
|
+
channel?: string;
|
|
8
|
+
/** Children! */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** A function which will be called when an event is fired on this Listener's
|
|
11
|
+
* channel. It is passed the event and the channel as arguments. */
|
|
12
|
+
onEvent: (event: UIAnalyticsEvent, channel?: string) => void;
|
|
13
|
+
};
|
|
14
|
+
declare class AnalyticsListener extends Component<Props> {
|
|
15
|
+
context: any;
|
|
16
|
+
static contextTypes: {
|
|
17
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
};
|
|
20
|
+
static childContextTypes: {
|
|
21
|
+
getAtlaskitAnalyticsEventHandlers: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
+
getAtlaskitAnalyticsContext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
+
};
|
|
24
|
+
contextValue: AnalyticsReactContextInterface;
|
|
25
|
+
constructor(props: Props);
|
|
26
|
+
getChildContext: () => {
|
|
27
|
+
getAtlaskitAnalyticsContext: () => any;
|
|
28
|
+
getAtlaskitAnalyticsEventHandlers: () => any[];
|
|
29
|
+
};
|
|
30
|
+
getAnalyticsEventHandlers: () => any[];
|
|
31
|
+
getAtlaskitAnalyticsContext: () => any;
|
|
32
|
+
render(): React.JSX.Element;
|
|
33
|
+
}
|
|
34
|
+
export default AnalyticsListener;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { AnalyticsListenerFunction } from './types';
|
|
2
|
+
declare const AnalyticsListener: AnalyticsListenerFunction;
|
|
3
|
+
export default AnalyticsListener;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnalyticsReactContextInterface } from '@atlaskit/analytics-next-stable-react-context';
|
|
2
2
|
import type UIAnalyticsEvent from '../../events/UIAnalyticsEvent';
|
|
3
3
|
export type AnalyticsListenerFunction = (props: {
|
|
4
4
|
/** The channel to listen for events on. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { CreateEventMap, CreateUIAnalyticsEvent } from '../types';
|
|
3
3
|
export interface WithAnalyticsEventsProps {
|
|
4
4
|
/**
|
|
5
5
|
* You should not be accessing this prop under any circumstances.
|
|
@@ -11,8 +11,8 @@ export { default as AnalyticsErrorBoundary } from './components/AnalyticsErrorBo
|
|
|
11
11
|
export type { AnalyticsErrorBoundaryProps } from './components/AnalyticsErrorBoundary';
|
|
12
12
|
export { default as withAnalyticsEvents } from './hocs/withAnalyticsEvents';
|
|
13
13
|
export type { WithAnalyticsEventsProps } from './hocs/withAnalyticsEvents';
|
|
14
|
-
export { default as AnalyticsReactContext } from '
|
|
15
|
-
export type { AnalyticsReactContextInterface } from '
|
|
14
|
+
export { default as AnalyticsReactContext } from './components/AnalyticsReactContext';
|
|
15
|
+
export type { AnalyticsReactContextInterface } from './components/AnalyticsReactContext';
|
|
16
16
|
export { useAnalyticsEvents } from './hooks/useAnalyticsEvents';
|
|
17
17
|
export type { UseAnalyticsEventsHook } from './hooks/useAnalyticsEvents';
|
|
18
18
|
export { useCallbackWithAnalytics } from './hooks/useCallbackWithAnalytics';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnalyticsEventPayload } from './events/AnalyticsEvent';
|
|
2
2
|
import type UIAnalyticsEvent from './events/UIAnalyticsEvent';
|
|
3
3
|
export type CreateUIAnalyticsEvent = (payload: AnalyticsEventPayload) => UIAnalyticsEvent;
|
|
4
4
|
export type AnalyticsEventCreator = (create: CreateUIAnalyticsEvent, props: Record<string, any>) => UIAnalyticsEvent | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import type { AnalyticsEventPayload } from '../events/AnalyticsEvent';
|
|
2
|
+
import type UIAnalyticsEvent from '../events/UIAnalyticsEvent';
|
|
3
|
+
import type { CreateUIAnalyticsEvent } from '../types';
|
|
4
|
+
declare const _default: (channel?: string) => (payload: AnalyticsEventPayload) => (createAnalyticsEvent: CreateUIAnalyticsEvent) => UIAnalyticsEvent;
|
|
4
5
|
export default _default;
|