Removing sensitive data to env and log identifier at login
This commit is contained in:
13
index.js
13
index.js
@@ -16,7 +16,7 @@ const webPush = require('web-push');
|
||||
const PostHog = require('posthog-node');
|
||||
|
||||
const client_logger = new PostHog.PostHog(
|
||||
'phc_2zh7SoBDi83vaa7Rz4YWTXWCjV0bOLfiqRyUo2mkf0b',
|
||||
process.env.POSTHOG_API_KEY,
|
||||
{ host: 'https://us.i.posthog.com' }
|
||||
)
|
||||
|
||||
@@ -242,6 +242,12 @@ DB.getDB.then((DB) => {
|
||||
// Chooses the most recent update profile as current active profile
|
||||
const latestUpdatedProfile = await DB.latestProfile(user._id);
|
||||
res.cookie('profile_id', latestUpdatedProfile._id, cookiesOptions);
|
||||
client_logger.identify({
|
||||
distinctId: user._id,
|
||||
properties: {
|
||||
name: latestUpdatedProfile.profile.firstName,
|
||||
}
|
||||
});
|
||||
client_logger.capture({
|
||||
distinctId: user._id,
|
||||
event: 'server@'+req.method+'@'+req.originalUrl,
|
||||
@@ -391,17 +397,16 @@ DB.getDB.then((DB) => {
|
||||
app.use('/payments', sessionChecker, paymentsRoute);
|
||||
app.use('/bible', sessionChecker, bibleRoute);
|
||||
app.use('/songs', sessionChecker, songsRoute);
|
||||
|
||||
//Public Routes
|
||||
app.use('/subsplash', subsplashRoute);
|
||||
|
||||
// route for handling 404 requests(unavailable routes)
|
||||
app.use(function (req, res, next) {
|
||||
res.status(404).send("Sorry can't find that!")
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening at http://localhost:${port}`);
|
||||
}).on('error', (err) => {
|
||||
console.error('Server failed to start:', err);
|
||||
});
|
||||
}).catch((err) => {
|
||||
throw err;
|
||||
|
||||
Reference in New Issue
Block a user