@atlaskit/analytics
Advanced tools
Comparing version 8.0.0 to 8.0.1
# @atlaskit/analytics | ||
## 8.0.1 | ||
### Patch Changes | ||
- [`6c525a8229`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6c525a8229) - Upgraded to TypeScript 3.9.6 and tslib to 2.0.0 | ||
Since tslib is a dependency for all our packages we recommend that products also follow this tslib upgrade | ||
to prevent duplicates of tslib being bundled. | ||
## 8.0.0 | ||
@@ -4,0 +13,0 @@ |
@@ -12,18 +12,2 @@ "use strict"; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -37,7 +21,9 @@ | ||
/* eslint-disable react/sort-comp */ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* The Decorator component extends analytics event data for any events fired by | ||
its descendents, then passes the event up the hierarchy */ | ||
var ContextTypes = { | ||
const ContextTypes = { | ||
onAnalyticsEvent: _propTypes.default.func, | ||
@@ -52,31 +38,19 @@ getParentAnalyticsData: _propTypes.default.func | ||
var AnalyticsDecorator = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(AnalyticsDecorator, _Component); | ||
function AnalyticsDecorator() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
(0, _classCallCheck2.default)(this, AnalyticsDecorator); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(AnalyticsDecorator)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getDecoratedAnalyticsData", function (name, srcData, isPrivate) { | ||
class AnalyticsDecorator extends _react.Component { | ||
constructor(...args) { | ||
super(...args); | ||
(0, _defineProperty2.default)(this, "getDecoratedAnalyticsData", (name, srcData, isPrivate) => { | ||
// Decorate the event data if this decorator matches the event name | ||
// eslint-disable-next-line react/prop-types | ||
var _this$props = _this.props, | ||
data = _this$props.data, | ||
getData = _this$props.getData, | ||
match = _this$props.match, | ||
matchPrivate = _this$props.matchPrivate; | ||
var decoratedData = (0, _objectSpread2.default)({}, srcData); | ||
const { | ||
data, | ||
getData, | ||
match, | ||
matchPrivate | ||
} = this.props; | ||
const decoratedData = _objectSpread({}, srcData); | ||
if (matchPrivate === isPrivate && (0, _matchEvent.default)(match, name)) { | ||
if ((0, _typeof2.default)(data) === 'object') { | ||
if (typeof data === 'object') { | ||
Object.assign(decoratedData, data); | ||
@@ -92,19 +66,20 @@ } | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAnalyticsEvent", function (name, srcData, isPrivate) { | ||
(0, _defineProperty2.default)(this, "onAnalyticsEvent", (name, srcData, isPrivate) => { | ||
// Check there is a listener to pass the event to, otherwise there's no need | ||
// to do any of this work | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (typeof onAnalyticsEvent !== 'function') return; | ||
const decoratedData = this.getDecoratedAnalyticsData(name, srcData, isPrivate); // Pass the decorated event data to the next listener up the hierarchy | ||
var decoratedData = _this.getDecoratedAnalyticsData(name, srcData, isPrivate); // Pass the decorated event data to the next listener up the hierarchy | ||
onAnalyticsEvent(name, decoratedData, isPrivate); | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParentAnalyticsData", function (name, isPrivate) { | ||
var parentData = _this.getDecoratedAnalyticsData(name, {}, isPrivate); // Get any analytics data from any decorators up the hierarchy | ||
(0, _defineProperty2.default)(this, "getParentAnalyticsData", (name, isPrivate) => { | ||
const parentData = this.getDecoratedAnalyticsData(name, {}, isPrivate); // Get any analytics data from any decorators up the hierarchy | ||
const { | ||
getParentAnalyticsData | ||
} = this.context; | ||
var getParentAnalyticsData = _this.context.getParentAnalyticsData; | ||
if (typeof getParentAnalyticsData === 'function') { | ||
@@ -116,24 +91,21 @@ Object.assign(parentData, getParentAnalyticsData(name, isPrivate)); | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass2.default)(AnalyticsDecorator, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var children = this.props.children; // eslint-disable-line react/prop-types | ||
getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData | ||
}; | ||
} | ||
return _react.default.Children.only(children); | ||
} | ||
}]); | ||
return AnalyticsDecorator; | ||
}(_react.Component); | ||
render() { | ||
const { | ||
children | ||
} = this.props; // eslint-disable-line react/prop-types | ||
return _react.default.Children.only(children); | ||
} | ||
} | ||
(0, _defineProperty2.default)(AnalyticsDecorator, "defaultProps", { | ||
@@ -140,0 +112,0 @@ match: '*', |
@@ -12,16 +12,2 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -33,4 +19,6 @@ | ||
/* eslint-disable react/sort-comp */ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* | ||
@@ -40,3 +28,3 @@ Listens to public and private events and delegates to an analytics | ||
*/ | ||
var ContextTypes = { | ||
const ContextTypes = { | ||
onAnalyticsEvent: _propTypes.default.func | ||
@@ -50,24 +38,12 @@ }; | ||
var AnalyticsDelegate = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(AnalyticsDelegate, _Component); | ||
function AnalyticsDelegate() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
(0, _classCallCheck2.default)(this, AnalyticsDelegate); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(AnalyticsDelegate)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAnalyticsEvent", function (name, data, isPrivate) { | ||
class AnalyticsDelegate extends _react.Component { | ||
constructor(...args) { | ||
super(...args); | ||
(0, _defineProperty2.default)(this, "onAnalyticsEvent", (name, data, isPrivate) => { | ||
// eslint-disable-next-line react/prop-types | ||
var delegateAnalyticsEvent = _this.props.delegateAnalyticsEvent; // send a clean data object so it can't be mutated between listeners | ||
const { | ||
delegateAnalyticsEvent | ||
} = this.props; // send a clean data object so it can't be mutated between listeners | ||
var eventData = (0, _objectSpread2.default)({}, data); | ||
const eventData = _objectSpread({}, data); | ||
@@ -79,3 +55,5 @@ if (delegateAnalyticsEvent) { | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
@@ -86,23 +64,20 @@ if (typeof onAnalyticsEvent === 'function') { | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass2.default)(AnalyticsDelegate, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var children = this.props.children; // eslint-disable-line react/prop-types | ||
getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
return _react.default.Children.only(children); | ||
} | ||
}]); | ||
return AnalyticsDelegate; | ||
}(_react.Component); | ||
render() { | ||
const { | ||
children | ||
} = this.props; // eslint-disable-line react/prop-types | ||
return _react.default.Children.only(children); | ||
} | ||
} | ||
(0, _defineProperty2.default)(AnalyticsDelegate, "contextTypes", ContextTypes); | ||
@@ -109,0 +84,0 @@ (0, _defineProperty2.default)(AnalyticsDelegate, "childContextTypes", ContextTypes); |
@@ -12,16 +12,2 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -35,4 +21,6 @@ | ||
/* eslint-disable react/sort-comp */ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* | ||
@@ -42,3 +30,3 @@ The Listener component is responsible for calling its `onEvent` handler when a | ||
*/ | ||
var ContextTypes = { | ||
const ContextTypes = { | ||
onAnalyticsEvent: _propTypes.default.func | ||
@@ -52,30 +40,18 @@ }; | ||
var AnalyticsListener = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(AnalyticsListener, _Component); | ||
function AnalyticsListener() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
(0, _classCallCheck2.default)(this, AnalyticsListener); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(AnalyticsListener)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAnalyticsEvent", function (name, data, isPrivate) { | ||
class AnalyticsListener extends _react.Component { | ||
constructor(...args) { | ||
super(...args); | ||
(0, _defineProperty2.default)(this, "onAnalyticsEvent", (name, data, isPrivate) => { | ||
// Call this component's onEvent method if it's a match | ||
// eslint-disable-next-line react/prop-types | ||
var _this$props = _this.props, | ||
onEvent = _this$props.onEvent, | ||
match = _this$props.match, | ||
matchPrivate = _this$props.matchPrivate; | ||
const { | ||
onEvent, | ||
match, | ||
matchPrivate | ||
} = this.props; | ||
if (matchPrivate === isPrivate && (0, _matchEvent.default)(match, name) && typeof onEvent === 'function') { | ||
// send a clean data object so it can't be mutated between listeners | ||
var eventData = (0, _objectSpread2.default)({}, data); | ||
const eventData = _objectSpread({}, data); | ||
onEvent(name, eventData); | ||
@@ -85,3 +61,5 @@ } // Pass the event up the hierarchy | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
@@ -92,23 +70,20 @@ if (typeof onAnalyticsEvent === 'function') { | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass2.default)(AnalyticsListener, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var children = this.props.children; // eslint-disable-line react/prop-types | ||
getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
return _react.default.Children.only(children); | ||
} | ||
}]); | ||
return AnalyticsListener; | ||
}(_react.Component); | ||
render() { | ||
const { | ||
children | ||
} = this.props; // eslint-disable-line react/prop-types | ||
return _react.default.Children.only(children); | ||
} | ||
} | ||
(0, _defineProperty2.default)(AnalyticsListener, "defaultProps", { | ||
@@ -115,0 +90,0 @@ match: '*', |
@@ -22,9 +22,11 @@ "use strict"; | ||
/* eslint-disable no-unused-vars */ | ||
var analyticsId = props.analyticsId, | ||
analyticsData = props.analyticsData, | ||
delegateAnalyticsEvent = props.delegateAnalyticsEvent, | ||
fireAnalyticsEvent = props.fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent = props.firePrivateAnalyticsEvent, | ||
getParentAnalyticsData = props.getParentAnalyticsData, | ||
cleanedProps = (0, _objectWithoutProperties2.default)(props, ["analyticsId", "analyticsData", "delegateAnalyticsEvent", "fireAnalyticsEvent", "firePrivateAnalyticsEvent", "getParentAnalyticsData"]); | ||
const { | ||
analyticsId, | ||
analyticsData, | ||
delegateAnalyticsEvent, | ||
fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent, | ||
getParentAnalyticsData | ||
} = props, | ||
cleanedProps = (0, _objectWithoutProperties2.default)(props, ["analyticsId", "analyticsData", "delegateAnalyticsEvent", "fireAnalyticsEvent", "firePrivateAnalyticsEvent", "getParentAnalyticsData"]); | ||
/* eslint-enable no-unused-vars */ | ||
@@ -31,0 +33,0 @@ |
@@ -12,3 +12,3 @@ "use strict"; | ||
*/ | ||
var ENDS_WITH_DOT = /\.$/; | ||
const ENDS_WITH_DOT = /\.$/; | ||
@@ -15,0 +15,0 @@ function matchEvent(matcher, name) { |
{ | ||
"name": "@atlaskit/analytics", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"sideEffects": false | ||
} |
@@ -16,16 +16,2 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -37,3 +23,6 @@ | ||
/* eslint-disable react/prop-types */ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
if (process.env.NODE_ENV !== 'production' && !process.env.CI) { | ||
@@ -57,53 +46,49 @@ // eslint-disable-next-line no-console | ||
var withAnalytics = function withAnalytics(WrappedComponent) { | ||
const withAnalytics = (WrappedComponent, map = {}, defaultProps = {}, withDelegation) => { | ||
var _class, _temp; | ||
var map = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var defaultProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var withDelegation = arguments.length > 3 ? arguments[3] : undefined; | ||
return _temp = _class = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2.default)(WithAnalytics, _Component); | ||
function WithAnalytics() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
(0, _classCallCheck2.default)(this, WithAnalytics); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(WithAnalytics)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "props", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "evaluatedMap", {}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "delegateAnalyticsEvent", function (analyticsId, data, isPrivate) { | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
return _temp = _class = class WithAnalytics extends _react.Component { | ||
constructor(...args) { | ||
super(...args); | ||
(0, _defineProperty2.default)(this, "props", void 0); | ||
(0, _defineProperty2.default)(this, "evaluatedMap", {}); | ||
(0, _defineProperty2.default)(this, "delegateAnalyticsEvent", (analyticsId, data, isPrivate) => { | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (!onAnalyticsEvent) return; | ||
onAnalyticsEvent(analyticsId, data, isPrivate); | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fireAnalyticsEvent", function (name, data) { | ||
var _this$props = _this.props, | ||
analyticsData = _this$props.analyticsData, | ||
analyticsId = _this$props.analyticsId; | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
(0, _defineProperty2.default)(this, "fireAnalyticsEvent", (name, data) => { | ||
const { | ||
analyticsData, | ||
analyticsId | ||
} = this.props; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (!analyticsId || !onAnalyticsEvent) return; | ||
var eventData = (0, _objectSpread2.default)({}, analyticsData, data); | ||
onAnalyticsEvent("".concat(analyticsId, ".").concat(name), eventData, false); | ||
const eventData = _objectSpread({}, analyticsData, {}, data); | ||
onAnalyticsEvent(`${analyticsId}.${name}`, eventData, false); | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "privateAnalyticsEvent", function (name, data) { | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
(0, _defineProperty2.default)(this, "privateAnalyticsEvent", (name, data) => { | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (!onAnalyticsEvent) return; | ||
onAnalyticsEvent("".concat(name), data, true); | ||
onAnalyticsEvent(`${name}`, data, true); | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParentAnalyticsData", function (name) { | ||
var getParentAnalyticsData = _this.context.getParentAnalyticsData; | ||
var parentData = {}; | ||
(0, _defineProperty2.default)(this, "getParentAnalyticsData", name => { | ||
const { | ||
getParentAnalyticsData | ||
} = this.context; | ||
let parentData = {}; | ||
if (typeof getParentAnalyticsData === 'function' && _this.props.analyticsId) { | ||
var analyticsId = _this.props.analyticsId; | ||
parentData = getParentAnalyticsData("".concat(analyticsId, ".").concat(name), false); | ||
if (typeof getParentAnalyticsData === 'function' && this.props.analyticsId) { | ||
const { | ||
analyticsId | ||
} = this.props; | ||
parentData = getParentAnalyticsData(`${analyticsId}.${name}`, false); | ||
} | ||
@@ -113,49 +98,44 @@ | ||
}); | ||
return _this; | ||
} | ||
(0, _createClass2.default)(WithAnalytics, [{ | ||
key: "UNSAFE_componentWillMount", | ||
value: function UNSAFE_componentWillMount() { | ||
this.evaluatedMap = typeof map === 'function' ? map(this.fireAnalyticsEvent) : map; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this2 = this; | ||
UNSAFE_componentWillMount() { | ||
this.evaluatedMap = typeof map === 'function' ? map(this.fireAnalyticsEvent) : map; | ||
} | ||
/* eslint-disable no-unused-vars */ | ||
var _this$props2 = this.props, | ||
analyticsId = _this$props2.analyticsId, | ||
analyticsData = _this$props2.analyticsData, | ||
componentProps = (0, _objectWithoutProperties2.default)(_this$props2, ["analyticsId", "analyticsData"]); | ||
/* eslint-enable no-unused-vars */ | ||
render() { | ||
/* eslint-disable no-unused-vars */ | ||
const _this$props = this.props, | ||
{ | ||
analyticsId, | ||
analyticsData | ||
} = _this$props, | ||
componentProps = (0, _objectWithoutProperties2.default)(_this$props, ["analyticsId", "analyticsData"]); | ||
/* eslint-enable no-unused-vars */ | ||
Object.keys(this.evaluatedMap).forEach(function (prop) { | ||
var handler = _this2.evaluatedMap[prop]; // may be eventName or a function | ||
Object.keys(this.evaluatedMap).forEach(prop => { | ||
const handler = this.evaluatedMap[prop]; // may be eventName or a function | ||
var originalProp = componentProps[prop]; | ||
const originalProp = componentProps[prop]; | ||
componentProps[prop] = function () { | ||
if (typeof handler === 'function') { | ||
handler.apply(void 0, arguments); | ||
} else { | ||
_this2.fireAnalyticsEvent(handler); | ||
} | ||
componentProps[prop] = (...args) => { | ||
if (typeof handler === 'function') { | ||
handler(...args); | ||
} else { | ||
this.fireAnalyticsEvent(handler); | ||
} | ||
if (typeof originalProp === 'function') originalProp.apply(void 0, arguments); | ||
}; | ||
}); | ||
return _react.default.createElement(WrappedComponent, (0, _extends2.default)({ | ||
fireAnalyticsEvent: this.fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent: this.privateAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData, | ||
delegateAnalyticsEvent: withDelegation ? this.delegateAnalyticsEvent : undefined, | ||
analyticsId: analyticsId, | ||
ref: this.props.innerRef | ||
}, componentProps)); | ||
} | ||
}]); | ||
return WithAnalytics; | ||
}(_react.Component), (0, _defineProperty2.default)(_class, "displayName", "WithAnalytics(".concat(WrappedComponent.displayName || WrappedComponent.name, ")")), (0, _defineProperty2.default)(_class, "contextTypes", { | ||
if (typeof originalProp === 'function') originalProp(...args); | ||
}; | ||
}); | ||
return _react.default.createElement(WrappedComponent, (0, _extends2.default)({ | ||
fireAnalyticsEvent: this.fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent: this.privateAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData, | ||
delegateAnalyticsEvent: withDelegation ? this.delegateAnalyticsEvent : undefined, | ||
analyticsId: analyticsId, | ||
ref: this.props.innerRef | ||
}, componentProps)); | ||
} | ||
}, (0, _defineProperty2.default)(_class, "displayName", `WithAnalytics(${WrappedComponent.displayName || WrappedComponent.name})`), (0, _defineProperty2.default)(_class, "contextTypes", { | ||
onAnalyticsEvent: _propTypes.default.func, | ||
@@ -162,0 +142,0 @@ getParentAnalyticsData: _propTypes.default.func |
{ | ||
"name": "@atlaskit/analytics", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"sideEffects": false | ||
} |
@@ -1,11 +0,7 @@ | ||
import _typeof from "@babel/runtime/helpers/typeof"; | ||
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 _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* eslint-disable react/sort-comp */ | ||
@@ -18,3 +14,3 @@ import React, { Component } from 'react'; | ||
var ContextTypes = { | ||
const ContextTypes = { | ||
onAnalyticsEvent: PropTypes.func, | ||
@@ -29,33 +25,20 @@ getParentAnalyticsData: PropTypes.func | ||
var AnalyticsDecorator = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(AnalyticsDecorator, _Component); | ||
class AnalyticsDecorator extends Component { | ||
constructor(...args) { | ||
super(...args); | ||
function AnalyticsDecorator() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, AnalyticsDecorator); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AnalyticsDecorator)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_this), "getDecoratedAnalyticsData", function (name, srcData, isPrivate) { | ||
_defineProperty(this, "getDecoratedAnalyticsData", (name, srcData, isPrivate) => { | ||
// Decorate the event data if this decorator matches the event name | ||
// eslint-disable-next-line react/prop-types | ||
var _this$props = _this.props, | ||
data = _this$props.data, | ||
getData = _this$props.getData, | ||
match = _this$props.match, | ||
matchPrivate = _this$props.matchPrivate; | ||
const { | ||
data, | ||
getData, | ||
match, | ||
matchPrivate | ||
} = this.props; | ||
var decoratedData = _objectSpread({}, srcData); | ||
const decoratedData = _objectSpread({}, srcData); | ||
if (matchPrivate === isPrivate && matchEvent(match, name)) { | ||
if (_typeof(data) === 'object') { | ||
if (typeof data === 'object') { | ||
Object.assign(decoratedData, data); | ||
@@ -72,20 +55,21 @@ } | ||
_defineProperty(_assertThisInitialized(_this), "onAnalyticsEvent", function (name, srcData, isPrivate) { | ||
_defineProperty(this, "onAnalyticsEvent", (name, srcData, isPrivate) => { | ||
// Check there is a listener to pass the event to, otherwise there's no need | ||
// to do any of this work | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (typeof onAnalyticsEvent !== 'function') return; | ||
const decoratedData = this.getDecoratedAnalyticsData(name, srcData, isPrivate); // Pass the decorated event data to the next listener up the hierarchy | ||
var decoratedData = _this.getDecoratedAnalyticsData(name, srcData, isPrivate); // Pass the decorated event data to the next listener up the hierarchy | ||
onAnalyticsEvent(name, decoratedData, isPrivate); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "getParentAnalyticsData", function (name, isPrivate) { | ||
var parentData = _this.getDecoratedAnalyticsData(name, {}, isPrivate); // Get any analytics data from any decorators up the hierarchy | ||
_defineProperty(this, "getParentAnalyticsData", (name, isPrivate) => { | ||
const parentData = this.getDecoratedAnalyticsData(name, {}, isPrivate); // Get any analytics data from any decorators up the hierarchy | ||
const { | ||
getParentAnalyticsData | ||
} = this.context; | ||
var getParentAnalyticsData = _this.context.getParentAnalyticsData; | ||
if (typeof getParentAnalyticsData === 'function') { | ||
@@ -97,25 +81,20 @@ Object.assign(parentData, getParentAnalyticsData(name, isPrivate)); | ||
}); | ||
} | ||
return _this; | ||
getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData | ||
}; | ||
} | ||
_createClass(AnalyticsDecorator, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var children = this.props.children; // eslint-disable-line react/prop-types | ||
render() { | ||
const { | ||
children | ||
} = this.props; // eslint-disable-line react/prop-types | ||
return React.Children.only(children); | ||
} | ||
}]); | ||
return React.Children.only(children); | ||
} | ||
return AnalyticsDecorator; | ||
}(Component); | ||
} | ||
@@ -122,0 +101,0 @@ _defineProperty(AnalyticsDecorator, "defaultProps", { |
@@ -1,10 +0,7 @@ | ||
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 _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* eslint-disable react/sort-comp */ | ||
@@ -18,3 +15,3 @@ import React, { Component } from 'react'; | ||
var ContextTypes = { | ||
const ContextTypes = { | ||
onAnalyticsEvent: PropTypes.func | ||
@@ -28,25 +25,13 @@ }; | ||
var AnalyticsDelegate = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(AnalyticsDelegate, _Component); | ||
class AnalyticsDelegate extends Component { | ||
constructor(...args) { | ||
super(...args); | ||
function AnalyticsDelegate() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, AnalyticsDelegate); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AnalyticsDelegate)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_this), "onAnalyticsEvent", function (name, data, isPrivate) { | ||
_defineProperty(this, "onAnalyticsEvent", (name, data, isPrivate) => { | ||
// eslint-disable-next-line react/prop-types | ||
var delegateAnalyticsEvent = _this.props.delegateAnalyticsEvent; // send a clean data object so it can't be mutated between listeners | ||
const { | ||
delegateAnalyticsEvent | ||
} = this.props; // send a clean data object so it can't be mutated between listeners | ||
var eventData = _objectSpread({}, data); | ||
const eventData = _objectSpread({}, data); | ||
@@ -58,3 +43,5 @@ if (delegateAnalyticsEvent) { | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
@@ -65,24 +52,19 @@ if (typeof onAnalyticsEvent === 'function') { | ||
}); | ||
} | ||
return _this; | ||
getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
_createClass(AnalyticsDelegate, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var children = this.props.children; // eslint-disable-line react/prop-types | ||
render() { | ||
const { | ||
children | ||
} = this.props; // eslint-disable-line react/prop-types | ||
return React.Children.only(children); | ||
} | ||
}]); | ||
return React.Children.only(children); | ||
} | ||
return AnalyticsDelegate; | ||
}(Component); | ||
} | ||
@@ -89,0 +71,0 @@ _defineProperty(AnalyticsDelegate, "contextTypes", ContextTypes); |
@@ -1,10 +0,7 @@ | ||
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 _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* eslint-disable react/sort-comp */ | ||
@@ -19,3 +16,3 @@ import React, { Component } from 'react'; | ||
var ContextTypes = { | ||
const ContextTypes = { | ||
onAnalyticsEvent: PropTypes.func | ||
@@ -29,31 +26,18 @@ }; | ||
var AnalyticsListener = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(AnalyticsListener, _Component); | ||
class AnalyticsListener extends Component { | ||
constructor(...args) { | ||
super(...args); | ||
function AnalyticsListener() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, AnalyticsListener); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AnalyticsListener)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_this), "onAnalyticsEvent", function (name, data, isPrivate) { | ||
_defineProperty(this, "onAnalyticsEvent", (name, data, isPrivate) => { | ||
// Call this component's onEvent method if it's a match | ||
// eslint-disable-next-line react/prop-types | ||
var _this$props = _this.props, | ||
onEvent = _this$props.onEvent, | ||
match = _this$props.match, | ||
matchPrivate = _this$props.matchPrivate; | ||
const { | ||
onEvent, | ||
match, | ||
matchPrivate | ||
} = this.props; | ||
if (matchPrivate === isPrivate && matchEvent(match, name) && typeof onEvent === 'function') { | ||
// send a clean data object so it can't be mutated between listeners | ||
var eventData = _objectSpread({}, data); | ||
const eventData = _objectSpread({}, data); | ||
@@ -64,3 +48,5 @@ onEvent(name, eventData); | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
@@ -71,24 +57,19 @@ if (typeof onAnalyticsEvent === 'function') { | ||
}); | ||
} | ||
return _this; | ||
getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
_createClass(AnalyticsListener, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
onAnalyticsEvent: this.onAnalyticsEvent | ||
}; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var children = this.props.children; // eslint-disable-line react/prop-types | ||
render() { | ||
const { | ||
children | ||
} = this.props; // eslint-disable-line react/prop-types | ||
return React.Children.only(children); | ||
} | ||
}]); | ||
return React.Children.only(children); | ||
} | ||
return AnalyticsListener; | ||
}(Component); | ||
} | ||
@@ -95,0 +76,0 @@ _defineProperty(AnalyticsListener, "defaultProps", { |
@@ -13,9 +13,11 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
/* eslint-disable no-unused-vars */ | ||
var analyticsId = props.analyticsId, | ||
analyticsData = props.analyticsData, | ||
delegateAnalyticsEvent = props.delegateAnalyticsEvent, | ||
fireAnalyticsEvent = props.fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent = props.firePrivateAnalyticsEvent, | ||
getParentAnalyticsData = props.getParentAnalyticsData, | ||
cleanedProps = _objectWithoutProperties(props, ["analyticsId", "analyticsData", "delegateAnalyticsEvent", "fireAnalyticsEvent", "firePrivateAnalyticsEvent", "getParentAnalyticsData"]); | ||
const { | ||
analyticsId, | ||
analyticsData, | ||
delegateAnalyticsEvent, | ||
fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent, | ||
getParentAnalyticsData | ||
} = props, | ||
cleanedProps = _objectWithoutProperties(props, ["analyticsId", "analyticsData", "delegateAnalyticsEvent", "fireAnalyticsEvent", "firePrivateAnalyticsEvent", "getParentAnalyticsData"]); | ||
/* eslint-enable no-unused-vars */ | ||
@@ -22,0 +24,0 @@ |
@@ -5,3 +5,3 @@ /* | ||
*/ | ||
var ENDS_WITH_DOT = /\.$/; | ||
const ENDS_WITH_DOT = /\.$/; | ||
@@ -8,0 +8,0 @@ function matchEvent(matcher, name) { |
{ | ||
"name": "@atlaskit/analytics", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"sideEffects": false | ||
} |
import _extends from "@babel/runtime/helpers/extends"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
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 _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
/* eslint-disable react/prop-types */ | ||
@@ -34,32 +31,17 @@ import React, { Component } from 'react'; | ||
var withAnalytics = function withAnalytics(WrappedComponent) { | ||
const withAnalytics = (WrappedComponent, map = {}, defaultProps = {}, withDelegation) => { | ||
var _class, _temp; | ||
var map = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var defaultProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var withDelegation = arguments.length > 3 ? arguments[3] : undefined; | ||
return _temp = _class = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(WithAnalytics, _Component); | ||
return _temp = _class = class WithAnalytics extends Component { | ||
constructor(...args) { | ||
super(...args); | ||
function WithAnalytics() { | ||
var _getPrototypeOf2; | ||
_defineProperty(this, "props", void 0); | ||
var _this; | ||
_defineProperty(this, "evaluatedMap", {}); | ||
_classCallCheck(this, WithAnalytics); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(WithAnalytics)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_this), "props", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "evaluatedMap", {}); | ||
_defineProperty(_assertThisInitialized(_this), "delegateAnalyticsEvent", function (analyticsId, data, isPrivate) { | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
_defineProperty(this, "delegateAnalyticsEvent", (analyticsId, data, isPrivate) => { | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (!onAnalyticsEvent) return; | ||
@@ -69,27 +51,36 @@ onAnalyticsEvent(analyticsId, data, isPrivate); | ||
_defineProperty(_assertThisInitialized(_this), "fireAnalyticsEvent", function (name, data) { | ||
var _this$props = _this.props, | ||
analyticsData = _this$props.analyticsData, | ||
analyticsId = _this$props.analyticsId; | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
_defineProperty(this, "fireAnalyticsEvent", (name, data) => { | ||
const { | ||
analyticsData, | ||
analyticsId | ||
} = this.props; | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (!analyticsId || !onAnalyticsEvent) return; | ||
var eventData = _objectSpread({}, analyticsData, data); | ||
const eventData = _objectSpread({}, analyticsData, {}, data); | ||
onAnalyticsEvent("".concat(analyticsId, ".").concat(name), eventData, false); | ||
onAnalyticsEvent(`${analyticsId}.${name}`, eventData, false); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "privateAnalyticsEvent", function (name, data) { | ||
var onAnalyticsEvent = _this.context.onAnalyticsEvent; | ||
_defineProperty(this, "privateAnalyticsEvent", (name, data) => { | ||
const { | ||
onAnalyticsEvent | ||
} = this.context; | ||
if (!onAnalyticsEvent) return; | ||
onAnalyticsEvent("".concat(name), data, true); | ||
onAnalyticsEvent(`${name}`, data, true); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "getParentAnalyticsData", function (name) { | ||
var getParentAnalyticsData = _this.context.getParentAnalyticsData; | ||
var parentData = {}; | ||
_defineProperty(this, "getParentAnalyticsData", name => { | ||
const { | ||
getParentAnalyticsData | ||
} = this.context; | ||
let parentData = {}; | ||
if (typeof getParentAnalyticsData === 'function' && _this.props.analyticsId) { | ||
var analyticsId = _this.props.analyticsId; | ||
parentData = getParentAnalyticsData("".concat(analyticsId, ".").concat(name), false); | ||
if (typeof getParentAnalyticsData === 'function' && this.props.analyticsId) { | ||
const { | ||
analyticsId | ||
} = this.props; | ||
parentData = getParentAnalyticsData(`${analyticsId}.${name}`, false); | ||
} | ||
@@ -99,52 +90,45 @@ | ||
}); | ||
} | ||
return _this; | ||
UNSAFE_componentWillMount() { | ||
this.evaluatedMap = typeof map === 'function' ? map(this.fireAnalyticsEvent) : map; | ||
} | ||
_createClass(WithAnalytics, [{ | ||
key: "UNSAFE_componentWillMount", | ||
value: function UNSAFE_componentWillMount() { | ||
this.evaluatedMap = typeof map === 'function' ? map(this.fireAnalyticsEvent) : map; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this2 = this; | ||
render() { | ||
/* eslint-disable no-unused-vars */ | ||
const _this$props = this.props, | ||
{ | ||
analyticsId, | ||
analyticsData | ||
} = _this$props, | ||
componentProps = _objectWithoutProperties(_this$props, ["analyticsId", "analyticsData"]); | ||
/* eslint-enable no-unused-vars */ | ||
/* eslint-disable no-unused-vars */ | ||
var _this$props2 = this.props, | ||
analyticsId = _this$props2.analyticsId, | ||
analyticsData = _this$props2.analyticsData, | ||
componentProps = _objectWithoutProperties(_this$props2, ["analyticsId", "analyticsData"]); | ||
/* eslint-enable no-unused-vars */ | ||
Object.keys(this.evaluatedMap).forEach(prop => { | ||
const handler = this.evaluatedMap[prop]; // may be eventName or a function | ||
Object.keys(this.evaluatedMap).forEach(function (prop) { | ||
var handler = _this2.evaluatedMap[prop]; // may be eventName or a function | ||
const originalProp = componentProps[prop]; | ||
var originalProp = componentProps[prop]; | ||
componentProps[prop] = (...args) => { | ||
if (typeof handler === 'function') { | ||
handler(...args); | ||
} else { | ||
this.fireAnalyticsEvent(handler); | ||
} | ||
componentProps[prop] = function () { | ||
if (typeof handler === 'function') { | ||
handler.apply(void 0, arguments); | ||
} else { | ||
_this2.fireAnalyticsEvent(handler); | ||
} | ||
if (typeof originalProp === 'function') originalProp(...args); | ||
}; | ||
}); | ||
return React.createElement(WrappedComponent, _extends({ | ||
fireAnalyticsEvent: this.fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent: this.privateAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData, | ||
delegateAnalyticsEvent: withDelegation ? this.delegateAnalyticsEvent : undefined, | ||
analyticsId: analyticsId, | ||
ref: this.props.innerRef | ||
}, componentProps)); | ||
} | ||
if (typeof originalProp === 'function') originalProp.apply(void 0, arguments); | ||
}; | ||
}); | ||
return React.createElement(WrappedComponent, _extends({ | ||
fireAnalyticsEvent: this.fireAnalyticsEvent, | ||
firePrivateAnalyticsEvent: this.privateAnalyticsEvent, | ||
getParentAnalyticsData: this.getParentAnalyticsData, | ||
delegateAnalyticsEvent: withDelegation ? this.delegateAnalyticsEvent : undefined, | ||
analyticsId: analyticsId, | ||
ref: this.props.innerRef | ||
}, componentProps)); | ||
} | ||
}]); | ||
return WithAnalytics; | ||
}(Component), _defineProperty(_class, "displayName", "WithAnalytics(".concat(WrappedComponent.displayName || WrappedComponent.name, ")")), _defineProperty(_class, "contextTypes", { | ||
}, _defineProperty(_class, "displayName", `WithAnalytics(${WrappedComponent.displayName || WrappedComponent.name})`), _defineProperty(_class, "contextTypes", { | ||
onAnalyticsEvent: PropTypes.func, | ||
@@ -151,0 +135,0 @@ getParentAnalyticsData: PropTypes.func |
{ | ||
"name": "@atlaskit/analytics", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"description": "The Atlaskit Component Analytics Framework", | ||
@@ -19,2 +19,3 @@ "publishConfig": { | ||
"team": "Atlassian Frontend Platform", | ||
"deprecatedAutoEntryPoints": true, | ||
"releaseModel": "continuous", | ||
@@ -21,0 +22,0 @@ "website": { |
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
67984
1147