UNPKG

libre

Version:
45 lines (36 loc) 849 B
import { browserHistory } from 'react-router'; import _ from 'lodash'; import GA from 'react-ga'; export function goto(path) { browserHistory.push(path); }; class Packet { constructor({category, action, label, data}) { _.assign(this, {category, action, label, data}); } get ga() { return { category: this.category, action: this.action, label: this.label, value: this.data }; } } class Dealer { init(gaID) { GA.initialize(gaID); } call(packetData) { const packet = new Packet(packetData); GA.event(packet.ga); // console.log('[DEALER] EVENT:', packet.ga); } page() { GA.set({ page: window.location.pathname }); GA.pageview(window.location.pathname); console.log(`[LIBRE] PAGE: [${window.location.pathname}]`); } } const D = new Dealer(); export default D;