Closed kristian2x closed 4 years ago
It support matomo but for react-router v4 I haven't try it for the moment with this plugin. Can you try it and give me feed back about it?
thanks, which react-router is officially supported then? I'll test v4 and report back.
Hi @guillaumeparis2000,
Could you report back if this library works with the latest Matomo and React(router) version?
If so, we could add it to the https://matomo.org/integrate/ page.
See also https://github.com/joernroeder/piwik-react-router/issues/60
cc @mattab
Hi @Findus23,
This library work with the latest Matomo but I haven't tested it with the last react router version. For the moment I haven't got any time to do this test, if you can test it and report the result in this issue?
Thanks
Unfortunatly I know hardly anything about React, but maybe @idodav can confirm this.
For me it doesn't work with react-router@v5:
TypeError: Cannot read property 'path' of undefined
t.value
node_modules/react-piwik/lib/React-Piwik.js:88
85 | value: function (t) {
86 | var e = this,
87 | i = void 0 === t.getCurrentLocation ? t.location : t.getCurrentLocation();
> 88 | return this.previousPath = i.path || (i.pathname + i.search).replace(/^\//, ""), this.unlistenFromHistory = t.listen(function (t) {
| ^ 89 | e.track(t);
90 | }), t;
91 | }
Ok, I got it working:
react-router@v5 Matomo
I had to install the history module from npm (not use the global one).
const piwik = new ReactPiwik({
url: '//localhost',
siteId: 1,
trackErrors: true,
jsFilename: 'matomo.js',
phpFilename: 'matomo.php'
})
piwik.connectToHistory(createHashHistory())
Allready fixed
Does this support matomo and react-router v4?