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';
import { getUtmParams } from '../../helpers/url.js';

/**
 * Formats a trackingIntent object to be compatible with Doodle Data Layer track API
 *
 * @param {TrackingDefinitionData} trackingData - An object produced by getTrackingDefinition function
 * @return {Object}
 */

const mapTrackingDataToDoodleDataLayer = ({
  track,
  identify
}) => {
  if (track) {
    const {
      userId,
      ...restTrack
    } = track;
    return {
      timestamp: new Date().toISOString(),
      user_id: userId,
      type: EVENT_TYPE.userInteraction,
      ...getUtmParams(),
      ...restTrack
    };
  }

  if (identify) {
    const {
      userId,
      properties
    } = identify;
    return {
      timestamp: new Date().toISOString(),
      user_id: userId,
      properties
    };
  }

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

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