Repository URL to install this package:
|
Version:
2.0.2 ▾
|
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* Validates tracking calls
*
* @param {TrackingDefinitionData} trackingData The data that needs to be tracked
* @return {Array.<Error>}
*/
var validateTrackingData = function validateTrackingData(_ref) {
var track = _ref.track,
page = _ref.page,
identify = _ref.identify;
var errors = []; // Validate mandatory fields for Track API
if (track) {
if (!track.event) {
errors.push('track.event');
}
if (!track.properties || !track.properties.category) {
errors.push('track.properties.category');
}
} // Validate mandatory fields for Page API
if (page) {
if (!page.name) {
errors.push('page.name');
}
if (!page.properties || !page.properties.path) {
errors.push('page.properties.path');
}
if (!page.properties || !page.properties.title) {
errors.push('page.properties.title');
}
if (!page.properties || !page.properties.url) {
errors.push('page.properties.url');
}
} // Validate mandatory fields for Identify API
if (identify) {
if (identify.userId === undefined) {
errors.push('identify.userId');
}
}
return errors;
};
exports.validateTrackingData = validateTrackingData;
//# sourceMappingURL=validators.js.map