From 5e297a152c2426212742da2c25536cf5b5704225 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Mon, 26 Feb 2024 15:32:57 +0000 Subject: [PATCH 1/3] fix page view logging --- src/controllers/pageController.js | 4 ++-- src/controllers/uploadController.js | 2 +- src/utils/logging.js | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/controllers/pageController.js b/src/controllers/pageController.js index 9265debd..5de575ba 100644 --- a/src/controllers/pageController.js +++ b/src/controllers/pageController.js @@ -8,8 +8,8 @@ class PageController extends Controller { super.locals(req, res, callback) } - async get (req, res, next) { - await logPageView(this.options.route, req.sessionID, req.ip) + get (req, res, next) { + logPageView(this.options.route, req.sessionID, req.ip) super.get(req, res, next) } } diff --git a/src/controllers/uploadController.js b/src/controllers/uploadController.js index 555b5ad2..d7f3f60b 100644 --- a/src/controllers/uploadController.js +++ b/src/controllers/uploadController.js @@ -8,7 +8,7 @@ import logger from '../utils/logger.js' class UploadController extends PageController { apiRoute = config.api.url + config.api.validationEndpoint - async get (req, res, next) { + get (req, res, next) { req.form.options.validationError = this.validationErrorMessage super.get(req, res, next) } diff --git a/src/utils/logging.js b/src/utils/logging.js index 8339634a..994095a8 100644 --- a/src/utils/logging.js +++ b/src/utils/logging.js @@ -1,14 +1,15 @@ import logger from '../utils/logger.js' import hash from '../utils/hasher.js' -const logPageView = async (route, sessionID, ipAddress) => { - logger.info({ - type: 'PageView', - pageRoute: route, - message: `page view occurred for page: ${route}`, - sessionId: await hash(sessionID), - ipAddress: await hash(ipAddress) - }) +const logPageView = (route, sessionID) => { + return hash(sessionID).then(hashedSessionID => { + logger.info({ + type: 'PageView', + pageRoute: route, + message: `page view occurred for page: ${route}`, + sessionId: hashedSessionID + }); + }); } -export { logPageView } +export { logPageView } \ No newline at end of file From d1a9cba3500663182bb5b920ff6c67d46b8605cc Mon Sep 17 00:00:00 2001 From: George Goodall Date: Mon, 26 Feb 2024 15:33:08 +0000 Subject: [PATCH 2/3] linting --- src/utils/logging.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/logging.js b/src/utils/logging.js index 994095a8..0fe4d166 100644 --- a/src/utils/logging.js +++ b/src/utils/logging.js @@ -8,8 +8,8 @@ const logPageView = (route, sessionID) => { pageRoute: route, message: `page view occurred for page: ${route}`, sessionId: hashedSessionID - }); - }); + }) + }) } -export { logPageView } \ No newline at end of file +export { logPageView } From 6150ee9bfd8592c92e5e1a569b53e861e4b61e11 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Mon, 26 Feb 2024 15:34:05 +0000 Subject: [PATCH 3/3] fix logging --- src/utils/logging.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/utils/logging.js b/src/utils/logging.js index 0fe4d166..b4b32fdc 100644 --- a/src/utils/logging.js +++ b/src/utils/logging.js @@ -1,14 +1,13 @@ import logger from '../utils/logger.js' import hash from '../utils/hasher.js' -const logPageView = (route, sessionID) => { - return hash(sessionID).then(hashedSessionID => { - logger.info({ - type: 'PageView', - pageRoute: route, - message: `page view occurred for page: ${route}`, - sessionId: hashedSessionID - }) +const logPageView = (route, sessionID, ipAddress) => { + logger.info({ + type: 'PageView', + pageRoute: route, + message: `page view occurred for page: ${route}`, + sessionId: hash(sessionID), + ipAddress: hash(ipAddress) }) }