Cleaning code for index.js

This commit is contained in:
Adolfo Reyna
2025-02-20 23:27:13 -05:00
parent e4dfee39ff
commit 0b20f05124
10 changed files with 364 additions and 414 deletions

8
utils/analyticsLogger.js Normal file
View File

@@ -0,0 +1,8 @@
const PostHog = require('posthog-node');
const client_logger = new PostHog.PostHog(
process.env.POSTHOG_API_KEY,
{ host: 'https://us.i.posthog.com' }
)
module.exports = { client_logger };

15
utils/sessionUtils.js Normal file
View File

@@ -0,0 +1,15 @@
// Utilities
const getSessionId = function (req) {
const session_id = req.cookies.session_id || req.query.session_id || req.body.session_id;
return session_id;
}
const getUserId = function (req) {
const user_sid = req.cookies.user_sid || req.query.user_sid || req.body.user_sid;
return user_sid;
}
const getProfileId = function (req) {
const profile_id = req.cookies.profile_id || req.query.profile_id || req.body.profile_id;
return profile_id;
}
module.exports = { getSessionId, getUserId, getProfileId };