@atlaskit/analytics-next
Advanced tools
Comparing version 3.0.8 to 3.0.9
# @atlaskit/analytics-next | ||
## 3.0.9 | ||
- [patch] adds missing babel-runtime dependency to package json [93b031a](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/93b031a) | ||
## 3.0.8 | ||
@@ -4,0 +7,0 @@ - [patch] Fixing analytics events for checkbox/radio/select [3e428e3](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/3e428e3) |
@@ -1,72 +0,67 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _react = require("react"); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _react = require('react'); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var ContextTypes = { | ||
getAtlaskitAnalyticsContext: _propTypes2.default.func | ||
getAtlaskitAnalyticsContext: _propTypes.default.func | ||
}; | ||
var AnalyticsContext = function (_Component) { | ||
(0, _inherits3.default)(AnalyticsContext, _Component); | ||
var AnalyticsContext = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(AnalyticsContext, _Component); | ||
function AnalyticsContext() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
(0, _classCallCheck3.default)(this, AnalyticsContext); | ||
(0, _classCallCheck2.default)(this, AnalyticsContext); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = AnalyticsContext.__proto__ || (0, _getPrototypeOf2.default)(AnalyticsContext)).call.apply(_ref, [this].concat(args))), _this), _this.getChildContext = function () { | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(AnalyticsContext)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "getChildContext", function () { | ||
return { | ||
getAtlaskitAnalyticsContext: _this.getAnalyticsContext | ||
}; | ||
}, _this.getAnalyticsContext = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "getAnalyticsContext", function () { | ||
var data = _this.props.data; | ||
var getAtlaskitAnalyticsContext = _this.context.getAtlaskitAnalyticsContext; | ||
var ancestorData = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
return [].concat((0, _toConsumableArray3.default)(ancestorData), [data]); | ||
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret); | ||
return (0, _toConsumableArray2.default)(ancestorData).concat([data]); | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass3.default)(AnalyticsContext, [{ | ||
key: 'render', | ||
(0, _createClass2.default)(AnalyticsContext, [{ | ||
key: "render", | ||
value: function render() { | ||
@@ -79,4 +74,4 @@ return _react.Children.only(this.props.children); | ||
AnalyticsContext.contextTypes = ContextTypes; | ||
AnalyticsContext.childContextTypes = ContextTypes; | ||
exports.default = AnalyticsContext; | ||
exports.default = AnalyticsContext; | ||
(0, _defineProperty2.default)(AnalyticsContext, "contextTypes", ContextTypes); | ||
(0, _defineProperty2.default)(AnalyticsContext, "childContextTypes", ContextTypes); |
@@ -1,54 +0,47 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _typeof2 = require('babel-runtime/helpers/typeof'); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _typeof3 = _interopRequireDefault(_typeof2); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var AnalyticsEvent = function () { | ||
var AnalyticsEvent = | ||
/*#__PURE__*/ | ||
function () { | ||
function AnalyticsEvent(props) { | ||
var _this = this; | ||
(0, _classCallCheck3.default)(this, AnalyticsEvent); | ||
this.clone = function () { | ||
(0, _classCallCheck2.default)(this, AnalyticsEvent); | ||
(0, _defineProperty2.default)(this, "payload", void 0); | ||
(0, _defineProperty2.default)(this, "clone", function () { | ||
// We stringify and parse here to get a hacky "deep clone" of the object. | ||
// This has some limitations in that it wont support functions, regexs, Maps, Sets, etc, | ||
// but none of those need to be represented in our payload, so we consider this fine | ||
var payload = JSON.parse((0, _stringify2.default)(_this.payload)); | ||
return new AnalyticsEvent({ payload: payload }); | ||
}; | ||
var payload = JSON.parse(JSON.stringify(_this.payload)); | ||
return new AnalyticsEvent({ | ||
payload: payload | ||
}); | ||
}); | ||
this.payload = props.payload; | ||
} | ||
(0, _createClass3.default)(AnalyticsEvent, [{ | ||
key: 'update', | ||
(0, _createClass2.default)(AnalyticsEvent, [{ | ||
key: "update", | ||
value: function update(updater) { | ||
if (typeof updater === 'function') { | ||
this.payload = updater(this.payload); | ||
} else if ((typeof updater === 'undefined' ? 'undefined' : (0, _typeof3.default)(updater)) === 'object') { | ||
this.payload = (0, _extends3.default)({}, this.payload, updater); | ||
} else if ((0, _typeof2.default)(updater) === 'object') { | ||
this.payload = (0, _objectSpread2.default)({}, this.payload, updater); | ||
} | ||
@@ -55,0 +48,0 @@ |
@@ -1,9 +0,11 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* This map was originally used to configure the analytics codemod to run over | ||
* each component. | ||
* It is now also used as the source of truth for the instrumented components section of | ||
* the docs. | ||
* If analytics has been manually for a component and you do not wish for it to be | ||
* codemodded, add an `ignore: true` prop to it. | ||
*/ | ||
var analyticsEventMap = [{ | ||
@@ -498,15 +500,4 @@ path: 'avatar/src/components/Avatar.js', | ||
componentTestPath: 'tooltip/src/components/__tests__/Tooltip.js' | ||
}]; | ||
}]; // $FlowFixMe | ||
// $FlowFixMe | ||
/** | ||
* This map was originally used to configure the analytics codemod to run over | ||
* each component. | ||
* It is now also used as the source of truth for the instrumented components section of | ||
* the docs. | ||
* If analytics has been manually for a component and you do not wish for it to be | ||
* codemodded, add an `ignore: true` prop to it. | ||
*/ | ||
module.exports.analyticsPackages = analyticsEventMap.filter(function (pkg) { | ||
@@ -516,8 +507,5 @@ return pkg.test !== true; | ||
var path = config.path; | ||
return path.substring(0, path.indexOf('/')); | ||
}); | ||
module.exports.analyticsEventMap = analyticsEventMap; | ||
module.exports.instrumentedComponents = analyticsEventMap.filter(function (pkg) { | ||
@@ -529,14 +517,16 @@ return pkg.test !== true; | ||
var items = []; | ||
(0, _keys2.default)(config.props).forEach(function (propName) { | ||
Object.keys(config.props).forEach(function (propName) { | ||
var components = config.derivatives ? [config.component].concat(config.derivatives).join(', ') : config.component; | ||
items.push({ | ||
packageName: '@atlaskit/' + packageSuffix, | ||
packageName: "@atlaskit/".concat(packageSuffix), | ||
component: components, | ||
actionSubject: config.actionSubject, | ||
prop: propName, | ||
payload: { action: config.props[propName] } | ||
payload: { | ||
action: config.props[propName] | ||
} | ||
}); | ||
}); | ||
// $FlowFixMe | ||
}); // $FlowFixMe | ||
return acc.concat(items); | ||
}, []); |
@@ -1,66 +0,59 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _react = require("react"); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _UIAnalyticsEvent = _interopRequireDefault(require("./UIAnalyticsEvent")); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _react = require('react'); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _UIAnalyticsEvent = require('./UIAnalyticsEvent'); | ||
var _UIAnalyticsEvent2 = _interopRequireDefault(_UIAnalyticsEvent); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var ContextTypes = { | ||
getAtlaskitAnalyticsEventHandlers: _propTypes2.default.func | ||
getAtlaskitAnalyticsEventHandlers: _propTypes.default.func | ||
}; | ||
var AnalyticsListener = function (_Component) { | ||
(0, _inherits3.default)(AnalyticsListener, _Component); | ||
var AnalyticsListener = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(AnalyticsListener, _Component); | ||
function AnalyticsListener() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
(0, _classCallCheck3.default)(this, AnalyticsListener); | ||
(0, _classCallCheck2.default)(this, AnalyticsListener); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = AnalyticsListener.__proto__ || (0, _getPrototypeOf2.default)(AnalyticsListener)).call.apply(_ref, [this].concat(args))), _this), _this.getChildContext = function () { | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(AnalyticsListener)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "getChildContext", function () { | ||
return { | ||
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers | ||
}; | ||
}, _this.getAnalyticsEventHandlers = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "getAnalyticsEventHandlers", function () { | ||
var _this$props = _this.props, | ||
@@ -70,4 +63,4 @@ channel = _this$props.channel, | ||
var getAtlaskitAnalyticsEventHandlers = _this.context.getAtlaskitAnalyticsEventHandlers; | ||
var parentEventHandlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
var parentEventHandlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
var handler = function handler(event, eventChannel) { | ||
@@ -78,8 +71,10 @@ if (channel === '*' || channel === eventChannel) { | ||
}; | ||
return [handler].concat((0, _toConsumableArray3.default)(parentEventHandlers)); | ||
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret); | ||
return [handler].concat((0, _toConsumableArray2.default)(parentEventHandlers)); | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass3.default)(AnalyticsListener, [{ | ||
key: 'render', | ||
(0, _createClass2.default)(AnalyticsListener, [{ | ||
key: "render", | ||
value: function render() { | ||
@@ -92,4 +87,4 @@ return this.props.children; | ||
AnalyticsListener.contextTypes = ContextTypes; | ||
AnalyticsListener.childContextTypes = ContextTypes; | ||
exports.default = AnalyticsListener; | ||
exports.default = AnalyticsListener; | ||
(0, _defineProperty2.default)(AnalyticsListener, "contextTypes", ContextTypes); | ||
(0, _defineProperty2.default)(AnalyticsListener, "childContextTypes", ContextTypes); |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _objectWithoutProperties2 = require("babel-runtime/helpers/objectWithoutProperties"); | ||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2); | ||
exports.default = cleanProps; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
@@ -21,3 +18,3 @@ /* | ||
var createAnalyticsEvent = props.createAnalyticsEvent, | ||
cleanedProps = (0, _objectWithoutProperties3.default)(props, ["createAnalyticsEvent"]); | ||
cleanedProps = (0, _objectWithoutProperties2.default)(props, ["createAnalyticsEvent"]); | ||
/* eslint-enable no-unused-vars */ | ||
@@ -24,0 +21,0 @@ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,8 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
require('./types'); | ||
require('./withAnalyticsEvents'); | ||
exports.default = function (channel) { | ||
var _default = function _default(channel) { | ||
return function (payload) { | ||
@@ -20,2 +17,4 @@ return function (createAnalyticsEvent) { | ||
}; | ||
}; | ||
}; | ||
exports.default = _default; |
@@ -1,79 +0,71 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _AnalyticsEvent = require('./AnalyticsEvent'); | ||
Object.defineProperty(exports, 'AnalyticsEvent', { | ||
Object.defineProperty(exports, "AnalyticsEvent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_AnalyticsEvent).default; | ||
return _AnalyticsEvent.default; | ||
} | ||
}); | ||
var _UIAnalyticsEvent = require('./UIAnalyticsEvent'); | ||
Object.defineProperty(exports, 'UIAnalyticsEvent', { | ||
Object.defineProperty(exports, "UIAnalyticsEvent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_UIAnalyticsEvent).default; | ||
return _UIAnalyticsEvent.default; | ||
} | ||
}); | ||
var _AnalyticsListener = require('./AnalyticsListener'); | ||
Object.defineProperty(exports, 'AnalyticsListener', { | ||
Object.defineProperty(exports, "AnalyticsListener", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_AnalyticsListener).default; | ||
return _AnalyticsListener.default; | ||
} | ||
}); | ||
var _AnalyticsContext = require('./AnalyticsContext'); | ||
Object.defineProperty(exports, 'AnalyticsContext', { | ||
Object.defineProperty(exports, "AnalyticsContext", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_AnalyticsContext).default; | ||
return _AnalyticsContext.default; | ||
} | ||
}); | ||
var _withAnalyticsContext = require('./withAnalyticsContext'); | ||
Object.defineProperty(exports, 'withAnalyticsContext', { | ||
Object.defineProperty(exports, "withAnalyticsContext", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_withAnalyticsContext).default; | ||
return _withAnalyticsContext.default; | ||
} | ||
}); | ||
var _withAnalyticsEvents = require('./withAnalyticsEvents'); | ||
Object.defineProperty(exports, 'withAnalyticsEvents', { | ||
Object.defineProperty(exports, "withAnalyticsEvents", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_withAnalyticsEvents).default; | ||
return _withAnalyticsEvents.default; | ||
} | ||
}); | ||
var _createAndFireEvent = require('./createAndFireEvent'); | ||
Object.defineProperty(exports, 'createAndFireEvent', { | ||
Object.defineProperty(exports, "createAndFireEvent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_createAndFireEvent).default; | ||
return _createAndFireEvent.default; | ||
} | ||
}); | ||
var _cleanProps = require('./cleanProps'); | ||
Object.defineProperty(exports, 'cleanProps', { | ||
Object.defineProperty(exports, "cleanProps", { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_cleanProps).default; | ||
return _cleanProps.default; | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _AnalyticsEvent = _interopRequireDefault(require("./AnalyticsEvent")); | ||
var _UIAnalyticsEvent = _interopRequireDefault(require("./UIAnalyticsEvent")); | ||
var _AnalyticsListener = _interopRequireDefault(require("./AnalyticsListener")); | ||
var _AnalyticsContext = _interopRequireDefault(require("./AnalyticsContext")); | ||
var _withAnalyticsContext = _interopRequireDefault(require("./withAnalyticsContext")); | ||
var _withAnalyticsEvents = _interopRequireDefault(require("./withAnalyticsEvents")); | ||
var _createAndFireEvent = _interopRequireDefault(require("./createAndFireEvent")); | ||
var _cleanProps = _interopRequireDefault(require("./cleanProps")); |
@@ -1,11 +0,7 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _AnalyticsEvent = require('./AnalyticsEvent'); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _AnalyticsEvent2 = _interopRequireDefault(_AnalyticsEvent); | ||
var _AnalyticsEvent = _interopRequireDefault(require("./AnalyticsEvent")); | ||
var _UIAnalyticsEvent = require('./UIAnalyticsEvent'); | ||
var _UIAnalyticsEvent2 = _interopRequireDefault(_UIAnalyticsEvent); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _UIAnalyticsEvent = _interopRequireDefault(require("./UIAnalyticsEvent")); |
@@ -1,57 +0,47 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get")); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _AnalyticsEvent2 = _interopRequireDefault(require("./AnalyticsEvent")); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _get2 = require('babel-runtime/helpers/get'); | ||
var _get3 = _interopRequireDefault(_get2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
var _AnalyticsEvent2 = require('./AnalyticsEvent'); | ||
var _AnalyticsEvent3 = _interopRequireDefault(_AnalyticsEvent2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _console = console, | ||
warn = _console.warn; | ||
var UIAnalyticsEvent = function (_AnalyticsEvent) { | ||
(0, _inherits3.default)(UIAnalyticsEvent, _AnalyticsEvent); | ||
var UIAnalyticsEvent = | ||
/*#__PURE__*/ | ||
function (_AnalyticsEvent) { | ||
(0, _inherits2.default)(UIAnalyticsEvent, _AnalyticsEvent); | ||
function UIAnalyticsEvent(props) { | ||
(0, _classCallCheck3.default)(this, UIAnalyticsEvent); | ||
var _this; | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (UIAnalyticsEvent.__proto__ || (0, _getPrototypeOf2.default)(UIAnalyticsEvent)).call(this, props)); | ||
_this.clone = function () { | ||
(0, _classCallCheck2.default)(this, UIAnalyticsEvent); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(UIAnalyticsEvent).call(this, props)); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "context", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "handlers", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "hasFired", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "clone", function () { | ||
if (_this.hasFired) { | ||
@@ -61,14 +51,16 @@ warn("Cannot clone an event after it's been fired."); | ||
} | ||
var context = [].concat((0, _toConsumableArray3.default)(_this.context)); | ||
var handlers = [].concat((0, _toConsumableArray3.default)(_this.handlers)); | ||
// We stringify and parse here to get a hacky "deep clone" of the object. | ||
var context = (0, _toConsumableArray2.default)(_this.context); | ||
var handlers = (0, _toConsumableArray2.default)(_this.handlers); // We stringify and parse here to get a hacky "deep clone" of the object. | ||
// This has some limitations in that it wont support functions, regexs, Maps, Sets, etc, | ||
// but none of those need to be represented in our payload, so we consider this fine | ||
var payload = JSON.parse((0, _stringify2.default)(_this.payload)); | ||
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload }); | ||
}; | ||
_this.fire = function (channel) { | ||
var payload = JSON.parse(JSON.stringify(_this.payload)); | ||
return new UIAnalyticsEvent({ | ||
context: context, | ||
handlers: handlers, | ||
payload: payload | ||
}); | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "fire", function (channel) { | ||
if (_this.hasFired) { | ||
@@ -78,8 +70,9 @@ warn('Cannot fire an event twice.'); | ||
} | ||
_this.handlers.forEach(function (handler) { | ||
handler(_this, channel); | ||
handler((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), channel); | ||
}); | ||
_this.hasFired = true; | ||
}; | ||
}); | ||
_this.context = props.context || []; | ||
@@ -91,4 +84,4 @@ _this.handlers = props.handlers || []; | ||
(0, _createClass3.default)(UIAnalyticsEvent, [{ | ||
key: 'update', | ||
(0, _createClass2.default)(UIAnalyticsEvent, [{ | ||
key: "update", | ||
value: function update(updater) { | ||
@@ -99,8 +92,9 @@ if (this.hasFired) { | ||
} | ||
return (0, _get3.default)(UIAnalyticsEvent.prototype.__proto__ || (0, _getPrototypeOf2.default)(UIAnalyticsEvent.prototype), 'update', this).call(this, updater); | ||
return (0, _get2.default)((0, _getPrototypeOf2.default)(UIAnalyticsEvent.prototype), "update", this).call(this, updater); | ||
} | ||
}]); | ||
return UIAnalyticsEvent; | ||
}(_AnalyticsEvent3.default); | ||
}(_AnalyticsEvent2.default); | ||
exports.default = UIAnalyticsEvent; |
@@ -1,49 +0,39 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties'); | ||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2); | ||
exports.default = withAnalyticsContext; | ||
var _react = require('react'); | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _AnalyticsContext = require('./AnalyticsContext'); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _AnalyticsContext2 = _interopRequireDefault(_AnalyticsContext); | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _AnalyticsContext = _interopRequireDefault(require("./AnalyticsContext")); | ||
function withAnalyticsContext() { | ||
var defaultData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return function (WrappedComponent) { | ||
// $FlowFixMe - flow 0.67 doesn't know about forwardRef | ||
var WithAnalyticsContext = _react2.default.forwardRef(function (props, ref) { | ||
var WithAnalyticsContext = _react.default.forwardRef(function (props, ref) { | ||
var _props$analyticsConte = props.analyticsContext, | ||
analyticsContext = _props$analyticsConte === undefined ? {} : _props$analyticsConte, | ||
others = (0, _objectWithoutProperties3.default)(props, ['analyticsContext']); | ||
var data = (0, _extends3.default)({}, defaultData, analyticsContext); | ||
return _react2.default.createElement( | ||
_AnalyticsContext2.default, | ||
{ data: data }, | ||
_react2.default.createElement(WrappedComponent, (0, _extends3.default)({}, others, { ref: ref })) | ||
); | ||
analyticsContext = _props$analyticsConte === void 0 ? {} : _props$analyticsConte, | ||
others = (0, _objectWithoutProperties2.default)(props, ["analyticsContext"]); | ||
var data = (0, _objectSpread2.default)({}, defaultData, analyticsContext); | ||
return _react.default.createElement(_AnalyticsContext.default, { | ||
data: data | ||
}, _react.default.createElement(WrappedComponent, (0, _extends2.default)({}, others, { | ||
ref: ref | ||
}))); | ||
}); | ||
WithAnalyticsContext.displayName = 'WithAnalyticsContext(' + (WrappedComponent.displayName || WrappedComponent.name) + ')'; | ||
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat(WrappedComponent.displayName || WrappedComponent.name, ")"); | ||
return WithAnalyticsContext; | ||
}; | ||
} |
@@ -1,85 +0,73 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = withAnalyticsEvents; | ||
var _defineProperty2 = require('babel-runtime/helpers/defineProperty'); | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _defineProperty3 = _interopRequireDefault(_defineProperty2); | ||
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _extends3 = require('babel-runtime/helpers/extends'); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _extends4 = _interopRequireDefault(_extends3); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _UIAnalyticsEvent = _interopRequireDefault(require("./UIAnalyticsEvent")); | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
exports.default = withAnalyticsEvents; | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _UIAnalyticsEvent = require('./UIAnalyticsEvent'); | ||
var _UIAnalyticsEvent2 = _interopRequireDefault(_UIAnalyticsEvent); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// This component is used to grab the analytics functions off context. | ||
// It uses legacy context, but provides an API similar to 16.3 context. | ||
// This makes it easier to use with the forward ref API. | ||
var AnalyticsContextConsumer = function (_Component) { | ||
(0, _inherits3.default)(AnalyticsContextConsumer, _Component); | ||
var AnalyticsContextConsumer = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(AnalyticsContextConsumer, _Component); | ||
function AnalyticsContextConsumer() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
(0, _classCallCheck3.default)(this, AnalyticsContextConsumer); | ||
(0, _classCallCheck2.default)(this, AnalyticsContextConsumer); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = AnalyticsContextConsumer.__proto__ || (0, _getPrototypeOf2.default)(AnalyticsContextConsumer)).call.apply(_ref, [this].concat(args))), _this), _this.createAnalyticsEvent = function (payload) { | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(AnalyticsContextConsumer)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "createAnalyticsEvent", function (payload) { | ||
var _this$context = _this.context, | ||
getAtlaskitAnalyticsEventHandlers = _this$context.getAtlaskitAnalyticsEventHandlers, | ||
getAtlaskitAnalyticsContext = _this$context.getAtlaskitAnalyticsContext; | ||
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
return new _UIAnalyticsEvent2.default({ context: context, handlers: handlers, payload: payload }); | ||
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret); | ||
return new _UIAnalyticsEvent.default({ | ||
context: context, | ||
handlers: handlers, | ||
payload: payload | ||
}); | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass3.default)(AnalyticsContextConsumer, [{ | ||
key: 'render', | ||
(0, _createClass2.default)(AnalyticsContextConsumer, [{ | ||
key: "render", | ||
value: function render() { | ||
@@ -90,21 +78,21 @@ return this.props.children(this.createAnalyticsEvent); | ||
return AnalyticsContextConsumer; | ||
}(_react.Component); | ||
}(_react.Component); // patch the callback so it provides analytics information. | ||
// patch the callback so it provides analytics information. | ||
(0, _defineProperty2.default)(AnalyticsContextConsumer, "contextTypes", { | ||
getAtlaskitAnalyticsEventHandlers: _propTypes.default.func, | ||
getAtlaskitAnalyticsContext: _propTypes.default.func | ||
}); | ||
AnalyticsContextConsumer.contextTypes = { | ||
getAtlaskitAnalyticsEventHandlers: _propTypes2.default.func, | ||
getAtlaskitAnalyticsContext: _propTypes2.default.func | ||
}; | ||
var modifyCallbackProp = function modifyCallbackProp(propName, eventMapEntry, props, createAnalyticsEvent) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
var event = typeof eventMapEntry === 'function' ? eventMapEntry(createAnalyticsEvent, props) : createAnalyticsEvent(eventMapEntry); | ||
var providedCallback = props[propName]; | ||
if (providedCallback) { | ||
providedCallback.apply(undefined, args.concat([event])); | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
providedCallback.apply(void 0, args.concat([event])); | ||
} | ||
@@ -117,4 +105,4 @@ }; | ||
var vmap = function vmap(obj, fn) { | ||
return (0, _keys2.default)(obj).reduce(function (curr, k) { | ||
return (0, _extends4.default)({}, curr, (0, _defineProperty3.default)({}, k, fn(k, obj[k]))); | ||
return Object.keys(obj).reduce(function (curr, k) { | ||
return (0, _objectSpread3.default)({}, curr, (0, _defineProperty2.default)({}, k, fn(k, obj[k]))); | ||
}, {}); | ||
@@ -125,25 +113,19 @@ }; | ||
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return function (WrappedComponent) { | ||
// $FlowFixMe - flow 0.67 doesn't know about forwardRef | ||
var WithAnalyticsEvents = _react2.default.forwardRef(function (props, ref) { | ||
return _react2.default.createElement( | ||
AnalyticsContextConsumer, | ||
null, | ||
function (createAnalyticsEvent) { | ||
var modifiedProps = vmap(createEventMap, function (propName, entry) { | ||
return modifyCallbackProp(propName, entry, props, createAnalyticsEvent); | ||
}); | ||
return _react2.default.createElement(WrappedComponent, (0, _extends4.default)({}, props, modifiedProps, { | ||
createAnalyticsEvent: createAnalyticsEvent, | ||
ref: ref | ||
})); | ||
} | ||
); | ||
var WithAnalyticsEvents = _react.default.forwardRef(function (props, ref) { | ||
return _react.default.createElement(AnalyticsContextConsumer, null, function (createAnalyticsEvent) { | ||
var modifiedProps = vmap(createEventMap, function (propName, entry) { | ||
return modifyCallbackProp(propName, entry, props, createAnalyticsEvent); | ||
}); | ||
return _react.default.createElement(WrappedComponent, (0, _extends2.default)({}, props, modifiedProps, { | ||
createAnalyticsEvent: createAnalyticsEvent, | ||
ref: ref | ||
})); | ||
}); | ||
}); | ||
WithAnalyticsEvents.displayName = 'WithAnalyticsEvents(' + (WrappedComponent.displayName || WrappedComponent.name) + ')'; | ||
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat(WrappedComponent.displayName || WrappedComponent.name, ")"); | ||
return WithAnalyticsEvents; | ||
}; | ||
} |
@@ -1,10 +0,11 @@ | ||
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray'; | ||
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { Children, Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
var ContextTypes = { | ||
@@ -14,31 +15,38 @@ getAtlaskitAnalyticsContext: PropTypes.func | ||
var AnalyticsContext = function (_Component) { | ||
var AnalyticsContext = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(AnalyticsContext, _Component); | ||
function AnalyticsContext() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, AnalyticsContext); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AnalyticsContext.__proto__ || _Object$getPrototypeOf(AnalyticsContext)).call.apply(_ref, [this].concat(args))), _this), _this.getChildContext = function () { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AnalyticsContext)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getChildContext", function () { | ||
return { | ||
getAtlaskitAnalyticsContext: _this.getAnalyticsContext | ||
}; | ||
}, _this.getAnalyticsContext = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getAnalyticsContext", function () { | ||
var data = _this.props.data; | ||
var getAtlaskitAnalyticsContext = _this.context.getAtlaskitAnalyticsContext; | ||
var ancestorData = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
return _toConsumableArray(ancestorData).concat([data]); | ||
}); | ||
var ancestorData = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
return [].concat(_toConsumableArray(ancestorData), [data]); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
return _this; | ||
} | ||
_createClass(AnalyticsContext, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
@@ -52,4 +60,6 @@ return Children.only(this.props.children); | ||
AnalyticsContext.contextTypes = ContextTypes; | ||
AnalyticsContext.childContextTypes = ContextTypes; | ||
export default AnalyticsContext; | ||
_defineProperty(AnalyticsContext, "contextTypes", ContextTypes); | ||
_defineProperty(AnalyticsContext, "childContextTypes", ContextTypes); | ||
export { AnalyticsContext as default }; |
@@ -1,8 +0,10 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _typeof from 'babel-runtime/helpers/typeof'; | ||
import _JSON$stringify from 'babel-runtime/core-js/json/stringify'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _typeof from "@babel/runtime/helpers/typeof"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
var AnalyticsEvent = function () { | ||
var AnalyticsEvent = | ||
/*#__PURE__*/ | ||
function () { | ||
function AnalyticsEvent(props) { | ||
@@ -13,11 +15,14 @@ var _this = this; | ||
this.clone = function () { | ||
_defineProperty(this, "payload", void 0); | ||
_defineProperty(this, "clone", function () { | ||
// We stringify and parse here to get a hacky "deep clone" of the object. | ||
// This has some limitations in that it wont support functions, regexs, Maps, Sets, etc, | ||
// but none of those need to be represented in our payload, so we consider this fine | ||
var payload = JSON.parse(_JSON$stringify(_this.payload)); | ||
var payload = JSON.parse(JSON.stringify(_this.payload)); | ||
return new AnalyticsEvent({ | ||
payload: payload | ||
}); | ||
}); | ||
return new AnalyticsEvent({ payload: payload }); | ||
}; | ||
this.payload = props.payload; | ||
@@ -27,8 +32,8 @@ } | ||
_createClass(AnalyticsEvent, [{ | ||
key: 'update', | ||
key: "update", | ||
value: function update(updater) { | ||
if (typeof updater === 'function') { | ||
this.payload = updater(this.payload); | ||
} else if ((typeof updater === 'undefined' ? 'undefined' : _typeof(updater)) === 'object') { | ||
this.payload = _extends({}, this.payload, updater); | ||
} else if (_typeof(updater) === 'object') { | ||
this.payload = _objectSpread({}, this.payload, updater); | ||
} | ||
@@ -43,2 +48,2 @@ | ||
export default AnalyticsEvent; | ||
export { AnalyticsEvent as default }; |
@@ -1,4 +0,9 @@ | ||
import _Object$keys from 'babel-runtime/core-js/object/keys'; | ||
/** | ||
* This map was originally used to configure the analytics codemod to run over | ||
* each component. | ||
* It is now also used as the source of truth for the instrumented components section of | ||
* the docs. | ||
* If analytics has been manually for a component and you do not wish for it to be | ||
* codemodded, add an `ignore: true` prop to it. | ||
*/ | ||
var analyticsEventMap = [{ | ||
@@ -493,15 +498,4 @@ path: 'avatar/src/components/Avatar.js', | ||
componentTestPath: 'tooltip/src/components/__tests__/Tooltip.js' | ||
}]; | ||
}]; // $FlowFixMe | ||
// $FlowFixMe | ||
/** | ||
* This map was originally used to configure the analytics codemod to run over | ||
* each component. | ||
* It is now also used as the source of truth for the instrumented components section of | ||
* the docs. | ||
* If analytics has been manually for a component and you do not wish for it to be | ||
* codemodded, add an `ignore: true` prop to it. | ||
*/ | ||
module.exports.analyticsPackages = analyticsEventMap.filter(function (pkg) { | ||
@@ -511,8 +505,5 @@ return pkg.test !== true; | ||
var path = config.path; | ||
return path.substring(0, path.indexOf('/')); | ||
}); | ||
module.exports.analyticsEventMap = analyticsEventMap; | ||
module.exports.instrumentedComponents = analyticsEventMap.filter(function (pkg) { | ||
@@ -524,14 +515,16 @@ return pkg.test !== true; | ||
var items = []; | ||
_Object$keys(config.props).forEach(function (propName) { | ||
Object.keys(config.props).forEach(function (propName) { | ||
var components = config.derivatives ? [config.component].concat(config.derivatives).join(', ') : config.component; | ||
items.push({ | ||
packageName: '@atlaskit/' + packageSuffix, | ||
packageName: "@atlaskit/".concat(packageSuffix), | ||
component: components, | ||
actionSubject: config.actionSubject, | ||
prop: propName, | ||
payload: { action: config.props[propName] } | ||
payload: { | ||
action: config.props[propName] | ||
} | ||
}); | ||
}); | ||
// $FlowFixMe | ||
}); // $FlowFixMe | ||
return acc.concat(items); | ||
}, []); |
@@ -1,12 +0,12 @@ | ||
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray'; | ||
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import UIAnalyticsEvent from './UIAnalyticsEvent'; | ||
var ContextTypes = { | ||
@@ -16,21 +16,27 @@ getAtlaskitAnalyticsEventHandlers: PropTypes.func | ||
var AnalyticsListener = function (_Component) { | ||
var AnalyticsListener = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(AnalyticsListener, _Component); | ||
function AnalyticsListener() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, AnalyticsListener); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AnalyticsListener.__proto__ || _Object$getPrototypeOf(AnalyticsListener)).call.apply(_ref, [this].concat(args))), _this), _this.getChildContext = function () { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AnalyticsListener)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getChildContext", function () { | ||
return { | ||
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers | ||
}; | ||
}, _this.getAnalyticsEventHandlers = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getAnalyticsEventHandlers", function () { | ||
var _this$props = _this.props, | ||
@@ -40,4 +46,4 @@ channel = _this$props.channel, | ||
var getAtlaskitAnalyticsEventHandlers = _this.context.getAtlaskitAnalyticsEventHandlers; | ||
var parentEventHandlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
var parentEventHandlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
var handler = function handler(event, eventChannel) { | ||
@@ -48,8 +54,11 @@ if (channel === '*' || channel === eventChannel) { | ||
}; | ||
return [handler].concat(_toConsumableArray(parentEventHandlers)); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
}); | ||
return _this; | ||
} | ||
_createClass(AnalyticsListener, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
@@ -63,4 +72,6 @@ return this.props.children; | ||
AnalyticsListener.contextTypes = ContextTypes; | ||
AnalyticsListener.childContextTypes = ContextTypes; | ||
export default AnalyticsListener; | ||
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes); | ||
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes); | ||
export { AnalyticsListener as default }; |
@@ -1,4 +0,3 @@ | ||
import _objectWithoutProperties from "babel-runtime/helpers/objectWithoutProperties"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
/* | ||
@@ -5,0 +4,0 @@ cleanProps removes props added by the withAnalyticsEvents HOC from an object |
@@ -1,4 +0,1 @@ | ||
import './types'; | ||
import './withAnalyticsEvents'; | ||
export default (function (channel) { | ||
@@ -5,0 +2,0 @@ return function (payload) { |
@@ -1,20 +0,13 @@ | ||
// Analytics event classes | ||
export { default as AnalyticsEvent } from './AnalyticsEvent'; | ||
export { default as UIAnalyticsEvent } from './UIAnalyticsEvent'; | ||
// AnalyticsListener component | ||
export { default as AnalyticsListener } from './AnalyticsListener'; | ||
export { default as AnalyticsListener } from './AnalyticsListener'; // AnalyticsContext component and HOC | ||
// AnalyticsContext component and HOC | ||
export { default as AnalyticsContext } from './AnalyticsContext'; | ||
export { default as withAnalyticsContext } from './withAnalyticsContext'; | ||
export { default as withAnalyticsContext } from './withAnalyticsContext'; // createAnalyticsEvent HOC | ||
// createAnalyticsEvent HOC | ||
export { default as withAnalyticsEvents } from './withAnalyticsEvents'; // Helper functions | ||
export { default as withAnalyticsEvents } from './withAnalyticsEvents'; | ||
// Helper functions | ||
export { default as createAndFireEvent } from './createAndFireEvent'; | ||
export { default as cleanProps } from './cleanProps'; |
import AnalyticsEvent from './AnalyticsEvent'; | ||
import UIAnalyticsEvent from './UIAnalyticsEvent'; | ||
// Basic events | ||
// UI events | ||
import UIAnalyticsEvent from './UIAnalyticsEvent'; // Basic events |
@@ -1,9 +0,10 @@ | ||
import _JSON$stringify from 'babel-runtime/core-js/json/stringify'; | ||
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray'; | ||
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _get from 'babel-runtime/helpers/get'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; | ||
import _get from "@babel/runtime/helpers/get"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import AnalyticsEvent from './AnalyticsEvent'; | ||
@@ -13,11 +14,21 @@ var _console = console, | ||
var UIAnalyticsEvent = function (_AnalyticsEvent) { | ||
var UIAnalyticsEvent = | ||
/*#__PURE__*/ | ||
function (_AnalyticsEvent) { | ||
_inherits(UIAnalyticsEvent, _AnalyticsEvent); | ||
function UIAnalyticsEvent(props) { | ||
var _this; | ||
_classCallCheck(this, UIAnalyticsEvent); | ||
var _this = _possibleConstructorReturn(this, (UIAnalyticsEvent.__proto__ || _Object$getPrototypeOf(UIAnalyticsEvent)).call(this, props)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(UIAnalyticsEvent).call(this, props)); | ||
_this.clone = function () { | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "context", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handlers", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "hasFired", void 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "clone", function () { | ||
if (_this.hasFired) { | ||
@@ -27,14 +38,19 @@ warn("Cannot clone an event after it's been fired."); | ||
} | ||
var context = [].concat(_toConsumableArray(_this.context)); | ||
var handlers = [].concat(_toConsumableArray(_this.handlers)); | ||
// We stringify and parse here to get a hacky "deep clone" of the object. | ||
var context = _toConsumableArray(_this.context); | ||
var handlers = _toConsumableArray(_this.handlers); // We stringify and parse here to get a hacky "deep clone" of the object. | ||
// This has some limitations in that it wont support functions, regexs, Maps, Sets, etc, | ||
// but none of those need to be represented in our payload, so we consider this fine | ||
var payload = JSON.parse(_JSON$stringify(_this.payload)); | ||
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload }); | ||
}; | ||
_this.fire = function (channel) { | ||
var payload = JSON.parse(JSON.stringify(_this.payload)); | ||
return new UIAnalyticsEvent({ | ||
context: context, | ||
handlers: handlers, | ||
payload: payload | ||
}); | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "fire", function (channel) { | ||
if (_this.hasFired) { | ||
@@ -44,7 +60,9 @@ warn('Cannot fire an event twice.'); | ||
} | ||
_this.handlers.forEach(function (handler) { | ||
handler(_this, channel); | ||
handler(_assertThisInitialized(_assertThisInitialized(_this)), channel); | ||
}); | ||
_this.hasFired = true; | ||
}; | ||
}); | ||
@@ -58,3 +76,3 @@ _this.context = props.context || []; | ||
_createClass(UIAnalyticsEvent, [{ | ||
key: 'update', | ||
key: "update", | ||
value: function update(updater) { | ||
@@ -65,3 +83,4 @@ if (this.hasFired) { | ||
} | ||
return _get(UIAnalyticsEvent.prototype.__proto__ || _Object$getPrototypeOf(UIAnalyticsEvent.prototype), 'update', this).call(this, updater); | ||
return _get(_getPrototypeOf(UIAnalyticsEvent.prototype), "update", this).call(this, updater); | ||
} | ||
@@ -73,2 +92,2 @@ }]); | ||
export default UIAnalyticsEvent; | ||
export { UIAnalyticsEvent as default }; |
@@ -1,10 +0,8 @@ | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
import React from 'react'; | ||
import AnalyticsContext from './AnalyticsContext'; | ||
export default function withAnalyticsContext() { | ||
var defaultData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return function (WrappedComponent) { | ||
@@ -14,17 +12,16 @@ // $FlowFixMe - flow 0.67 doesn't know about forwardRef | ||
var _props$analyticsConte = props.analyticsContext, | ||
analyticsContext = _props$analyticsConte === undefined ? {} : _props$analyticsConte, | ||
others = _objectWithoutProperties(props, ['analyticsContext']); | ||
analyticsContext = _props$analyticsConte === void 0 ? {} : _props$analyticsConte, | ||
others = _objectWithoutProperties(props, ["analyticsContext"]); | ||
var data = _extends({}, defaultData, analyticsContext); | ||
return React.createElement( | ||
AnalyticsContext, | ||
{ data: data }, | ||
React.createElement(WrappedComponent, _extends({}, others, { ref: ref })) | ||
); | ||
var data = _objectSpread({}, defaultData, analyticsContext); | ||
return React.createElement(AnalyticsContext, { | ||
data: data | ||
}, React.createElement(WrappedComponent, _extends({}, others, { | ||
ref: ref | ||
}))); | ||
}); | ||
WithAnalyticsContext.displayName = 'WithAnalyticsContext(' + (WrappedComponent.displayName || WrappedComponent.name) + ')'; | ||
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat(WrappedComponent.displayName || WrappedComponent.name, ")"); | ||
return WithAnalyticsContext; | ||
}; | ||
} |
@@ -1,12 +0,12 @@ | ||
import _defineProperty from 'babel-runtime/helpers/defineProperty'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _Object$keys from 'babel-runtime/core-js/object/keys'; | ||
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import _createClass from 'babel-runtime/helpers/createClass'; | ||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; | ||
import _inherits from 'babel-runtime/helpers/inherits'; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import UIAnalyticsEvent from './UIAnalyticsEvent'; | ||
@@ -17,29 +17,38 @@ | ||
// This makes it easier to use with the forward ref API. | ||
var AnalyticsContextConsumer = function (_Component) { | ||
var AnalyticsContextConsumer = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(AnalyticsContextConsumer, _Component); | ||
function AnalyticsContextConsumer() { | ||
var _ref; | ||
var _getPrototypeOf2; | ||
var _temp, _this, _ret; | ||
var _this; | ||
_classCallCheck(this, AnalyticsContextConsumer); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AnalyticsContextConsumer.__proto__ || _Object$getPrototypeOf(AnalyticsContextConsumer)).call.apply(_ref, [this].concat(args))), _this), _this.createAnalyticsEvent = function (payload) { | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AnalyticsContextConsumer)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "createAnalyticsEvent", function (payload) { | ||
var _this$context = _this.context, | ||
getAtlaskitAnalyticsEventHandlers = _this$context.getAtlaskitAnalyticsEventHandlers, | ||
getAtlaskitAnalyticsContext = _this$context.getAtlaskitAnalyticsContext; | ||
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload }); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
return new UIAnalyticsEvent({ | ||
context: context, | ||
handlers: handlers, | ||
payload: payload | ||
}); | ||
}); | ||
return _this; | ||
} | ||
_createClass(AnalyticsContextConsumer, [{ | ||
key: 'render', | ||
key: "render", | ||
value: function render() { | ||
@@ -51,21 +60,21 @@ return this.props.children(this.createAnalyticsEvent); | ||
return AnalyticsContextConsumer; | ||
}(Component); | ||
}(Component); // patch the callback so it provides analytics information. | ||
// patch the callback so it provides analytics information. | ||
AnalyticsContextConsumer.contextTypes = { | ||
_defineProperty(AnalyticsContextConsumer, "contextTypes", { | ||
getAtlaskitAnalyticsEventHandlers: PropTypes.func, | ||
getAtlaskitAnalyticsContext: PropTypes.func | ||
}; | ||
}); | ||
var modifyCallbackProp = function modifyCallbackProp(propName, eventMapEntry, props, createAnalyticsEvent) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
var event = typeof eventMapEntry === 'function' ? eventMapEntry(createAnalyticsEvent, props) : createAnalyticsEvent(eventMapEntry); | ||
var providedCallback = props[propName]; | ||
if (providedCallback) { | ||
providedCallback.apply(undefined, args.concat([event])); | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
providedCallback.apply(void 0, args.concat([event])); | ||
} | ||
@@ -78,4 +87,4 @@ }; | ||
var vmap = function vmap(obj, fn) { | ||
return _Object$keys(obj).reduce(function (curr, k) { | ||
return _extends({}, curr, _defineProperty({}, k, fn(k, obj[k]))); | ||
return Object.keys(obj).reduce(function (curr, k) { | ||
return _objectSpread({}, curr, _defineProperty({}, k, fn(k, obj[k]))); | ||
}, {}); | ||
@@ -86,25 +95,18 @@ }; | ||
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return function (WrappedComponent) { | ||
// $FlowFixMe - flow 0.67 doesn't know about forwardRef | ||
var WithAnalyticsEvents = React.forwardRef(function (props, ref) { | ||
return React.createElement( | ||
AnalyticsContextConsumer, | ||
null, | ||
function (createAnalyticsEvent) { | ||
var modifiedProps = vmap(createEventMap, function (propName, entry) { | ||
return modifyCallbackProp(propName, entry, props, createAnalyticsEvent); | ||
}); | ||
return React.createElement(WrappedComponent, _extends({}, props, modifiedProps, { | ||
createAnalyticsEvent: createAnalyticsEvent, | ||
ref: ref | ||
})); | ||
} | ||
); | ||
return React.createElement(AnalyticsContextConsumer, null, function (createAnalyticsEvent) { | ||
var modifiedProps = vmap(createEventMap, function (propName, entry) { | ||
return modifyCallbackProp(propName, entry, props, createAnalyticsEvent); | ||
}); | ||
return React.createElement(WrappedComponent, _extends({}, props, modifiedProps, { | ||
createAnalyticsEvent: createAnalyticsEvent, | ||
ref: ref | ||
})); | ||
}); | ||
}); | ||
WithAnalyticsEvents.displayName = 'WithAnalyticsEvents(' + (WrappedComponent.displayName || WrappedComponent.name) + ')'; | ||
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat(WrappedComponent.displayName || WrappedComponent.name, ")"); | ||
return WithAnalyticsEvents; | ||
}; | ||
} |
{ | ||
"name": "@atlaskit/analytics-next", | ||
"version": "3.0.8", | ||
"version": "3.0.9", | ||
"sideEffects": false | ||
} |
{ | ||
"name": "@atlaskit/analytics-next", | ||
"version": "3.0.8", | ||
"version": "3.0.9", | ||
"description": "The 🆕 Atlaskit component analytics framework", | ||
@@ -25,2 +25,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"prop-types": "^15.5.10" | ||
@@ -27,0 +28,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
139088
1845
3
+ Addedbabel-runtime@^6.26.0
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)