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('/');
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, {
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);
}