Created
June 27, 2017 06:55
-
-
Save MaksimAbramchuk/e0de6350c319d1f74bae910a322c1a62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment