mirror of
https://github.com/Redume/Kekkai.git
synced 2025-04-02 21:37:36 +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')();
|
require('../shared/database/src/create_table.js')();
|
||||||
|
|
||||||
const fastify = require('fastify')({
|
const fastify = require('fastify')({
|
||||||
logger: config['server']['log']['print'] ? logger : false,
|
logger: config['server']['log']['level'] !== 'none' ? logger : false,
|
||||||
...(config['server']['ssl']['work']
|
...(config['server']['ssl']['enabled']
|
||||||
? {
|
? {
|
||||||
https: {
|
https: {
|
||||||
key: fs.readFileSync(
|
key: fs.readFileSync(
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue