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 _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
var constants = require('../../constants.js');
var url = require('../../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 = _rollupPluginBabelHelpers.objectWithoutProperties(track, ["userId"]);

    return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({
      timestamp: new Date().toISOString(),
      user_id: userId,
      type: constants.EVENT_TYPE.userInteraction
    }, url.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');
};

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