UNPKG

owtlab-tracking

Version:
53 lines (42 loc) 1.42 kB
import OwtlabCore from './core'; import { queue } from './utils/queue'; import { setOptOut } from './utils/optOut'; import pkg from '../package.json'; OwtlabCore.helpers = OwtlabCore.helpers || {}; OwtlabCore.prototype.observers = OwtlabCore.observers || {}; // Install internal queue OwtlabCore.on('client', function (client) { client.extensions = { events: [], collections: {}, }; if (!client.config.respectDoNotTrack) { this.doNotTrack = false; } if (typeof client.config.optOut !== 'undefined') { setOptOut(client.config.optOut); this.optedOut = client.config.optOut; } client.queue = queue(client.config.queue); client.queue.on('flush', () => { client.recordDeferredEvents(); }); }); // Accessors OwtlabCore.prototype.client_secret = function (str) { if (!arguments.length) return this.config.client_secret; this.config.client_secret = str ? String(str) : null; return this; }; OwtlabCore.prototype.referrerPolicy = function (str) { if (!arguments.length) return this.config.referrerPolicy; this.config.referrerPolicy = str ? String(str) : null; return this; }; // DEPRECATED OwtlabCore.prototype.setGlobalProperties = function (props) { OwtlabCore.log('This method has been removed. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events'); return this; }; OwtlabCore.version = pkg.version; export default OwtlabCore;