From dd73f73869b955243c98cf082319c709c87592ee Mon Sep 17 00:00:00 2001 From: Redume Date: Wed, 5 Mar 2025 22:25:26 +0300 Subject: [PATCH] Revert "chore(server): Changed the name of the keys. Made it easier to change the domain" This reverts commit da7134f4441428b6efba26cd5e80444a6de3e062. --- config.example.hjson | 1 + server/main.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.example.hjson b/config.example.hjson index 4cafc6b..4685ea6 100644 --- a/config.example.hjson +++ b/config.example.hjson @@ -25,6 +25,7 @@ { plausible_domain: plausible.io plausible_token: TOKEN + plausiblee_api: https://plausible.io//api/event/ enabled: false } currency: diff --git a/server/main.js b/server/main.js index 33142a0..7c72dc3 100644 --- a/server/main.js +++ b/server/main.js @@ -47,11 +47,7 @@ fastify.addHook('onResponse', async (request, reply) => { routePartFiltered.unshift('/'); - if ( - !config?.['analytics']['enabled'] - ? config?.['analytics']['enabled'] - : false - ) + if (!config?.['analytics']['work'] ? config?.['analytics']['work'] : false) return; else if (!fastify.printRoutes().includes(routePartFiltered.at(-1))) return; @@ -85,6 +81,7 @@ fastify.addHook('onResponse', async (request, reply) => { }; try { +<<<<<<< HEAD await axios.post( `https://${config['analytics']['plausible_domain']}/api/event/`, event, @@ -94,8 +91,15 @@ fastify.addHook('onResponse', async (request, reply) => { 'Content-Type': 'application/json', 'User-Agent': userAgent, }, +======= + await axios.post(config['analytics']['plausible_api'], event, { + headers: { + Authorization: `Bearer ${config['analytics']['plausible_token']}`, + 'Content-Type': 'application/json', + 'User-Agent': userAgent, +>>>>>>> parent of da7134f (chore(server): Changed the name of the keys. Made it easier to change the domain) }, - ); + }); } catch (error) { fastify.log.error('Error sending event to Plausible:', error.message); }