Repository URL to install this package:
|
Version:
3.2.0 ▾
|
'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');
var _excluded = ["userId"],
_excluded2 = ["path", "referrer", "title", "url"];
/**
* Formats a trackingIntent object to be compatible with Doodle Data Layer API
*
* @see https://ambassador-stg.doodle-test.com/data-layer/docs
* @param {TrackingDefinitionData} trackingData - An object produced by getTrackingDefinition function
* @return {Object}
*/
var mapTrackingDataToDoodleDataLayer = function mapTrackingDataToDoodleDataLayer(_ref) {
var track = _ref.track,
identify = _ref.identify,
page = _ref.page;
if (track) {
var userId = track.userId,
restTrack = _rollupPluginBabelHelpers.objectWithoutProperties(track, _excluded);
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
};
}
if (page) {
var name = page.name,
_page$properties = page.properties,
path = _page$properties.path,
referrer = _page$properties.referrer,
title = _page$properties.title,
url$1 = _page$properties.url,
_properties = _rollupPluginBabelHelpers.objectWithoutProperties(_page$properties, _excluded2);
return {
timestamp: new Date().toISOString(),
name: name,
path: path,
referrer: referrer,
title: title,
url: url$1,
properties: _properties
};
}
throw new TypeError('Please check a valid tracking intent was provided');
};
exports.mapTrackingDataToDoodleDataLayer = mapTrackingDataToDoodleDataLayer;
//# sourceMappingURL=mapper.js.map