diff --git a/server/main.js b/server/main.js index 6a21296..33142a0 100644 --- a/server/main.js +++ b/server/main.js @@ -8,8 +8,8 @@ const UAParser = require('ua-parser-js'); require('../shared/database/src/create_table.js')(); const fastify = require('fastify')({ - logger: config['server']['log']['print'] ? logger : false, - ...(config['server']['ssl']['work'] + logger: config['server']['log']['level'] !== 'none' ? logger : false, + ...(config['server']['ssl']['enabled'] ? { https: { key: fs.readFileSync( @@ -47,7 +47,11 @@ fastify.addHook('onResponse', async (request, reply) => { routePartFiltered.unshift('/'); - if (!config?.['analytics']['work'] ? config?.['analytics']['work'] : false) + if ( + !config?.['analytics']['enabled'] + ? config?.['analytics']['enabled'] + : false + ) return; else if (!fastify.printRoutes().includes(routePartFiltered.at(-1))) return; @@ -81,13 +85,17 @@ fastify.addHook('onResponse', async (request, reply) => { }; try { - await axios.post(config['analytics']['plausible_api'], event, { - headers: { - Authorization: `Bearer ${config['analytics']['plausible_token']}`, - 'Content-Type': 'application/json', - 'User-Agent': userAgent, + await axios.post( + `https://${config['analytics']['plausible_domain']}/api/event/`, + event, + { + headers: { + Authorization: `Bearer ${config['analytics']['plausible_token']}`, + 'Content-Type': 'application/json', + 'User-Agent': userAgent, + }, }, - }); + ); } catch (error) { fastify.log.error('Error sending event to Plausible:', error.message); }