Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
import { EVENT_TYPE } from '../../constants.js';

/**
 * Formats a trackingIntent object to be compatible with Google Analytics tracker API
 *
 * @param {TrackingDefinitionData} trackingData - An object produced by getTrackingDefinition function
 * @return {Object}
 */

var mapTrackingDataToGoogleAnalytics = function mapTrackingDataToGoogleAnalytics(_ref) {
  var track = _ref.track;

  if (track) {
    var eventAction = track.event,
        _track$type = track.type,
        eventCategory = _track$type === void 0 ? EVENT_TYPE.userInteraction : _track$type,
        _track$properties = track.properties,
        _track$properties$cat = _track$properties.category,
        eventPage = _track$properties$cat === void 0 ? '' : _track$properties$cat,
        _track$properties$lab = _track$properties.label,
        eventLabel = _track$properties$lab === void 0 ? '' : _track$properties$lab,
        _track$properties$nam = _track$properties.name,
        eventName = _track$properties$nam === void 0 ? '' : _track$properties$nam,
        _track$properties$val = _track$properties.value,
        eventValue = _track$properties$val === void 0 ? '' : _track$properties$val;
    var destinationData = {
      eventAction: eventAction,
      eventCategory: eventCategory,
      eventLabel: eventLabel,
      eventName: eventName,
      eventValue: eventValue,
      eventPage: eventPage
    };
    return destinationData;
  }

  throw new TypeError('Please check a valid tracking intent was provided');
};

export { mapTrackingDataToGoogleAnalytics };
//# sourceMappingURL=mapper.js.map