mirror of
https://github.com/kremalicious/gatsby-plugin-matomo.git
synced 2024-12-22 09:13:19 +01:00
do nothing on route updates when piwik isn't loaded and in development
This commit is contained in:
parent
71fb56db48
commit
6c0a840de2
@ -13,6 +13,7 @@ function getDuration() {
|
||||
}
|
||||
|
||||
exports.onRouteUpdate = ({ location }) => {
|
||||
if (process.env.NODE_ENV !== 'production' && typeof _paq !== 'undefined') {
|
||||
window._paq = window._paq || []
|
||||
|
||||
if (first) {
|
||||
@ -22,11 +23,13 @@ exports.onRouteUpdate = ({ location }) => {
|
||||
'javascript',
|
||||
'load',
|
||||
'duration',
|
||||
getDuration(),
|
||||
getDuration()
|
||||
])
|
||||
} else {
|
||||
window._paq.push(['setCustomUrl', location.pathname])
|
||||
window._paq.push(['setDocumentTitle', location.pathname])
|
||||
window._paq.push(['trackPageView'])
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user