Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. const ua = require('universal-analytics');
  2. const bluebird = require('bluebird');
  3.  
  4. const GOOGLE_ANALYTICS_ID = require('../../config').googleAnalytics.uid;
  5.  
  6. class GoogleAnalytics {
  7. constructor(uid) {
  8. this._uid = uid;
  9. this._visitor = ua(GOOGLE_ANALYTICS_ID, this._uid, { strictCidFormat: false, });
  10.  
  11. bluebird.promisifyAll(this._visitor);
  12. }
  13.  
  14. sendEvent(category, action, label) {
  15. if (!this._visitor) return;
  16.  
  17. this._visitor.eventAsync(category, action, label)
  18. .catch(error => console.error(error));
  19. }
  20. }
  21.  
  22. module.exports = GoogleAnalytics;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement