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 { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
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}
 */

var mapTrackingDataToDoodleDataLayer = function mapTrackingDataToDoodleDataLayer(_ref) {
  var track = _ref.track,
      identify = _ref.identify;

  if (track) {
    var userId = track.userId,
        restTrack = _objectWithoutProperties(track, ["userId"]);

    return _objectSpread2(_objectSpread2({
      timestamp: new Date().toISOString(),
      user_id: userId,
      type: EVENT_TYPE.userInteraction
    }, getUtmParams()), restTrack);
  }

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

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

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