Compare commits

..

No commits in common. "e2c513fe8122107d33011fcfe614b5fd646d1223" and "7240fc4472b28f35a5f08cc8a8d80929e5ecd7b5" have entirely different histories.

View file

@ -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']['level'] !== 'none' ? logger : false,
...(config['server']['ssl']['enabled']
logger: config['server']['log']['print'] ? logger : false,
...(config['server']['ssl']['work']
? {
https: {
key: fs.readFileSync(
@ -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,17 +81,13 @@ fastify.addHook('onResponse', async (request, reply) => {
};
try {
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,
},
await axios.post(config['analytics']['plausible_api'], 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);
}