mirror of
https://github.com/Redume/Kekkai.git
synced 2025-04-01 21:07:35 +03:00
Compare commits
4 commits
7240fc4472
...
e2c513fe81
Author | SHA1 | Date | |
---|---|---|---|
e2c513fe81 | |||
547b6c2754 | |||
8aa070d0d1 | |||
da7134f444 |
1 changed files with 17 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue