diff --git a/source/image-handler/logger/send.js b/source/image-handler/logger/send.js index dddea2797..30e0cde52 100644 --- a/source/image-handler/logger/send.js +++ b/source/image-handler/logger/send.js @@ -39,7 +39,8 @@ function getMdc({ event }) { } return { - accept: event.headers && (event.headers.accept || event.headers.Accept) + accept: event.headers && (event.headers.accept || event.headers.Accept), + user_agent: event.headers && (event.headers["User-Agent"] || event.headers["user-agent"]) }; } diff --git a/source/image-handler/logger/send.spec.js b/source/image-handler/logger/send.spec.js index a4e575e8b..e4e26c861 100644 --- a/source/image-handler/logger/send.spec.js +++ b/source/image-handler/logger/send.spec.js @@ -9,7 +9,8 @@ const TEST_DATA = { const TEST_API_GATEWAY_EVENT = { path: "/path/to/image.png", headers: { - accept: 'imgage/webp' + accept: 'image/webp', + 'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' }, eventId: 12345, }; @@ -109,12 +110,13 @@ describe("sendMessage", () => { }); }); - it("should log the Cloudwatch event path to the image to be processed", () => { + it("should log headers", () => { sendMessage({level: "log", args: [], event: TEST_API_GATEWAY_EVENT}); expect(getLastMessage().path).toStrictEqual(TEST_API_GATEWAY_EVENT.path) expect(getLastMessage().mdc).toStrictEqual({ - accept: 'imgage/webp' + accept: 'image/webp', + user_agent: 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' }); }); });