constructor(options) { // Check if `ga` object is available if (typeof SplitToGa.getGa() !== 'function') { log.warn('`ga` command queue not found. No hits will be sent.'); // Return an empty object to avoid creating a SplitToGa instance return {}; } this.trackerNames = SplitToGa.defaultTrackerNames; if (options) { if (typeof options.filter === 'function') this.filter = options.filter; if (typeof options.mapper === 'function') this.mapper = options.mapper; // We strip off duplicated values if we received a `trackerNames` param. // We don't warn if a tracker does not exist, since the user might create it after the SDK is initialized. // Note: GA allows to create and get trackers using a string or number as tracker name, and does nothing if other types are used. if (Array.isArray(options.trackerNames)) this.trackerNames = uniq(options.trackerNames); // No need to validate `impressions` and `events` flags. Any other value than `false` is ignored. this.impressions = options.impressions; this.events = options.events; } log.info('Started Split-to-GA integration'); }
constructor(options) { // Check if `ga` object is available if (typeof SplitToGa.getGa() !== 'function') { log.warn('`ga` command queue not found. No hits will be sent.'); // Return an empty object to avoid creating a SplitToGa instance return {}; } this.trackerNames = SplitToGa.defaultTrackerNames; if (options) { if (typeof options.filter === 'function') this.filter = options.filter; if (typeof options.mapper === 'function') this.mapper = options.mapper; // We strip off duplicated values if we received a `trackerNames` param. // We don't warn if a tracker does not exist, since the user might create it after the SDK is initialized. // Note: GA allows to create and get trackers using a string or number as tracker name, and does nothing if other types are used. if (Array.isArray(options.trackerNames)) this.trackerNames = uniq(options.trackerNames); // No need to validate `impressions` and `events` flags. Any other value than `false` is ignored. this.impressions = options.impressions; this.events = options.events; } log.info('Started Split-to-GA integration'); }