From 928f6e70095f71295d2a55c0e70812d315e9c2d0 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Fri, 1 Jul 2022 20:15:01 -0700 Subject: [PATCH] Add ariadnee (#560) --- middleware/analytics.js | 21 +++++++++++++-------- nuxt.config.js | 11 +++++++++-- plugins/shorthands.js | 2 +- store/auth.js | 2 +- store/tag.js | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/middleware/analytics.js b/middleware/analytics.js index cb13c4bed..fee859f87 100644 --- a/middleware/analytics.js +++ b/middleware/analytics.js @@ -1,6 +1,4 @@ export default function (context) { - // Temporary disable analytics - /* if (process.client && context.from.path === context.route.path) { return } @@ -11,15 +9,22 @@ export default function (context) { setTimeout(() => { context.$axios - .post(`${context.$config.analytics.base_url}/register/visit`, { - path: context.route.path, - domain: process.server ? context.req.headers.host : location.host, - consent: false, - }) + .post( + `${context.$config.analytics.base_url}view`, + { + url: process.env.domain + context.route.fullPath, + }, + context.$config.analytics.admin_key + ? { + headers: { + 'Modrinth-Admin': context.$config.analytics.admin_key, + }, + } + : {} + ) .then(() => {}) .catch((e) => { console.error('An error occurred while registering the visit: ', e) }) }) - */ } diff --git a/nuxt.config.js b/nuxt.config.js index cb7444b9b..f88ff29f8 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -291,7 +291,9 @@ export default { ethicalAds: process.env.ETHICAL_ADS, }, analytics: { - base_url: process.env.ARIADNE_URL, + base_url: + process.env.BROWSER_ARIADNE_URL || + 'https://staging-ariadne.modrinth.com/v1/', }, }, privateRuntimeConfig: { @@ -299,10 +301,15 @@ export default { baseURL: process.env.BASE_URL, headers: { common: { - 'x-ratelimit-key': process.env.RATE_LIMIT_IGNORE_KEY, + 'x-ratelimit-key': process.env.RATE_LIMIT_IGNORE_KEY || '', }, }, }, + analytics: { + base_url: + process.env.ARIADNE_URL || 'https://staging-ariadne.modrinth.com/v1/', + admin_key: process.env.ARIADNE_ADMIN_KEY, + }, }, } diff --git a/plugins/shorthands.js b/plugins/shorthands.js index 2f945496c..9806bf45b 100644 --- a/plugins/shorthands.js +++ b/plugins/shorthands.js @@ -6,7 +6,7 @@ export default ({ store }, inject) => { const obj = { headers: {} } if (process.server && process.env.RATE_LIMIT_IGNORE_KEY) { - obj.headers['x-ratelimit-key'] = process.env.RATE_LIMIT_IGNORE_KEY + obj.headers['x-ratelimit-key'] = process.env.RATE_LIMIT_IGNORE_KEY || '' } if (store.state.auth.user) { diff --git a/store/auth.js b/store/auth.js index 1515eab3f..49e434d16 100644 --- a/store/auth.js +++ b/store/auth.js @@ -24,7 +24,7 @@ export const actions = { headers: { Authorization: token, 'x-ratelimit-key': process.server - ? process.env.RATE_LIMIT_IGNORE_KEY + ? process.env.RATE_LIMIT_IGNORE_KEY || '' : '', }, }) diff --git a/store/tag.js b/store/tag.js index 8aa6c54c3..7fb3220e7 100644 --- a/store/tag.js +++ b/store/tag.js @@ -29,7 +29,7 @@ export const actions = { const headers = { headers: { 'x-ratelimit-key': process.server - ? process.env.RATE_LIMIT_IGNORE_KEY + ? process.env.RATE_LIMIT_IGNORE_KEY || '' : '', }, }