Closed sephi-dev closed 7 years ago
Hi guys,
just a little bug, I don't know if I do the thing the good way but here is the point :
App.js
middleware
PiwikEvents
setCustomDimension
setUserId
heres is the code :
import ReactPiwik from 'react-piwik'; class PiwikEvents { constructor(opts) { ReactPiwik.push(['enableHeartBeatTimer']); }; setCustomDimension(opts) { ReactPiwik.push(['setCustomDimension', customDimension = opts.nb, customDimensionValue = opts.dimensionValue]); }; addTrackEvent(opts) { ReactPiwik.push(['trackEvent', opts.page, opts.action]); }; setUserId(opts) { ReactPiwik.push(['setUserId', opts.user]); }; }; const p = new PiwikEvents(); export function setUser(opts) { p.setUserId(opts); }; export function setNewDimension(opts) { p.setCustomDimension(opts); }; export function setTrackEvent(opts) { p.addTrackEvent(opts) };
But when my app is running, in my console I have : Uncaught TypeError: Cannot read property 'push' of undefined
Uncaught TypeError: Cannot read property 'push' of undefined
Any idea ?
Hi,
It seems that your PiwikEvents constructor is run before creating and connecting the react-piwik to the history.
Yep, found it too late ahaha sorry about that mate.
Hi guys,
just a little bug, I don't know if I do the thing the good way but here is the point :
App.js
running fine.middleware
to plug my piwik event on my redux action.PiwikEvents
in another file to make stuff likesetCustomDimension
,setUserId
...heres is the code :
But when my app is running, in my console I have :
Uncaught TypeError: Cannot read property 'push' of undefined
Any idea ?