Socket
Socket
Sign inDemoInstall

@atlaskit/analytics-next

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlaskit/analytics-next - npm Package Compare versions

Comparing version 2.1.9 to 3.0.0

dist/cjs/AnalyticsEventMap.js

12

CHANGELOG.md
# @atlaskit/analytics-next
## 3.0.0
- [major] Updates to React ^16.4.0 [7edb866](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/7edb866)
- [major] Updated dependencies [563a7eb](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/563a7eb)
- @atlaskit/field-text@7.0.0
- @atlaskit/button@9.0.0
- @atlaskit/docs@5.0.0
- [major] Updated dependencies [7edb866](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/7edb866)
- @atlaskit/field-text@7.0.0
- @atlaskit/button@9.0.0
- @atlaskit/docs@5.0.0
## 2.1.9

@@ -4,0 +16,0 @@ - [patch] removes requirement of children to be a single React node [53cba6b](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/53cba6b)

60

dist/cjs/withAnalyticsContext.js

@@ -15,22 +15,2 @@ 'use strict';

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
exports.default = withAnalyticsContext;

@@ -52,32 +32,20 @@

return function (WrappedComponent) {
var _class, _temp;
// $FlowFixMe - flow 0.67 doesn't know about forwardRef
var WithAnalyticsContext = _react2.default.forwardRef(function (props, ref) {
var _props$analyticsConte = props.analyticsContext,
analyticsContext = _props$analyticsConte === undefined ? {} : _props$analyticsConte,
others = (0, _objectWithoutProperties3.default)(props, ['analyticsContext']);
return _temp = _class = function (_Component) {
(0, _inherits3.default)(WithAnalyticsContext, _Component);
var data = (0, _extends3.default)({}, defaultData, analyticsContext);
return _react2.default.createElement(
_AnalyticsContext2.default,
{ data: data },
_react2.default.createElement(WrappedComponent, (0, _extends3.default)({}, others, { ref: ref }))
);
});
function WithAnalyticsContext() {
(0, _classCallCheck3.default)(this, WithAnalyticsContext);
return (0, _possibleConstructorReturn3.default)(this, (WithAnalyticsContext.__proto__ || (0, _getPrototypeOf2.default)(WithAnalyticsContext)).apply(this, arguments));
}
WithAnalyticsContext.displayName = 'WithAnalyticsContext(' + (WrappedComponent.displayName || WrappedComponent.name) + ')';
(0, _createClass3.default)(WithAnalyticsContext, [{
key: 'render',
value: function render() {
var _props = this.props,
analyticsContext = _props.analyticsContext,
props = (0, _objectWithoutProperties3.default)(_props, ['analyticsContext']);
var data = (0, _extends3.default)({}, defaultData, analyticsContext);
return _react2.default.createElement(
_AnalyticsContext2.default,
{ data: data },
_react2.default.createElement(WrappedComponent, props)
);
}
}]);
return WithAnalyticsContext;
}(_react.Component), _class.displayName = 'WithAnalyticsContext(' + (WrappedComponent.displayName || WrappedComponent.name) + ')', _class.defaultProps = {
analyticsContext: {}
}, _temp;
return WithAnalyticsContext;
};
}

@@ -11,6 +11,2 @@ 'use strict';

var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _extends3 = require('babel-runtime/helpers/extends');

@@ -60,97 +56,93 @@

