Adding analitycs with PostHog

This commit is contained in:
Adolfo Reyna
2025-02-06 09:57:03 -05:00
parent 0d06e2a446
commit 6664dd5f89
3 changed files with 49 additions and 14 deletions

View File

@@ -13,6 +13,12 @@ const cookieParser = require('cookie-parser');
const cors = require('cors');
const Notifications = require("./notifications"); // Custom Notification Methods
const webPush = require('web-push');
const PostHog = require('posthog-node');
const client_logger = new PostHog.PostHog(
'phc_2zh7SoBDi83vaa7Rz4YWTXWCjV0bOLfiqRyUo2mkf0b',
{ host: 'https://us.i.posthog.com' }
)
// TODO: we are probably missing a rate limiter here.
@@ -86,6 +92,11 @@ DB.getDB.then((DB) => {
}
req.profileInfo = { _id: profile_id }
if (!userInfo) return res.redirect('/login');
// Log Reuquest
client_logger.capture({
distinctId: user_sid,
event: 'server@'+req.url,
})
next();
} else {
return res.redirect('/login');