Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atlaskit/analytics

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaskit/analytics - npm Package Compare versions

Comparing version 8.0.1 to 8.0.2

6

CHANGELOG.md
# @atlaskit/analytics
## 8.0.2
### Patch Changes
- [`30853172ff`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30853172ff) - Reset babel config back to ie11 to prevent runtime issues in Jira and to unbreak the Confluence es5-check
## 8.0.1

@@ -4,0 +10,0 @@

103

dist/cjs/AnalyticsDecorator.js

@@ -12,2 +12,16 @@ "use strict";

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
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"));

@@ -27,3 +41,3 @@

its descendents, then passes the event up the hierarchy */
const ContextTypes = {
var ContextTypes = {
onAnalyticsEvent: _propTypes.default.func,

@@ -38,19 +52,30 @@ getParentAnalyticsData: _propTypes.default.func

class AnalyticsDecorator extends _react.Component {
constructor(...args) {
super(...args);
(0, _defineProperty2.default)(this, "getDecoratedAnalyticsData", (name, srcData, isPrivate) => {
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) {
// Decorate the event data if this decorator matches the event name
// eslint-disable-next-line react/prop-types
const {
data,
getData,
match,
matchPrivate
} = this.props;
var _this$props = _this.props,
data = _this$props.data,
getData = _this$props.getData,
match = _this$props.match,
matchPrivate = _this$props.matchPrivate;
const decoratedData = _objectSpread({}, srcData);
var decoratedData = _objectSpread({}, srcData);
if (matchPrivate === isPrivate && (0, _matchEvent.default)(match, name)) {
if (typeof data === 'object') {
if ((0, _typeof2.default)(data) === 'object') {
Object.assign(decoratedData, data);

@@ -66,20 +91,19 @@ }

});
(0, _defineProperty2.default)(this, "onAnalyticsEvent", (name, srcData, isPrivate) => {
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onAnalyticsEvent", function (name, srcData, isPrivate) {
// Check there is a listener to pass the event to, otherwise there's no need
// to do any of this work
const {
onAnalyticsEvent
} = this.context;
var onAnalyticsEvent = _this.context.onAnalyticsEvent;
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)(this, "getParentAnalyticsData", (name, isPrivate) => {
const parentData = this.getDecoratedAnalyticsData(name, {}, isPrivate); // Get any analytics data from any decorators up the hierarchy
(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
const {
getParentAnalyticsData
} = this.context;
var getParentAnalyticsData = _this.context.getParentAnalyticsData;
if (typeof getParentAnalyticsData === 'function') {

@@ -91,21 +115,24 @@ Object.assign(parentData, getParentAnalyticsData(name, isPrivate));

});
return _this;
}
getChildContext() {
return {
onAnalyticsEvent: this.onAnalyticsEvent,
getParentAnalyticsData: this.getParentAnalyticsData
};
}
(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
render() {
const {
children
} = this.props; // eslint-disable-line react/prop-types
return _react.default.Children.only(children);
}
}]);
return AnalyticsDecorator;
}(_react.Component);
return _react.default.Children.only(children);
}
}
(0, _defineProperty2.default)(AnalyticsDecorator, "defaultProps", {

@@ -112,0 +139,0 @@ match: '*',

@@ -12,2 +12,14 @@ "use strict";

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"));

@@ -27,3 +39,3 @@

*/
const ContextTypes = {
var ContextTypes = {
onAnalyticsEvent: _propTypes.default.func

@@ -37,12 +49,22 @@ };

class AnalyticsDelegate extends _react.Component {
constructor(...args) {
super(...args);
(0, _defineProperty2.default)(this, "onAnalyticsEvent", (name, data, isPrivate) => {
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) {
// eslint-disable-next-line react/prop-types
const {
delegateAnalyticsEvent
} = this.props; // send a clean data object so it can't be mutated between listeners
var delegateAnalyticsEvent = _this.props.delegateAnalyticsEvent; // send a clean data object so it can't be mutated between listeners
const eventData = _objectSpread({}, data);
var eventData = _objectSpread({}, data);

@@ -54,5 +76,3 @@ if (delegateAnalyticsEvent) {

const {
onAnalyticsEvent
} = this.context;
var onAnalyticsEvent = _this.context.onAnalyticsEvent;

@@ -63,20 +83,23 @@ if (typeof onAnalyticsEvent === 'function') {

});
return _this;
}
getChildContext() {
return {
onAnalyticsEvent: this.onAnalyticsEvent
};
}
(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
render() {
const {
children
} = this.props; // eslint-disable-line react/prop-types
return _react.default.Children.only(children);
}
}]);
return AnalyticsDelegate;
}(_react.Component);
return _react.default.Children.only(children);
}
}
(0, _defineProperty2.default)(AnalyticsDelegate, "contextTypes", ContextTypes);

@@ -83,0 +106,0 @@ (0, _defineProperty2.default)(AnalyticsDelegate, "childContextTypes", ContextTypes);

@@ -12,2 +12,14 @@ "use strict";

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"));

@@ -29,3 +41,3 @@

*/
const ContextTypes = {
var ContextTypes = {
onAnalyticsEvent: _propTypes.default.func

@@ -39,17 +51,28 @@ };

class AnalyticsListener extends _react.Component {
constructor(...args) {
super(...args);
(0, _defineProperty2.default)(this, "onAnalyticsEvent", (name, data, isPrivate) => {
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) {
// Call this component's onEvent method if it's a match
// eslint-disable-next-line react/prop-types
const {
onEvent,
match,
matchPrivate
} = this.props;
var _this$props = _this.props,
onEvent = _this$props.onEvent,
match = _this$props.match,
matchPrivate = _this$props.matchPrivate;
if (matchPrivate === isPrivate && (0, _matchEvent.default)(match, name) && typeof onEvent === 'function') {
// send a clean data object so it can't be mutated between listeners
const eventData = _objectSpread({}, data);
var eventData = _objectSpread({}, data);

@@ -60,5 +83,3 @@ onEvent(name, eventData);

const {
onAnalyticsEvent
} = this.context;
var onAnalyticsEvent = _this.context.onAnalyticsEvent;

@@ -69,20 +90,23 @@ if (typeof onAnalyticsEvent === 'function') {

});
return _this;
}
getChildContext() {
return {
onAnalyticsEvent: this.onAnalyticsEvent
};
}
(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
render() {
const {
children
} = this.props; // eslint-disable-line react/prop-types
return _react.default.Children.only(children);
}
}]);
return AnalyticsListener;
}(_react.Component);
return _react.default.Children.only(children);
}
}
(0, _defineProperty2.default)(AnalyticsListener, "defaultProps", {

@@ -89,0 +113,0 @@ match: '*',

@@ -22,11 +22,9 @@ "use strict";

/* eslint-disable no-unused-vars */
const {
analyticsId,
analyticsData,
delegateAnalyticsEvent,
fireAnalyticsEvent,
firePrivateAnalyticsEvent,
getParentAnalyticsData
} = props,
cleanedProps = (0, _objectWithoutProperties2.default)(props, ["analyticsId", "analyticsData", "delegateAnalyticsEvent", "fireAnalyticsEvent", "firePrivateAnalyticsEvent", "getParentAnalyticsData"]);
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"]);
/* eslint-enable no-unused-vars */

@@ -33,0 +31,0 @@

@@ -12,3 +12,3 @@ "use strict";

*/
const ENDS_WITH_DOT = /\.$/;
var ENDS_WITH_DOT = /\.$/;

@@ -15,0 +15,0 @@ function matchEvent(matcher, name) {

{
"name": "@atlaskit/analytics",
"version": "8.0.1",
"version": "8.0.2",
"sideEffects": false
}

@@ -16,2 +16,14 @@ "use strict";

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"));

@@ -45,49 +57,53 @@

const withAnalytics = (WrappedComponent, map = {}, defaultProps = {}, withDelegation) => {
var withAnalytics = function withAnalytics(WrappedComponent) {
var _class, _temp;
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;
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;
if (!onAnalyticsEvent) return;
onAnalyticsEvent(analyticsId, data, isPrivate);
});
(0, _defineProperty2.default)(this, "fireAnalyticsEvent", (name, data) => {
const {
analyticsData,
analyticsId
} = this.props;
const {
onAnalyticsEvent
} = this.context;
(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;
if (!analyticsId || !onAnalyticsEvent) return;
const eventData = _objectSpread({}, analyticsData, {}, data);
var eventData = _objectSpread({}, analyticsData, {}, data);
onAnalyticsEvent(`${analyticsId}.${name}`, eventData, false);
onAnalyticsEvent("".concat(analyticsId, ".").concat(name), eventData, false);
});
(0, _defineProperty2.default)(this, "privateAnalyticsEvent", (name, data) => {
const {
onAnalyticsEvent
} = this.context;
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "privateAnalyticsEvent", function (name, data) {
var onAnalyticsEvent = _this.context.onAnalyticsEvent;
if (!onAnalyticsEvent) return;
onAnalyticsEvent(`${name}`, data, true);
onAnalyticsEvent("".concat(name), data, true);
});
(0, _defineProperty2.default)(this, "getParentAnalyticsData", name => {
const {
getParentAnalyticsData
} = this.context;
let parentData = {};
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParentAnalyticsData", function (name) {
var getParentAnalyticsData = _this.context.getParentAnalyticsData;
var parentData = {};
if (typeof getParentAnalyticsData === 'function' && this.props.analyticsId) {
const {
analyticsId
} = this.props;
parentData = getParentAnalyticsData(`${analyticsId}.${name}`, false);
if (typeof getParentAnalyticsData === 'function' && _this.props.analyticsId) {
var analyticsId = _this.props.analyticsId;
parentData = getParentAnalyticsData("".concat(analyticsId, ".").concat(name), false);
}

@@ -97,44 +113,49 @@

});
return _this;
}
UNSAFE_componentWillMount() {
this.evaluatedMap = typeof map === 'function' ? map(this.fireAnalyticsEvent) : map;
}
(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;
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 */
/* 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 */
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.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", {
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", {
onAnalyticsEvent: _propTypes.default.func,

@@ -141,0 +162,0 @@ getParentAnalyticsData: _propTypes.default.func

{
"name": "@atlaskit/analytics",
"version": "8.0.1",
"version": "8.0.2",
"sideEffects": false
}

@@ -0,1 +1,8 @@

import _typeof from "@babel/runtime/helpers/typeof";
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";

@@ -14,3 +21,3 @@

const ContextTypes = {
var ContextTypes = {
onAnalyticsEvent: PropTypes.func,

@@ -25,20 +32,31 @@ getParentAnalyticsData: PropTypes.func

class AnalyticsDecorator extends Component {
constructor(...args) {
super(...args);
var AnalyticsDecorator = /*#__PURE__*/function (_Component) {
_inherits(AnalyticsDecorator, _Component);
_defineProperty(this, "getDecoratedAnalyticsData", (name, srcData, isPrivate) => {
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) {
// Decorate the event data if this decorator matches the event name
// eslint-disable-next-line react/prop-types
const {
data,
getData,
match,
matchPrivate
} = this.props;
var _this$props = _this.props,
data = _this$props.data,
getData = _this$props.getData,
match = _this$props.match,
matchPrivate = _this$props.matchPrivate;
const decoratedData = _objectSpread({}, srcData);
var decoratedData = _objectSpread({}, srcData);
if (matchPrivate === isPrivate && matchEvent(match, name)) {
if (typeof data === 'object') {
if (_typeof(data) === 'object') {
Object.assign(decoratedData, data);

@@ -55,21 +73,20 @@ }

_defineProperty(this, "onAnalyticsEvent", (name, srcData, isPrivate) => {
_defineProperty(_assertThisInitialized(_this), "onAnalyticsEvent", function (name, srcData, isPrivate) {
// Check there is a listener to pass the event to, otherwise there's no need
// to do any of this work
const {
onAnalyticsEvent
} = this.context;
var onAnalyticsEvent = _this.context.onAnalyticsEvent;
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(this, "getParentAnalyticsData", (name, isPrivate) => {
const parentData = this.getDecoratedAnalyticsData(name, {}, isPrivate); // Get any analytics data from any decorators up the hierarchy
_defineProperty(_assertThisInitialized(_this), "getParentAnalyticsData", function (name, isPrivate) {
var 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') {

@@ -81,20 +98,25 @@ Object.assign(parentData, getParentAnalyticsData(name, isPrivate));

});
}
getChildContext() {
return {
onAnalyticsEvent: this.onAnalyticsEvent,
getParentAnalyticsData: this.getParentAnalyticsData
};
return _this;
}
render() {
const {
children
} = this.props; // eslint-disable-line react/prop-types
_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
return React.Children.only(children);
}
return React.Children.only(children);
}
}]);
}
return AnalyticsDecorator;
}(Component);

@@ -101,0 +123,0 @@ _defineProperty(AnalyticsDecorator, "defaultProps", {

@@ -0,1 +1,7 @@

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";

@@ -15,3 +21,3 @@

const ContextTypes = {
var ContextTypes = {
onAnalyticsEvent: PropTypes.func

@@ -25,13 +31,23 @@ };

class AnalyticsDelegate extends Component {
constructor(...args) {
super(...args);
var AnalyticsDelegate = /*#__PURE__*/function (_Component) {
_inherits(AnalyticsDelegate, _Component);
_defineProperty(this, "onAnalyticsEvent", (name, data, isPrivate) => {
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) {
// eslint-disable-next-line react/prop-types
const {
delegateAnalyticsEvent
} = this.props; // send a clean data object so it can't be mutated between listeners
var delegateAnalyticsEvent = _this.props.delegateAnalyticsEvent; // send a clean data object so it can't be mutated between listeners
const eventData = _objectSpread({}, data);
var eventData = _objectSpread({}, data);

@@ -43,5 +59,3 @@ if (delegateAnalyticsEvent) {

const {
onAnalyticsEvent
} = this.context;
var onAnalyticsEvent = _this.context.onAnalyticsEvent;

@@ -52,19 +66,24 @@ if (typeof onAnalyticsEvent === 'function') {

});
}
getChildContext() {
return {
onAnalyticsEvent: this.onAnalyticsEvent
};
return _this;
}
render() {
const {
children
} = this.props; // eslint-disable-line react/prop-types
_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
return React.Children.only(children);
}
return React.Children.only(children);
}
}]);
}
return AnalyticsDelegate;
}(Component);

@@ -71,0 +90,0 @@ _defineProperty(AnalyticsDelegate, "contextTypes", ContextTypes);

@@ -0,1 +1,7 @@

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";

@@ -16,3 +22,3 @@

const ContextTypes = {
var ContextTypes = {
onAnalyticsEvent: PropTypes.func

@@ -26,18 +32,29 @@ };

class AnalyticsListener extends Component {
constructor(...args) {
super(...args);
var AnalyticsListener = /*#__PURE__*/function (_Component) {
_inherits(AnalyticsListener, _Component);
_defineProperty(this, "onAnalyticsEvent", (name, data, isPrivate) => {
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) {
// Call this component's onEvent method if it's a match
// eslint-disable-next-line react/prop-types
const {
onEvent,
match,
matchPrivate
} = this.props;
var _this$props = _this.props,
onEvent = _this$props.onEvent,
match = _this$props.match,
matchPrivate = _this$props.matchPrivate;
if (matchPrivate === isPrivate && matchEvent(match, name) && typeof onEvent === 'function') {
// send a clean data object so it can't be mutated between listeners
const eventData = _objectSpread({}, data);
var eventData = _objectSpread({}, data);

@@ -48,5 +65,3 @@ onEvent(name, eventData);

const {
onAnalyticsEvent
} = this.context;
var onAnalyticsEvent = _this.context.onAnalyticsEvent;

@@ -57,19 +72,24 @@ if (typeof onAnalyticsEvent === 'function') {

});
}
getChildContext() {
return {
onAnalyticsEvent: this.onAnalyticsEvent
};
return _this;
}
render() {
const {
children
} = this.props; // eslint-disable-line react/prop-types
_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
return React.Children.only(children);
}
return React.Children.only(children);
}
}]);
}
return AnalyticsListener;
}(Component);

@@ -76,0 +96,0 @@ _defineProperty(AnalyticsListener, "defaultProps", {

@@ -13,11 +13,9 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

/* eslint-disable no-unused-vars */
const {
analyticsId,
analyticsData,
delegateAnalyticsEvent,
fireAnalyticsEvent,
firePrivateAnalyticsEvent,
getParentAnalyticsData
} = props,
cleanedProps = _objectWithoutProperties(props, ["analyticsId", "analyticsData", "delegateAnalyticsEvent", "fireAnalyticsEvent", "firePrivateAnalyticsEvent", "getParentAnalyticsData"]);
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"]);
/* eslint-enable no-unused-vars */

@@ -24,0 +22,0 @@

@@ -5,3 +5,3 @@ /*

*/
const ENDS_WITH_DOT = /\.$/;
var ENDS_WITH_DOT = /\.$/;

@@ -8,0 +8,0 @@ function matchEvent(matcher, name) {

{
"name": "@atlaskit/analytics",
"version": "8.0.1",
"version": "8.0.2",
"sideEffects": false
}
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
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";

@@ -31,17 +37,30 @@

const withAnalytics = (WrappedComponent, map = {}, defaultProps = {}, withDelegation) => {
var withAnalytics = function withAnalytics(WrappedComponent) {
var _class, _temp;
return _temp = _class = class WithAnalytics extends Component {
constructor(...args) {
super(...args);
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);
_defineProperty(this, "props", void 0);
function WithAnalytics() {
var _getPrototypeOf2;
_defineProperty(this, "evaluatedMap", {});
var _this;
_defineProperty(this, "delegateAnalyticsEvent", (analyticsId, data, isPrivate) => {
const {
onAnalyticsEvent
} = this.context;
_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;
if (!onAnalyticsEvent) return;

@@ -51,36 +70,27 @@ onAnalyticsEvent(analyticsId, data, isPrivate);

_defineProperty(this, "fireAnalyticsEvent", (name, data) => {
const {
analyticsData,
analyticsId
} = this.props;
const {
onAnalyticsEvent
} = this.context;
_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;
if (!analyticsId || !onAnalyticsEvent) return;
const eventData = _objectSpread({}, analyticsData, {}, data);
var eventData = _objectSpread({}, analyticsData, {}, data);
onAnalyticsEvent(`${analyticsId}.${name}`, eventData, false);
onAnalyticsEvent("".concat(analyticsId, ".").concat(name), eventData, false);
});
_defineProperty(this, "privateAnalyticsEvent", (name, data) => {
const {
onAnalyticsEvent
} = this.context;
_defineProperty(_assertThisInitialized(_this), "privateAnalyticsEvent", function (name, data) {
var onAnalyticsEvent = _this.context.onAnalyticsEvent;
if (!onAnalyticsEvent) return;
onAnalyticsEvent(`${name}`, data, true);
onAnalyticsEvent("".concat(name), data, true);
});
_defineProperty(this, "getParentAnalyticsData", name => {
const {
getParentAnalyticsData
} = this.context;
let parentData = {};
_defineProperty(_assertThisInitialized(_this), "getParentAnalyticsData", function (name) {
var getParentAnalyticsData = _this.context.getParentAnalyticsData;
var parentData = {};
if (typeof getParentAnalyticsData === 'function' && this.props.analyticsId) {
const {
analyticsId
} = this.props;
parentData = getParentAnalyticsData(`${analyticsId}.${name}`, false);
if (typeof getParentAnalyticsData === 'function' && _this.props.analyticsId) {
var analyticsId = _this.props.analyticsId;
parentData = getParentAnalyticsData("".concat(analyticsId, ".").concat(name), false);
}

@@ -90,45 +100,52 @@

});
}
UNSAFE_componentWillMount() {
this.evaluatedMap = typeof map === 'function' ? map(this.fireAnalyticsEvent) : map;
return _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 */
_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;
/* 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
const originalProp = componentProps[prop];
Object.keys(this.evaluatedMap).forEach(function (prop) {
var handler = _this2.evaluatedMap[prop]; // may be eventName or a function
componentProps[prop] = (...args) => {
if (typeof handler === 'function') {
handler(...args);
} else {
this.fireAnalyticsEvent(handler);
}
var originalProp = componentProps[prop];
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));
}
componentProps[prop] = function () {
if (typeof handler === 'function') {
handler.apply(void 0, arguments);
} else {
_this2.fireAnalyticsEvent(handler);
}
}, _defineProperty(_class, "displayName", `WithAnalytics(${WrappedComponent.displayName || WrappedComponent.name})`), _defineProperty(_class, "contextTypes", {
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", {
onAnalyticsEvent: PropTypes.func,

@@ -135,0 +152,0 @@ getParentAnalyticsData: PropTypes.func

{
"name": "@atlaskit/analytics",
"version": "8.0.1",
"version": "8.0.2",
"description": "The Atlaskit Component Analytics Framework",

@@ -5,0 +5,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc