Modrinth/middleware/analytics.js
2022-07-02 11:23:24 -07:00

25 lines
513 B
JavaScript

export default function (context) {
if (!process.client) {
return
}
if (context.from.path === context.route.path) {
return
}
if (context.$config.analytics.base_url == null) {
return
}
setTimeout(() => {
context.$axios
.post(`${context.$config.analytics.base_url}view`, {
url: process.env.domain + context.route.fullPath,
})
.then(() => {})
.catch((e) => {
console.error('An error occurred while registering the visit: ', e)
})
})
}