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

@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 8.1.0 to 8.1.1

6

CHANGELOG.md
# @atlaskit/analytics-next
## 8.1.1
### Patch Changes
- [`d3265f19be`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d3265f19be) - Transpile packages using babel rather than tsc
## 8.1.0

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

29

dist/cjs/components/AnalyticsContext/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var LegacyAnalyticsContext_1 = tslib_1.__importDefault(require("./LegacyAnalyticsContext"));
var ModernAnalyticsContext_1 = tslib_1.__importDefault(require("./ModernAnalyticsContext"));
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _LegacyAnalyticsContext = _interopRequireDefault(require("./LegacyAnalyticsContext"));
var _ModernAnalyticsContext = _interopRequireDefault(require("./ModernAnalyticsContext"));
var ExportedAnalyticsContext;
if (process.env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
ExportedAnalyticsContext = ModernAnalyticsContext_1.default;
ExportedAnalyticsContext = _ModernAnalyticsContext.default;
} else {
ExportedAnalyticsContext = _LegacyAnalyticsContext.default;
}
else {
ExportedAnalyticsContext = LegacyAnalyticsContext_1.default;
}
exports.default = ExportedAnalyticsContext;
//# sourceMappingURL=index.js.map
var _default = ExportedAnalyticsContext;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var analytics_next_stable_react_context_1 = tslib_1.__importDefault(require("@atlaskit/analytics-next-stable-react-context"));
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var ContextTypes = {
getAtlaskitAnalyticsContext: prop_types_1.default.func,
getAtlaskitAnalyticsEventHandlers: prop_types_1.default.func,
getAtlaskitAnalyticsContext: _propTypes.default.func,
getAtlaskitAnalyticsEventHandlers: _propTypes.default.func
};
var noop = function () { return []; };
// eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsContext = /** @class */ (function (_super) {
tslib_1.__extends(AnalyticsContext, _super);
function AnalyticsContext(props) {
var _this = _super.call(this, props) || this;
_this.getChildContext = function () { return ({
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
}); };
_this.getAnalyticsContext = function () {
var data = _this.props.data;
var _a = _this.context.getAtlaskitAnalyticsContext, getAtlaskitAnalyticsContext = _a === void 0 ? noop : _a;
return tslib_1.__spread(getAtlaskitAnalyticsContext(), [data]);
};
_this.getAnalyticsEventHandlers = function () {
var _a = _this.context.getAtlaskitAnalyticsEventHandlers, getAtlaskitAnalyticsEventHandlers = _a === void 0 ? noop : _a;
return getAtlaskitAnalyticsEventHandlers();
};
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
};
return _this;
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsContext = /*#__PURE__*/function (_Component) {
(0, _inherits2.default)(AnalyticsContext, _Component);
var _super = _createSuper(AnalyticsContext);
function AnalyticsContext(props) {
var _this;
(0, _classCallCheck2.default)(this, AnalyticsContext);
_this = _super.call(this, props);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getChildContext", function () {
return {
getAtlaskitAnalyticsContext: _this.getAnalyticsContext
};
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getAnalyticsContext", function () {
var data = _this.props.data;
var _this$context$getAtla = _this.context.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
return [].concat((0, _toConsumableArray2.default)(getAtlaskitAnalyticsContext()), [data]);
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getAnalyticsEventHandlers", function () {
var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsEventHandlers();
});
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
};
return _this;
}
(0, _createClass2.default)(AnalyticsContext, [{
key: "render",
value: function render() {
var children = this.props.children;
return /*#__PURE__*/_react.default.createElement(_analyticsNextStableReactContext.default.Provider, {
value: this.contextValue
}, children);
}
AnalyticsContext.prototype.render = function () {
var children = this.props.children;
return (react_1.default.createElement(analytics_next_stable_react_context_1.default.Provider, { value: this.contextValue }, children));
};
AnalyticsContext.contextTypes = ContextTypes;
AnalyticsContext.childContextTypes = ContextTypes;
return AnalyticsContext;
}(react_1.Component));
exports.default = AnalyticsContext;
//# sourceMappingURL=LegacyAnalyticsContext.js.map
}]);
return AnalyticsContext;
}(_react.Component);
(0, _defineProperty2.default)(AnalyticsContext, "contextTypes", ContextTypes);
(0, _defineProperty2.default)(AnalyticsContext, "childContextTypes", ContextTypes);
var _default = AnalyticsContext;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var analytics_next_stable_react_context_1 = tslib_1.__importDefault(require("@atlaskit/analytics-next-stable-react-context"));
var useAnalyticsContext_1 = require("../../hooks/useAnalyticsContext");
var useTrackedRef_1 = require("../../hooks/useTrackedRef");
var AnalyticsContext = function (_a) {
var data = _a.data, children = _a.children;
var dataRef = useTrackedRef_1.useTrackedRef(data);
var analyticsContext = useAnalyticsContext_1.useAnalyticsContext();
var getAtlaskitAnalyticsContext = react_1.useCallback(function () {
return tslib_1.__spread(analyticsContext.getAtlaskitAnalyticsContext(), [dataRef.current]);
}, [analyticsContext, dataRef]);
var value = react_1.useMemo(function () { return ({
getAtlaskitAnalyticsContext: getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: analyticsContext.getAtlaskitAnalyticsEventHandlers,
}); }, [analyticsContext, getAtlaskitAnalyticsContext]);
return (react_1.default.createElement(analytics_next_stable_react_context_1.default.Provider, { value: value }, children));
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _react = _interopRequireWildcard(require("react"));
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
var _useAnalyticsContext = require("../../hooks/useAnalyticsContext");
var _useTrackedRef = require("../../hooks/useTrackedRef");
var AnalyticsContext = function AnalyticsContext(_ref) {
var data = _ref.data,
children = _ref.children;
var dataRef = (0, _useTrackedRef.useTrackedRef)(data);
var analyticsContext = (0, _useAnalyticsContext.useAnalyticsContext)();
var getAtlaskitAnalyticsContext = (0, _react.useCallback)(function () {
return [].concat((0, _toConsumableArray2.default)(analyticsContext.getAtlaskitAnalyticsContext()), [dataRef.current]);
}, [analyticsContext, dataRef]);
var value = (0, _react.useMemo)(function () {
return {
getAtlaskitAnalyticsContext: getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: analyticsContext.getAtlaskitAnalyticsEventHandlers
};
}, [analyticsContext, getAtlaskitAnalyticsContext]);
return /*#__PURE__*/_react.default.createElement(_analyticsNextStableReactContext.default.Provider, {
value: value
}, children);
};
exports.default = AnalyticsContext;
//# sourceMappingURL=ModernAnalyticsContext.js.map
var _default = AnalyticsContext;
exports.default = _default;

@@ -1,3 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseAnalyticsErrorBoundary = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var withAnalyticsEvents_1 = tslib_1.__importDefault(require("../hocs/withAnalyticsEvents"));
var LegacyAnalyticsContext_1 = tslib_1.__importDefault(require("./AnalyticsContext/LegacyAnalyticsContext"));
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.BaseAnalyticsErrorBoundary = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _withAnalyticsEvents = _interopRequireDefault(require("../hocs/withAnalyticsEvents"));
var _LegacyAnalyticsContext = _interopRequireDefault(require("./AnalyticsContext/LegacyAnalyticsContext"));
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; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
// eslint-disable-next-line @repo/internal/react/no-class-components
var BaseAnalyticsErrorBoundary = /** @class */ (function (_super) {
tslib_1.__extends(BaseAnalyticsErrorBoundary, _super);
function BaseAnalyticsErrorBoundary() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.fireAnalytics = function (analyticsErrorPayload) {
var _a = _this.props, createAnalyticsEvent = _a.createAnalyticsEvent, channel = _a.channel, data = _a.data;
createAnalyticsEvent({
action: 'UnhandledError',
eventType: 'ui',
attributes: tslib_1.__assign(tslib_1.__assign({ browserInfo: window && window.navigator && window.navigator.userAgent
? window.navigator.userAgent
: 'unknown' }, data), analyticsErrorPayload),
}).fire(channel);
};
return _this;
var BaseAnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
(0, _inherits2.default)(BaseAnalyticsErrorBoundary, _Component);
var _super = _createSuper(BaseAnalyticsErrorBoundary);
function BaseAnalyticsErrorBoundary() {
var _this;
(0, _classCallCheck2.default)(this, BaseAnalyticsErrorBoundary);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
BaseAnalyticsErrorBoundary.prototype.componentDidCatch = function (error, info) {
var payload = {
error: error,
info: info,
};
this.fireAnalytics(payload);
};
BaseAnalyticsErrorBoundary.prototype.render = function () {
var _a = this.props, data = _a.data, children = _a.children;
return react_1.default.createElement(LegacyAnalyticsContext_1.default, { data: data }, children);
};
return BaseAnalyticsErrorBoundary;
}(react_1.Component));
_this = _super.call.apply(_super, [this].concat(args));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fireAnalytics", function (analyticsErrorPayload) {
var _this$props = _this.props,
createAnalyticsEvent = _this$props.createAnalyticsEvent,
channel = _this$props.channel,
data = _this$props.data;
createAnalyticsEvent({
action: 'UnhandledError',
eventType: 'ui',
attributes: _objectSpread(_objectSpread({
browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown'
}, data), analyticsErrorPayload)
}).fire(channel);
});
return _this;
}
(0, _createClass2.default)(BaseAnalyticsErrorBoundary, [{
key: "componentDidCatch",
value: function componentDidCatch(error, info) {
var payload = {
error: error,
info: info
};
this.fireAnalytics(payload);
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
data = _this$props2.data,
children = _this$props2.children;
return /*#__PURE__*/_react.default.createElement(_LegacyAnalyticsContext.default, {
data: data
}, children);
}
}]);
return BaseAnalyticsErrorBoundary;
}(_react.Component);
exports.BaseAnalyticsErrorBoundary = BaseAnalyticsErrorBoundary;
var AnalyticsErrorBoundary = withAnalyticsEvents_1.default()(BaseAnalyticsErrorBoundary);
exports.default = AnalyticsErrorBoundary;
//# sourceMappingURL=AnalyticsErrorBoundary.js.map
var AnalyticsErrorBoundary = (0, _withAnalyticsEvents.default)()(BaseAnalyticsErrorBoundary);
var _default = AnalyticsErrorBoundary;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var LegacyAnalyticsListener_1 = tslib_1.__importDefault(require("./LegacyAnalyticsListener"));
var ModernAnalyticsListener_1 = tslib_1.__importDefault(require("./ModernAnalyticsListener"));
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _LegacyAnalyticsListener = _interopRequireDefault(require("./LegacyAnalyticsListener"));
var _ModernAnalyticsListener = _interopRequireDefault(require("./ModernAnalyticsListener"));
var ExportedAnalyticsListener;
if (process.env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
ExportedAnalyticsListener = ModernAnalyticsListener_1.default;
ExportedAnalyticsListener = _ModernAnalyticsListener.default;
} else {
ExportedAnalyticsListener = _LegacyAnalyticsListener.default;
}
else {
ExportedAnalyticsListener = LegacyAnalyticsListener_1.default;
}
exports.default = ExportedAnalyticsListener;
//# sourceMappingURL=index.js.map
var _default = ExportedAnalyticsListener;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var analytics_next_stable_react_context_1 = tslib_1.__importDefault(require("@atlaskit/analytics-next-stable-react-context"));
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var ContextTypes = {
getAtlaskitAnalyticsEventHandlers: prop_types_1.default.func,
getAtlaskitAnalyticsContext: prop_types_1.default.func,
getAtlaskitAnalyticsEventHandlers: _propTypes.default.func,
getAtlaskitAnalyticsContext: _propTypes.default.func
};
var noop = function () { return []; };
// eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsListener = /** @class */ (function (_super) {
tslib_1.__extends(AnalyticsListener, _super);
function AnalyticsListener(props) {
var _this = _super.call(this, props) || this;
_this.getChildContext = function () { return ({
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
}); };
_this.getAnalyticsEventHandlers = function () {
var _a = _this.props, channel = _a.channel, onEvent = _a.onEvent;
var _b = _this.context.getAtlaskitAnalyticsEventHandlers, getAtlaskitAnalyticsEventHandlers = _b === void 0 ? noop : _b;
var handler = function (event, eventChannel) {
if (channel === '*' || channel === eventChannel) {
onEvent(event, eventChannel);
}
};
return tslib_1.__spread([handler], getAtlaskitAnalyticsEventHandlers());
};
_this.getAtlaskitAnalyticsContext = function () {
var _a = _this.context.getAtlaskitAnalyticsContext, getAtlaskitAnalyticsContext = _a === void 0 ? noop : _a;
return getAtlaskitAnalyticsContext();
};
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
};
return _this;
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsListener = /*#__PURE__*/function (_Component) {
(0, _inherits2.default)(AnalyticsListener, _Component);
var _super = _createSuper(AnalyticsListener);
function AnalyticsListener(props) {
var _this;
(0, _classCallCheck2.default)(this, AnalyticsListener);
_this = _super.call(this, props);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getChildContext", function () {
return {
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext
};
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getAnalyticsEventHandlers", function () {
var _this$props = _this.props,
channel = _this$props.channel,
onEvent = _this$props.onEvent;
var _this$context$getAtla = _this.context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
var handler = function handler(event, eventChannel) {
if (channel === '*' || channel === eventChannel) {
onEvent(event, eventChannel);
}
};
return [handler].concat((0, _toConsumableArray2.default)(getAtlaskitAnalyticsEventHandlers()));
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getAtlaskitAnalyticsContext", function () {
var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsContext();
});
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
};
return _this;
}
(0, _createClass2.default)(AnalyticsListener, [{
key: "render",
value: function render() {
var children = this.props.children;
return /*#__PURE__*/_react.default.createElement(_analyticsNextStableReactContext.default.Provider, {
value: this.contextValue
}, children);
}
AnalyticsListener.prototype.render = function () {
var children = this.props.children;
return (react_1.default.createElement(analytics_next_stable_react_context_1.default.Provider, { value: this.contextValue }, children));
};
AnalyticsListener.contextTypes = ContextTypes;
AnalyticsListener.childContextTypes = ContextTypes;
return AnalyticsListener;
}(react_1.Component));
exports.default = AnalyticsListener;
//# sourceMappingURL=LegacyAnalyticsListener.js.map
}]);
return AnalyticsListener;
}(_react.Component);
(0, _defineProperty2.default)(AnalyticsListener, "contextTypes", ContextTypes);
(0, _defineProperty2.default)(AnalyticsListener, "childContextTypes", ContextTypes);
var _default = AnalyticsListener;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var analytics_next_stable_react_context_1 = tslib_1.__importDefault(require("@atlaskit/analytics-next-stable-react-context"));
var useAnalyticsContext_1 = require("../../hooks/useAnalyticsContext");
var useTrackedRef_1 = require("../../hooks/useTrackedRef");
var AnalyticsListener = function (_a) {
var children = _a.children, channel = _a.channel, onEvent = _a.onEvent;
var analyticsContext = useAnalyticsContext_1.useAnalyticsContext();
var onEventRef = useTrackedRef_1.useTrackedRef(onEvent);
var channelRef = useTrackedRef_1.useTrackedRef(channel);
var getAtlaskitAnalyticsEventHandlers = react_1.useCallback(function () {
var thisHandler = function (event, eventChannel) {
if (channelRef.current === '*' || channelRef.current === eventChannel) {
onEventRef.current(event, eventChannel);
}
};
return tslib_1.__spread(analyticsContext.getAtlaskitAnalyticsEventHandlers(), [
thisHandler,
]);
}, [analyticsContext, channelRef, onEventRef]);
var value = react_1.useMemo(function () {
return {
getAtlaskitAnalyticsEventHandlers: getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: analyticsContext.getAtlaskitAnalyticsContext,
};
}, [analyticsContext, getAtlaskitAnalyticsEventHandlers]);
return (react_1.default.createElement(analytics_next_stable_react_context_1.default.Provider, { value: value }, children));
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _react = _interopRequireWildcard(require("react"));
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
var _useAnalyticsContext = require("../../hooks/useAnalyticsContext");
var _useTrackedRef = require("../../hooks/useTrackedRef");
var AnalyticsListener = function AnalyticsListener(_ref) {
var children = _ref.children,
channel = _ref.channel,
onEvent = _ref.onEvent;
var analyticsContext = (0, _useAnalyticsContext.useAnalyticsContext)();
var onEventRef = (0, _useTrackedRef.useTrackedRef)(onEvent);
var channelRef = (0, _useTrackedRef.useTrackedRef)(channel);
var getAtlaskitAnalyticsEventHandlers = (0, _react.useCallback)(function () {
var thisHandler = function thisHandler(event, eventChannel) {
if (channelRef.current === '*' || channelRef.current === eventChannel) {
onEventRef.current(event, eventChannel);
}
};
return [].concat((0, _toConsumableArray2.default)(analyticsContext.getAtlaskitAnalyticsEventHandlers()), [thisHandler]);
}, [analyticsContext, channelRef, onEventRef]);
var value = (0, _react.useMemo)(function () {
return {
getAtlaskitAnalyticsEventHandlers: getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: analyticsContext.getAtlaskitAnalyticsContext
};
}, [analyticsContext, getAtlaskitAnalyticsEventHandlers]);
return /*#__PURE__*/_react.default.createElement(_analyticsNextStableReactContext.default.Provider, {
value: value
}, children);
};
exports.default = AnalyticsListener;
//# sourceMappingURL=ModernAnalyticsListener.js.map
var _default = AnalyticsListener;
exports.default = _default;

@@ -1,3 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var AnalyticsEvent = /** @class */ (function () {
function AnalyticsEvent(props) {
var _this = this;
this.clone = function () {
// just a shallow clone, don't change sub refs unless you want to
// affect the original's too
var payload = tslib_1.__assign({}, _this.payload);
return new AnalyticsEvent({ payload: payload });
};
this.payload = props.payload;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
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 _defineProperty2 = _interopRequireDefault(require("@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) { (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; }
var AnalyticsEvent = /*#__PURE__*/function () {
function AnalyticsEvent(props) {
var _this = this;
(0, _classCallCheck2.default)(this, AnalyticsEvent);
(0, _defineProperty2.default)(this, "clone", function () {
// just a shallow clone, don't change sub refs unless you want to
// affect the original's too
var payload = _objectSpread({}, _this.payload);
return new AnalyticsEvent({
payload: payload
});
});
this.payload = props.payload;
}
(0, _createClass2.default)(AnalyticsEvent, [{
key: "update",
value: function update(updater) {
if (typeof updater === 'function') {
this.payload = updater(this.payload);
}
if ((0, _typeof2.default)(updater) === 'object') {
this.payload = _objectSpread(_objectSpread({}, this.payload), updater);
}
return this;
}
AnalyticsEvent.prototype.update = function (updater) {
if (typeof updater === 'function') {
this.payload = updater(this.payload);
}
if (typeof updater === 'object') {
this.payload = tslib_1.__assign(tslib_1.__assign({}, this.payload), updater);
}
return this;
};
return AnalyticsEvent;
}());
exports.default = AnalyticsEvent;
//# sourceMappingURL=AnalyticsEvent.js.map
}]);
return AnalyticsEvent;
}();
exports.default = AnalyticsEvent;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var AnalyticsEvent_1 = tslib_1.__importDefault(require("./AnalyticsEvent"));
var UIAnalyticsEvent = /** @class */ (function (_super) {
tslib_1.__extends(UIAnalyticsEvent, _super);
function UIAnalyticsEvent(props) {
var _this = _super.call(this, props) || this;
_this.clone = function () {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot clone an event after it's been fired.");
}
return null;
}
var context = tslib_1.__spread(_this.context);
var handlers = tslib_1.__spread(_this.handlers);
/**
* A hacky "deep clone" of the object. This is limited in that it wont
* support functions, regexs, Maps, Sets, etc, but none of those need to
* be represented in our payload.
*/
var payload = JSON.parse(JSON.stringify(_this.payload));
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload });
};
_this.fire = function (channel) {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn('Cannot fire an event twice.');
}
return;
}
_this.handlers.forEach(function (handler) { return handler(_this, channel); });
_this.hasFired = true;
};
_this.context = props.context || [];
_this.handlers = props.handlers || [];
_this.hasFired = false;
return _this;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _AnalyticsEvent2 = _interopRequireDefault(require("./AnalyticsEvent"));
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
var UIAnalyticsEvent = /*#__PURE__*/function (_AnalyticsEvent) {
(0, _inherits2.default)(UIAnalyticsEvent, _AnalyticsEvent);
var _super = _createSuper(UIAnalyticsEvent);
function UIAnalyticsEvent(props) {
var _this;
(0, _classCallCheck2.default)(this, UIAnalyticsEvent);
_this = _super.call(this, props);
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clone", function () {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot clone an event after it's been fired.");
}
return null;
}
var context = (0, _toConsumableArray2.default)(_this.context);
var handlers = (0, _toConsumableArray2.default)(_this.handlers);
/**
* A hacky "deep clone" of the object. This is limited in that it wont
* support functions, regexs, Maps, Sets, etc, but none of those need to
* be represented in our payload.
*/
var payload = JSON.parse(JSON.stringify(_this.payload));
return new UIAnalyticsEvent({
context: context,
handlers: handlers,
payload: payload
});
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fire", function (channel) {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn('Cannot fire an event twice.');
}
return;
}
_this.handlers.forEach(function (handler) {
return handler((0, _assertThisInitialized2.default)(_this), channel);
});
_this.hasFired = true;
});
_this.context = props.context || [];
_this.handlers = props.handlers || [];
_this.hasFired = false;
return _this;
}
(0, _createClass2.default)(UIAnalyticsEvent, [{
key: "update",
value: function update(updater) {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot update an event after it's been fired.");
}
return this;
}
return (0, _get2.default)((0, _getPrototypeOf2.default)(UIAnalyticsEvent.prototype), "update", this).call(this, updater);
}
UIAnalyticsEvent.prototype.update = function (updater) {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot update an event after it's been fired.");
}
return this;
}
return _super.prototype.update.call(this, updater);
};
return UIAnalyticsEvent;
}(AnalyticsEvent_1.default));
exports.default = UIAnalyticsEvent;
//# sourceMappingURL=UIAnalyticsEvent.js.map
}]);
return UIAnalyticsEvent;
}(_AnalyticsEvent2.default);
exports.default = UIAnalyticsEvent;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var AnalyticsContext_1 = tslib_1.__importDefault(require("../components/AnalyticsContext"));
var withAnalyticsContext = function (defaultData) { return function (WrappedComponent) {
var WithAnalyticsContext = react_1.forwardRef(function (_a, ref) {
var analyticsContext = _a.analyticsContext, rest = tslib_1.__rest(_a, ["analyticsContext"]);
var analyticsData = react_1.useMemo(function () { return (tslib_1.__assign(tslib_1.__assign({}, defaultData), analyticsContext)); }, [analyticsContext]);
return (react_1.default.createElement(AnalyticsContext_1.default, { data: analyticsData },
react_1.default.createElement(WrappedComponent, tslib_1.__assign({}, rest, { ref: ref }))));
});
// @ts-ignore
WithAnalyticsContext.displayName = "WithAnalyticsContext(" + (
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name) + ")";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireWildcard(require("react"));
var _AnalyticsContext = _interopRequireDefault(require("../components/AnalyticsContext"));
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; }
var withAnalyticsContext = function withAnalyticsContext(defaultData) {
return function (WrappedComponent) {
var WithAnalyticsContext = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
var analyticsContext = _ref.analyticsContext,
rest = (0, _objectWithoutProperties2.default)(_ref, ["analyticsContext"]);
var analyticsData = (0, _react.useMemo)(function () {
return _objectSpread(_objectSpread({}, defaultData), analyticsContext);
}, [analyticsContext]);
return /*#__PURE__*/_react.default.createElement(_AnalyticsContext.default, {
data: analyticsData
}, /*#__PURE__*/_react.default.createElement(WrappedComponent, (0, _extends2.default)({}, rest, {
ref: ref
})));
}); // @ts-ignore
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat( // @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");
return WithAnalyticsContext;
}; };
exports.default = withAnalyticsContext;
//# sourceMappingURL=withAnalyticsContext.js.map
};
};
var _default = withAnalyticsContext;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var useAnalyticsEvents_1 = require("../hooks/useAnalyticsEvents");
var usePatchedProps_1 = require("../hooks/usePatchedProps");
var withAnalyticsEvents = function (createEventMap) {
if (createEventMap === void 0) { createEventMap = {}; }
return function (WrappedComponent) {
var WithAnalyticsEvents = react_1.forwardRef(function (props, ref) {
var patchedEventProps = usePatchedProps_1.usePatchedProps(createEventMap, props).patchedEventProps;
var createAnalyticsEvent = useAnalyticsEvents_1.useAnalyticsEvents().createAnalyticsEvent;
return (react_1.default.createElement(WrappedComponent, tslib_1.__assign({}, props, patchedEventProps, { createAnalyticsEvent: createAnalyticsEvent, ref: ref })));
});
// @ts-ignore
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(" + (
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name) + ")";
return WithAnalyticsEvents;
};
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _useAnalyticsEvents2 = require("../hooks/useAnalyticsEvents");
var _usePatchedProps2 = require("../hooks/usePatchedProps");
var withAnalyticsEvents = function withAnalyticsEvents() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return function (WrappedComponent) {
var WithAnalyticsEvents = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
var _usePatchedProps = (0, _usePatchedProps2.usePatchedProps)(createEventMap, props),
patchedEventProps = _usePatchedProps.patchedEventProps;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
return /*#__PURE__*/_react.default.createElement(WrappedComponent, (0, _extends2.default)({}, props, patchedEventProps, {
createAnalyticsEvent: createAnalyticsEvent,
ref: ref
}));
}); // @ts-ignore
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat( // @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");
return WithAnalyticsEvents;
};
};
exports.default = withAnalyticsEvents;
//# sourceMappingURL=withAnalyticsEvents.js.map
var _default = withAnalyticsEvents;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useAnalyticsContext = void 0;
var tslib_1 = require("tslib");
var react_1 = require("react");
var analytics_next_stable_react_context_1 = tslib_1.__importDefault(require("@atlaskit/analytics-next-stable-react-context"));
exports.useAnalyticsContext = function () {
return react_1.useContext(analytics_next_stable_react_context_1.default);
var _react = require("react");
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
var useAnalyticsContext = function useAnalyticsContext() {
return (0, _react.useContext)(_analyticsNextStableReactContext.default);
};
//# sourceMappingURL=useAnalyticsContext.js.map
exports.useAnalyticsContext = useAnalyticsContext;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAnalyticsEvents = void 0;
var tslib_1 = require("tslib");
var use_memo_one_1 = require("use-memo-one");
var UIAnalyticsEvent_1 = tslib_1.__importDefault(require("../events/UIAnalyticsEvent"));
var useAnalyticsContext_1 = require("./useAnalyticsContext");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useAnalyticsEvents = useAnalyticsEvents;
var _useMemoOne = require("use-memo-one");
var _UIAnalyticsEvent = _interopRequireDefault(require("../events/UIAnalyticsEvent"));
var _useAnalyticsContext = require("./useAnalyticsContext");
function useAnalyticsEvents() {
var analyticsContext = useAnalyticsContext_1.useAnalyticsContext();
var createAnalyticsEvent = use_memo_one_1.useCallbackOne(function (payload) {
return new UIAnalyticsEvent_1.default({
context: analyticsContext.getAtlaskitAnalyticsContext(),
handlers: analyticsContext.getAtlaskitAnalyticsEventHandlers(),
payload: payload,
});
}, [analyticsContext]);
return {
createAnalyticsEvent: createAnalyticsEvent,
};
}
exports.useAnalyticsEvents = useAnalyticsEvents;
//# sourceMappingURL=useAnalyticsEvents.js.map
var analyticsContext = (0, _useAnalyticsContext.useAnalyticsContext)();
var createAnalyticsEvent = (0, _useMemoOne.useCallbackOne)(function (payload) {
return new _UIAnalyticsEvent.default({
context: analyticsContext.getAtlaskitAnalyticsContext(),
handlers: analyticsContext.getAtlaskitAnalyticsEventHandlers(),
payload: payload
});
}, [analyticsContext]);
return {
createAnalyticsEvent: createAnalyticsEvent
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCallbackWithAnalytics = void 0;
var tslib_1 = require("tslib");
var react_1 = require("react");
var useAnalyticsEvents_1 = require("./useAnalyticsEvents");
var useTrackedRef_1 = require("./useTrackedRef");
exports.useCallbackWithAnalytics = function (method, payload, channel) {
var createAnalyticsEvent = useAnalyticsEvents_1.useAnalyticsEvents().createAnalyticsEvent;
var methodRef = useTrackedRef_1.useTrackedRef(method);
var payloadRef = useTrackedRef_1.useTrackedRef(payload);
return react_1.useCallback(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var pload = typeof payloadRef.current === 'function'
? payloadRef.current.apply(payloadRef, tslib_1.__spread(args)) : payloadRef.current;
createAnalyticsEvent(pload).fire(channel);
methodRef.current.apply(methodRef, tslib_1.__spread(args));
}, [createAnalyticsEvent, methodRef, payloadRef, channel]);
var _react = require("react");
var _useAnalyticsEvents2 = require("./useAnalyticsEvents");
var _useTrackedRef = require("./useTrackedRef");
var useCallbackWithAnalytics = function useCallbackWithAnalytics(method, payload, channel) {
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var methodRef = (0, _useTrackedRef.useTrackedRef)(method);
var payloadRef = (0, _useTrackedRef.useTrackedRef)(payload);
return (0, _react.useCallback)(function () {
var pload = typeof payloadRef.current === 'function' ? payloadRef.current.apply(payloadRef, arguments) : payloadRef.current;
createAnalyticsEvent(pload).fire(channel);
methodRef.current.apply(methodRef, arguments);
}, [createAnalyticsEvent, methodRef, payloadRef, channel]);
};
//# sourceMappingURL=useCallbackWithAnalytics.js.map
exports.useCallbackWithAnalytics = useCallbackWithAnalytics;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePatchedProps = void 0;
var tslib_1 = require("tslib");
var react_1 = require("react");
var useAnalyticsEvents_1 = require("./useAnalyticsEvents");
function usePatchedProps(createEventMap, wrappedComponentProps) {
if (createEventMap === void 0) { createEventMap = {}; }
var createAnalyticsEvent = useAnalyticsEvents_1.useAnalyticsEvents().createAnalyticsEvent;
var patchedProps = react_1.useMemo(function () {
return Object.keys(createEventMap).reduce(function (p, k) {
var _a;
var eventCreator = createEventMap[k];
if (!['object', 'function'].includes(typeof eventCreator)) {
return p;
}
var propValue = wrappedComponentProps[k];
var wrappedCallback = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var analyticsEvent = typeof eventCreator === 'function'
? eventCreator(createAnalyticsEvent, wrappedComponentProps)
: createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {
propValue.apply(void 0, tslib_1.__spread(args, [analyticsEvent]));
}
};
return wrappedCallback ? tslib_1.__assign(tslib_1.__assign({}, p), (_a = {}, _a[k] = wrappedCallback, _a)) : p;
}, {});
}, [createEventMap, wrappedComponentProps, createAnalyticsEvent]);
return {
patchedEventProps: patchedProps,
};
}
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.usePatchedProps = usePatchedProps;
//# sourceMappingURL=usePatchedProps.js.map
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _react = require("react");
var _useAnalyticsEvents2 = require("./useAnalyticsEvents");
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; }
function usePatchedProps() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var wrappedComponentProps = arguments.length > 1 ? arguments[1] : undefined;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var patchedProps = (0, _react.useMemo)(function () {
return Object.keys(createEventMap).reduce(function (p, k) {
var eventCreator = createEventMap[k];
if (!['object', 'function'].includes((0, _typeof2.default)(eventCreator))) {
return p;
}
var propValue = wrappedComponentProps[k];
var wrappedCallback = function wrappedCallback() {
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
propValue.apply(void 0, args.concat([analyticsEvent]));
}
};
return wrappedCallback ? _objectSpread(_objectSpread({}, p), {}, (0, _defineProperty2.default)({}, k, wrappedCallback)) : p;
}, {});
}, [createEventMap, wrappedComponentProps, createAnalyticsEvent]);
return {
patchedEventProps: patchedProps
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePlatformLeafEventHandler = void 0;
var tslib_1 = require("tslib");
var react_1 = require("react");
var useAnalyticsEvents_1 = require("./useAnalyticsEvents");
var useTrackedRef_1 = require("./useTrackedRef");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.usePlatformLeafEventHandler = usePlatformLeafEventHandler;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("react");
var _useAnalyticsEvents2 = require("./useAnalyticsEvents");
var _useTrackedRef = require("./useTrackedRef");
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; }
// WARNING: This hook will only function correctly for leaf node components - as in

@@ -14,49 +28,52 @@ // no children inside the component will require analytics themselves.

// or AnalyticsContext component instead.
function usePlatformLeafEventHandler(_a) {
var fn = _a.fn, action = _a.action, componentName = _a.componentName, packageName = _a.packageName, packageVersion = _a.packageVersion, analyticsData = _a.analyticsData;
var createAnalyticsEvent = useAnalyticsEvents_1.useAnalyticsEvents().createAnalyticsEvent;
// We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = useTrackedRef_1.useTrackedRef(analyticsData);
var fnRef = useTrackedRef_1.useTrackedRef(fn);
var handler = react_1.useCallback(function (value) {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion,
},
});
// To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = tslib_1.__assign({ componentName: componentName,
packageName: packageName,
packageVersion: packageVersion }, dataRef.current);
analyticsEvent.context.push(context);
// fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(value, analyticsEvent);
}, [
// These are strings and won't change
action,
componentName,
packageName,
packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef,
fnRef,
]);
return handler;
}
exports.usePlatformLeafEventHandler = usePlatformLeafEventHandler;
//# sourceMappingURL=usePlatformLeafEventHandler.js.map
function usePlatformLeafEventHandler(_ref) {
var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = (0, _useTrackedRef.useTrackedRef)(analyticsData);
var fnRef = (0, _useTrackedRef.useTrackedRef)(fn);
var handler = (0, _react.useCallback)(function (value) {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}
}); // To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = _objectSpread({
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}, dataRef.current);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(value, analyticsEvent);
}, [// These are strings and won't change
action, componentName, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePlatformLeafSyntheticEventHandler = void 0;
var tslib_1 = require("tslib");
var react_1 = require("react");
var useAnalyticsEvents_1 = require("./useAnalyticsEvents");
var useTrackedRef_1 = require("./useTrackedRef");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.usePlatformLeafSyntheticEventHandler = usePlatformLeafSyntheticEventHandler;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("react");
var _useAnalyticsEvents2 = require("./useAnalyticsEvents");
var _useTrackedRef = require("./useTrackedRef");
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; }
// WARNING: This hook will only function correctly for leaf node components - as in

@@ -14,49 +28,52 @@ // no children inside the component will require analytics themselves.

// or AnalyticsContext component instead.
function usePlatformLeafSyntheticEventHandler(_a) {
var fn = _a.fn, action = _a.action, componentName = _a.componentName, packageName = _a.packageName, packageVersion = _a.packageVersion, analyticsData = _a.analyticsData;
var createAnalyticsEvent = useAnalyticsEvents_1.useAnalyticsEvents().createAnalyticsEvent;
// We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = useTrackedRef_1.useTrackedRef(analyticsData);
var fnRef = useTrackedRef_1.useTrackedRef(fn);
var handler = react_1.useCallback(function () {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion,
},
});
// To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = tslib_1.__assign({ componentName: componentName,
packageName: packageName,
packageVersion: packageVersion }, dataRef.current);
analyticsEvent.context.push(context);
// fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(analyticsEvent);
}, [
// These are strings and won't change
action,
componentName,
packageName,
packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef,
fnRef,
]);
return handler;
}
exports.usePlatformLeafSyntheticEventHandler = usePlatformLeafSyntheticEventHandler;
//# sourceMappingURL=usePlatformLeafSyntheticEventHandler.js.map
function usePlatformLeafSyntheticEventHandler(_ref) {
var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = (0, _useTrackedRef.useTrackedRef)(analyticsData);
var fnRef = (0, _useTrackedRef.useTrackedRef)(fn);
var handler = (0, _react.useCallback)(function () {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}
}); // To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = _objectSpread({
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}, dataRef.current);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(analyticsEvent);
}, [// These are strings and won't change
action, componentName, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useTrackedRef = void 0;
var react_1 = require("react");
exports.useTrackedRef = function (value) {
var ref = react_1.useRef(value);
react_1.useEffect(function () {
ref.current = value;
}, [value]);
return ref;
var _react = require("react");
var useTrackedRef = function useTrackedRef(value) {
var ref = (0, _react.useRef)(value);
(0, _react.useEffect)(function () {
ref.current = value;
}, [value]);
return ref;
};
//# sourceMappingURL=useTrackedRef.js.map
exports.useTrackedRef = useTrackedRef;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Analytics event classes
var AnalyticsEvent_1 = require("./events/AnalyticsEvent");
Object.defineProperty(exports, "AnalyticsEvent", { enumerable: true, get: function () { return AnalyticsEvent_1.default; } });
var UIAnalyticsEvent_1 = require("./events/UIAnalyticsEvent");
Object.defineProperty(exports, "UIAnalyticsEvent", { enumerable: true, get: function () { return UIAnalyticsEvent_1.default; } });
// AnalyticsListener component
var index_1 = require("./components/AnalyticsListener/index");
Object.defineProperty(exports, "AnalyticsListener", { enumerable: true, get: function () { return index_1.default; } });
// AnalyticsContext component and HOC
var index_2 = require("./components/AnalyticsContext/index");
Object.defineProperty(exports, "AnalyticsContext", { enumerable: true, get: function () { return index_2.default; } });
var withAnalyticsContext_1 = require("./hocs/withAnalyticsContext");
Object.defineProperty(exports, "withAnalyticsContext", { enumerable: true, get: function () { return withAnalyticsContext_1.default; } });
// AnalyticsErrorBoundary component
var AnalyticsErrorBoundary_1 = require("./components/AnalyticsErrorBoundary");
Object.defineProperty(exports, "AnalyticsErrorBoundary", { enumerable: true, get: function () { return AnalyticsErrorBoundary_1.default; } });
// createAnalyticsEvent HOC
var withAnalyticsEvents_1 = require("./hocs/withAnalyticsEvents");
Object.defineProperty(exports, "withAnalyticsEvents", { enumerable: true, get: function () { return withAnalyticsEvents_1.default; } });
// React context
var analytics_next_stable_react_context_1 = require("@atlaskit/analytics-next-stable-react-context");
Object.defineProperty(exports, "AnalyticsReactContext", { enumerable: true, get: function () { return analytics_next_stable_react_context_1.default; } });
// Hook for creating and firing analytics events
var useAnalyticsEvents_1 = require("./hooks/useAnalyticsEvents");
Object.defineProperty(exports, "useAnalyticsEvents", { enumerable: true, get: function () { return useAnalyticsEvents_1.useAnalyticsEvents; } });
var useCallbackWithAnalytics_1 = require("./hooks/useCallbackWithAnalytics");
Object.defineProperty(exports, "useCallbackWithAnalytics", { enumerable: true, get: function () { return useCallbackWithAnalytics_1.useCallbackWithAnalytics; } });
var usePlatformLeafEventHandler_1 = require("./hooks/usePlatformLeafEventHandler");
Object.defineProperty(exports, "usePlatformLeafEventHandler", { enumerable: true, get: function () { return usePlatformLeafEventHandler_1.usePlatformLeafEventHandler; } });
var usePlatformLeafSyntheticEventHandler_1 = require("./hooks/usePlatformLeafSyntheticEventHandler");
Object.defineProperty(exports, "usePlatformLeafSyntheticEventHandler", { enumerable: true, get: function () { return usePlatformLeafSyntheticEventHandler_1.usePlatformLeafSyntheticEventHandler; } });
// Helper functions
var createAndFireEvent_1 = require("./utils/createAndFireEvent");
Object.defineProperty(exports, "createAndFireEvent", { enumerable: true, get: function () { return createAndFireEvent_1.default; } });
var cleanProps_1 = require("./utils/cleanProps");
Object.defineProperty(exports, "cleanProps", { enumerable: true, get: function () { return cleanProps_1.default; } });
//# sourceMappingURL=index.js.map
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "AnalyticsEvent", {
enumerable: true,
get: function get() {
return _AnalyticsEvent.default;
}
});
Object.defineProperty(exports, "UIAnalyticsEvent", {
enumerable: true,
get: function get() {
return _UIAnalyticsEvent.default;
}
});
Object.defineProperty(exports, "AnalyticsListener", {
enumerable: true,
get: function get() {
return _index.default;
}
});
Object.defineProperty(exports, "AnalyticsContext", {
enumerable: true,
get: function get() {
return _index2.default;
}
});
Object.defineProperty(exports, "withAnalyticsContext", {
enumerable: true,
get: function get() {
return _withAnalyticsContext.default;
}
});
Object.defineProperty(exports, "AnalyticsErrorBoundary", {
enumerable: true,
get: function get() {
return _AnalyticsErrorBoundary.default;
}
});
Object.defineProperty(exports, "withAnalyticsEvents", {
enumerable: true,
get: function get() {
return _withAnalyticsEvents.default;
}
});
Object.defineProperty(exports, "AnalyticsReactContext", {
enumerable: true,
get: function get() {
return _analyticsNextStableReactContext.default;
}
});
Object.defineProperty(exports, "useAnalyticsEvents", {
enumerable: true,
get: function get() {
return _useAnalyticsEvents.useAnalyticsEvents;
}
});
Object.defineProperty(exports, "useCallbackWithAnalytics", {
enumerable: true,
get: function get() {
return _useCallbackWithAnalytics.useCallbackWithAnalytics;
}
});
Object.defineProperty(exports, "usePlatformLeafEventHandler", {
enumerable: true,
get: function get() {
return _usePlatformLeafEventHandler.usePlatformLeafEventHandler;
}
});
Object.defineProperty(exports, "usePlatformLeafSyntheticEventHandler", {
enumerable: true,
get: function get() {
return _usePlatformLeafSyntheticEventHandler.usePlatformLeafSyntheticEventHandler;
}
});
Object.defineProperty(exports, "createAndFireEvent", {
enumerable: true,
get: function get() {
return _createAndFireEvent.default;
}
});
Object.defineProperty(exports, "cleanProps", {
enumerable: true,
get: function get() {
return _cleanProps.default;
}
});
var _AnalyticsEvent = _interopRequireDefault(require("./events/AnalyticsEvent"));
var _UIAnalyticsEvent = _interopRequireDefault(require("./events/UIAnalyticsEvent"));
var _index = _interopRequireDefault(require("./components/AnalyticsListener/index"));
var _index2 = _interopRequireDefault(require("./components/AnalyticsContext/index"));
var _withAnalyticsContext = _interopRequireDefault(require("./hocs/withAnalyticsContext"));
var _AnalyticsErrorBoundary = _interopRequireDefault(require("./components/AnalyticsErrorBoundary"));
var _withAnalyticsEvents = _interopRequireDefault(require("./hocs/withAnalyticsEvents"));
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
var _useAnalyticsEvents = require("./hooks/useAnalyticsEvents");
var _useCallbackWithAnalytics = require("./hooks/useCallbackWithAnalytics");
var _usePlatformLeafEventHandler = require("./hooks/usePlatformLeafEventHandler");
var _usePlatformLeafSyntheticEventHandler = require("./hooks/usePlatformLeafSyntheticEventHandler");
var _createAndFireEvent = _interopRequireDefault(require("./utils/createAndFireEvent"));
var _cleanProps = _interopRequireDefault(require("./utils/cleanProps"));
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HOCSTest = exports.UseCallbackWithAnalyticsHookTest = exports.UseAnalyticsEventHookTest = exports.UsePlatformLeafEventHandlerHookTest = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var react_2 = require("@testing-library/react");
var AnalyticsListener_1 = tslib_1.__importDefault(require("../components/AnalyticsListener"));
var withAnalyticsContext_1 = tslib_1.__importDefault(require("../hocs/withAnalyticsContext"));
var withAnalyticsEvents_1 = tslib_1.__importDefault(require("../hocs/withAnalyticsEvents"));
var useAnalyticsEvents_1 = require("../hooks/useAnalyticsEvents");
var useCallbackWithAnalytics_1 = require("../hooks/useCallbackWithAnalytics");
var usePlatformLeafEventHandler_1 = require("../hooks/usePlatformLeafEventHandler");
var createAndFireEvent_1 = tslib_1.__importDefault(require("../utils/createAndFireEvent"));
var ButtonWithUsePlatformLeafEventHandlerHook = function (_a) {
var providedOnClick = _a.onClick;
var onClick = usePlatformLeafEventHandler_1.usePlatformLeafEventHandler({
fn: providedOnClick,
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@testing-library/react");
var _AnalyticsListener = _interopRequireDefault(require("../components/AnalyticsListener"));
var _withAnalyticsContext = _interopRequireDefault(require("../hocs/withAnalyticsContext"));
var _withAnalyticsEvents = _interopRequireDefault(require("../hocs/withAnalyticsEvents"));
var _useAnalyticsEvents2 = require("../hooks/useAnalyticsEvents");
var _useCallbackWithAnalytics = require("../hooks/useCallbackWithAnalytics");
var _usePlatformLeafEventHandler = require("../hooks/usePlatformLeafEventHandler");
var _createAndFireEvent = _interopRequireDefault(require("../utils/createAndFireEvent"));
var ButtonWithUsePlatformLeafEventHandlerHook = function ButtonWithUsePlatformLeafEventHandlerHook(_ref) {
var providedOnClick = _ref.onClick;
var onClick = (0, _usePlatformLeafEventHandler.usePlatformLeafEventHandler)({
fn: providedOnClick,
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
action: 'clicked',
analyticsData: {
additionalData: true
}
});
return /*#__PURE__*/_react.default.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
};
var ButtonWithUseAnalyticsEventHook = (0, _withAnalyticsContext.default)({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(function (_ref2) {
var providedOnClick = _ref2.onClick;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var onClick = (0, _react.useCallback)(function (mouseEvt) {
var analyticsEvent = createAnalyticsEvent({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
action: 'clicked',
analyticsData: {
additionalData: true,
},
packageVersion: '0.1.0'
}
});
return (react_1.default.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
};
var ButtonWithUseAnalyticsEventHook = withAnalyticsContext_1.default({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(function (_a) {
var providedOnClick = _a.onClick;
var createAnalyticsEvent = useAnalyticsEvents_1.useAnalyticsEvents().createAnalyticsEvent;
var onClick = react_1.useCallback(function (mouseEvt) {
var analyticsEvent = createAnalyticsEvent({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
});
analyticsEvent.fire('atlaskit');
providedOnClick(mouseEvt);
}, [providedOnClick, createAnalyticsEvent]);
return (react_1.default.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
analyticsEvent.fire('atlaskit');
providedOnClick(mouseEvt);
}, [providedOnClick, createAnalyticsEvent]);
return /*#__PURE__*/_react.default.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
});
var ButtonWithUseCallbackWithAnalyticsHook = withAnalyticsContext_1.default({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(function (_a) {
var providedOnClick = _a.onClick;
var onClick = useCallbackWithAnalytics_1.useCallbackWithAnalytics(providedOnClick, {
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
}, 'atlaskit');
return (react_1.default.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
var ButtonWithUseCallbackWithAnalyticsHook = (0, _withAnalyticsContext.default)({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(function (_ref3) {
var providedOnClick = _ref3.onClick;
var onClick = (0, _useCallbackWithAnalytics.useCallbackWithAnalytics)(providedOnClick, {
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0'
}
}, 'atlaskit');
return /*#__PURE__*/_react.default.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
});
var ButtonWithHOCs = withAnalyticsContext_1.default({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(withAnalyticsEvents_1.default({
onClick: createAndFireEvent_1.default('atlaskit')({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
}),
})(function (_a) {
var onClick = _a.onClick;
return (react_1.default.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
var ButtonWithHOCs = (0, _withAnalyticsContext.default)({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})((0, _withAnalyticsEvents.default)({
onClick: (0, _createAndFireEvent.default)('atlaskit')({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0'
}
})
})(function (_ref4) {
var onClick = _ref4.onClick;
return /*#__PURE__*/_react.default.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
}));
var createEventHandler = function () {
var done = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
};
var promise;
var onEvent = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
done(args);
};
var create = function () {
promise = new Promise(function (resolve) {
done = resolve;
});
};
var getPromise = function () { return promise; };
return { onEvent: onEvent, create: create, getPromise: getPromise };
var createEventHandler = function createEventHandler() {
var done = function done() {};
var promise;
var onEvent = function onEvent() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
done(args);
};
var create = function create() {
promise = new Promise(function (resolve) {
done = resolve;
});
};
var getPromise = function getPromise() {
return promise;
};
return {
onEvent: onEvent,
create: create,
getPromise: getPromise
};
};
var eventHandler = createEventHandler();
var WithListener = function (Component) { return function () {
var WithListener = function WithListener(Component) {
return function () {
eventHandler.create();
var onEvent = eventHandler.onEvent;
var onClick = function () { };
return (react_1.default.createElement(AnalyticsListener_1.default, { channel: "atlaskit", onEvent: onEvent },
react_1.default.createElement(Component, { onClick: onClick })));
}; };
var interactionTasks = [
{
name: 'Dispatch event',
description: 'Recording how long it takes to fire and receive an event on the listener',
run: function (_a) {
var container = _a.container;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var button;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
button = container.querySelector('button');
if (button == null) {
throw new Error('Could not find button element');
}
react_2.fireEvent.click(button);
return [4 /*yield*/, eventHandler.getPromise()];
case 1:
_b.sent();
return [2 /*return*/];
}
});
});
},
},
];
exports.UsePlatformLeafEventHandlerHookTest = WithListener(ButtonWithUsePlatformLeafEventHandlerHook);
exports.UseAnalyticsEventHookTest = WithListener(ButtonWithUseAnalyticsEventHook);
exports.UseCallbackWithAnalyticsHookTest = WithListener(ButtonWithUseCallbackWithAnalyticsHook);
exports.HOCSTest = WithListener(ButtonWithHOCs);
exports.UsePlatformLeafEventHandlerHookTest.story = {
name: 'usePlatformLeafEventHandler based component',
component: exports.UsePlatformLeafEventHandlerHookTest,
parameters: {
performance: {
interactions: interactionTasks,
},
},
var onClick = function onClick() {};
return /*#__PURE__*/_react.default.createElement(_AnalyticsListener.default, {
channel: "atlaskit",
onEvent: onEvent
}, /*#__PURE__*/_react.default.createElement(Component, {
onClick: onClick
}));
};
};
exports.UseAnalyticsEventHookTest.story = {
name: 'useAnalyticsEvent based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
var interactionTasks = [{
name: 'Dispatch event',
description: 'Recording how long it takes to fire and receive an event on the listener',
run: function () {
var _run = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref5) {
var container, button;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
container = _ref5.container;
button = container.querySelector('button');
if (!(button == null)) {
_context.next = 4;
break;
}
throw new Error('Could not find button element');
case 4:
_react2.fireEvent.click(button);
_context.next = 7;
return eventHandler.getPromise();
case 7:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function run(_x) {
return _run.apply(this, arguments);
}
return run;
}()
}];
var UsePlatformLeafEventHandlerHookTest = WithListener(ButtonWithUsePlatformLeafEventHandlerHook);
exports.UsePlatformLeafEventHandlerHookTest = UsePlatformLeafEventHandlerHookTest;
var UseAnalyticsEventHookTest = WithListener(ButtonWithUseAnalyticsEventHook);
exports.UseAnalyticsEventHookTest = UseAnalyticsEventHookTest;
var UseCallbackWithAnalyticsHookTest = WithListener(ButtonWithUseCallbackWithAnalyticsHook);
exports.UseCallbackWithAnalyticsHookTest = UseCallbackWithAnalyticsHookTest;
var HOCSTest = WithListener(ButtonWithHOCs);
exports.HOCSTest = HOCSTest;
UsePlatformLeafEventHandlerHookTest.story = {
name: 'usePlatformLeafEventHandler based component',
component: UsePlatformLeafEventHandlerHookTest,
parameters: {
performance: {
interactions: interactionTasks
}
}
};
exports.UseCallbackWithAnalyticsHookTest.story = {
name: 'useCallbackWithAnalytics based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
UseAnalyticsEventHookTest.story = {
name: 'useAnalyticsEvent based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
exports.HOCSTest.story = {
name: 'HOC based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
UseCallbackWithAnalyticsHookTest.story = {
name: 'useCallbackWithAnalytics based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
//# sourceMappingURL=examples.js.map
HOCSTest.story = {
name: 'HOC based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useRenderCounter = void 0;
var react_1 = require("react");
var _react = require("react");
// Hook to track the number of renders in tests
exports.useRenderCounter = function () {
var ref = react_1.useRef(1);
react_1.useEffect(function () {
ref.current++;
});
return ref.current;
var useRenderCounter = function useRenderCounter() {
var ref = (0, _react.useRef)(1);
(0, _react.useEffect)(function () {
ref.current++;
});
return ref.current;
};
//# sourceMappingURL=useRenderCounter.js.map
exports.useRenderCounter = useRenderCounter;

@@ -1,3 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cleanProps;
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
function cleanProps(props) {
var createAnalyticsEvent = props.createAnalyticsEvent, cleanedProps = tslib_1.__rest(props, ["createAnalyticsEvent"]);
return cleanedProps;
}
exports.default = cleanProps;
//# sourceMappingURL=cleanProps.js.map
var createAnalyticsEvent = props.createAnalyticsEvent,
cleanedProps = (0, _objectWithoutProperties2.default)(props, ["createAnalyticsEvent"]);
return cleanedProps;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (function (channel) { return function (payload) { return function (createAnalyticsEvent) {
var consumerEvent = createAnalyticsEvent(payload);
var clonedEvent = consumerEvent.clone();
if (clonedEvent) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = function _default(channel) {
return function (payload) {
return function (createAnalyticsEvent) {
var consumerEvent = createAnalyticsEvent(payload);
var clonedEvent = consumerEvent.clone();
if (clonedEvent) {
clonedEvent.fire(channel);
}
return consumerEvent;
}; }; });
//# sourceMappingURL=createAndFireEvent.js.map
}
return consumerEvent;
};
};
};
exports.default = _default;
{
"name": "@atlaskit/analytics-next",
"version": "8.1.0",
"version": "8.1.1",
"sideEffects": false
}
import LegacyAnalyticsContext from './LegacyAnalyticsContext';
import ModernAnalyticsContext from './ModernAnalyticsContext';
let ExportedAnalyticsContext;
if (process.env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
ExportedAnalyticsContext = ModernAnalyticsContext;
ExportedAnalyticsContext = ModernAnalyticsContext;
} else {
ExportedAnalyticsContext = LegacyAnalyticsContext;
}
else {
ExportedAnalyticsContext = LegacyAnalyticsContext;
}
export default ExportedAnalyticsContext;
//# sourceMappingURL=index.js.map
export default ExportedAnalyticsContext;

@@ -0,38 +1,59 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { default as AnalyticsReactContext, } from '@atlaskit/analytics-next-stable-react-context';
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
const ContextTypes = {
getAtlaskitAnalyticsContext: PropTypes.func,
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func,
getAtlaskitAnalyticsEventHandlers: PropTypes.func
};
const noop = () => [];
// eslint-disable-next-line @repo/internal/react/no-class-components
const noop = () => []; // eslint-disable-next-line @repo/internal/react/no-class-components
class AnalyticsContext extends Component {
constructor(props) {
super(props);
this.getChildContext = () => ({
getAtlaskitAnalyticsContext: this.getAnalyticsContext,
});
this.getAnalyticsContext = () => {
const { data } = this.props;
const { getAtlaskitAnalyticsContext = noop } = this.context;
return [...getAtlaskitAnalyticsContext(), data];
};
this.getAnalyticsEventHandlers = () => {
const { getAtlaskitAnalyticsEventHandlers = noop } = this.context;
return getAtlaskitAnalyticsEventHandlers();
};
this.contextValue = {
getAtlaskitAnalyticsContext: this.getAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,
};
}
render() {
const { children } = this.props;
return (React.createElement(AnalyticsReactContext.Provider, { value: this.contextValue }, children));
}
constructor(props) {
super(props);
_defineProperty(this, "getChildContext", () => ({
getAtlaskitAnalyticsContext: this.getAnalyticsContext
}));
_defineProperty(this, "getAnalyticsContext", () => {
const {
data
} = this.props;
const {
getAtlaskitAnalyticsContext = noop
} = this.context;
return [...getAtlaskitAnalyticsContext(), data];
});
_defineProperty(this, "getAnalyticsEventHandlers", () => {
const {
getAtlaskitAnalyticsEventHandlers = noop
} = this.context;
return getAtlaskitAnalyticsEventHandlers();
});
this.contextValue = {
getAtlaskitAnalyticsContext: this.getAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers
};
}
render() {
const {
children
} = this.props;
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: this.contextValue
}, children);
}
}
AnalyticsContext.contextTypes = ContextTypes;
AnalyticsContext.childContextTypes = ContextTypes;
export default AnalyticsContext;
//# sourceMappingURL=LegacyAnalyticsContext.js.map
_defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
_defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
export default AnalyticsContext;

@@ -5,15 +5,21 @@ import React, { useCallback, useMemo } from 'react';

import { useTrackedRef } from '../../hooks/useTrackedRef';
const AnalyticsContext = ({ data, children }) => {
const dataRef = useTrackedRef(data);
const analyticsContext = useAnalyticsContext();
const getAtlaskitAnalyticsContext = useCallback(() => {
return [...analyticsContext.getAtlaskitAnalyticsContext(), dataRef.current];
}, [analyticsContext, dataRef]);
const value = useMemo(() => ({
getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: analyticsContext.getAtlaskitAnalyticsEventHandlers,
}), [analyticsContext, getAtlaskitAnalyticsContext]);
return (React.createElement(AnalyticsReactContext.Provider, { value: value }, children));
const AnalyticsContext = ({
data,
children
}) => {
const dataRef = useTrackedRef(data);
const analyticsContext = useAnalyticsContext();
const getAtlaskitAnalyticsContext = useCallback(() => {
return [...analyticsContext.getAtlaskitAnalyticsContext(), dataRef.current];
}, [analyticsContext, dataRef]);
const value = useMemo(() => ({
getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: analyticsContext.getAtlaskitAnalyticsEventHandlers
}), [analyticsContext, getAtlaskitAnalyticsContext]);
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: value
}, children);
};
export default AnalyticsContext;
//# sourceMappingURL=ModernAnalyticsContext.js.map
export default AnalyticsContext;

@@ -0,1 +1,2 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';

@@ -6,33 +7,43 @@ import withAnalyticsEvents from '../hocs/withAnalyticsEvents';

export class BaseAnalyticsErrorBoundary extends Component {
constructor() {
super(...arguments);
this.fireAnalytics = (analyticsErrorPayload) => {
const { createAnalyticsEvent, channel, data } = this.props;
createAnalyticsEvent({
action: 'UnhandledError',
eventType: 'ui',
attributes: {
browserInfo: window && window.navigator && window.navigator.userAgent
? window.navigator.userAgent
: 'unknown',
...data,
...analyticsErrorPayload,
},
}).fire(channel);
};
}
componentDidCatch(error, info) {
const payload = {
error,
info,
};
this.fireAnalytics(payload);
}
render() {
const { data, children } = this.props;
return React.createElement(AnalyticsContext, { data: data }, children);
}
constructor(...args) {
super(...args);
_defineProperty(this, "fireAnalytics", analyticsErrorPayload => {
const {
createAnalyticsEvent,
channel,
data
} = this.props;
createAnalyticsEvent({
action: 'UnhandledError',
eventType: 'ui',
attributes: {
browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown',
...data,
...analyticsErrorPayload
}
}).fire(channel);
});
}
componentDidCatch(error, info) {
const payload = {
error,
info
};
this.fireAnalytics(payload);
}
render() {
const {
data,
children
} = this.props;
return /*#__PURE__*/React.createElement(AnalyticsContext, {
data: data
}, children);
}
}
const AnalyticsErrorBoundary = withAnalyticsEvents()(BaseAnalyticsErrorBoundary);
export default AnalyticsErrorBoundary;
//# sourceMappingURL=AnalyticsErrorBoundary.js.map
export default AnalyticsErrorBoundary;
import LegacyAnalyticsListener from './LegacyAnalyticsListener';
import ModernAnalyticsListener from './ModernAnalyticsListener';
let ExportedAnalyticsListener;
if (process.env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
ExportedAnalyticsListener = ModernAnalyticsListener;
ExportedAnalyticsListener = ModernAnalyticsListener;
} else {
ExportedAnalyticsListener = LegacyAnalyticsListener;
}
else {
ExportedAnalyticsListener = LegacyAnalyticsListener;
}
export default ExportedAnalyticsListener;
//# sourceMappingURL=index.js.map
export default ExportedAnalyticsListener;

@@ -0,44 +1,68 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { default as AnalyticsReactContext, } from '@atlaskit/analytics-next-stable-react-context';
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
const ContextTypes = {
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func,
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func
};
const noop = () => [];
// eslint-disable-next-line @repo/internal/react/no-class-components
const noop = () => []; // eslint-disable-next-line @repo/internal/react/no-class-components
class AnalyticsListener extends Component {
constructor(props) {
super(props);
this.getChildContext = () => ({
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext,
});
this.getAnalyticsEventHandlers = () => {
const { channel, onEvent } = this.props;
const { getAtlaskitAnalyticsEventHandlers = noop } = this.context;
const handler = (event, eventChannel) => {
if (channel === '*' || channel === eventChannel) {
onEvent(event, eventChannel);
}
};
return [handler, ...getAtlaskitAnalyticsEventHandlers()];
};
this.getAtlaskitAnalyticsContext = () => {
const { getAtlaskitAnalyticsContext = noop } = this.context;
return getAtlaskitAnalyticsContext();
};
this.contextValue = {
getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,
};
}
render() {
const { children } = this.props;
return (React.createElement(AnalyticsReactContext.Provider, { value: this.contextValue }, children));
}
constructor(props) {
super(props);
_defineProperty(this, "getChildContext", () => ({
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext
}));
_defineProperty(this, "getAnalyticsEventHandlers", () => {
const {
channel,
onEvent
} = this.props;
const {
getAtlaskitAnalyticsEventHandlers = noop
} = this.context;
const handler = (event, eventChannel) => {
if (channel === '*' || channel === eventChannel) {
onEvent(event, eventChannel);
}
};
return [handler, ...getAtlaskitAnalyticsEventHandlers()];
});
_defineProperty(this, "getAtlaskitAnalyticsContext", () => {
const {
getAtlaskitAnalyticsContext = noop
} = this.context;
return getAtlaskitAnalyticsContext();
});
this.contextValue = {
getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers
};
}
render() {
const {
children
} = this.props;
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: this.contextValue
}, children);
}
}
AnalyticsListener.contextTypes = ContextTypes;
AnalyticsListener.childContextTypes = ContextTypes;
export default AnalyticsListener;
//# sourceMappingURL=LegacyAnalyticsListener.js.map
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
export default AnalyticsListener;

@@ -5,26 +5,31 @@ import React, { useCallback, useMemo } from 'react';

import { useTrackedRef } from '../../hooks/useTrackedRef';
const AnalyticsListener = ({ children, channel, onEvent, }) => {
const analyticsContext = useAnalyticsContext();
const onEventRef = useTrackedRef(onEvent);
const channelRef = useTrackedRef(channel);
const getAtlaskitAnalyticsEventHandlers = useCallback(() => {
const thisHandler = (event, eventChannel) => {
if (channelRef.current === '*' || channelRef.current === eventChannel) {
onEventRef.current(event, eventChannel);
}
};
return [
...analyticsContext.getAtlaskitAnalyticsEventHandlers(),
thisHandler,
];
}, [analyticsContext, channelRef, onEventRef]);
const value = useMemo(() => {
return {
getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: analyticsContext.getAtlaskitAnalyticsContext,
};
}, [analyticsContext, getAtlaskitAnalyticsEventHandlers]);
return (React.createElement(AnalyticsReactContext.Provider, { value: value }, children));
const AnalyticsListener = ({
children,
channel,
onEvent
}) => {
const analyticsContext = useAnalyticsContext();
const onEventRef = useTrackedRef(onEvent);
const channelRef = useTrackedRef(channel);
const getAtlaskitAnalyticsEventHandlers = useCallback(() => {
const thisHandler = (event, eventChannel) => {
if (channelRef.current === '*' || channelRef.current === eventChannel) {
onEventRef.current(event, eventChannel);
}
};
return [...analyticsContext.getAtlaskitAnalyticsEventHandlers(), thisHandler];
}, [analyticsContext, channelRef, onEventRef]);
const value = useMemo(() => {
return {
getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: analyticsContext.getAtlaskitAnalyticsContext
};
}, [analyticsContext, getAtlaskitAnalyticsEventHandlers]);
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: value
}, children);
};
export default AnalyticsListener;
//# sourceMappingURL=ModernAnalyticsListener.js.map
export default AnalyticsListener;

@@ -0,24 +1,31 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
export default class AnalyticsEvent {
constructor(props) {
this.clone = () => {
// just a shallow clone, don't change sub refs unless you want to
// affect the original's too
const payload = { ...this.payload };
return new AnalyticsEvent({ payload });
};
this.payload = props.payload;
constructor(props) {
_defineProperty(this, "clone", () => {
// just a shallow clone, don't change sub refs unless you want to
// affect the original's too
const payload = { ...this.payload
};
return new AnalyticsEvent({
payload
});
});
this.payload = props.payload;
}
update(updater) {
if (typeof updater === 'function') {
this.payload = updater(this.payload);
}
update(updater) {
if (typeof updater === 'function') {
this.payload = updater(this.payload);
}
if (typeof updater === 'object') {
this.payload = {
...this.payload,
...updater,
};
}
return this;
if (typeof updater === 'object') {
this.payload = { ...this.payload,
...updater
};
}
}
//# sourceMappingURL=AnalyticsEvent.js.map
return this;
}
}

@@ -0,49 +1,65 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import AnalyticsEvent from './AnalyticsEvent';
export default class UIAnalyticsEvent extends AnalyticsEvent {
constructor(props) {
super(props);
this.clone = () => {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot clone an event after it's been fired.");
}
return null;
}
const context = [...this.context];
const handlers = [...this.handlers];
/**
* A hacky "deep clone" of the object. This is limited in that it wont
* support functions, regexs, Maps, Sets, etc, but none of those need to
* be represented in our payload.
*/
const payload = JSON.parse(JSON.stringify(this.payload));
return new UIAnalyticsEvent({ context, handlers, payload });
};
this.fire = (channel) => {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn('Cannot fire an event twice.');
}
return;
}
this.handlers.forEach(handler => handler(this, channel));
this.hasFired = true;
};
this.context = props.context || [];
this.handlers = props.handlers || [];
this.hasFired = false;
}
update(updater) {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot update an event after it's been fired.");
}
return this;
constructor(props) {
super(props);
_defineProperty(this, "clone", () => {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot clone an event after it's been fired.");
}
return super.update(updater);
return null;
}
const context = [...this.context];
const handlers = [...this.handlers];
/**
* A hacky "deep clone" of the object. This is limited in that it wont
* support functions, regexs, Maps, Sets, etc, but none of those need to
* be represented in our payload.
*/
const payload = JSON.parse(JSON.stringify(this.payload));
return new UIAnalyticsEvent({
context,
handlers,
payload
});
});
_defineProperty(this, "fire", channel => {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn('Cannot fire an event twice.');
}
return;
}
this.handlers.forEach(handler => handler(this, channel));
this.hasFired = true;
});
this.context = props.context || [];
this.handlers = props.handlers || [];
this.hasFired = false;
}
update(updater) {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot update an event after it's been fired.");
}
return this;
}
}
//# sourceMappingURL=UIAnalyticsEvent.js.map
return super.update(updater);
}
}

@@ -0,19 +1,25 @@

import _extends from "@babel/runtime/helpers/extends";
import React, { forwardRef, useMemo } from 'react';
import AnalyticsContext from '../components/AnalyticsContext';
const withAnalyticsContext = (defaultData) => (WrappedComponent) => {
const WithAnalyticsContext = forwardRef(({ analyticsContext, ...rest }, ref) => {
const analyticsData = useMemo(() => ({
...defaultData,
...analyticsContext,
}), [analyticsContext]);
return (React.createElement(AnalyticsContext, { data: analyticsData },
React.createElement(WrappedComponent, Object.assign({}, rest, { ref: ref }))));
});
// @ts-ignore
WithAnalyticsContext.displayName = `WithAnalyticsContext(${
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name})`;
return WithAnalyticsContext;
const withAnalyticsContext = defaultData => WrappedComponent => {
const WithAnalyticsContext = /*#__PURE__*/forwardRef(({
analyticsContext,
...rest
}, ref) => {
const analyticsData = useMemo(() => ({ ...defaultData,
...analyticsContext
}), [analyticsContext]);
return /*#__PURE__*/React.createElement(AnalyticsContext, {
data: analyticsData
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, rest, {
ref: ref
})));
}); // @ts-ignore
WithAnalyticsContext.displayName = `WithAnalyticsContext(${// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name})`;
return WithAnalyticsContext;
};
export default withAnalyticsContext;
//# sourceMappingURL=withAnalyticsContext.js.map
export default withAnalyticsContext;

@@ -0,17 +1,25 @@

import _extends from "@babel/runtime/helpers/extends";
import React, { forwardRef } from 'react';
import { useAnalyticsEvents } from '../hooks/useAnalyticsEvents';
import { usePatchedProps } from '../hooks/usePatchedProps';
const withAnalyticsEvents = (createEventMap = {}) => (WrappedComponent) => {
const WithAnalyticsEvents = forwardRef((props, ref) => {
const { patchedEventProps } = usePatchedProps(createEventMap, props);
const { createAnalyticsEvent } = useAnalyticsEvents();
return (React.createElement(WrappedComponent, Object.assign({}, props, patchedEventProps, { createAnalyticsEvent: createAnalyticsEvent, ref: ref })));
});
// @ts-ignore
WithAnalyticsEvents.displayName = `WithAnalyticsEvents(${
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name})`;
return WithAnalyticsEvents;
const withAnalyticsEvents = (createEventMap = {}) => WrappedComponent => {
const WithAnalyticsEvents = /*#__PURE__*/forwardRef((props, ref) => {
const {
patchedEventProps
} = usePatchedProps(createEventMap, props);
const {
createAnalyticsEvent
} = useAnalyticsEvents();
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, patchedEventProps, {
createAnalyticsEvent: createAnalyticsEvent,
ref: ref
}));
}); // @ts-ignore
WithAnalyticsEvents.displayName = `WithAnalyticsEvents(${// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name})`;
return WithAnalyticsEvents;
};
export default withAnalyticsEvents;
//# sourceMappingURL=withAnalyticsEvents.js.map
export default withAnalyticsEvents;
import { useContext } from 'react';
import { default as AnalyticsReactContext, } from '@atlaskit/analytics-next-stable-react-context';
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
export const useAnalyticsContext = () => {
return useContext(AnalyticsReactContext);
};
//# sourceMappingURL=useAnalyticsContext.js.map
return useContext(AnalyticsReactContext);
};

@@ -5,14 +5,13 @@ import { useCallbackOne } from 'use-memo-one';

export function useAnalyticsEvents() {
const analyticsContext = useAnalyticsContext();
const createAnalyticsEvent = useCallbackOne((payload) => {
return new UIAnalyticsEvent({
context: analyticsContext.getAtlaskitAnalyticsContext(),
handlers: analyticsContext.getAtlaskitAnalyticsEventHandlers(),
payload,
});
}, [analyticsContext]);
return {
createAnalyticsEvent,
};
}
//# sourceMappingURL=useAnalyticsEvents.js.map
const analyticsContext = useAnalyticsContext();
const createAnalyticsEvent = useCallbackOne(payload => {
return new UIAnalyticsEvent({
context: analyticsContext.getAtlaskitAnalyticsContext(),
handlers: analyticsContext.getAtlaskitAnalyticsEventHandlers(),
payload
});
}, [analyticsContext]);
return {
createAnalyticsEvent
};
}

@@ -5,13 +5,12 @@ import { useCallback } from 'react';

export const useCallbackWithAnalytics = (method, payload, channel) => {
const { createAnalyticsEvent } = useAnalyticsEvents();
const methodRef = useTrackedRef(method);
const payloadRef = useTrackedRef(payload);
return useCallback((...args) => {
const pload = typeof payloadRef.current === 'function'
? payloadRef.current(...args)
: payloadRef.current;
createAnalyticsEvent(pload).fire(channel);
methodRef.current(...args);
}, [createAnalyticsEvent, methodRef, payloadRef, channel]);
};
//# sourceMappingURL=useCallbackWithAnalytics.js.map
const {
createAnalyticsEvent
} = useAnalyticsEvents();
const methodRef = useTrackedRef(method);
const payloadRef = useTrackedRef(payload);
return useCallback((...args) => {
const pload = typeof payloadRef.current === 'function' ? payloadRef.current(...args) : payloadRef.current;
createAnalyticsEvent(pload).fire(channel);
methodRef.current(...args);
}, [createAnalyticsEvent, methodRef, payloadRef, channel]);
};
import { useMemo } from 'react';
import { useAnalyticsEvents } from './useAnalyticsEvents';
export function usePatchedProps(createEventMap = {}, wrappedComponentProps) {
const { createAnalyticsEvent } = useAnalyticsEvents();
const patchedProps = useMemo(() => {
return Object.keys(createEventMap).reduce((p, k) => {
const eventCreator = createEventMap[k];
if (!['object', 'function'].includes(typeof eventCreator)) {
return p;
}
const propValue = wrappedComponentProps[k];
const wrappedCallback = (...args) => {
const analyticsEvent = typeof eventCreator === 'function'
? eventCreator(createAnalyticsEvent, wrappedComponentProps)
: createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {
propValue(...args, analyticsEvent);
}
};
return wrappedCallback ? { ...p, [k]: wrappedCallback } : p;
}, {});
}, [createEventMap, wrappedComponentProps, createAnalyticsEvent]);
return {
patchedEventProps: patchedProps,
};
}
//# sourceMappingURL=usePatchedProps.js.map
const {
createAnalyticsEvent
} = useAnalyticsEvents();
const patchedProps = useMemo(() => {
return Object.keys(createEventMap).reduce((p, k) => {
const eventCreator = createEventMap[k];
if (!['object', 'function'].includes(typeof eventCreator)) {
return p;
}
const propValue = wrappedComponentProps[k];
const wrappedCallback = (...args) => {
const analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {
propValue(...args, analyticsEvent);
}
};
return wrappedCallback ? { ...p,
[k]: wrappedCallback
} : p;
}, {});
}, [createEventMap, wrappedComponentProps, createAnalyticsEvent]);
return {
patchedEventProps: patchedProps
};
}

@@ -10,50 +10,52 @@ import { useCallback } from 'react';

// or AnalyticsContext component instead.
export function usePlatformLeafEventHandler({ fn, action, componentName, packageName, packageVersion, analyticsData, }) {
const { createAnalyticsEvent } = useAnalyticsEvents();
// We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
const dataRef = useTrackedRef(analyticsData);
const fnRef = useTrackedRef(fn);
const handler = useCallback(value => {
const analyticsEvent = createAnalyticsEvent({
action,
actionSubject: componentName,
attributes: {
componentName,
packageName,
packageVersion,
},
});
// To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
const context = {
componentName,
packageName,
packageVersion,
...dataRef.current,
};
analyticsEvent.context.push(context);
// fire an event on the atlaskit channel
const clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(value, analyticsEvent);
}, [
// These are strings and won't change
action,
export function usePlatformLeafEventHandler({
fn,
action,
componentName,
packageName,
packageVersion,
analyticsData
}) {
const {
createAnalyticsEvent
} = useAnalyticsEvents(); // We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
const dataRef = useTrackedRef(analyticsData);
const fnRef = useTrackedRef(fn);
const handler = useCallback(value => {
const analyticsEvent = createAnalyticsEvent({
action,
actionSubject: componentName,
attributes: {
componentName,
packageName,
packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef,
fnRef,
]);
return handler;
}
//# sourceMappingURL=usePlatformLeafEventHandler.js.map
packageVersion
}
}); // To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
const context = {
componentName,
packageName,
packageVersion,
...dataRef.current
};
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
const clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(value, analyticsEvent);
}, [// These are strings and won't change
action, componentName, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}

@@ -10,50 +10,52 @@ import { useCallback } from 'react';

// or AnalyticsContext component instead.
export function usePlatformLeafSyntheticEventHandler({ fn, action, componentName, packageName, packageVersion, analyticsData, }) {
const { createAnalyticsEvent } = useAnalyticsEvents();
// We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
const dataRef = useTrackedRef(analyticsData);
const fnRef = useTrackedRef(fn);
const handler = useCallback(() => {
const analyticsEvent = createAnalyticsEvent({
action,
actionSubject: componentName,
attributes: {
componentName,
packageName,
packageVersion,
},
});
// To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
const context = {
componentName,
packageName,
packageVersion,
...dataRef.current,
};
analyticsEvent.context.push(context);
// fire an event on the atlaskit channel
const clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(analyticsEvent);
}, [
// These are strings and won't change
action,
export function usePlatformLeafSyntheticEventHandler({
fn,
action,
componentName,
packageName,
packageVersion,
analyticsData
}) {
const {
createAnalyticsEvent
} = useAnalyticsEvents(); // We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
const dataRef = useTrackedRef(analyticsData);
const fnRef = useTrackedRef(fn);
const handler = useCallback(() => {
const analyticsEvent = createAnalyticsEvent({
action,
actionSubject: componentName,
attributes: {
componentName,
packageName,
packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef,
fnRef,
]);
return handler;
}
//# sourceMappingURL=usePlatformLeafSyntheticEventHandler.js.map
packageVersion
}
}); // To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
const context = {
componentName,
packageName,
packageVersion,
...dataRef.current
};
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
const clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(analyticsEvent);
}, [// These are strings and won't change
action, componentName, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}
import { useEffect, useRef } from 'react';
export const useTrackedRef = (value) => {
const ref = useRef(value);
useEffect(() => {
ref.current = value;
}, [value]);
return ref;
};
//# sourceMappingURL=useTrackedRef.js.map
export const useTrackedRef = value => {
const ref = useRef(value);
useEffect(() => {
ref.current = value;
}, [value]);
return ref;
};

@@ -5,4 +5,4 @@ // Analytics event classes

// AnalyticsListener component
export { default as AnalyticsListener } from './components/AnalyticsListener/index';
// AnalyticsContext component and HOC
export { default as AnalyticsListener } from './components/AnalyticsListener/index'; // AnalyticsContext component and HOC
export { default as AnalyticsContext } from './components/AnalyticsContext/index';

@@ -23,3 +23,2 @@ export { default as withAnalyticsContext } from './hocs/withAnalyticsContext';

export { default as createAndFireEvent } from './utils/createAndFireEvent';
export { default as cleanProps } from './utils/cleanProps';
//# sourceMappingURL=index.js.map
export { default as cleanProps } from './utils/cleanProps';

@@ -10,108 +10,153 @@ import React, { useCallback } from 'react';

import createAndFireEvent from '../utils/createAndFireEvent';
const ButtonWithUsePlatformLeafEventHandlerHook = ({ onClick: providedOnClick, }) => {
const onClick = usePlatformLeafEventHandler({
fn: providedOnClick,
const ButtonWithUsePlatformLeafEventHandlerHook = ({
onClick: providedOnClick
}) => {
const onClick = usePlatformLeafEventHandler({
fn: providedOnClick,
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
action: 'clicked',
analyticsData: {
additionalData: true
}
});
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
};
const ButtonWithUseAnalyticsEventHook = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(({
onClick: providedOnClick
}) => {
const {
createAnalyticsEvent
} = useAnalyticsEvents();
const onClick = useCallback(mouseEvt => {
const analyticsEvent = createAnalyticsEvent({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
action: 'clicked',
analyticsData: {
additionalData: true,
},
packageVersion: '0.1.0'
}
});
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
};
const ButtonWithUseAnalyticsEventHook = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(({ onClick: providedOnClick }) => {
const { createAnalyticsEvent } = useAnalyticsEvents();
const onClick = useCallback((mouseEvt) => {
const analyticsEvent = createAnalyticsEvent({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
});
analyticsEvent.fire('atlaskit');
providedOnClick(mouseEvt);
}, [providedOnClick, createAnalyticsEvent]);
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
analyticsEvent.fire('atlaskit');
providedOnClick(mouseEvt);
}, [providedOnClick, createAnalyticsEvent]);
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
});
const ButtonWithUseCallbackWithAnalyticsHook = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(({ onClick: providedOnClick }) => {
const onClick = useCallbackWithAnalytics(providedOnClick, {
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
}, 'atlaskit');
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(({
onClick: providedOnClick
}) => {
const onClick = useCallbackWithAnalytics(providedOnClick, {
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0'
}
}, 'atlaskit');
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
});
const ButtonWithHOCs = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(withAnalyticsEvents({
onClick: createAndFireEvent('atlaskit')({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
}),
})(({ onClick }) => {
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
onClick: createAndFireEvent('atlaskit')({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0'
}
})
})(({
onClick
}) => {
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
}));
const createEventHandler = () => {
let done = (...args) => { };
let promise;
const onEvent = (...args) => {
done(args);
};
const create = () => {
promise = new Promise(resolve => {
done = resolve;
});
};
const getPromise = () => promise;
return { onEvent, create, getPromise };
let done = (...args) => {};
let promise;
const onEvent = (...args) => {
done(args);
};
const create = () => {
promise = new Promise(resolve => {
done = resolve;
});
};
const getPromise = () => promise;
return {
onEvent,
create,
getPromise
};
};
const eventHandler = createEventHandler();
const WithListener = (Component) => () => {
eventHandler.create();
const onEvent = eventHandler.onEvent;
const onClick = () => { };
return (React.createElement(AnalyticsListener, { channel: "atlaskit", onEvent: onEvent },
React.createElement(Component, { onClick: onClick })));
const WithListener = Component => () => {
eventHandler.create();
const onEvent = eventHandler.onEvent;
const onClick = () => {};
return /*#__PURE__*/React.createElement(AnalyticsListener, {
channel: "atlaskit",
onEvent: onEvent
}, /*#__PURE__*/React.createElement(Component, {
onClick: onClick
}));
};
const interactionTasks = [
{
name: 'Dispatch event',
description: 'Recording how long it takes to fire and receive an event on the listener',
run: async ({ container }) => {
const button = container.querySelector('button');
if (button == null) {
throw new Error('Could not find button element');
}
fireEvent.click(button);
await eventHandler.getPromise();
},
},
];
const interactionTasks = [{
name: 'Dispatch event',
description: 'Recording how long it takes to fire and receive an event on the listener',
run: async ({
container
}) => {
const button = container.querySelector('button');
if (button == null) {
throw new Error('Could not find button element');
}
fireEvent.click(button);
await eventHandler.getPromise();
}
}];
export const UsePlatformLeafEventHandlerHookTest = WithListener(ButtonWithUsePlatformLeafEventHandlerHook);

@@ -122,34 +167,33 @@ export const UseAnalyticsEventHookTest = WithListener(ButtonWithUseAnalyticsEventHook);

UsePlatformLeafEventHandlerHookTest.story = {
name: 'usePlatformLeafEventHandler based component',
component: UsePlatformLeafEventHandlerHookTest,
parameters: {
performance: {
interactions: interactionTasks,
},
},
name: 'usePlatformLeafEventHandler based component',
component: UsePlatformLeafEventHandlerHookTest,
parameters: {
performance: {
interactions: interactionTasks
}
}
};
UseAnalyticsEventHookTest.story = {
name: 'useAnalyticsEvent based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
name: 'useAnalyticsEvent based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
UseCallbackWithAnalyticsHookTest.story = {
name: 'useCallbackWithAnalytics based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
name: 'useCallbackWithAnalytics based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
HOCSTest.story = {
name: 'HOC based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
};
//# sourceMappingURL=examples.js.map
name: 'HOC based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};

@@ -1,10 +0,9 @@

import { useEffect, useRef } from 'react';
// Hook to track the number of renders in tests
import { useEffect, useRef } from 'react'; // Hook to track the number of renders in tests
export const useRenderCounter = () => {
const ref = useRef(1);
useEffect(() => {
ref.current++;
});
return ref.current;
};
//# sourceMappingURL=useRenderCounter.js.map
const ref = useRef(1);
useEffect(() => {
ref.current++;
});
return ref.current;
};
export default function cleanProps(props) {
const { createAnalyticsEvent, ...cleanedProps } = props;
return cleanedProps;
}
//# sourceMappingURL=cleanProps.js.map
const {
createAnalyticsEvent,
...cleanedProps
} = props;
return cleanedProps;
}

@@ -1,9 +0,10 @@

export default (channel) => (payload) => (createAnalyticsEvent) => {
const consumerEvent = createAnalyticsEvent(payload);
const clonedEvent = consumerEvent.clone();
if (clonedEvent) {
clonedEvent.fire(channel);
}
return consumerEvent;
};
//# sourceMappingURL=createAndFireEvent.js.map
export default (channel => payload => createAnalyticsEvent => {
const consumerEvent = createAnalyticsEvent(payload);
const clonedEvent = consumerEvent.clone();
if (clonedEvent) {
clonedEvent.fire(channel);
}
return consumerEvent;
});
{
"name": "@atlaskit/analytics-next",
"version": "8.1.0",
"version": "8.1.1",
"sideEffects": false
}
import LegacyAnalyticsContext from './LegacyAnalyticsContext';
import ModernAnalyticsContext from './ModernAnalyticsContext';
var ExportedAnalyticsContext;
if (process.env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
ExportedAnalyticsContext = ModernAnalyticsContext;
ExportedAnalyticsContext = ModernAnalyticsContext;
} else {
ExportedAnalyticsContext = LegacyAnalyticsContext;
}
else {
ExportedAnalyticsContext = LegacyAnalyticsContext;
}
export default ExportedAnalyticsContext;
//# sourceMappingURL=index.js.map
export default ExportedAnalyticsContext;

@@ -1,42 +0,82 @@

import { __extends, __read, __spread } from "tslib";
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { default as AnalyticsReactContext, } from '@atlaskit/analytics-next-stable-react-context';
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
var ContextTypes = {
getAtlaskitAnalyticsContext: PropTypes.func,
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func,
getAtlaskitAnalyticsEventHandlers: PropTypes.func
};
var noop = function () { return []; };
// eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsContext = /** @class */ (function (_super) {
__extends(AnalyticsContext, _super);
function AnalyticsContext(props) {
var _this = _super.call(this, props) || this;
_this.getChildContext = function () { return ({
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
}); };
_this.getAnalyticsContext = function () {
var data = _this.props.data;
var _a = _this.context.getAtlaskitAnalyticsContext, getAtlaskitAnalyticsContext = _a === void 0 ? noop : _a;
return __spread(getAtlaskitAnalyticsContext(), [data]);
};
_this.getAnalyticsEventHandlers = function () {
var _a = _this.context.getAtlaskitAnalyticsEventHandlers, getAtlaskitAnalyticsEventHandlers = _a === void 0 ? noop : _a;
return getAtlaskitAnalyticsEventHandlers();
};
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
};
return _this;
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsContext = /*#__PURE__*/function (_Component) {
_inherits(AnalyticsContext, _Component);
var _super = _createSuper(AnalyticsContext);
function AnalyticsContext(props) {
var _this;
_classCallCheck(this, AnalyticsContext);
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "getChildContext", function () {
return {
getAtlaskitAnalyticsContext: _this.getAnalyticsContext
};
});
_defineProperty(_assertThisInitialized(_this), "getAnalyticsContext", function () {
var data = _this.props.data;
var _this$context$getAtla = _this.context.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
return [].concat(_toConsumableArray(getAtlaskitAnalyticsContext()), [data]);
});
_defineProperty(_assertThisInitialized(_this), "getAnalyticsEventHandlers", function () {
var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsEventHandlers();
});
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
};
return _this;
}
_createClass(AnalyticsContext, [{
key: "render",
value: function render() {
var children = this.props.children;
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: this.contextValue
}, children);
}
AnalyticsContext.prototype.render = function () {
var children = this.props.children;
return (React.createElement(AnalyticsReactContext.Provider, { value: this.contextValue }, children));
};
AnalyticsContext.contextTypes = ContextTypes;
AnalyticsContext.childContextTypes = ContextTypes;
return AnalyticsContext;
}(Component));
export default AnalyticsContext;
//# sourceMappingURL=LegacyAnalyticsContext.js.map
}]);
return AnalyticsContext;
}(Component);
_defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
_defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
export default AnalyticsContext;

@@ -1,2 +0,2 @@

import { __read, __spread } from "tslib";
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import React, { useCallback, useMemo } from 'react';

@@ -6,16 +6,22 @@ import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';

import { useTrackedRef } from '../../hooks/useTrackedRef';
var AnalyticsContext = function (_a) {
var data = _a.data, children = _a.children;
var dataRef = useTrackedRef(data);
var analyticsContext = useAnalyticsContext();
var getAtlaskitAnalyticsContext = useCallback(function () {
return __spread(analyticsContext.getAtlaskitAnalyticsContext(), [dataRef.current]);
}, [analyticsContext, dataRef]);
var value = useMemo(function () { return ({
getAtlaskitAnalyticsContext: getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: analyticsContext.getAtlaskitAnalyticsEventHandlers,
}); }, [analyticsContext, getAtlaskitAnalyticsContext]);
return (React.createElement(AnalyticsReactContext.Provider, { value: value }, children));
var AnalyticsContext = function AnalyticsContext(_ref) {
var data = _ref.data,
children = _ref.children;
var dataRef = useTrackedRef(data);
var analyticsContext = useAnalyticsContext();
var getAtlaskitAnalyticsContext = useCallback(function () {
return [].concat(_toConsumableArray(analyticsContext.getAtlaskitAnalyticsContext()), [dataRef.current]);
}, [analyticsContext, dataRef]);
var value = useMemo(function () {
return {
getAtlaskitAnalyticsContext: getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: analyticsContext.getAtlaskitAnalyticsEventHandlers
};
}, [analyticsContext, getAtlaskitAnalyticsContext]);
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: value
}, children);
};
export default AnalyticsContext;
//# sourceMappingURL=ModernAnalyticsContext.js.map
export default AnalyticsContext;

@@ -1,2 +0,17 @@

import { __assign, __extends } from "tslib";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
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; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import React, { Component } from 'react';

@@ -6,34 +21,59 @@ import withAnalyticsEvents from '../hocs/withAnalyticsEvents';

// eslint-disable-next-line @repo/internal/react/no-class-components
var BaseAnalyticsErrorBoundary = /** @class */ (function (_super) {
__extends(BaseAnalyticsErrorBoundary, _super);
function BaseAnalyticsErrorBoundary() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.fireAnalytics = function (analyticsErrorPayload) {
var _a = _this.props, createAnalyticsEvent = _a.createAnalyticsEvent, channel = _a.channel, data = _a.data;
createAnalyticsEvent({
action: 'UnhandledError',
eventType: 'ui',
attributes: __assign(__assign({ browserInfo: window && window.navigator && window.navigator.userAgent
? window.navigator.userAgent
: 'unknown' }, data), analyticsErrorPayload),
}).fire(channel);
};
return _this;
export var BaseAnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
_inherits(BaseAnalyticsErrorBoundary, _Component);
var _super = _createSuper(BaseAnalyticsErrorBoundary);
function BaseAnalyticsErrorBoundary() {
var _this;
_classCallCheck(this, BaseAnalyticsErrorBoundary);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
BaseAnalyticsErrorBoundary.prototype.componentDidCatch = function (error, info) {
var payload = {
error: error,
info: info,
};
this.fireAnalytics(payload);
};
BaseAnalyticsErrorBoundary.prototype.render = function () {
var _a = this.props, data = _a.data, children = _a.children;
return React.createElement(AnalyticsContext, { data: data }, children);
};
return BaseAnalyticsErrorBoundary;
}(Component));
export { BaseAnalyticsErrorBoundary };
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "fireAnalytics", function (analyticsErrorPayload) {
var _this$props = _this.props,
createAnalyticsEvent = _this$props.createAnalyticsEvent,
channel = _this$props.channel,
data = _this$props.data;
createAnalyticsEvent({
action: 'UnhandledError',
eventType: 'ui',
attributes: _objectSpread(_objectSpread({
browserInfo: window && window.navigator && window.navigator.userAgent ? window.navigator.userAgent : 'unknown'
}, data), analyticsErrorPayload)
}).fire(channel);
});
return _this;
}
_createClass(BaseAnalyticsErrorBoundary, [{
key: "componentDidCatch",
value: function componentDidCatch(error, info) {
var payload = {
error: error,
info: info
};
this.fireAnalytics(payload);
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
data = _this$props2.data,
children = _this$props2.children;
return /*#__PURE__*/React.createElement(AnalyticsContext, {
data: data
}, children);
}
}]);
return BaseAnalyticsErrorBoundary;
}(Component);
var AnalyticsErrorBoundary = withAnalyticsEvents()(BaseAnalyticsErrorBoundary);
export default AnalyticsErrorBoundary;
//# sourceMappingURL=AnalyticsErrorBoundary.js.map
export default AnalyticsErrorBoundary;
import LegacyAnalyticsListener from './LegacyAnalyticsListener';
import ModernAnalyticsListener from './ModernAnalyticsListener';
var ExportedAnalyticsListener;
if (process.env['ANALYTICS_NEXT_MODERN_CONTEXT']) {
ExportedAnalyticsListener = ModernAnalyticsListener;
ExportedAnalyticsListener = ModernAnalyticsListener;
} else {
ExportedAnalyticsListener = LegacyAnalyticsListener;
}
else {
ExportedAnalyticsListener = LegacyAnalyticsListener;
}
export default ExportedAnalyticsListener;
//# sourceMappingURL=index.js.map
export default ExportedAnalyticsListener;

@@ -1,48 +0,92 @@

import { __extends, __read, __spread } from "tslib";
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { default as AnalyticsReactContext, } from '@atlaskit/analytics-next-stable-react-context';
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
var ContextTypes = {
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func,
getAtlaskitAnalyticsEventHandlers: PropTypes.func,
getAtlaskitAnalyticsContext: PropTypes.func
};
var noop = function () { return []; };
// eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsListener = /** @class */ (function (_super) {
__extends(AnalyticsListener, _super);
function AnalyticsListener(props) {
var _this = _super.call(this, props) || this;
_this.getChildContext = function () { return ({
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
}); };
_this.getAnalyticsEventHandlers = function () {
var _a = _this.props, channel = _a.channel, onEvent = _a.onEvent;
var _b = _this.context.getAtlaskitAnalyticsEventHandlers, getAtlaskitAnalyticsEventHandlers = _b === void 0 ? noop : _b;
var handler = function (event, eventChannel) {
if (channel === '*' || channel === eventChannel) {
onEvent(event, eventChannel);
}
};
return __spread([handler], getAtlaskitAnalyticsEventHandlers());
};
_this.getAtlaskitAnalyticsContext = function () {
var _a = _this.context.getAtlaskitAnalyticsContext, getAtlaskitAnalyticsContext = _a === void 0 ? noop : _a;
return getAtlaskitAnalyticsContext();
};
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
};
return _this;
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
var AnalyticsListener = /*#__PURE__*/function (_Component) {
_inherits(AnalyticsListener, _Component);
var _super = _createSuper(AnalyticsListener);
function AnalyticsListener(props) {
var _this;
_classCallCheck(this, AnalyticsListener);
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "getChildContext", function () {
return {
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext
};
});
_defineProperty(_assertThisInitialized(_this), "getAnalyticsEventHandlers", function () {
var _this$props = _this.props,
channel = _this$props.channel,
onEvent = _this$props.onEvent;
var _this$context$getAtla = _this.context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
var handler = function handler(event, eventChannel) {
if (channel === '*' || channel === eventChannel) {
onEvent(event, eventChannel);
}
};
return [handler].concat(_toConsumableArray(getAtlaskitAnalyticsEventHandlers()));
});
_defineProperty(_assertThisInitialized(_this), "getAtlaskitAnalyticsContext", function () {
var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsContext();
});
_this.contextValue = {
getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsEventHandlers: _this.getAnalyticsEventHandlers
};
return _this;
}
_createClass(AnalyticsListener, [{
key: "render",
value: function render() {
var children = this.props.children;
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: this.contextValue
}, children);
}
AnalyticsListener.prototype.render = function () {
var children = this.props.children;
return (React.createElement(AnalyticsReactContext.Provider, { value: this.contextValue }, children));
};
AnalyticsListener.contextTypes = ContextTypes;
AnalyticsListener.childContextTypes = ContextTypes;
return AnalyticsListener;
}(Component));
export default AnalyticsListener;
//# sourceMappingURL=LegacyAnalyticsListener.js.map
}]);
return AnalyticsListener;
}(Component);
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
export default AnalyticsListener;

@@ -1,2 +0,2 @@

import { __read, __spread } from "tslib";
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import React, { useCallback, useMemo } from 'react';

@@ -6,26 +6,30 @@ import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';

import { useTrackedRef } from '../../hooks/useTrackedRef';
var AnalyticsListener = function (_a) {
var children = _a.children, channel = _a.channel, onEvent = _a.onEvent;
var analyticsContext = useAnalyticsContext();
var onEventRef = useTrackedRef(onEvent);
var channelRef = useTrackedRef(channel);
var getAtlaskitAnalyticsEventHandlers = useCallback(function () {
var thisHandler = function (event, eventChannel) {
if (channelRef.current === '*' || channelRef.current === eventChannel) {
onEventRef.current(event, eventChannel);
}
};
return __spread(analyticsContext.getAtlaskitAnalyticsEventHandlers(), [
thisHandler,
]);
}, [analyticsContext, channelRef, onEventRef]);
var value = useMemo(function () {
return {
getAtlaskitAnalyticsEventHandlers: getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: analyticsContext.getAtlaskitAnalyticsContext,
};
}, [analyticsContext, getAtlaskitAnalyticsEventHandlers]);
return (React.createElement(AnalyticsReactContext.Provider, { value: value }, children));
var AnalyticsListener = function AnalyticsListener(_ref) {
var children = _ref.children,
channel = _ref.channel,
onEvent = _ref.onEvent;
var analyticsContext = useAnalyticsContext();
var onEventRef = useTrackedRef(onEvent);
var channelRef = useTrackedRef(channel);
var getAtlaskitAnalyticsEventHandlers = useCallback(function () {
var thisHandler = function thisHandler(event, eventChannel) {
if (channelRef.current === '*' || channelRef.current === eventChannel) {
onEventRef.current(event, eventChannel);
}
};
return [].concat(_toConsumableArray(analyticsContext.getAtlaskitAnalyticsEventHandlers()), [thisHandler]);
}, [analyticsContext, channelRef, onEventRef]);
var value = useMemo(function () {
return {
getAtlaskitAnalyticsEventHandlers: getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsContext: analyticsContext.getAtlaskitAnalyticsContext
};
}, [analyticsContext, getAtlaskitAnalyticsEventHandlers]);
return /*#__PURE__*/React.createElement(AnalyticsReactContext.Provider, {
value: value
}, children);
};
export default AnalyticsListener;
//# sourceMappingURL=ModernAnalyticsListener.js.map
export default AnalyticsListener;

@@ -1,25 +0,47 @@

import { __assign } from "tslib";
var AnalyticsEvent = /** @class */ (function () {
function AnalyticsEvent(props) {
var _this = this;
this.clone = function () {
// just a shallow clone, don't change sub refs unless you want to
// affect the original's too
var payload = __assign({}, _this.payload);
return new AnalyticsEvent({ payload: payload });
};
this.payload = props.payload;
import _typeof from "@babel/runtime/helpers/typeof";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
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; }
var AnalyticsEvent = /*#__PURE__*/function () {
function AnalyticsEvent(props) {
var _this = this;
_classCallCheck(this, AnalyticsEvent);
_defineProperty(this, "clone", function () {
// just a shallow clone, don't change sub refs unless you want to
// affect the original's too
var payload = _objectSpread({}, _this.payload);
return new AnalyticsEvent({
payload: payload
});
});
this.payload = props.payload;
}
_createClass(AnalyticsEvent, [{
key: "update",
value: function update(updater) {
if (typeof updater === 'function') {
this.payload = updater(this.payload);
}
if (_typeof(updater) === 'object') {
this.payload = _objectSpread(_objectSpread({}, this.payload), updater);
}
return this;
}
AnalyticsEvent.prototype.update = function (updater) {
if (typeof updater === 'function') {
this.payload = updater(this.payload);
}
if (typeof updater === 'object') {
this.payload = __assign(__assign({}, this.payload), updater);
}
return this;
};
return AnalyticsEvent;
}());
export default AnalyticsEvent;
//# sourceMappingURL=AnalyticsEvent.js.map
}]);
return AnalyticsEvent;
}();
export { AnalyticsEvent as default };

@@ -1,54 +0,99 @@

import { __extends, __read, __spread } from "tslib";
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _get from "@babel/runtime/helpers/get";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
import AnalyticsEvent from './AnalyticsEvent';
var UIAnalyticsEvent = /** @class */ (function (_super) {
__extends(UIAnalyticsEvent, _super);
function UIAnalyticsEvent(props) {
var _this = _super.call(this, props) || this;
_this.clone = function () {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot clone an event after it's been fired.");
}
return null;
}
var context = __spread(_this.context);
var handlers = __spread(_this.handlers);
/**
* A hacky "deep clone" of the object. This is limited in that it wont
* support functions, regexs, Maps, Sets, etc, but none of those need to
* be represented in our payload.
*/
var payload = JSON.parse(JSON.stringify(_this.payload));
return new UIAnalyticsEvent({ context: context, handlers: handlers, payload: payload });
};
_this.fire = function (channel) {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn('Cannot fire an event twice.');
}
return;
}
_this.handlers.forEach(function (handler) { return handler(_this, channel); });
_this.hasFired = true;
};
_this.context = props.context || [];
_this.handlers = props.handlers || [];
_this.hasFired = false;
return _this;
var UIAnalyticsEvent = /*#__PURE__*/function (_AnalyticsEvent) {
_inherits(UIAnalyticsEvent, _AnalyticsEvent);
var _super = _createSuper(UIAnalyticsEvent);
function UIAnalyticsEvent(props) {
var _this;
_classCallCheck(this, UIAnalyticsEvent);
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "clone", function () {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot clone an event after it's been fired.");
}
return null;
}
var context = _toConsumableArray(_this.context);
var handlers = _toConsumableArray(_this.handlers);
/**
* A hacky "deep clone" of the object. This is limited in that it wont
* support functions, regexs, Maps, Sets, etc, but none of those need to
* be represented in our payload.
*/
var payload = JSON.parse(JSON.stringify(_this.payload));
return new UIAnalyticsEvent({
context: context,
handlers: handlers,
payload: payload
});
});
_defineProperty(_assertThisInitialized(_this), "fire", function (channel) {
if (_this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn('Cannot fire an event twice.');
}
return;
}
_this.handlers.forEach(function (handler) {
return handler(_assertThisInitialized(_this), channel);
});
_this.hasFired = true;
});
_this.context = props.context || [];
_this.handlers = props.handlers || [];
_this.hasFired = false;
return _this;
}
_createClass(UIAnalyticsEvent, [{
key: "update",
value: function update(updater) {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot update an event after it's been fired.");
}
return this;
}
return _get(_getPrototypeOf(UIAnalyticsEvent.prototype), "update", this).call(this, updater);
}
UIAnalyticsEvent.prototype.update = function (updater) {
if (this.hasFired) {
if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
// eslint-disable-next-line no-console
console.warn("Cannot update an event after it's been fired.");
}
return this;
}
return _super.prototype.update.call(this, updater);
};
return UIAnalyticsEvent;
}(AnalyticsEvent));
export default UIAnalyticsEvent;
//# sourceMappingURL=UIAnalyticsEvent.js.map
}]);
return UIAnalyticsEvent;
}(AnalyticsEvent);
export { UIAnalyticsEvent as default };

@@ -1,18 +0,34 @@

import { __assign, __rest } from "tslib";
import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
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; }
import React, { forwardRef, useMemo } from 'react';
import AnalyticsContext from '../components/AnalyticsContext';
var withAnalyticsContext = function (defaultData) { return function (WrappedComponent) {
var WithAnalyticsContext = forwardRef(function (_a, ref) {
var analyticsContext = _a.analyticsContext, rest = __rest(_a, ["analyticsContext"]);
var analyticsData = useMemo(function () { return (__assign(__assign({}, defaultData), analyticsContext)); }, [analyticsContext]);
return (React.createElement(AnalyticsContext, { data: analyticsData },
React.createElement(WrappedComponent, __assign({}, rest, { ref: ref }))));
});
// @ts-ignore
WithAnalyticsContext.displayName = "WithAnalyticsContext(" + (
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name) + ")";
var withAnalyticsContext = function withAnalyticsContext(defaultData) {
return function (WrappedComponent) {
var WithAnalyticsContext = /*#__PURE__*/forwardRef(function (_ref, ref) {
var analyticsContext = _ref.analyticsContext,
rest = _objectWithoutProperties(_ref, ["analyticsContext"]);
var analyticsData = useMemo(function () {
return _objectSpread(_objectSpread({}, defaultData), analyticsContext);
}, [analyticsContext]);
return /*#__PURE__*/React.createElement(AnalyticsContext, {
data: analyticsData
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, rest, {
ref: ref
})));
}); // @ts-ignore
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat( // @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");
return WithAnalyticsContext;
}; };
export default withAnalyticsContext;
//# sourceMappingURL=withAnalyticsContext.js.map
};
};
export default withAnalyticsContext;

@@ -1,21 +0,28 @@

import { __assign } from "tslib";
import _extends from "@babel/runtime/helpers/extends";
import React, { forwardRef } from 'react';
import { useAnalyticsEvents } from '../hooks/useAnalyticsEvents';
import { usePatchedProps } from '../hooks/usePatchedProps';
var withAnalyticsEvents = function (createEventMap) {
if (createEventMap === void 0) { createEventMap = {}; }
return function (WrappedComponent) {
var WithAnalyticsEvents = forwardRef(function (props, ref) {
var patchedEventProps = usePatchedProps(createEventMap, props).patchedEventProps;
var createAnalyticsEvent = useAnalyticsEvents().createAnalyticsEvent;
return (React.createElement(WrappedComponent, __assign({}, props, patchedEventProps, { createAnalyticsEvent: createAnalyticsEvent, ref: ref })));
});
// @ts-ignore
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(" + (
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name) + ")";
return WithAnalyticsEvents;
};
var withAnalyticsEvents = function withAnalyticsEvents() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return function (WrappedComponent) {
var WithAnalyticsEvents = /*#__PURE__*/forwardRef(function (props, ref) {
var _usePatchedProps = usePatchedProps(createEventMap, props),
patchedEventProps = _usePatchedProps.patchedEventProps;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, patchedEventProps, {
createAnalyticsEvent: createAnalyticsEvent,
ref: ref
}));
}); // @ts-ignore
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat( // @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");
return WithAnalyticsEvents;
};
};
export default withAnalyticsEvents;
//# sourceMappingURL=withAnalyticsEvents.js.map
export default withAnalyticsEvents;
import { useContext } from 'react';
import { default as AnalyticsReactContext, } from '@atlaskit/analytics-next-stable-react-context';
export var useAnalyticsContext = function () {
return useContext(AnalyticsReactContext);
};
//# sourceMappingURL=useAnalyticsContext.js.map
import { default as AnalyticsReactContext } from '@atlaskit/analytics-next-stable-react-context';
export var useAnalyticsContext = function useAnalyticsContext() {
return useContext(AnalyticsReactContext);
};

@@ -5,14 +5,13 @@ import { useCallbackOne } from 'use-memo-one';

export function useAnalyticsEvents() {
var analyticsContext = useAnalyticsContext();
var createAnalyticsEvent = useCallbackOne(function (payload) {
return new UIAnalyticsEvent({
context: analyticsContext.getAtlaskitAnalyticsContext(),
handlers: analyticsContext.getAtlaskitAnalyticsEventHandlers(),
payload: payload,
});
}, [analyticsContext]);
return {
createAnalyticsEvent: createAnalyticsEvent,
};
}
//# sourceMappingURL=useAnalyticsEvents.js.map
var analyticsContext = useAnalyticsContext();
var createAnalyticsEvent = useCallbackOne(function (payload) {
return new UIAnalyticsEvent({
context: analyticsContext.getAtlaskitAnalyticsContext(),
handlers: analyticsContext.getAtlaskitAnalyticsEventHandlers(),
payload: payload
});
}, [analyticsContext]);
return {
createAnalyticsEvent: createAnalyticsEvent
};
}

@@ -1,20 +0,15 @@

import { __read, __spread } from "tslib";
import { useCallback } from 'react';
import { useAnalyticsEvents } from './useAnalyticsEvents';
import { useTrackedRef } from './useTrackedRef';
export var useCallbackWithAnalytics = function (method, payload, channel) {
var createAnalyticsEvent = useAnalyticsEvents().createAnalyticsEvent;
var methodRef = useTrackedRef(method);
var payloadRef = useTrackedRef(payload);
return useCallback(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var pload = typeof payloadRef.current === 'function'
? payloadRef.current.apply(payloadRef, __spread(args)) : payloadRef.current;
createAnalyticsEvent(pload).fire(channel);
methodRef.current.apply(methodRef, __spread(args));
}, [createAnalyticsEvent, methodRef, payloadRef, channel]);
};
//# sourceMappingURL=useCallbackWithAnalytics.js.map
export var useCallbackWithAnalytics = function useCallbackWithAnalytics(method, payload, channel) {
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var methodRef = useTrackedRef(method);
var payloadRef = useTrackedRef(payload);
return useCallback(function () {
var pload = typeof payloadRef.current === 'function' ? payloadRef.current.apply(payloadRef, arguments) : payloadRef.current;
createAnalyticsEvent(pload).fire(channel);
methodRef.current.apply(methodRef, arguments);
}, [createAnalyticsEvent, methodRef, payloadRef, channel]);
};

@@ -1,34 +0,45 @@

import { __assign, __read, __spread } from "tslib";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _typeof from "@babel/runtime/helpers/typeof";
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; }
import { useMemo } from 'react';
import { useAnalyticsEvents } from './useAnalyticsEvents';
export function usePatchedProps(createEventMap, wrappedComponentProps) {
if (createEventMap === void 0) { createEventMap = {}; }
var createAnalyticsEvent = useAnalyticsEvents().createAnalyticsEvent;
var patchedProps = useMemo(function () {
return Object.keys(createEventMap).reduce(function (p, k) {
var _a;
var eventCreator = createEventMap[k];
if (!['object', 'function'].includes(typeof eventCreator)) {
return p;
}
var propValue = wrappedComponentProps[k];
var wrappedCallback = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var analyticsEvent = typeof eventCreator === 'function'
? eventCreator(createAnalyticsEvent, wrappedComponentProps)
: createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {
propValue.apply(void 0, __spread(args, [analyticsEvent]));
}
};
return wrappedCallback ? __assign(__assign({}, p), (_a = {}, _a[k] = wrappedCallback, _a)) : p;
}, {});
}, [createEventMap, wrappedComponentProps, createAnalyticsEvent]);
return {
patchedEventProps: patchedProps,
};
}
//# sourceMappingURL=usePatchedProps.js.map
export function usePatchedProps() {
var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var wrappedComponentProps = arguments.length > 1 ? arguments[1] : undefined;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var patchedProps = useMemo(function () {
return Object.keys(createEventMap).reduce(function (p, k) {
var eventCreator = createEventMap[k];
if (!['object', 'function'].includes(_typeof(eventCreator))) {
return p;
}
var propValue = wrappedComponentProps[k];
var wrappedCallback = function wrappedCallback() {
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
propValue.apply(void 0, args.concat([analyticsEvent]));
}
};
return wrappedCallback ? _objectSpread(_objectSpread({}, p), {}, _defineProperty({}, k, wrappedCallback)) : p;
}, {});
}, [createEventMap, wrappedComponentProps, createAnalyticsEvent]);
return {
patchedEventProps: patchedProps
};
}

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

import { __assign } from "tslib";
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; }
import { useCallback } from 'react';

@@ -11,48 +16,52 @@ import { useAnalyticsEvents } from './useAnalyticsEvents';

// or AnalyticsContext component instead.
export function usePlatformLeafEventHandler(_a) {
var fn = _a.fn, action = _a.action, componentName = _a.componentName, packageName = _a.packageName, packageVersion = _a.packageVersion, analyticsData = _a.analyticsData;
var createAnalyticsEvent = useAnalyticsEvents().createAnalyticsEvent;
// We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = useTrackedRef(analyticsData);
var fnRef = useTrackedRef(fn);
var handler = useCallback(function (value) {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion,
},
});
// To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = __assign({ componentName: componentName,
packageName: packageName,
packageVersion: packageVersion }, dataRef.current);
analyticsEvent.context.push(context);
// fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(value, analyticsEvent);
}, [
// These are strings and won't change
action,
componentName,
packageName,
packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef,
fnRef,
]);
return handler;
}
//# sourceMappingURL=usePlatformLeafEventHandler.js.map
export function usePlatformLeafEventHandler(_ref) {
var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = useTrackedRef(analyticsData);
var fnRef = useTrackedRef(fn);
var handler = useCallback(function (value) {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}
}); // To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = _objectSpread({
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}, dataRef.current);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(value, analyticsEvent);
}, [// These are strings and won't change
action, componentName, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}

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

import { __assign } from "tslib";
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; }
import { useCallback } from 'react';

@@ -11,48 +16,52 @@ import { useAnalyticsEvents } from './useAnalyticsEvents';

// or AnalyticsContext component instead.
export function usePlatformLeafSyntheticEventHandler(_a) {
var fn = _a.fn, action = _a.action, componentName = _a.componentName, packageName = _a.packageName, packageVersion = _a.packageVersion, analyticsData = _a.analyticsData;
var createAnalyticsEvent = useAnalyticsEvents().createAnalyticsEvent;
// We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = useTrackedRef(analyticsData);
var fnRef = useTrackedRef(fn);
var handler = useCallback(function () {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion,
},
});
// To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = __assign({ componentName: componentName,
packageName: packageName,
packageVersion: packageVersion }, dataRef.current);
analyticsEvent.context.push(context);
// fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(analyticsEvent);
}, [
// These are strings and won't change
action,
componentName,
packageName,
packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef,
fnRef,
]);
return handler;
}
//# sourceMappingURL=usePlatformLeafSyntheticEventHandler.js.map
export function usePlatformLeafSyntheticEventHandler(_ref) {
var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// memoization.
// Generally these could be defined by consumers inline
// and so we do this to avoid breaking memoization of useCallback
var dataRef = useTrackedRef(analyticsData);
var fnRef = useTrackedRef(fn);
var handler = useCallback(function () {
var analyticsEvent = createAnalyticsEvent({
action: action,
actionSubject: componentName,
attributes: {
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}
}); // To avoid wrapping this component in AnalyticsContext we manually
// push the parent context's meta data into the context.
// Note: this new 'context'
var context = _objectSpread({
componentName: componentName,
packageName: packageName,
packageVersion: packageVersion
}, dataRef.current);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
var clone = analyticsEvent.clone();
if (clone) {
clone.fire('atlaskit');
}
fnRef.current(analyticsEvent);
}, [// These are strings and won't change
action, componentName, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}
import { useEffect, useRef } from 'react';
export var useTrackedRef = function (value) {
var ref = useRef(value);
useEffect(function () {
ref.current = value;
}, [value]);
return ref;
};
//# sourceMappingURL=useTrackedRef.js.map
export var useTrackedRef = function useTrackedRef(value) {
var ref = useRef(value);
useEffect(function () {
ref.current = value;
}, [value]);
return ref;
};

@@ -5,4 +5,4 @@ // Analytics event classes

// AnalyticsListener component
export { default as AnalyticsListener } from './components/AnalyticsListener/index';
// AnalyticsContext component and HOC
export { default as AnalyticsListener } from './components/AnalyticsListener/index'; // AnalyticsContext component and HOC
export { default as AnalyticsContext } from './components/AnalyticsContext/index';

@@ -23,3 +23,2 @@ export { default as withAnalyticsContext } from './hocs/withAnalyticsContext';

export { default as createAndFireEvent } from './utils/createAndFireEvent';
export { default as cleanProps } from './utils/cleanProps';
//# sourceMappingURL=index.js.map
export { default as cleanProps } from './utils/cleanProps';

@@ -1,2 +0,3 @@

import { __awaiter, __generator } from "tslib";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import React, { useCallback } from 'react';

@@ -11,133 +12,182 @@ import { fireEvent } from '@testing-library/react';

import createAndFireEvent from '../utils/createAndFireEvent';
var ButtonWithUsePlatformLeafEventHandlerHook = function (_a) {
var providedOnClick = _a.onClick;
var onClick = usePlatformLeafEventHandler({
fn: providedOnClick,
var ButtonWithUsePlatformLeafEventHandlerHook = function ButtonWithUsePlatformLeafEventHandlerHook(_ref) {
var providedOnClick = _ref.onClick;
var onClick = usePlatformLeafEventHandler({
fn: providedOnClick,
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
action: 'clicked',
analyticsData: {
additionalData: true
}
});
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
};
var ButtonWithUseAnalyticsEventHook = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(function (_ref2) {
var providedOnClick = _ref2.onClick;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var onClick = useCallback(function (mouseEvt) {
var analyticsEvent = createAnalyticsEvent({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
action: 'clicked',
analyticsData: {
additionalData: true,
},
packageVersion: '0.1.0'
}
});
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
};
var ButtonWithUseAnalyticsEventHook = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(function (_a) {
var providedOnClick = _a.onClick;
var createAnalyticsEvent = useAnalyticsEvents().createAnalyticsEvent;
var onClick = useCallback(function (mouseEvt) {
var analyticsEvent = createAnalyticsEvent({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
});
analyticsEvent.fire('atlaskit');
providedOnClick(mouseEvt);
}, [providedOnClick, createAnalyticsEvent]);
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
analyticsEvent.fire('atlaskit');
providedOnClick(mouseEvt);
}, [providedOnClick, createAnalyticsEvent]);
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
});
var ButtonWithUseCallbackWithAnalyticsHook = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
})(function (_a) {
var providedOnClick = _a.onClick;
var onClick = useCallbackWithAnalytics(providedOnClick, {
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
}, 'atlaskit');
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(function (_ref3) {
var providedOnClick = _ref3.onClick;
var onClick = useCallbackWithAnalytics(providedOnClick, {
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0'
}
}, 'atlaskit');
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
});
var ButtonWithHOCs = withAnalyticsContext({
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true,
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
additionalData: true
})(withAnalyticsEvents({
onClick: createAndFireEvent('atlaskit')({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0',
},
}),
})(function (_a) {
var onClick = _a.onClick;
return (React.createElement("button", { onClick: onClick, "data-testid": "button" }, "Click me"));
onClick: createAndFireEvent('atlaskit')({
action: 'clicked',
actionSubject: 'perf-test-button',
attributes: {
componentName: 'perf-test-button',
packageName: '@atlaskit/perf-test-button',
packageVersion: '0.1.0'
}
})
})(function (_ref4) {
var onClick = _ref4.onClick;
return /*#__PURE__*/React.createElement("button", {
onClick: onClick,
"data-testid": "button"
}, "Click me");
}));
var createEventHandler = function () {
var done = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
};
var promise;
var onEvent = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
done(args);
};
var create = function () {
promise = new Promise(function (resolve) {
done = resolve;
});
};
var getPromise = function () { return promise; };
return { onEvent: onEvent, create: create, getPromise: getPromise };
var createEventHandler = function createEventHandler() {
var done = function done() {};
var promise;
var onEvent = function onEvent() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
done(args);
};
var create = function create() {
promise = new Promise(function (resolve) {
done = resolve;
});
};
var getPromise = function getPromise() {
return promise;
};
return {
onEvent: onEvent,
create: create,
getPromise: getPromise
};
};
var eventHandler = createEventHandler();
var WithListener = function (Component) { return function () {
var WithListener = function WithListener(Component) {
return function () {
eventHandler.create();
var onEvent = eventHandler.onEvent;
var onClick = function () { };
return (React.createElement(AnalyticsListener, { channel: "atlaskit", onEvent: onEvent },
React.createElement(Component, { onClick: onClick })));
}; };
var interactionTasks = [
{
name: 'Dispatch event',
description: 'Recording how long it takes to fire and receive an event on the listener',
run: function (_a) {
var container = _a.container;
return __awaiter(void 0, void 0, void 0, function () {
var button;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
button = container.querySelector('button');
if (button == null) {
throw new Error('Could not find button element');
}
fireEvent.click(button);
return [4 /*yield*/, eventHandler.getPromise()];
case 1:
_b.sent();
return [2 /*return*/];
}
});
});
},
},
];
var onClick = function onClick() {};
return /*#__PURE__*/React.createElement(AnalyticsListener, {
channel: "atlaskit",
onEvent: onEvent
}, /*#__PURE__*/React.createElement(Component, {
onClick: onClick
}));
};
};
var interactionTasks = [{
name: 'Dispatch event',
description: 'Recording how long it takes to fire and receive an event on the listener',
run: function () {
var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref5) {
var container, button;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
container = _ref5.container;
button = container.querySelector('button');
if (!(button == null)) {
_context.next = 4;
break;
}
throw new Error('Could not find button element');
case 4:
fireEvent.click(button);
_context.next = 7;
return eventHandler.getPromise();
case 7:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function run(_x) {
return _run.apply(this, arguments);
}
return run;
}()
}];
export var UsePlatformLeafEventHandlerHookTest = WithListener(ButtonWithUsePlatformLeafEventHandlerHook);

@@ -148,34 +198,33 @@ export var UseAnalyticsEventHookTest = WithListener(ButtonWithUseAnalyticsEventHook);

UsePlatformLeafEventHandlerHookTest.story = {
name: 'usePlatformLeafEventHandler based component',
component: UsePlatformLeafEventHandlerHookTest,
parameters: {
performance: {
interactions: interactionTasks,
},
},
name: 'usePlatformLeafEventHandler based component',
component: UsePlatformLeafEventHandlerHookTest,
parameters: {
performance: {
interactions: interactionTasks
}
}
};
UseAnalyticsEventHookTest.story = {
name: 'useAnalyticsEvent based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
name: 'useAnalyticsEvent based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
UseCallbackWithAnalyticsHookTest.story = {
name: 'useCallbackWithAnalytics based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
name: 'useCallbackWithAnalytics based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};
HOCSTest.story = {
name: 'HOC based component',
parameters: {
performance: {
interactions: interactionTasks,
},
},
};
//# sourceMappingURL=examples.js.map
name: 'HOC based component',
parameters: {
performance: {
interactions: interactionTasks
}
}
};

@@ -1,10 +0,9 @@

import { useEffect, useRef } from 'react';
// Hook to track the number of renders in tests
export var useRenderCounter = function () {
var ref = useRef(1);
useEffect(function () {
ref.current++;
});
return ref.current;
};
//# sourceMappingURL=useRenderCounter.js.map
import { useEffect, useRef } from 'react'; // Hook to track the number of renders in tests
export var useRenderCounter = function useRenderCounter() {
var ref = useRef(1);
useEffect(function () {
ref.current++;
});
return ref.current;
};

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

import { __rest } from "tslib";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
export default function cleanProps(props) {
var createAnalyticsEvent = props.createAnalyticsEvent, cleanedProps = __rest(props, ["createAnalyticsEvent"]);
return cleanedProps;
}
//# sourceMappingURL=cleanProps.js.map
var createAnalyticsEvent = props.createAnalyticsEvent,
cleanedProps = _objectWithoutProperties(props, ["createAnalyticsEvent"]);
return cleanedProps;
}

@@ -1,9 +0,14 @@

export default (function (channel) { return function (payload) { return function (createAnalyticsEvent) {
var consumerEvent = createAnalyticsEvent(payload);
var clonedEvent = consumerEvent.clone();
if (clonedEvent) {
export default (function (channel) {
return function (payload) {
return function (createAnalyticsEvent) {
var consumerEvent = createAnalyticsEvent(payload);
var clonedEvent = consumerEvent.clone();
if (clonedEvent) {
clonedEvent.fire(channel);
}
return consumerEvent;
}; }; });
//# sourceMappingURL=createAndFireEvent.js.map
}
return consumerEvent;
};
};
});
{
"name": "@atlaskit/analytics-next",
"version": "8.1.0",
"version": "8.1.1",
"sideEffects": false
}
{
"name": "@atlaskit/analytics-next",
"version": "8.1.0",
"version": "8.1.1",
"description": "React components, HOCs and hooks to assist with tracking user activity with React components",

@@ -43,4 +43,4 @@ "publishConfig": {

"@atlaskit/analytics-next-stable-react-context": "1.0.1",
"@babel/runtime": "^7.0.0",
"prop-types": "^15.5.10",
"tslib": "^2.0.0",
"use-memo-one": "^1.1.1"

@@ -47,0 +47,0 @@ },

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