function withAnalyticsEvents() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// This component is used to grab the analytics functions off context.
// It uses legacy context, but provides an API similar to 16.3 context.
// This makes it easier to use with the forward ref API.
var AnalyticsContextConsumer = function (_Component) {
(0, _inherits3.default)(AnalyticsContextConsumer, _Component);
return function (WrappedComponent) {
var _class, _temp, _initialiseProps;
function AnalyticsContextConsumer() {
var _ref;
return _temp = _class = function (_Component) {
(0, _inherits3.default)(WithAnalyticsEvents, _Component);
var _temp, _this, _ret;
// 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);
(0, _classCallCheck3.default)(this, AnalyticsContextConsumer);
var _this = (0, _possibleConstructorReturn3.default)(this, (WithAnalyticsEvents.__proto__ || (0, _getPrototypeOf2.default)(WithAnalyticsEvents)).call(this, props));
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_initialiseProps.call(_this);
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = AnalyticsContextConsumer.__proto__ || (0, _getPrototypeOf2.default)(AnalyticsContextConsumer)).call.apply(_ref, [this].concat(args))), _this), _this.createAnalyticsEvent = function (payload) {
var _this$context = _this.context,
getAtlaskitAnalyticsEventHandlers = _this$context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext = _this$context.getAtlaskitAnalyticsContext;
(0, _keys2.default)(createEventMap).forEach(function (p) {
_this.originalEventProps[p] = props[p];
});
_this.patchedEventProps = _this.mapCreateEventsToProps((0, _keys2.default)(createEventMap), props);
return _this;
}
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || [];
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || [];
return new _UIAnalyticsEvent2.default({ context: context, handlers: handlers, payload: payload });
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
}
// Update patched event props only if the original props have changed
(0, _createClass3.default)(AnalyticsContextConsumer, [{
key: 'render',
value: function render() {
return this.props.children(this.createAnalyticsEvent);
}
}]);
return AnalyticsContextConsumer;
}(_react.Component);
// patch the callback so it provides analytics information.
(0, _createClass3.default)(WithAnalyticsEvents, [{
key: 'render',
value: function render() {
var patchedEventProps = this.updatePatchedEventProps(this.props);
var props = (0, _extends4.default)({}, this.props, patchedEventProps);
return _react2.default.createElement(WrappedComponent, (0, _extends4.default)({}, props, {
createAnalyticsEvent: this.createAnalyticsEvent
}));
}
}]);
return WithAnalyticsEvents;
}(_react.Component), _class.displayName = 'WithAnalyticsEvents(' + (WrappedComponent.displayName || WrappedComponent.name) + ')', _class.contextTypes = {
getAtlaskitAnalyticsEventHandlers: _propTypes2.default.func,
getAtlaskitAnalyticsContext: _propTypes2.default.func
}, _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.originalEventProps = {};
this.patchedEventProps = {};
AnalyticsContextConsumer.contextTypes = {
getAtlaskitAnalyticsEventHandlers: _propTypes2.default.func,
getAtlaskitAnalyticsContext: _propTypes2.default.func
};
var modifyCallbackProp = function modifyCallbackProp(propName, eventMapEntry, props, createAnalyticsEvent) {
return function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
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];
});
}
var event = typeof eventMapEntry === 'function' ? eventMapEntry(createAnalyticsEvent, props) : createAnalyticsEvent(eventMapEntry);
var providedCallback = props[propName];
if (providedCallback) {
providedCallback.apply(undefined, args.concat([event]));
}
};
};
return _this2.patchedEventProps;
};
// helper that provides an easy way to map an object's values
// ({ string: A }, (string, A) => B) => { string: B }
var vmap = function vmap(obj, fn) {
return (0, _keys2.default)(obj).reduce(function (curr, k) {
return (0, _extends4.default)({}, curr, (0, _defineProperty3.default)({}, k, fn(k, obj[k])));
}, {});
};
this.createAnalyticsEvent = function (payload) {
var _context = _this2.context,
getAtlaskitAnalyticsEventHandlers = _context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext = _context.getAtlaskitAnalyticsContext;
function withAnalyticsEvents() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || [];
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || [];
return new _UIAnalyticsEvent2.default({ context: context, handlers: handlers, payload: payload });
};
return function (WrappedComponent) {
// $FlowFixMe - flow 0.67 doesn't know about forwardRef
var WithAnalyticsEvents = _react2.default.forwardRef(function (props, ref) {
return _react2.default.createElement(
AnalyticsContextConsumer,
null,
function (createAnalyticsEvent) {
var modifiedProps = vmap(createEventMap, function (propName, entry) {
return modifyCallbackProp(propName, entry, props, createAnalyticsEvent);
});
return _react2.default.createElement(WrappedComponent, (0, _extends4.default)({}, props, modifiedProps, {
createAnalyticsEvent: createAnalyticsEvent,
ref: ref
}));
}
);
});
this.mapCreateEventsToProps = function (changedPropNames, props) {
return changedPropNames.reduce(function (modified, propCallbackName) {
var eventCreator = createEventMap[propCallbackName];
var providedCallback = props[propCallbackName];
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : (0, _typeof3.default)(eventCreator))) {
return modified;
}
var modifiedCallback = function modifiedCallback() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
WithAnalyticsEvents.displayName = 'WithAnalyticsEvents(' + (WrappedComponent.displayName || WrappedComponent.name) + ')';
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, props) : _this2.createAnalyticsEvent(eventCreator);
if (providedCallback) {
providedCallback.apply(undefined, args.concat([analyticsEvent]));
}
};
return (0, _extends4.default)({}, modified, (0, _defineProperty3.default)({}, propCallbackName, modifiedCallback));
}, {});
};
}, _temp;
return WithAnalyticsEvents;
};
}
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React, { Component } from 'react';
import React from 'react';

@@ -16,34 +11,20 @@ import AnalyticsContext from './AnalyticsContext';

return function (WrappedComponent) {
var _class, _temp;
// $FlowFixMe - flow 0.67 doesn't know about forwardRef
var WithAnalyticsContext = React.forwardRef(function (props, ref) {
var _props$analyticsConte = props.analyticsContext,
analyticsContext = _props$analyticsConte === undefined ? {} : _props$analyticsConte,
others = _objectWithoutProperties(props, ['analyticsContext']);
return _temp = _class = function (_Component) {
_inherits(WithAnalyticsContext, _Component);
var data = _extends({}, defaultData, analyticsContext);
return React.createElement(
AnalyticsContext,
{ data: data },
React.createElement(WrappedComponent, _extends({}, others, { ref: ref }))
);
});
function WithAnalyticsContext() {
_classCallCheck(this, WithAnalyticsContext);
WithAnalyticsContext.displayName = 'WithAnalyticsContext(' + (WrappedComponent.displayName || WrappedComponent.name) + ')';
return _possibleConstructorReturn(this, (WithAnalyticsContext.__proto__ || _Object$getPrototypeOf(WithAnalyticsContext)).apply(this, arguments));
}
_createClass(WithAnalyticsContext, [{
key: 'render',
value: function render() {
var _props = this.props,
analyticsContext = _props.analyticsContext,
props = _objectWithoutProperties(_props, ['analyticsContext']);
var data = _extends({}, defaultData, analyticsContext);
return React.createElement(
AnalyticsContext,
{ data: data },
React.createElement(WrappedComponent, props)
);
}
}]);
return WithAnalyticsContext;
}(Component), _class.displayName = 'WithAnalyticsContext(' + (WrappedComponent.displayName || WrappedComponent.name) + ')', _class.defaultProps = {
analyticsContext: {}
}, _temp;
return WithAnalyticsContext;
};
}
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _typeof from 'babel-runtime/helpers/typeof';
import _extends from 'babel-runtime/helpers/extends';

@@ -15,99 +14,94 @@ import _Object$keys from 'babel-runtime/core-js/object/keys';

