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.3.5 to 9.0.0

6

CHANGELOG.md
# @atlaskit/analytics-next
## 9.0.0
### Major Changes
- [`cf21f06ff72`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cf21f06ff72) - Bugfix, removed sending event fn and deprecated AnalyticErrorBoundary
## 8.3.5

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

7

dist/cjs/components/AnalyticsContext/index.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,6 @@ value: true

exports.default = void 0;
var _LegacyAnalyticsContext = _interopRequireDefault(require("./LegacyAnalyticsContext"));
var _ModernAnalyticsContext = _interopRequireDefault(require("./ModernAnalyticsContext"));
var _process$env;
var ExportedAnalyticsContext;
if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {

@@ -24,4 +18,3 @@ ExportedAnalyticsContext = _ModernAnalyticsContext.default;

}
var _default = ExportedAnalyticsContext;
exports.default = _default;

32

dist/cjs/components/AnalyticsContext/LegacyAnalyticsContext.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,33 +9,17 @@ 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 _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
var ContextTypes = {

@@ -47,16 +29,12 @@ getAtlaskitAnalyticsContext: _propTypes.default.func,

};
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
};
// 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);

@@ -72,3 +50,3 @@ _this = _super.call(this, props);

var _this$context$getAtla = _this.context.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
getAtlaskitAnalyticsContext = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
return [].concat((0, _toConsumableArray2.default)(getAtlaskitAnalyticsContext()), [data]);

@@ -78,3 +56,3 @@ });

var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsEventHandlers,
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsEventHandlers();

@@ -88,3 +66,2 @@ });

}
(0, _createClass2.default)(AnalyticsContext, [{

@@ -101,3 +78,2 @@ key: "render",

}(_react.Component);
(0, _defineProperty2.default)(AnalyticsContext, "contextTypes", ContextTypes);

@@ -104,0 +80,0 @@ (0, _defineProperty2.default)(AnalyticsContext, "childContextTypes", ContextTypes);

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,20 +9,12 @@ 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");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var AnalyticsContext = function AnalyticsContext(_ref) {
var data = _ref.data,
children = _ref.children;
children = _ref.children;
var dataRef = (0, _useTrackedRef.useTrackedRef)(data);

@@ -45,4 +35,3 @@ var analyticsContext = (0, _useAnalyticsContext.useAnalyticsContext)();

};
var _default = AnalyticsContext;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.BaseAnalyticsErrorBoundary = void 0;
exports.default = 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 _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
/**
* @deprecated
*/
// eslint-disable-next-line @repo/internal/react/no-class-components
var BaseAnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
(0, _inherits2.default)(BaseAnalyticsErrorBoundary, _Component);
var _super = _createSuper(BaseAnalyticsErrorBoundary);
function BaseAnalyticsErrorBoundary(props) {
var AnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
(0, _inherits2.default)(AnalyticsErrorBoundary, _Component);
var _super = _createSuper(AnalyticsErrorBoundary);
function AnalyticsErrorBoundary(props) {
var _this;
(0, _classCallCheck2.default)(this, BaseAnalyticsErrorBoundary);
(0, _classCallCheck2.default)(this, AnalyticsErrorBoundary);
_this = _super.call(this, props);
(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);
});
_this.state = {

@@ -73,12 +36,6 @@ hasError: false

}
(0, _createClass2.default)(BaseAnalyticsErrorBoundary, [{
(0, _createClass2.default)(AnalyticsErrorBoundary, [{
key: "componentDidCatch",
value: function componentDidCatch(error, info) {
var onError = this.props.onError;
var payload = {
error: error,
info: info
};
this.fireAnalytics(payload);
onError && onError(error, info);

@@ -92,14 +49,12 @@ this.setState({

value: function render() {
var _this$props2 = this.props,
data = _this$props2.data,
children = _this$props2.children,
ErrorComponent = _this$props2.ErrorComponent;
var _this$props = this.props,
data = _this$props.data,
children = _this$props.children,
ErrorComponent = _this$props.ErrorComponent;
var hasError = this.state.hasError;
if (hasError && ErrorComponent) {
return /*#__PURE__*/_react.default.createElement(_LegacyAnalyticsContext.default, {
if (hasError) {
return ErrorComponent ? /*#__PURE__*/_react.default.createElement(_LegacyAnalyticsContext.default, {
data: data
}, /*#__PURE__*/_react.default.createElement(ErrorComponent, null));
}, /*#__PURE__*/_react.default.createElement(ErrorComponent, null)) : null;
}
return /*#__PURE__*/_react.default.createElement(_LegacyAnalyticsContext.default, {

@@ -110,8 +65,4 @@ data: data

}]);
return BaseAnalyticsErrorBoundary;
return AnalyticsErrorBoundary;
}(_react.Component);
exports.BaseAnalyticsErrorBoundary = BaseAnalyticsErrorBoundary;
var AnalyticsErrorBoundary = (0, _withAnalyticsEvents.default)()(BaseAnalyticsErrorBoundary);
var _default = AnalyticsErrorBoundary;
exports.default = _default;
exports.default = AnalyticsErrorBoundary;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,6 @@ value: true

exports.default = void 0;
var _LegacyAnalyticsListener = _interopRequireDefault(require("./LegacyAnalyticsListener"));
var _ModernAnalyticsListener = _interopRequireDefault(require("./ModernAnalyticsListener"));
var _process$env;
var ExportedAnalyticsListener;
if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {

@@ -24,4 +18,3 @@ ExportedAnalyticsListener = _ModernAnalyticsListener.default;

}
var _default = ExportedAnalyticsListener;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,33 +9,17 @@ 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 _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
var ContextTypes = {

@@ -47,16 +29,12 @@ getAtlaskitAnalyticsEventHandlers: _propTypes.default.func,

};
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
};
// 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);

@@ -72,7 +50,6 @@ _this = _super.call(this, props);

var _this$props = _this.props,
channel = _this$props.channel,
onEvent = _this$props.onEvent;
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;
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
var handler = function handler(event, eventChannel) {

@@ -83,3 +60,2 @@ if (channel === '*' || channel === eventChannel) {

};
return [handler].concat((0, _toConsumableArray2.default)(getAtlaskitAnalyticsEventHandlers()));

@@ -89,3 +65,3 @@ });

var _this$context$getAtla2 = _this.context.getAtlaskitAnalyticsContext,
getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsContext();

@@ -99,3 +75,2 @@ });

}
(0, _createClass2.default)(AnalyticsListener, [{

@@ -112,3 +87,2 @@ key: "render",

}(_react.Component);
(0, _defineProperty2.default)(AnalyticsListener, "contextTypes", ContextTypes);

@@ -115,0 +89,0 @@ (0, _defineProperty2.default)(AnalyticsListener, "childContextTypes", ContextTypes);

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,21 +9,13 @@ 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");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var AnalyticsListener = function AnalyticsListener(_ref) {
var children = _ref.children,
channel = _ref.channel,
onEvent = _ref.onEvent;
channel = _ref.channel,
onEvent = _ref.onEvent;
var analyticsContext = (0, _useAnalyticsContext.useAnalyticsContext)();

@@ -40,3 +30,2 @@ var onEventRef = (0, _useTrackedRef.useTrackedRef)(onEvent);

};
return [].concat((0, _toConsumableArray2.default)(analyticsContext.getAtlaskitAnalyticsEventHandlers()), [thisHandler]);

@@ -54,4 +43,3 @@ }, [analyticsContext, channelRef, onEventRef]);

};
var _default = AnalyticsListener;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,28 +8,18 @@ value: true

exports.isAnalyticsEvent = 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); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var isAnalyticsEvent = function isAnalyticsEvent(obj) {
var _obj$constructor;
return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) ||
// Backwards compatibility with older analytics-next packages
(obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'AnalyticsEvent';
};
exports.isAnalyticsEvent = isAnalyticsEvent;
var AnalyticsEvent = /*#__PURE__*/function () {
function AnalyticsEvent(props) {
var _this = this;
(0, _classCallCheck2.default)(this, AnalyticsEvent);

@@ -42,3 +31,2 @@ (0, _defineProperty2.default)(this, "_isAnalyticsEvent", true);

var payload = _objectSpread({}, _this.payload);
return new AnalyticsEvent({

@@ -50,3 +38,2 @@ payload: payload

}
(0, _createClass2.default)(AnalyticsEvent, [{

@@ -58,7 +45,5 @@ key: "update",

}
if ((0, _typeof2.default)(updater) === 'object') {
this.payload = _objectSpread(_objectSpread({}, this.payload), updater);
}
return this;

@@ -69,3 +54,2 @@ }

}();
exports.default = AnalyticsEvent;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,44 +8,26 @@ value: true

exports.isUIAnalyticsEvent = 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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
var isUIAnalyticsEvent = function isUIAnalyticsEvent(obj) {
var _obj$constructor;
return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) ||
// Backwards compatibility with older analytics-next packages
(obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'UIAnalyticsEvent';
};
exports.isUIAnalyticsEvent = isUIAnalyticsEvent;
var UIAnalyticsEvent = /*#__PURE__*/function (_AnalyticsEvent) {
(0, _inherits2.default)(UIAnalyticsEvent, _AnalyticsEvent);
var _super = _createSuper(UIAnalyticsEvent);
function UIAnalyticsEvent(props) {
var _this;
(0, _classCallCheck2.default)(this, UIAnalyticsEvent);

@@ -61,8 +42,7 @@ _this = _super.call(this, props);

}
return null;
}
var context = (0, _toConsumableArray2.default)(_this.context);
var handlers = (0, _toConsumableArray2.default)(_this.handlers);
/**

@@ -73,3 +53,2 @@ * A hacky "deep clone" of the object. This is limited in that it wont

*/
var payload = JSON.parse(JSON.stringify(_this.payload));

@@ -88,10 +67,7 @@ return new UIAnalyticsEvent({

}
return;
}
_this.handlers.forEach(function (handler) {
return handler((0, _assertThisInitialized2.default)(_this), channel);
});
_this.hasFired = true;

@@ -104,3 +80,2 @@ });

}
(0, _createClass2.default)(UIAnalyticsEvent, [{

@@ -114,6 +89,4 @@ key: "update",

}
return this;
}
return (0, _get2.default)((0, _getPrototypeOf2.default)(UIAnalyticsEvent.prototype), "update", this).call(this, updater);

@@ -124,3 +97,2 @@ }

}(_AnalyticsEvent2.default);
exports.default = UIAnalyticsEvent;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,23 +9,12 @@ 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"));
var _excluded = ["analyticsContext"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var withAnalyticsContext = function withAnalyticsContext(defaultData) {

@@ -37,3 +24,3 @@ return function (WrappedComponent) {

var analyticsContext = _ref.analyticsContext,
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
var analyticsData = (0, _react.useMemo)(function () {

@@ -47,5 +34,7 @@ return _objectSpread(_objectSpread({}, defaultData), analyticsContext);

})));
}); // @ts-ignore
});
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat( // @ts-ignore disneyName doesn't exist on type
// @ts-ignore
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat(
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");

@@ -55,4 +44,3 @@ return WithAnalyticsContext;

};
var _default = withAnalyticsContext;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,15 +9,8 @@ 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");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var withAnalyticsEvents = function withAnalyticsEvents() {

@@ -30,7 +21,5 @@ var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var _usePatchedProps = (0, _usePatchedProps2.usePatchedProps)(createEventMap, props),
patchedEventProps = _usePatchedProps.patchedEventProps;
patchedEventProps = _usePatchedProps.patchedEventProps;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
return /*#__PURE__*/_react.default.createElement(WrappedComponent, (0, _extends2.default)({}, props, patchedEventProps, {

@@ -40,5 +29,7 @@ createAnalyticsEvent: createAnalyticsEvent,

}));
}); // @ts-ignore
});
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat( // @ts-ignore disneyName doesn't exist on type
// @ts-ignore
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat(
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");

@@ -48,4 +39,3 @@ return WithAnalyticsEvents;

};
var _default = withAnalyticsEvents;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,7 @@ value: true

exports.useAnalyticsContext = void 0;
var _react = require("react");
var _analyticsNextStableReactContext = _interopRequireDefault(require("@atlaskit/analytics-next-stable-react-context"));
var useAnalyticsContext = function useAnalyticsContext() {
return (0, _react.useContext)(_analyticsNextStableReactContext.default);
};
exports.useAnalyticsContext = useAnalyticsContext;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,9 +8,5 @@ value: true

exports.useAnalyticsEvents = useAnalyticsEvents;
var _useMemoOne = require("use-memo-one");
var _UIAnalyticsEvent = _interopRequireDefault(require("../events/UIAnalyticsEvent"));
var _useAnalyticsContext = require("./useAnalyticsContext");
function useAnalyticsEvents() {

@@ -18,0 +13,0 @@ var analyticsContext = (0, _useAnalyticsContext.useAnalyticsContext)();

@@ -7,13 +7,8 @@ "use strict";

exports.useCallbackWithAnalytics = void 0;
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;
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var methodRef = (0, _useTrackedRef.useTrackedRef)(method);

@@ -27,3 +22,2 @@ var payloadRef = (0, _useTrackedRef.useTrackedRef)(payload);

};
exports.useCallbackWithAnalytics = useCallbackWithAnalytics;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,26 +8,18 @@ value: true

exports.usePatchedProps = usePatchedProps;
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); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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;
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var handlerCache = (0, _react.useRef)({});
var patchedProps = (0, _react.useMemo)(function () {
var cache = handlerCache.current; // Clean up no longer used handlers in cache
var cache = handlerCache.current;
// Clean up no longer used handlers in cache
Object.keys(cache).filter(function (key) {

@@ -41,16 +32,11 @@ return !(key in createEventMap);

var eventCreator = createEventMap[k];
if (!['object', 'function'].includes((0, _typeof2.default)(eventCreator))) {
return p;
}
var propValue = wrappedComponentProps[k];
if (k in cache && cache[k].eventCreator === eventCreator && cache[k].propValue === propValue) {
return _objectSpread(_objectSpread({}, p), {}, (0, _defineProperty2.default)({}, k, cache[k].wrappedCallback));
}
var wrappedCallback = function wrappedCallback() {
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {

@@ -60,7 +46,5 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

}
propValue.apply(void 0, args.concat([analyticsEvent]));
}
};
cache[k] = {

@@ -67,0 +51,0 @@ eventCreator: eventCreator,

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,15 +8,8 @@ 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); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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

@@ -31,16 +23,15 @@ // no children inside the component will require analytics themselves.

var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
actionSubject = _ref.actionSubject,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
action = _ref.action,
componentName = _ref.componentName,
actionSubject = _ref.actionSubject,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// 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);

@@ -57,6 +48,7 @@ var fnRef = (0, _useTrackedRef.useTrackedRef)(fn);

}
}); // To avoid wrapping this component in AnalyticsContext we manually
});
// 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({

@@ -67,17 +59,18 @@ componentName: componentName,

}, dataRef.current);
analyticsEvent.context.push(context);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
// 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, actionSubject, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
}, [
// These are strings and won't change
action, componentName, actionSubject, 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";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,15 +8,8 @@ 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); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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

@@ -31,15 +23,14 @@ // no children inside the component will require analytics themselves.

var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// 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);

@@ -56,6 +47,7 @@ var fnRef = (0, _useTrackedRef.useTrackedRef)(fn);

}
}); // To avoid wrapping this component in AnalyticsContext we manually
});
// 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({

@@ -66,17 +58,18 @@ componentName: componentName,

}, dataRef.current);
analyticsEvent.context.push(context);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
// 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
}, [
// 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;
}

@@ -7,5 +7,3 @@ "use strict";

exports.useTrackedRef = void 0;
var _react = require("react");
var useTrackedRef = function useTrackedRef(value) {

@@ -18,3 +16,2 @@ var ref = (0, _react.useRef)(value);

};
exports.useTrackedRef = useTrackedRef;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -106,33 +104,17 @@ value: true

});
var _AnalyticsEvent = _interopRequireWildcard(require("./events/AnalyticsEvent"));
var _UIAnalyticsEvent = _interopRequireWildcard(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"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -7,5 +7,3 @@ "use strict";

exports.useRenderCounter = void 0;
var _react = require("react");
// Hook to track the number of renders in tests

@@ -19,3 +17,2 @@ var useRenderCounter = function useRenderCounter() {

};
exports.useRenderCounter = useRenderCounter;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,8 @@ value: true

exports.default = cleanProps;
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _excluded = ["createAnalyticsEvent"];
function cleanProps(props) {
var createAnalyticsEvent = props.createAnalyticsEvent,
cleanedProps = (0, _objectWithoutProperties2.default)(props, _excluded);
cleanedProps = (0, _objectWithoutProperties2.default)(props, _excluded);
return cleanedProps;
}

@@ -7,3 +7,2 @@ "use strict";

exports.default = void 0;
var _default = function _default(channel) {

@@ -14,7 +13,5 @@ return function (payload) {

var clonedEvent = consumerEvent.clone();
if (clonedEvent) {
clonedEvent.fire(channel);
}
return consumerEvent;

@@ -24,3 +21,2 @@ };

};
exports.default = _default;
{
"name": "@atlaskit/analytics-next",
"version": "8.3.5",
"version": "9.0.0",
"sideEffects": false
}
var _process$env;
import LegacyAnalyticsContext from './LegacyAnalyticsContext';
import ModernAnalyticsContext from './ModernAnalyticsContext';
let ExportedAnalyticsContext;
if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {

@@ -12,3 +10,2 @@ ExportedAnalyticsContext = ModernAnalyticsContext;

}
export default ExportedAnalyticsContext;

@@ -9,14 +9,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

};
const noop = () => [];
const noop = () => []; // eslint-disable-next-line @repo/internal/react/no-class-components
// eslint-disable-next-line @repo/internal/react/no-class-components
class AnalyticsContext extends Component {
constructor(props) {
super(props);
_defineProperty(this, "getChildContext", () => ({
getAtlaskitAnalyticsContext: this.getAnalyticsContext
}));
_defineProperty(this, "getAnalyticsContext", () => {

@@ -31,3 +28,2 @@ const {

});
_defineProperty(this, "getAnalyticsEventHandlers", () => {

@@ -39,3 +35,2 @@ const {

});
this.contextValue = {

@@ -46,3 +41,2 @@ getAtlaskitAnalyticsContext: this.getAnalyticsContext,

}
render() {

@@ -56,9 +50,5 @@ const {

}
}
_defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
_defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
export default AnalyticsContext;

@@ -5,3 +5,2 @@ import React, { useCallback, useMemo } from 'react';

import { useTrackedRef } from '../../hooks/useTrackedRef';
const AnalyticsContext = ({

@@ -24,3 +23,2 @@ data,

};
export default AnalyticsContext;

@@ -1,27 +0,10 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';
import withAnalyticsEvents from '../hocs/withAnalyticsEvents';
import AnalyticsContext from './AnalyticsContext/LegacyAnalyticsContext';
/**
* @deprecated
*/
// eslint-disable-next-line @repo/internal/react/no-class-components
export class BaseAnalyticsErrorBoundary extends Component {
export default class AnalyticsErrorBoundary extends Component {
constructor(props) {
super(props);
_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);
});
this.state = {

@@ -31,3 +14,2 @@ hasError: false

}
componentDidCatch(error, info) {

@@ -37,7 +19,2 @@ const {

} = this.props;
const payload = {
error,
info
};
this.fireAnalytics(payload);
onError && onError(error, info);

@@ -48,3 +25,2 @@ this.setState({

}
render() {

@@ -59,9 +35,7 @@ const {

} = this.state;
if (hasError && ErrorComponent) {
return /*#__PURE__*/React.createElement(AnalyticsContext, {
if (hasError) {
return ErrorComponent ? /*#__PURE__*/React.createElement(AnalyticsContext, {
data: data
}, /*#__PURE__*/React.createElement(ErrorComponent, null));
}, /*#__PURE__*/React.createElement(ErrorComponent, null)) : null;
}
return /*#__PURE__*/React.createElement(AnalyticsContext, {

@@ -71,5 +45,2 @@ data: data

}
}
const AnalyticsErrorBoundary = withAnalyticsEvents()(BaseAnalyticsErrorBoundary);
export default AnalyticsErrorBoundary;
}
var _process$env;
import LegacyAnalyticsListener from './LegacyAnalyticsListener';
import ModernAnalyticsListener from './ModernAnalyticsListener';
let ExportedAnalyticsListener;
if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {

@@ -12,3 +10,2 @@ ExportedAnalyticsListener = ModernAnalyticsListener;

}
export default ExportedAnalyticsListener;

@@ -9,10 +9,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

};
const noop = () => [];
const noop = () => []; // eslint-disable-next-line @repo/internal/react/no-class-components
// eslint-disable-next-line @repo/internal/react/no-class-components
class AnalyticsListener extends Component {
constructor(props) {
super(props);
_defineProperty(this, "getChildContext", () => ({

@@ -22,3 +20,2 @@ getAtlaskitAnalyticsEventHandlers: this.getAnalyticsEventHandlers,

}));
_defineProperty(this, "getAnalyticsEventHandlers", () => {

@@ -32,3 +29,2 @@ const {

} = this.context;
const handler = (event, eventChannel) => {

@@ -39,6 +35,4 @@ if (channel === '*' || channel === eventChannel) {

};
return [handler, ...getAtlaskitAnalyticsEventHandlers()];
});
_defineProperty(this, "getAtlaskitAnalyticsContext", () => {

@@ -50,3 +44,2 @@ const {

});
this.contextValue = {

@@ -57,3 +50,2 @@ getAtlaskitAnalyticsContext: this.getAtlaskitAnalyticsContext,

}
render() {

@@ -67,9 +59,5 @@ const {

}
}
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
export default AnalyticsListener;

@@ -5,3 +5,2 @@ import React, { useCallback, useMemo } from 'react';

import { useTrackedRef } from '../../hooks/useTrackedRef';
const AnalyticsListener = ({

@@ -21,3 +20,2 @@ children,

};
return [...analyticsContext.getAtlaskitAnalyticsEventHandlers(), thisHandler];

@@ -35,3 +33,2 @@ }, [analyticsContext, channelRef, onEventRef]);

};
export default AnalyticsListener;
import _defineProperty from "@babel/runtime/helpers/defineProperty";
export const isAnalyticsEvent = obj => {
var _obj$constructor;
return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) ||
// Backwards compatibility with older analytics-next packages
(obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'AnalyticsEvent';

@@ -11,7 +11,7 @@ };

_defineProperty(this, "_isAnalyticsEvent", true);
_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
const payload = {
...this.payload
};

@@ -22,6 +22,4 @@ return new AnalyticsEvent({

});
this.payload = props.payload;
}
update(updater) {

@@ -31,12 +29,10 @@ if (typeof updater === 'function') {

}
if (typeof updater === 'object') {
this.payload = { ...this.payload,
this.payload = {
...this.payload,
...updater
};
}
return this;
}
}

@@ -5,4 +5,4 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

var _obj$constructor;
return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) ||
// Backwards compatibility with older analytics-next packages
(obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'UIAnalyticsEvent';

@@ -13,5 +13,3 @@ };

super(props);
_defineProperty(this, "_isUIAnalyticsEvent", true);
_defineProperty(this, "clone", () => {

@@ -23,8 +21,7 @@ if (this.hasFired) {

}
return null;
}
const context = [...this.context];
const handlers = [...this.handlers];
/**

@@ -35,3 +32,2 @@ * A hacky "deep clone" of the object. This is limited in that it wont

*/
const payload = JSON.parse(JSON.stringify(this.payload));

@@ -44,3 +40,2 @@ return new UIAnalyticsEvent({

});
_defineProperty(this, "fire", channel => {

@@ -52,10 +47,7 @@ if (this.hasFired) {

}
return;
}
this.handlers.forEach(handler => handler(this, channel));
this.hasFired = true;
});
this.context = props.context || [];

@@ -65,3 +57,2 @@ this.handlers = props.handlers || [];

}
update(updater) {

@@ -73,9 +64,6 @@ if (this.hasFired) {

}
return this;
}
return super.update(updater);
}
}
import _extends from "@babel/runtime/helpers/extends";
import React, { forwardRef, useMemo } from 'react';
import AnalyticsContext from '../components/AnalyticsContext';
const withAnalyticsContext = defaultData => WrappedComponent => {

@@ -10,3 +9,4 @@ const WithAnalyticsContext = /*#__PURE__*/forwardRef(({

}, ref) => {
const analyticsData = useMemo(() => ({ ...defaultData,
const analyticsData = useMemo(() => ({
...defaultData,
...analyticsContext

@@ -19,9 +19,10 @@ }), [analyticsContext]);

})));
}); // @ts-ignore
});
WithAnalyticsContext.displayName = `WithAnalyticsContext(${// @ts-ignore disneyName doesn't exist on type
// @ts-ignore
WithAnalyticsContext.displayName = `WithAnalyticsContext(${
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name})`;
return WithAnalyticsContext;
};
export default withAnalyticsContext;

@@ -5,3 +5,2 @@ import _extends from "@babel/runtime/helpers/extends";

import { usePatchedProps } from '../hooks/usePatchedProps';
const withAnalyticsEvents = (createEventMap = {}) => WrappedComponent => {

@@ -19,9 +18,10 @@ const WithAnalyticsEvents = /*#__PURE__*/forwardRef((props, ref) => {

}));
}); // @ts-ignore
});
WithAnalyticsEvents.displayName = `WithAnalyticsEvents(${// @ts-ignore disneyName doesn't exist on type
// @ts-ignore
WithAnalyticsEvents.displayName = `WithAnalyticsEvents(${
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name})`;
return WithAnalyticsEvents;
};
export default withAnalyticsEvents;

@@ -9,23 +9,20 @@ import { useMemo, useRef } from 'react';

const patchedProps = useMemo(() => {
const cache = handlerCache.current; // Clean up no longer used handlers in cache
const cache = handlerCache.current;
// Clean up no longer used handlers in cache
Object.keys(cache).filter(key => !(key in createEventMap)).forEach(key => delete cache[key]);
return Object.keys(createEventMap).reduce((p, k) => {
const eventCreator = createEventMap[k];
if (!['object', 'function'].includes(typeof eventCreator)) {
return p;
}
const propValue = wrappedComponentProps[k];
if (k in cache && cache[k].eventCreator === eventCreator && cache[k].propValue === propValue) {
return { ...p,
return {
...p,
[k]: cache[k].wrappedCallback
};
}
const wrappedCallback = (...args) => {
const analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {

@@ -35,3 +32,2 @@ propValue(...args, analyticsEvent);

};
cache[k] = {

@@ -42,3 +38,4 @@ eventCreator,

};
return { ...p,
return {
...p,
[k]: wrappedCallback

@@ -45,0 +42,0 @@ };

@@ -21,7 +21,8 @@ import { useCallback } from 'react';

createAnalyticsEvent
} = useAnalyticsEvents(); // We put analyticsData and fn in a ref so that we don't need to break
} = 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);

@@ -38,6 +39,7 @@ const fnRef = useTrackedRef(fn);

}
}); // To avoid wrapping this component in AnalyticsContext we manually
});
// 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 = {

@@ -49,16 +51,18 @@ componentName,

};
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
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, actionSubject, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
}, [
// These are strings and won't change
action, componentName, actionSubject, packageName, packageVersion,
// This function is memoized in the context
createAnalyticsEvent,
// these are a stable ref because of the useTrackedRef hook
dataRef, fnRef]);
return handler;
}

@@ -20,7 +20,8 @@ import { useCallback } from 'react';

createAnalyticsEvent
} = useAnalyticsEvents(); // We put analyticsData and fn in a ref so that we don't need to break
} = 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);

@@ -37,6 +38,7 @@ const fnRef = useTrackedRef(fn);

}
}); // To avoid wrapping this component in AnalyticsContext we manually
});
// 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 = {

@@ -48,16 +50,18 @@ componentName,

};
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
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
}, [
// 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;
}

@@ -5,4 +5,5 @@ // 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';

@@ -9,0 +10,0 @@ export { default as withAnalyticsContext } from './hocs/withAnalyticsContext';

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

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 = () => {

@@ -4,0 +5,0 @@ const ref = useRef(1);

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.3.5",
"version": "9.0.0",
"sideEffects": false
}
var _process$env;
import LegacyAnalyticsContext from './LegacyAnalyticsContext';
import ModernAnalyticsContext from './ModernAnalyticsContext';
var ExportedAnalyticsContext;
if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {

@@ -12,3 +10,2 @@ ExportedAnalyticsContext = ModernAnalyticsContext;

}
export default ExportedAnalyticsContext;

@@ -9,7 +9,4 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React, { Component } from 'react';

@@ -22,20 +19,14 @@ import PropTypes from 'prop-types';

};
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
};
// 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 () {

