MCPcopy Create free account
hub / github.com/monkeytypegame/monkeytype / buildAgentLog

Function buildAgentLog

backend/src/utils/misc.ts:31–52  ·  view source on GitHub ↗
(req: MonkeyRequest)

Source from the content-addressed store, hash-verified

29};
30
31export function buildAgentLog(req: MonkeyRequest): AgentLog {
32 const agent = uaparser(req.raw.headers["user-agent"]);
33
34 const agentLog: AgentLog = {
35 ip:
36 (req.raw.headers["cf-connecting-ip"] as string) ||
37 (req.raw.headers["x-forwarded-for"] as string) ||
38 (req.raw.ip as string) ||
39 "255.255.255.255",
40 agent: `${agent.os.name} ${agent.os.version} ${agent.browser.name} ${agent.browser.version}`,
41 };
42
43 const {
44 device: { vendor, model, type },
45 } = agent;
46
47 agentLog.device = `${vendor ?? "unknown vendor"} ${
48 model ?? "unknown model"
49 } ${type ?? "unknown type"}`;
50
51 return agentLog;
52}
53
54export function padNumbers(
55 numbers: number[],

Callers 1

getUserFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected