@atlaskit/analytics-next
Advanced tools
Comparing version 2.1.1 to 2.1.2
# @atlaskit/analytics-next | ||
## 2.1.2 | ||
- [patch] Fix prop callbacks specified in the create event map to not change reference values each render and instead only update when the original prop callback changes [586a80c](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/586a80c) | ||
- [none] Updated dependencies [586a80c](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/586a80c) | ||
## 2.1.1 | ||
@@ -4,0 +8,0 @@ - [patch] Updated dependencies [d662caa](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/d662caa) |
@@ -15,2 +15,6 @@ 'use strict'; | ||
var _extends3 = require('babel-runtime/helpers/extends'); | ||
var _extends4 = _interopRequireDefault(_extends3); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
@@ -20,6 +24,2 @@ | ||
var _extends3 = require('babel-runtime/helpers/extends'); | ||
var _extends4 = _interopRequireDefault(_extends3); | ||
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); | ||
@@ -65,25 +65,31 @@ | ||
return function (WrappedComponent) { | ||
var _class, _temp2, _initialiseProps; | ||
var _class, _temp, _initialiseProps; | ||
return _temp2 = _class = function (_Component) { | ||
return _temp = _class = function (_Component) { | ||
(0, _inherits3.default)(WithAnalyticsEvents, _Component); | ||
function WithAnalyticsEvents() { | ||
var _ref; | ||
// Store references to the original and patched event props so we can determine when to update | ||
// the patched props | ||
function WithAnalyticsEvents(props) { | ||
(0, _classCallCheck3.default)(this, WithAnalyticsEvents); | ||
var _temp, _this, _ret; | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (WithAnalyticsEvents.__proto__ || (0, _getPrototypeOf2.default)(WithAnalyticsEvents)).call(this, props)); | ||
(0, _classCallCheck3.default)(this, WithAnalyticsEvents); | ||
_initialiseProps.call(_this); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
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); | ||
(0, _keys2.default)(createEventMap).forEach(function (p) { | ||
_this.originalEventProps[p] = props[p]; | ||
}); | ||
_this.patchedEventProps = _this.mapCreateEventsToProps((0, _keys2.default)(createEventMap), props); | ||
return _this; | ||
} | ||
// Update patched event props only if the original props have changed | ||
(0, _createClass3.default)(WithAnalyticsEvents, [{ | ||
key: 'render', | ||
value: function render() { | ||
var props = (0, _extends4.default)({}, this.props, this.mapCreateEventsToProps()); | ||
var patchedEventProps = this.updatePatchedEventProps(this.props); | ||
var props = (0, _extends4.default)({}, this.props, patchedEventProps); | ||
return _react2.default.createElement(WrappedComponent, (0, _extends4.default)({}, props, { | ||
@@ -101,2 +107,19 @@ createAnalyticsEvent: this.createAnalyticsEvent | ||
this.originalEventProps = {}; | ||
this.patchedEventProps = {}; | ||
this.updatePatchedEventProps = function (props) { | ||
var changedPropCallbacks = (0, _keys2.default)(createEventMap).filter(function (p) { | ||
return _this2.originalEventProps[p] !== props[p]; | ||
}); | ||
if (changedPropCallbacks.length > 0) { | ||
_this2.patchedEventProps = (0, _extends4.default)({}, _this2.patchedEventProps, _this2.mapCreateEventsToProps(changedPropCallbacks, props)); | ||
changedPropCallbacks.forEach(function (p) { | ||
_this2.originalEventProps[p] = props[p]; | ||
}); | ||
} | ||
return _this2.patchedEventProps; | ||
}; | ||
this.createAnalyticsEvent = function (payload) { | ||
@@ -112,6 +135,6 @@ var _context = _this2.context, | ||
this.mapCreateEventsToProps = function () { | ||
return (0, _keys2.default)(createEventMap).reduce(function (modified, propCallbackName) { | ||
this.mapCreateEventsToProps = function (changedPropNames, props) { | ||
return changedPropNames.reduce(function (modified, propCallbackName) { | ||
var eventCreator = createEventMap[propCallbackName]; | ||
var providedCallback = _this2.props[propCallbackName]; | ||
var providedCallback = props[propCallbackName]; | ||
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : (0, _typeof3.default)(eventCreator))) { | ||
@@ -121,7 +144,7 @@ return modified; | ||
var modifiedCallback = function modifiedCallback() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, _this2.props) : _this2.createAnalyticsEvent(eventCreator); | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, props) : _this2.createAnalyticsEvent(eventCreator); | ||
@@ -135,4 +158,4 @@ if (providedCallback) { | ||
}; | ||
}, _temp2; | ||
}, _temp; | ||
}; | ||
} |
import _defineProperty from 'babel-runtime/helpers/defineProperty'; | ||
import _typeof from 'babel-runtime/helpers/typeof'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
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,25 +20,31 @@ import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
return function (WrappedComponent) { | ||
var _class, _temp2, _initialiseProps; | ||
var _class, _temp, _initialiseProps; | ||
return _temp2 = _class = function (_Component) { | ||
return _temp = _class = function (_Component) { | ||
_inherits(WithAnalyticsEvents, _Component); | ||
function WithAnalyticsEvents() { | ||
var _ref; | ||
// Store references to the original and patched event props so we can determine when to update | ||
// the patched props | ||
function WithAnalyticsEvents(props) { | ||
_classCallCheck(this, WithAnalyticsEvents); | ||
var _temp, _this, _ret; | ||
var _this = _possibleConstructorReturn(this, (WithAnalyticsEvents.__proto__ || _Object$getPrototypeOf(WithAnalyticsEvents)).call(this, props)); | ||
_classCallCheck(this, WithAnalyticsEvents); | ||
_initialiseProps.call(_this); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
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); | ||
_Object$keys(createEventMap).forEach(function (p) { | ||
_this.originalEventProps[p] = props[p]; | ||
}); | ||
_this.patchedEventProps = _this.mapCreateEventsToProps(_Object$keys(createEventMap), props); | ||
return _this; | ||
} | ||
// Update patched event props only if the original props have changed | ||
_createClass(WithAnalyticsEvents, [{ | ||
key: 'render', | ||
value: function render() { | ||
var props = _extends({}, this.props, this.mapCreateEventsToProps()); | ||
var patchedEventProps = this.updatePatchedEventProps(this.props); | ||
var props = _extends({}, this.props, patchedEventProps); | ||
return React.createElement(WrappedComponent, _extends({}, props, { | ||
@@ -57,2 +63,19 @@ createAnalyticsEvent: this.createAnalyticsEvent | ||
this.originalEventProps = {}; | ||
this.patchedEventProps = {}; | ||
this.updatePatchedEventProps = function (props) { | ||
var changedPropCallbacks = _Object$keys(createEventMap).filter(function (p) { | ||
return _this2.originalEventProps[p] !== props[p]; | ||
}); | ||
if (changedPropCallbacks.length > 0) { | ||
_this2.patchedEventProps = _extends({}, _this2.patchedEventProps, _this2.mapCreateEventsToProps(changedPropCallbacks, props)); | ||
changedPropCallbacks.forEach(function (p) { | ||
_this2.originalEventProps[p] = props[p]; | ||
}); | ||
} | ||
return _this2.patchedEventProps; | ||
}; | ||
this.createAnalyticsEvent = function (payload) { | ||
@@ -68,6 +91,6 @@ var _context = _this2.context, | ||
this.mapCreateEventsToProps = function () { | ||
return _Object$keys(createEventMap).reduce(function (modified, propCallbackName) { | ||
this.mapCreateEventsToProps = function (changedPropNames, props) { | ||
return changedPropNames.reduce(function (modified, propCallbackName) { | ||
var eventCreator = createEventMap[propCallbackName]; | ||
var providedCallback = _this2.props[propCallbackName]; | ||
var providedCallback = props[propCallbackName]; | ||
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : _typeof(eventCreator))) { | ||
@@ -77,7 +100,7 @@ return modified; | ||
var modifiedCallback = function modifiedCallback() { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, _this2.props) : _this2.createAnalyticsEvent(eventCreator); | ||
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, props) : _this2.createAnalyticsEvent(eventCreator); | ||
@@ -91,4 +114,4 @@ if (providedCallback) { | ||
}; | ||
}, _temp2; | ||
}, _temp; | ||
}; | ||
} |
{ | ||
"name": "@atlaskit/analytics-next", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"sideEffects": false | ||
} |
{ | ||
"name": "@atlaskit/analytics-next", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "The 🆕 Atlaskit component analytics framework", | ||
@@ -39,2 +39,2 @@ "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
72321
824