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:
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var constants = require('../../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}
 */

const mapTrackingDataToGoogleAnalytics = ({
  track
}) => {
  if (track) {
    const {
      event: eventAction,
      type: eventCategory = constants.EVENT_TYPE.userInteraction,
      context: {
        page: eventPage
      } = {},
      properties: {
        value: eventValue = '',
        label: eventLabel = ''
      }
    } = track;
    const destinationData = {
      eventAction,
      eventCategory,
      eventLabel,
      eventValue,
      eventPage: eventPage && eventPage.name || ''
    };
    return destinationData;
  }

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

exports.mapTrackingDataToGoogleAnalytics = mapTrackingDataToGoogleAnalytics;
//# sourceMappingURL=mapper.js.map