Sync analytics w/ api changes (#975)

This commit is contained in:
Geometrically
2023-02-01 11:34:20 -07:00
committed by GitHub
parent 0caa56e618
commit 6c910d2b5f
2 changed files with 5 additions and 12 deletions

View File

@@ -11,10 +11,6 @@ export default function (context) {
return return
} }
if (process.env.NODE_ENV !== 'production') {
return
}
setTimeout(() => { setTimeout(() => {
context.$axios context.$axios
.post(`${context.$config.analytics.base_url}view`, { .post(`${context.$config.analytics.base_url}view`, {

View File

@@ -375,22 +375,19 @@ export default {
render: { render: {
routeDone(url, result, context) { routeDone(url, result, context) {
setTimeout(() => { setTimeout(() => {
if (process.env.NODE_ENV !== 'production') return
axios axios
.post( .post(
`${process.env.ARIADNE_URL || STAGING_ARIADNE_URL}view`, `${process.env.ARIADNE_URL || STAGING_ARIADNE_URL}view`,
{ {
url: getDomain() + url, url: getDomain() + url,
ip:
context.req.headers['CF-Connecting-IP'] ??
context.req.connection.remoteAddress,
headers: context.req.headers,
}, },
{ {
headers: { headers: {
'Modrinth-Admin': process.env.ARIADNE_ADMIN_KEY || 'feedbeef', 'Modrinth-Admin': process.env.ARIADNE_ADMIN_KEY || 'feedbeef',
'User-Agent':
context.req.rawHeaders[
context.req.rawHeaders.findIndex(
(x) => x === 'User-Agent'
) + 1
],
}, },
} }
) )
@@ -398,7 +395,7 @@ export default {
.catch((e) => { .catch((e) => {
console.error( console.error(
'An error occurred while registering the visit: ', 'An error occurred while registering the visit: ',
e e.response.data
) )
}) })
}) })