Adding analitycs with PostHog
This commit is contained in:
11
index.js
11
index.js
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user