Modrinth/middleware/analytics.js
2023-02-01 11:34:20 -07:00

25 lines
494 B
JavaScript

export default function (context) {
if (!process.client) {
return
}
if (
context.from &&
context.route &&
context.from.path === context.route.path
) {
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)
})
})
}