// This component is used to grab the analytics functions off context.
// It uses legacy context, but provides an API similar to 16.3 context.
// This makes it easier to use with the forward ref API.
var AnalyticsContextConsumer = function (_Component) {
_inherits(AnalyticsContextConsumer, _Component);
export default function withAnalyticsEvents() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
function AnalyticsContextConsumer() {
var _ref;
return function (WrappedComponent) {
var _class, _temp, _initialiseProps;
var _temp, _this, _ret;
return _temp = _class = function (_Component) {
_inherits(WithAnalyticsEvents, _Component);
_classCallCheck(this, AnalyticsContextConsumer);
// 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);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = _possibleConstructorReturn(this, (WithAnalyticsEvents.__proto__ || _Object$getPrototypeOf(WithAnalyticsEvents)).call(this, props));
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AnalyticsContextConsumer.__proto__ || _Object$getPrototypeOf(AnalyticsContextConsumer)).call.apply(_ref, [this].concat(args))), _this), _this.createAnalyticsEvent = function (payload) {
var _this$context = _this.context,
getAtlaskitAnalyticsEventHandlers = _this$context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext = _this$context.getAtlaskitAnalyticsContext;
_initialiseProps.call(_this);
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || [];
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || [];
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload });
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_Object$keys(createEventMap).forEach(function (p) {
_this.originalEventProps[p] = props[p];
});
_this.patchedEventProps = _this.mapCreateEventsToProps(_Object$keys(createEventMap), props);
return _this;
}
_createClass(AnalyticsContextConsumer, [{
key: 'render',
value: function render() {
return this.props.children(this.createAnalyticsEvent);
}
}]);
// Update patched event props only if the original props have changed
return AnalyticsContextConsumer;
}(Component);
// patch the callback so it provides analytics information.
_createClass(WithAnalyticsEvents, [{
key: 'render',
value: function render() {
var patchedEventProps = this.updatePatchedEventProps(this.props);
var props = _extends({}, this.props, patchedEventProps);
return React.createElement(WrappedComponent, _extends({}, props, {
createAnalyticsEvent: this.createAnalyticsEvent
}));
}
}]);
return WithAnalyticsEvents;
}(Component), _class.displayName = 'WithAnalyticsEvents(' + (WrappedComponent.displayName || WrappedComponent.name) + ')', _class.contextTypes = {
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func
}, _initialiseProps = function _initialiseProps() {
var _this2 = this;
AnalyticsContextConsumer.contextTypes = {
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func
};
var modifyCallbackProp = function modifyCallbackProp(propName, eventMapEntry, props, createAnalyticsEvent) {
return function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
this.originalEventProps = {};
this.patchedEventProps = {};
var event = typeof eventMapEntry === 'function' ? eventMapEntry(createAnalyticsEvent, props) : createAnalyticsEvent(eventMapEntry);
var providedCallback = props[propName];
if (providedCallback) {
providedCallback.apply(undefined, args.concat([event]));
}
};
};
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];
// helper that provides an easy way to map an object's values
// ({ string: A }, (string, A) => B) => { string: B }
var vmap = function vmap(obj, fn) {
return _Object$keys(obj).reduce(function (curr, k) {
return _extends({}, curr, _defineProperty({}, k, fn(k, obj[k])));
}, {});
};
export default function withAnalyticsEvents() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return function (WrappedComponent) {
// $FlowFixMe - flow 0.67 doesn't know about forwardRef
var WithAnalyticsEvents = React.forwardRef(function (props, ref) {
return React.createElement(
AnalyticsContextConsumer,
null,
function (createAnalyticsEvent) {
var modifiedProps = vmap(createEventMap, function (propName, entry) {
return modifyCallbackProp(propName, entry, props, createAnalyticsEvent);
});
return React.createElement(WrappedComponent, _extends({}, props, modifiedProps, {
createAnalyticsEvent: createAnalyticsEvent,
ref: ref
}));
}
);
});
return _this2.patchedEventProps;
};
WithAnalyticsEvents.displayName = 'WithAnalyticsEvents(' + (WrappedComponent.displayName || WrappedComponent.name) + ')';
this.createAnalyticsEvent = function (payload) {
var _context = _this2.context,
getAtlaskitAnalyticsEventHandlers = _context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext = _context.getAtlaskitAnalyticsContext;
var context = typeof getAtlaskitAnalyticsContext === 'function' && getAtlaskitAnalyticsContext() || [];
var handlers = typeof getAtlaskitAnalyticsEventHandlers === 'function' && getAtlaskitAnalyticsEventHandlers() || [];
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload });
};
this.mapCreateEventsToProps = function (changedPropNames, props) {
return changedPropNames.reduce(function (modified, propCallbackName) {
var eventCreator = createEventMap[propCallbackName];
var providedCallback = props[propCallbackName];
if (!['object', 'function'].includes(typeof eventCreator === 'undefined' ? 'undefined' : _typeof(eventCreator))) {
return modified;
}
var modifiedCallback = function modifiedCallback() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(_this2.createAnalyticsEvent, props) : _this2.createAnalyticsEvent(eventCreator);
if (providedCallback) {
providedCallback.apply(undefined, args.concat([analyticsEvent]));
}
};
return _extends({}, modified, _defineProperty({}, propCallbackName, modifiedCallback));
}, {});
};
}, _temp;
return WithAnalyticsEvents;
};
}
{
"name": "@atlaskit/analytics-next",
"version": "2.1.8",
"version": "2.1.9",
"sideEffects": false
}
{
"name": "@atlaskit/analytics-next",
"version": "2.1.9",
"version": "3.0.0",
"description": "The 🆕 Atlaskit component analytics framework",

@@ -28,8 +28,8 @@ "license": "Apache-2.0",

"peerDependencies": {
"react": "^16.3.0"
"react": "^16.4.0"
},
"devDependencies": {
"@atlaskit/button": "^8.1.1",
"@atlaskit/docs": "^4.1.1",
"@atlaskit/field-text": "^6.0.2",
"@atlaskit/button": "^9.0.0",
"@atlaskit/docs": "^5.0.0",
"@atlaskit/field-text": "^7.0.0",
"enzyme": "https://registry.npmjs.org/@pgleeson/enzyme/-/enzyme-3.3.7.tgz",

@@ -39,2 +39,2 @@ "lodash.isequal": "^4.5.0",

}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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