2018-05-07 18:29:27 +02:00
|
|
|
let first = true
|
|
|
|
|
|
|
|
function getDuration() {
|
|
|
|
const start = window.start || new Date()
|
|
|
|
const now = new Date()
|
|
|
|
const difference = now.getTime() - start.getTime()
|
|
|
|
|
|
|
|
if (difference === 0) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return difference
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.onRouteUpdate = ({ location }) => {
|
2018-05-08 12:45:47 +02:00
|
|
|
if (process.env.NODE_ENV !== 'production' && typeof _paq !== 'undefined') {
|
|
|
|
window._paq = window._paq || []
|
2018-05-07 18:29:27 +02:00
|
|
|
|
2018-05-08 12:45:47 +02:00
|
|
|
if (first) {
|
|
|
|
first = false
|
|
|
|
window._paq.push([
|
|
|
|
'trackEvent',
|
|
|
|
'javascript',
|
|
|
|
'load',
|
|
|
|
'duration',
|
|
|
|
getDuration()
|
|
|
|
])
|
|
|
|
} else {
|
|
|
|
window._paq.push(['setCustomUrl', location.pathname])
|
|
|
|
window._paq.push(['setDocumentTitle', location.pathname])
|
|
|
|
window._paq.push(['trackPageView'])
|
|
|
|
}
|
2018-05-07 18:29:27 +02:00
|
|
|
}
|
2018-05-08 12:45:47 +02:00
|
|
|
return null
|
2018-05-07 18:29:27 +02:00
|
|
|
}
|