@atlaskit/analytics-next
Advanced tools
Comparing version 1.1.3 to 1.1.4
# @atlaskit/analytics-next | ||
## 1.1.4 | ||
- [patch] fixes problem with withAnalyticsEvents HOC passing old function props to wrapped component [c88b030](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/c88b030) | ||
## 1.1.3 | ||
@@ -4,0 +7,0 @@ - [patch] adds displayName to analytics HOCs [f69ccad](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/f69ccad) |
@@ -11,6 +11,2 @@ 'use strict'; | ||
var _extends3 = require('babel-runtime/helpers/extends'); | ||
var _extends4 = _interopRequireDefault(_extends3); | ||
var _typeof2 = require('babel-runtime/helpers/typeof'); | ||
@@ -24,2 +20,6 @@ | ||
var _extends3 = require('babel-runtime/helpers/extends'); | ||
var _extends4 = _interopRequireDefault(_extends3); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
@@ -65,47 +65,19 @@ | ||
return function (WrappedComponent) { | ||
var _class, _temp; | ||
var _class, _temp2, _initialiseProps; | ||
return _temp = _class = function (_Component) { | ||
return _temp2 = _class = function (_Component) { | ||
(0, _inherits3.default)(WithAnalyticsEvents, _Component); | ||
function WithAnalyticsEvents(props) { | ||
(0, _classCallCheck3.default)(this, WithAnalyticsEvents); | ||
function WithAnalyticsEvents() { | ||
var _ref; | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (WithAnalyticsEvents.__proto__ || (0, _getPrototypeOf2.default)(WithAnalyticsEvents)).call(this, props)); | ||
var _temp, _this, _ret; | ||
_this.createAnalyticsEvent = function () { | ||
var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _this$context = _this.context, | ||
getAtlaskitAnalyticsEventHandlers = _this$context.getAtlaskitAnalyticsEventHandlers, | ||
getAtlaskitAnalyticsContext = _this$context.getAtlaskitAnalyticsContext; | ||
(0, _classCallCheck3.default)(this, WithAnalyticsEvents); | ||
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
return new _UIAnalyticsEvent2.default({ context: context, handlers: handlers, payload: payload }); | ||
}; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.mapCreateEventsToProps = function () { | ||
return (0, _keys2.default)(createEventMap).reduce(function (modified, propCallbackName) { | ||
var eventCreator = createEventMap[propCallbackName]; | ||
var providedCallback = _this.props[propCallbackName]; | ||
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : (0, _typeof3.default)(eventCreator))) { | ||
return modified; | ||
} | ||
var modifiedCallback = function modifiedCallback() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this.createAnalyticsEvent, _this.props) : _this.createAnalyticsEvent(eventCreator); | ||
if (providedCallback) { | ||
providedCallback.apply(undefined, args.concat([analyticsEvent])); | ||
} | ||
}; | ||
return (0, _extends4.default)({}, modified, (0, _defineProperty3.default)({}, propCallbackName, modifiedCallback)); | ||
}, {}); | ||
}; | ||
_this.propsWithEvents = _this.mapCreateEventsToProps(); | ||
return _this; | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = WithAnalyticsEvents.__proto__ || (0, _getPrototypeOf2.default)(WithAnalyticsEvents)).call.apply(_ref, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), (0, _possibleConstructorReturn3.default)(_this, _ret); | ||
} | ||
@@ -116,3 +88,3 @@ | ||
value: function render() { | ||
var props = (0, _extends4.default)({}, this.props, this.propsWithEvents); | ||
var props = (0, _extends4.default)({}, this.props, this.mapCreateEventsToProps()); | ||
return _react2.default.createElement(WrappedComponent, (0, _extends4.default)({}, props, { | ||
@@ -127,4 +99,39 @@ createAnalyticsEvent: this.createAnalyticsEvent | ||
getAtlaskitAnalyticsContext: _propTypes2.default.func | ||
}, _temp; | ||
}, _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
this.createAnalyticsEvent = function () { | ||
var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _context = _this2.context, | ||
getAtlaskitAnalyticsEventHandlers = _context.getAtlaskitAnalyticsEventHandlers, | ||
getAtlaskitAnalyticsContext = _context.getAtlaskitAnalyticsContext; | ||
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
return new _UIAnalyticsEvent2.default({ context: context, handlers: handlers, payload: payload }); | ||
}; | ||
this.mapCreateEventsToProps = function () { | ||
return (0, _keys2.default)(createEventMap).reduce(function (modified, propCallbackName) { | ||
var eventCreator = createEventMap[propCallbackName]; | ||
var providedCallback = _this2.props[propCallbackName]; | ||
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : (0, _typeof3.default)(eventCreator))) { | ||
return modified; | ||
} | ||
var modifiedCallback = function modifiedCallback() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, _this2.props) : _this2.createAnalyticsEvent(eventCreator); | ||
if (providedCallback) { | ||
providedCallback.apply(undefined, args.concat([analyticsEvent])); | ||
} | ||
}; | ||
return (0, _extends4.default)({}, modified, (0, _defineProperty3.default)({}, propCallbackName, modifiedCallback)); | ||
}, {}); | ||
}; | ||
}, _temp2; | ||
}; | ||
} |
import _defineProperty from 'babel-runtime/helpers/defineProperty'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _typeof from 'babel-runtime/helpers/typeof'; | ||
import _Object$keys from 'babel-runtime/core-js/object/keys'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; | ||
@@ -20,47 +20,19 @@ import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
return function (WrappedComponent) { | ||
var _class, _temp; | ||
var _class, _temp2, _initialiseProps; | ||
return _temp = _class = function (_Component) { | ||
return _temp2 = _class = function (_Component) { | ||
_inherits(WithAnalyticsEvents, _Component); | ||
function WithAnalyticsEvents(props) { | ||
_classCallCheck(this, WithAnalyticsEvents); | ||
function WithAnalyticsEvents() { | ||
var _ref; | ||
var _this = _possibleConstructorReturn(this, (WithAnalyticsEvents.__proto__ || _Object$getPrototypeOf(WithAnalyticsEvents)).call(this, props)); | ||
var _temp, _this, _ret; | ||
_this.createAnalyticsEvent = function () { | ||
var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _this$context = _this.context, | ||
getAtlaskitAnalyticsEventHandlers = _this$context.getAtlaskitAnalyticsEventHandlers, | ||
getAtlaskitAnalyticsContext = _this$context.getAtlaskitAnalyticsContext; | ||
_classCallCheck(this, WithAnalyticsEvents); | ||
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload }); | ||
}; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.mapCreateEventsToProps = function () { | ||
return _Object$keys(createEventMap).reduce(function (modified, propCallbackName) { | ||
var eventCreator = createEventMap[propCallbackName]; | ||
var providedCallback = _this.props[propCallbackName]; | ||
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : _typeof(eventCreator))) { | ||
return modified; | ||
} | ||
var modifiedCallback = function modifiedCallback() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this.createAnalyticsEvent, _this.props) : _this.createAnalyticsEvent(eventCreator); | ||
if (providedCallback) { | ||
providedCallback.apply(undefined, args.concat([analyticsEvent])); | ||
} | ||
}; | ||
return _extends({}, modified, _defineProperty({}, propCallbackName, modifiedCallback)); | ||
}, {}); | ||
}; | ||
_this.propsWithEvents = _this.mapCreateEventsToProps(); | ||
return _this; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = WithAnalyticsEvents.__proto__ || _Object$getPrototypeOf(WithAnalyticsEvents)).call.apply(_ref, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
@@ -71,3 +43,3 @@ | ||
value: function render() { | ||
var props = _extends({}, this.props, this.propsWithEvents); | ||
var props = _extends({}, this.props, this.mapCreateEventsToProps()); | ||
return React.createElement(WrappedComponent, _extends({}, props, { | ||
@@ -83,4 +55,39 @@ createAnalyticsEvent: this.createAnalyticsEvent | ||
getAtlaskitAnalyticsContext: PropTypes.func | ||
}, _temp; | ||
}, _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
this.createAnalyticsEvent = function () { | ||
var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _context = _this2.context, | ||
getAtlaskitAnalyticsEventHandlers = _context.getAtlaskitAnalyticsEventHandlers, | ||
getAtlaskitAnalyticsContext = _context.getAtlaskitAnalyticsContext; | ||
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || []; | ||
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || []; | ||
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload }); | ||
}; | ||
this.mapCreateEventsToProps = function () { | ||
return _Object$keys(createEventMap).reduce(function (modified, propCallbackName) { | ||
var eventCreator = createEventMap[propCallbackName]; | ||
var providedCallback = _this2.props[propCallbackName]; | ||
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : _typeof(eventCreator))) { | ||
return modified; | ||
} | ||
var modifiedCallback = function modifiedCallback() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, _this2.props) : _this2.createAnalyticsEvent(eventCreator); | ||
if (providedCallback) { | ||
providedCallback.apply(undefined, args.concat([analyticsEvent])); | ||
} | ||
}; | ||
return _extends({}, modified, _defineProperty({}, propCallbackName, modifiedCallback)); | ||
}, {}); | ||
}; | ||
}, _temp2; | ||
}; | ||
} |
{ | ||
"name": "@atlaskit/analytics-next", | ||
"version": "1.1.2" | ||
"version": "1.1.3" | ||
} |
{ | ||
"name": "@atlaskit/analytics-next", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "The 🆕 Atlaskit component analytics framework", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
64856
775