From 6c910d2b5f3b5aafc02e5eee24cfb939cfdde5fc Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Wed, 1 Feb 2023 11:34:20 -0700 Subject: [PATCH] Sync analytics w/ api changes (#975) --- middleware/analytics.js | 4 ---- nuxt.config.js | 13 +++++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/middleware/analytics.js b/middleware/analytics.js index fed71cc48..f5fb4f46c 100644 --- a/middleware/analytics.js +++ b/middleware/analytics.js @@ -11,10 +11,6 @@ export default function (context) { return } - if (process.env.NODE_ENV !== 'production') { - return - } - setTimeout(() => { context.$axios .post(`${context.$config.analytics.base_url}view`, { diff --git a/nuxt.config.js b/nuxt.config.js index c21736d36..fc68054c4 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -375,22 +375,19 @@ export default { render: { routeDone(url, result, context) { setTimeout(() => { - if (process.env.NODE_ENV !== 'production') return axios .post( `${process.env.ARIADNE_URL || STAGING_ARIADNE_URL}view`, { url: getDomain() + url, + ip: + context.req.headers['CF-Connecting-IP'] ?? + context.req.connection.remoteAddress, + headers: context.req.headers, }, { headers: { '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) => { console.error( 'An error occurred while registering the visit: ', - e + e.response.data ) }) })