Skip to content

Commit b3ccc0c

Browse files
authored
feat(ua): log user agent with requests (#20)
1 parent 98daedf commit b3ccc0c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/telemetry/requestLogger.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function getBasicInfo(req: Request): [string, Record<string, string | number>] {
4040
m: req.method,
4141
};
4242

43+
if (req.headers['user-agent']) {
44+
preInfo.ua = req.headers['user-agent'];
45+
}
46+
4347
const sessionReq = req as WithIdentifiedSession;
4448
if (sessionReq.session?.id) {
4549
preInfo.sid = sessionReq.session.id;
@@ -113,7 +117,6 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
113117
endLog.resBody = bodyString;
114118
}
115119
}
116-
117120
const msg = service.getLogFields?.(req as RequestWithApp<SLocals>, endLog) || url;
118121
if (unexpectedError) {
119122
logger.error(endLog, msg);

0 commit comments

Comments
 (0)