mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 21:09:18 +08:00
only adding device when needed
This commit is contained in:
parent
860de29955
commit
d2e5c0afab
1 changed files with 19 additions and 14 deletions
|
@ -115,20 +115,25 @@ class UserController {
|
|||
}
|
||||
}
|
||||
let agent = uaparser(req.headers["user-agent"]);
|
||||
Logger.log(
|
||||
"user_data_requested",
|
||||
{
|
||||
ip:
|
||||
req.headers["cf-connecting-ip"] ||
|
||||
req.headers["x-forwarded-for"] ||
|
||||
req.ip ||
|
||||
"255.255.255.255",
|
||||
os: agent.os.name + " " + agent.os.version,
|
||||
browser: agent.browser.name + " " + agent.browser.version,
|
||||
device: agent.device.vendor + " " + agent.device.model,
|
||||
},
|
||||
uid
|
||||
);
|
||||
let logobj = {
|
||||
ip:
|
||||
req.headers["cf-connecting-ip"] ||
|
||||
req.headers["x-forwarded-for"] ||
|
||||
req.ip ||
|
||||
"255.255.255.255",
|
||||
os: agent.os.name + " " + agent.os.version,
|
||||
browser: agent.browser.name + " " + agent.browser.version,
|
||||
device: agent.device.vendor + " " + agent.device.model,
|
||||
};
|
||||
if (agent.device.vendor) {
|
||||
logobj.device =
|
||||
agent.device.vendor +
|
||||
" " +
|
||||
agent.device.model +
|
||||
" " +
|
||||
agent.device.type;
|
||||
}
|
||||
Logger.log("user_data_requested", logobj, uid);
|
||||
return res.status(200).json(userInfo);
|
||||
} catch (e) {
|
||||
return next(e);
|
||||
|
|
Loading…
Reference in a new issue