Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

35 строки
658 B

  1. const ua = require('universal-analytics');
  2. //eslint-disable-next-line no-process-env
  3. const analyticsId = process.env.IWD_GOOGLE_ANALYTICS_ID;
  4. const tracker = {
  5. id: null,
  6. ga: null,
  7. init: function (userId) {
  8. this.id = userId;
  9. this.ga = ua(analyticsId, userId, { strictCidFormat: false });
  10. },
  11. track: function ({ category, action, label, value }) {
  12. this.ga.event(category, action, label, value).send();
  13. }
  14. };
  15. const fakeTracker = {
  16. track: function () {}
  17. };
  18. module.exports = {
  19. connect: function (id) {
  20. if (!analyticsId)
  21. return fakeTracker;
  22. const builtTracker = extend({}, tracker);
  23. builtTracker.init(id);
  24. return builtTracker;
  25. }
  26. };