@@ -46,16 +37,13 @@ return {

});
_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;
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;
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsEventHandlers();
});
_this.contextValue = {

@@ -67,3 +55,2 @@ getAtlaskitAnalyticsContext: _this.getAnalyticsContext,

}
_createClass(AnalyticsContext, [{

@@ -78,10 +65,6 @@ key: "render",

}]);
return AnalyticsContext;
}(Component);
_defineProperty(AnalyticsContext, "contextTypes", ContextTypes);
_defineProperty(AnalyticsContext, "childContextTypes", ContextTypes);
export default AnalyticsContext;

@@ -6,6 +6,5 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

import { useTrackedRef } from '../../hooks/useTrackedRef';
var AnalyticsContext = function AnalyticsContext(_ref) {
var data = _ref.data,
children = _ref.children;
children = _ref.children;
var dataRef = useTrackedRef(data);

@@ -26,3 +25,2 @@ var analyticsContext = useAnalyticsContext();

};
export default AnalyticsContext;
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); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React, { Component } from 'react';
import withAnalyticsEvents from '../hocs/withAnalyticsEvents';
import AnalyticsContext from './AnalyticsContext/LegacyAnalyticsContext';
/**
* @deprecated
*/
// eslint-disable-next-line @repo/internal/react/no-class-components
export var BaseAnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
_inherits(BaseAnalyticsErrorBoundary, _Component);
var _super = _createSuper(BaseAnalyticsErrorBoundary);
function BaseAnalyticsErrorBoundary(props) {
var AnalyticsErrorBoundary = /*#__PURE__*/function (_Component) {
_inherits(AnalyticsErrorBoundary, _Component);
var _super = _createSuper(AnalyticsErrorBoundary);
function AnalyticsErrorBoundary(props) {
var _this;
_classCallCheck(this, BaseAnalyticsErrorBoundary);
_classCallCheck(this, AnalyticsErrorBoundary);
_this = _super.call(this, props);
_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);
});
_this.state = {

@@ -52,12 +26,6 @@ hasError: false

}
_createClass(BaseAnalyticsErrorBoundary, [{
_createClass(AnalyticsErrorBoundary, [{
key: "componentDidCatch",
value: function componentDidCatch(error, info) {
var onError = this.props.onError;
var payload = {
error: error,
info: info
};
this.fireAnalytics(payload);
onError && onError(error, info);

@@ -71,14 +39,12 @@ this.setState({

value: function render() {
var _this$props2 = this.props,
data = _this$props2.data,
children = _this$props2.children,
ErrorComponent = _this$props2.ErrorComponent;
var _this$props = this.props,
data = _this$props.data,
children = _this$props.children,
ErrorComponent = _this$props.ErrorComponent;
var hasError = this.state.hasError;
if (hasError && ErrorComponent) {
return /*#__PURE__*/React.createElement(AnalyticsContext, {
if (hasError) {
return ErrorComponent ? /*#__PURE__*/React.createElement(AnalyticsContext, {
data: data
}, /*#__PURE__*/React.createElement(ErrorComponent, null));
}, /*#__PURE__*/React.createElement(ErrorComponent, null)) : null;
}
return /*#__PURE__*/React.createElement(AnalyticsContext, {

@@ -89,6 +55,4 @@ data: data

}]);
return BaseAnalyticsErrorBoundary;
return AnalyticsErrorBoundary;
}(Component);
var AnalyticsErrorBoundary = withAnalyticsEvents()(BaseAnalyticsErrorBoundary);
export default AnalyticsErrorBoundary;
export { AnalyticsErrorBoundary as default };
var _process$env;
import LegacyAnalyticsListener from './LegacyAnalyticsListener';
import ModernAnalyticsListener from './ModernAnalyticsListener';
var ExportedAnalyticsListener;
if (typeof process !== 'undefined' && process !== null && (_process$env = process.env) !== null && _process$env !== void 0 && _process$env['ANALYTICS_NEXT_MODERN_CONTEXT']) {

@@ -12,3 +10,2 @@ ExportedAnalyticsListener = ModernAnalyticsListener;

}
export default ExportedAnalyticsListener;

@@ -9,7 +9,4 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React, { Component } from 'react';

@@ -22,20 +19,14 @@ import PropTypes from 'prop-types';

};
var noop = function noop() {
return [];
}; // eslint-disable-next-line @repo/internal/react/no-class-components
};
// 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 () {

@@ -47,10 +38,8 @@ return {

});
_defineProperty(_assertThisInitialized(_this), "getAnalyticsEventHandlers", function () {
var _this$props = _this.props,
channel = _this$props.channel,
onEvent = _this$props.onEvent;
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;
getAtlaskitAnalyticsEventHandlers = _this$context$getAtla === void 0 ? noop : _this$context$getAtla;
var handler = function handler(event, eventChannel) {

@@ -61,12 +50,9 @@ if (channel === '*' || channel === 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;
getAtlaskitAnalyticsContext = _this$context$getAtla2 === void 0 ? noop : _this$context$getAtla2;
return getAtlaskitAnalyticsContext();
});
_this.contextValue = {

@@ -78,3 +64,2 @@ getAtlaskitAnalyticsContext: _this.getAtlaskitAnalyticsContext,

}
_createClass(AnalyticsListener, [{

@@ -89,10 +74,6 @@ key: "render",

}]);
return AnalyticsListener;
}(Component);
_defineProperty(AnalyticsListener, "contextTypes", ContextTypes);
_defineProperty(AnalyticsListener, "childContextTypes", ContextTypes);
export default AnalyticsListener;

@@ -6,7 +6,6 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

import { useTrackedRef } from '../../hooks/useTrackedRef';
var AnalyticsListener = function AnalyticsListener(_ref) {
var children = _ref.children,
channel = _ref.channel,
onEvent = _ref.onEvent;
channel = _ref.channel,
onEvent = _ref.onEvent;
var analyticsContext = useAnalyticsContext();

@@ -21,3 +20,2 @@ var onEventRef = useTrackedRef(onEvent);

};
return [].concat(_toConsumableArray(analyticsContext.getAtlaskitAnalyticsEventHandlers()), [thisHandler]);

@@ -35,3 +33,2 @@ }, [analyticsContext, channelRef, onEventRef]);

};
export default AnalyticsListener;

@@ -5,22 +5,15 @@ import _typeof from "@babel/runtime/helpers/typeof";

import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
export var isAnalyticsEvent = function isAnalyticsEvent(obj) {
var _obj$constructor;
return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
return obj instanceof AnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isAnalyticsEvent) ||
// Backwards compatibility with older analytics-next packages
(obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'AnalyticsEvent';
};
var AnalyticsEvent = /*#__PURE__*/function () {
function AnalyticsEvent(props) {
var _this = this;
_classCallCheck(this, AnalyticsEvent);
_defineProperty(this, "_isAnalyticsEvent", true);
_defineProperty(this, "clone", function () {

@@ -30,3 +23,2 @@ // just a shallow clone, don't change sub refs unless you want to

var payload = _objectSpread({}, _this.payload);
return new AnalyticsEvent({

@@ -36,6 +28,4 @@ payload: payload

});
this.payload = props.payload;
}
_createClass(AnalyticsEvent, [{

@@ -47,14 +37,10 @@ key: "update",

}
if (_typeof(updater) === 'object') {
this.payload = _objectSpread(_objectSpread({}, this.payload), updater);
}
return this;
}
}]);
return AnalyticsEvent;
}();
export { AnalyticsEvent as default };

@@ -10,29 +10,19 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import AnalyticsEvent from './AnalyticsEvent';
export var isUIAnalyticsEvent = function isUIAnalyticsEvent(obj) {
var _obj$constructor;
return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) || // Backwards compatibility with older analytics-next packages
return obj instanceof UIAnalyticsEvent || !!(obj !== null && obj !== void 0 && obj._isUIAnalyticsEvent) ||
// Backwards compatibility with older analytics-next packages
(obj === null || obj === void 0 ? void 0 : (_obj$constructor = obj.constructor) === null || _obj$constructor === void 0 ? void 0 : _obj$constructor.name) === 'UIAnalyticsEvent';
};
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), "_isUIAnalyticsEvent", true);
_defineProperty(_assertThisInitialized(_this), "clone", function () {

@@ -44,9 +34,7 @@ if (_this.hasFired) {

}
return null;
}
var context = _toConsumableArray(_this.context);
var handlers = _toConsumableArray(_this.handlers);
var handlers = _toConsumableArray(_this.handlers);
/**

@@ -57,4 +45,2 @@ * A hacky "deep clone" of the object. This is limited in that it wont

*/
var payload = JSON.parse(JSON.stringify(_this.payload));

@@ -67,3 +53,2 @@ return new UIAnalyticsEvent({

});
_defineProperty(_assertThisInitialized(_this), "fire", function (channel) {

@@ -75,13 +60,9 @@ if (_this.hasFired) {

}
return;
}
_this.handlers.forEach(function (handler) {
return handler(_assertThisInitialized(_this), channel);
});
_this.hasFired = true;
});
_this.context = props.context || [];

@@ -92,3 +73,2 @@ _this.handlers = props.handlers || [];

}
_createClass(UIAnalyticsEvent, [{

@@ -102,13 +82,9 @@ key: "update",

}
return this;
}
return _get(_getPrototypeOf(UIAnalyticsEvent.prototype), "update", this).call(this, updater);
}
}]);
return UIAnalyticsEvent;
}(AnalyticsEvent);
export { UIAnalyticsEvent as default };

@@ -5,10 +5,6 @@ import _extends from "@babel/runtime/helpers/extends";

var _excluded = ["analyticsContext"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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 withAnalyticsContext(defaultData) {

@@ -18,4 +14,3 @@ return function (WrappedComponent) {

var analyticsContext = _ref.analyticsContext,
rest = _objectWithoutProperties(_ref, _excluded);
rest = _objectWithoutProperties(_ref, _excluded);
var analyticsData = useMemo(function () {

@@ -29,5 +24,7 @@ return _objectSpread(_objectSpread({}, defaultData), analyticsContext);

})));
}); // @ts-ignore
});
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat( // @ts-ignore disneyName doesn't exist on type
// @ts-ignore
WithAnalyticsContext.displayName = "WithAnalyticsContext(".concat(
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");

@@ -37,3 +34,2 @@ return WithAnalyticsContext;

};
export default withAnalyticsContext;

@@ -5,3 +5,2 @@ import _extends from "@babel/runtime/helpers/extends";

import { usePatchedProps } from '../hooks/usePatchedProps';
var withAnalyticsEvents = function withAnalyticsEvents() {

@@ -12,7 +11,5 @@ var createEventMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var _usePatchedProps = usePatchedProps(createEventMap, props),
patchedEventProps = _usePatchedProps.patchedEventProps;
patchedEventProps = _usePatchedProps.patchedEventProps;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, patchedEventProps, {

@@ -22,5 +19,7 @@ createAnalyticsEvent: createAnalyticsEvent,

}));
}); // @ts-ignore
});
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat( // @ts-ignore disneyName doesn't exist on type
// @ts-ignore
WithAnalyticsEvents.displayName = "WithAnalyticsEvents(".concat(
// @ts-ignore disneyName doesn't exist on type
WrappedComponent.displayName || WrappedComponent.name, ")");

@@ -30,3 +29,2 @@ return WithAnalyticsEvents;

};
export default withAnalyticsEvents;

@@ -6,4 +6,3 @@ import { useCallback } from 'react';

var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var methodRef = useTrackedRef(method);

@@ -10,0 +9,0 @@ var payloadRef = useTrackedRef(payload);

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); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
import { useMemo, useRef } from 'react';

@@ -13,10 +10,9 @@ import { useAnalyticsEvents } from './useAnalyticsEvents';

var wrappedComponentProps = arguments.length > 1 ? arguments[1] : undefined;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var handlerCache = useRef({});
var patchedProps = useMemo(function () {
var cache = handlerCache.current; // Clean up no longer used handlers in cache
var cache = handlerCache.current;
// Clean up no longer used handlers in cache
Object.keys(cache).filter(function (key) {

@@ -29,16 +25,11 @@ return !(key in createEventMap);

var eventCreator = createEventMap[k];
if (!['object', 'function'].includes(_typeof(eventCreator))) {
return p;
}
var propValue = wrappedComponentProps[k];
if (k in cache && cache[k].eventCreator === eventCreator && cache[k].propValue === propValue) {
return _objectSpread(_objectSpread({}, p), {}, _defineProperty({}, k, cache[k].wrappedCallback));
}
var wrappedCallback = function wrappedCallback() {
var analyticsEvent = typeof eventCreator === 'function' ? eventCreator(createAnalyticsEvent, wrappedComponentProps) : createAnalyticsEvent(eventCreator);
if (propValue && typeof propValue === 'function') {

@@ -48,7 +39,5 @@ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

}
propValue.apply(void 0, args.concat([analyticsEvent]));
}
};
cache[k] = {

@@ -55,0 +44,0 @@ eventCreator: eventCreator,

import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
import { useCallback } from 'react';

@@ -18,16 +15,15 @@ import { useAnalyticsEvents } from './useAnalyticsEvents';

var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
actionSubject = _ref.actionSubject,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
action = _ref.action,
componentName = _ref.componentName,
actionSubject = _ref.actionSubject,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// 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);

@@ -44,6 +40,7 @@ var fnRef = useTrackedRef(fn);

}
}); // To avoid wrapping this component in AnalyticsContext we manually
});
// 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({

@@ -54,17 +51,18 @@ componentName: componentName,

}, dataRef.current);
analyticsEvent.context.push(context);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
// 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, actionSubject, packageName, packageVersion, // This function is memoized in the context
createAnalyticsEvent, // these are a stable ref because of the useTrackedRef hook
}, [
// These are strings and won't change
action, componentName, actionSubject, 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 _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
import { useCallback } from 'react';

@@ -18,15 +15,14 @@ import { useAnalyticsEvents } from './useAnalyticsEvents';

var fn = _ref.fn,
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
action = _ref.action,
componentName = _ref.componentName,
packageName = _ref.packageName,
packageVersion = _ref.packageVersion,
analyticsData = _ref.analyticsData;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
var _useAnalyticsEvents = useAnalyticsEvents(),
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent; // We put analyticsData and fn in a ref so that we don't need to break
// 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);

@@ -43,6 +39,7 @@ var fnRef = useTrackedRef(fn);

}
}); // To avoid wrapping this component in AnalyticsContext we manually
});
// 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({

@@ -53,17 +50,18 @@ componentName: componentName,

}, dataRef.current);
analyticsEvent.context.push(context);
analyticsEvent.context.push(context); // fire an event on the atlaskit channel
// 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
}, [
// 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;
}

@@ -5,4 +5,5 @@ // 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';

@@ -9,0 +10,0 @@ export { default as withAnalyticsContext } from './hocs/withAnalyticsContext';

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

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 var useRenderCounter = function useRenderCounter() {

@@ -4,0 +5,0 @@ var ref = useRef(1);

@@ -5,5 +5,4 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

var createAnalyticsEvent = props.createAnalyticsEvent,
cleanedProps = _objectWithoutProperties(props, _excluded);
cleanedProps = _objectWithoutProperties(props, _excluded);
return cleanedProps;
}

@@ -6,7 +6,5 @@ export default (function (channel) {

var clonedEvent = consumerEvent.clone();
if (clonedEvent) {
clonedEvent.fire(channel);
}
return consumerEvent;

@@ -13,0 +11,0 @@ };

{
"name": "@atlaskit/analytics-next",
"version": "8.3.5",
"version": "9.0.0",
"sideEffects": false
}
import React, { Component, ReactNode } from 'react';
import { WithAnalyticsEventsProps } from '../hocs/withAnalyticsEvents';
declare type AnalyticsErrorBoundaryErrorInfo = {
componentStack: string;
};
export interface AnalyticsErrorBoundaryProps extends WithAnalyticsEventsProps {
export interface AnalyticsErrorBoundaryProps {
/** React component to be wrapped */

@@ -14,17 +13,13 @@ children: ReactNode;

}
declare type AnalyticsErrorBoundaryPayload = {
error: Error | string;
info?: AnalyticsErrorBoundaryErrorInfo;
[key: string]: any;
};
declare type AnalyticsErrorBoundaryState = {
hasError: boolean;
};
export declare class BaseAnalyticsErrorBoundary extends Component<AnalyticsErrorBoundaryProps, AnalyticsErrorBoundaryState> {
/**
* @deprecated
*/
export default class AnalyticsErrorBoundary extends Component<AnalyticsErrorBoundaryProps, AnalyticsErrorBoundaryState> {
constructor(props: AnalyticsErrorBoundaryProps);
fireAnalytics: (analyticsErrorPayload: AnalyticsErrorBoundaryPayload) => void;
componentDidCatch(error: Error, info?: AnalyticsErrorBoundaryErrorInfo): void;
render(): JSX.Element;
render(): JSX.Element | null;
}
declare const AnalyticsErrorBoundary: React.ForwardRefExoticComponent<Omit<AnalyticsErrorBoundaryProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
export default AnalyticsErrorBoundary;
export {};
{
"name": "@atlaskit/analytics-next",
"version": "8.3.5",
"version": "9.0.0",
"description": "React components, HOCs and hooks to assist with tracking user activity with React components",

@@ -15,10 +15,2 @@ "publishConfig": {

"types": "dist/types/index.d.ts",
"typesVersions": {
">=4.0 <4.5": {
"*": [
"dist/types-ts4.0/*",
"dist/types-ts4.0/index.d.ts"
]
}
},
"sideEffects": false,

@@ -60,3 +52,3 @@ "atlaskit:src": "src/index.ts",

"devDependencies": {
"@atlaskit/button": "^16.3.0",
"@atlaskit/button": "^16.5.0",
"@atlaskit/docs": "*",

@@ -84,2 +76,5 @@ "@atlaskit/ssr": "*",

],
"design-tokens": [
"color"
],
"theming": [

@@ -86,0 +81,0 @@ "react-context"

Sorry, the diff of this file is too big to display

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