Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ua = require('universal-analytics');
- const bluebird = require('bluebird');
- const GOOGLE_ANALYTICS_ID = require('../../config').googleAnalytics.uid;
- class GoogleAnalytics {
- constructor(uid) {
- this._uid = uid;
- this._visitor = ua(GOOGLE_ANALYTICS_ID, this._uid, { strictCidFormat: false, });
- bluebird.promisifyAll(this._visitor);
- }
- sendEvent(category, action, label) {
- if (!this._visitor) return;
- this._visitor.eventAsync(category, action, label)
- .catch(error => console.error(error));
- }
- }
- module.exports = GoogleAnalytics;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement