mirror of
https://github.com/Redume/Kekkai.git
synced 2025-03-12 11:34:38 +03:00
chore(server): Changed the name of the keys. Made it easier to change the domain
This commit is contained in:
parent
7240fc4472
commit
da7134f444
1 changed files with 15 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue