diff --git a/index.js b/index.js index bae8581..02dd52b 100644 --- a/index.js +++ b/index.js @@ -44,8 +44,9 @@ app.use((req, _, next) => { if (req.url !== "/healthcheck") { posthogClient.capture({ distinctId: req.ip, - event: "pageview", + event: "$pageview", properties: { + $current_url: req.originalUrl, path: req.path, url: req.originalUrl, method: req.method, @@ -188,6 +189,12 @@ app.listen(port, () => { console.log(`Server is running on port ${port}`); }); +process.on("SIGINT", async () => { + console.log("SIGINT signal received."); + await posthogClient.shutdown(); + process.exit(0); +}); + /** * @param {string} url * @param {string} pathToRemove