diff --git a/index.js b/index.js index f44fd71..8ac1fe3 100644 --- a/index.js +++ b/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;