Repository URL to install this package:
|
Version:
1.4.3 ▾
|
import { objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
import { isUndefined } from '../helpers/utils.js';
/**
* Returns an object with tracking-related data attributes to be spread over a JSX element
*
* @param {TrackingIntent} trackingIntent An object that holds the values that should be tracked
* @return {Object} An object with data attributes as keys
*/
var getTrackingDataAttrs = function getTrackingDataAttrs(_ref) {
var track = _ref.track,
identify = _ref.identify,
page = _ref.page,
_ref$options = _ref.options;
_ref$options = _ref$options === void 0 ? {} : _ref$options;
var services = _ref$options.services,
setOnce = _ref$options.setOnce,
autoTracking = _ref$options.autoTracking;
var trackingOptions = _objectSpread2(_objectSpread2(_objectSpread2({}, !isUndefined(services) && {
services: services
}), !isUndefined(setOnce) && {
setOnce: setOnce
}), !isUndefined(autoTracking) && {
autoTracking: autoTracking
});
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, trackingOptions && {
'data-tracking-options': JSON.stringify(trackingOptions)
}), track && {
'data-track': JSON.stringify(track)
}), identify && {
'data-identify': JSON.stringify(identify)
}), page && {
'data-page': JSON.stringify(page)
});
};
export { getTrackingDataAttrs };
//# sourceMappingURL=getTrackingDataAttrs.js.map