chore(server): Changed the name of the keys. Made it easier to change the domain

This commit is contained in:
Данил 2025-03-03 01:22:31 +03:00
parent 7240fc4472
commit da7134f444

View file

@ -47,7 +47,11 @@ fastify.addHook('onResponse', async (request, reply) => {
routePartFiltered.unshift('/'); routePartFiltered.unshift('/');
if (!config?.['analytics']['work'] ? config?.['analytics']['work'] : false) if (
!config?.['analytics']['enabled']
? config?.['analytics']['enabled']
: false
)
return; return;
else if (!fastify.printRoutes().includes(routePartFiltered.at(-1))) return; else if (!fastify.printRoutes().includes(routePartFiltered.at(-1))) return;
@ -81,13 +85,17 @@ fastify.addHook('onResponse', async (request, reply) => {
}; };
try { try {
await axios.post(config['analytics']['plausible_api'], event, { await axios.post(
headers: { `https://${config['analytics']['plausible_domain']}/api/event`,
Authorization: `Bearer ${config['analytics']['plausible_token']}`, event,
'Content-Type': 'application/json', {
'User-Agent': userAgent, headers: {
Authorization: `Bearer ${config['analytics']['plausible_token']}`,
'Content-Type': 'application/json',
'User-Agent': userAgent,
},
}, },
}); );
} catch (error) { } catch (error) {
fastify.log.error('Error sending event to Plausible:', error.message); fastify.log.error('Error sending event to Plausible:', error.message);
} }