1
0
mirror of https://github.com/kremalicious/gatsby-plugin-matomo.git synced 2024-12-22 17:23:23 +01:00

do nothing on route updates when piwik isn't loaded and in development

This commit is contained in:
Matthias Kretschmann 2018-05-08 12:45:47 +02:00
parent 71fb56db48
commit 6c0a840de2
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 25 additions and 22 deletions

View File

@ -13,6 +13,7 @@ function getDuration() {
} }
exports.onRouteUpdate = ({ location }) => { exports.onRouteUpdate = ({ location }) => {
if (process.env.NODE_ENV !== 'production' && typeof _paq !== 'undefined') {
window._paq = window._paq || [] window._paq = window._paq || []
if (first) { if (first) {
@ -22,11 +23,13 @@ exports.onRouteUpdate = ({ location }) => {
'javascript', 'javascript',
'load', 'load',
'duration', 'duration',
getDuration(), getDuration()
]) ])
} else { } else {
window._paq.push(['setCustomUrl', location.pathname]) window._paq.push(['setCustomUrl', location.pathname])
window._paq.push(['setDocumentTitle', location.pathname]) window._paq.push(['setDocumentTitle', location.pathname])
window._paq.push(['trackPageView']) window._paq.push(['trackPageView'])
} }
}
return null
} }