diff --git a/libs/metrics.js b/libs/metrics.js index 22e4c0330393478c5d0980a58fa88effa433185d..8d04b805cabcb48641fec74cf63974bcbf057fd6 100644 --- a/libs/metrics.js +++ b/libs/metrics.js @@ -108,10 +108,13 @@ exports.report = function(type, entry) { // utility function to log a bunch of stuff at user entry point exports.userEntry = function(req) { + var ipAddress = req.connection.remoteAddress; + if (req.headers['x-real-ip']) ipAddress = req.headers['x-real-ip']; + exports.report('signin', { browser: req.headers['user-agent'], rp: req.headers['referer'], // IP address (this probably needs to be replaced with the X-forwarded-for value - ip: req.connection.remoteAddress + ip: ipAddress }); };