-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: log user session during feedback form injection
- Loading branch information
Showing
3 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import { AuthedSessionData } from 'express-session' | ||
|
||
import { killEmailMode } from '../../../../config/config' | ||
import { createLoggerWithLabel } from '../../../../config/logger' | ||
import { ControllerHandler } from '../../../../modules/core/core.types' | ||
import { createReqMeta } from '../../../../utils/request' | ||
|
||
const logger = createLoggerWithLabel(module) | ||
|
||
// TODO: (Kill Email Mode) Remove this route after kill email mode is fully implemented. | ||
export const injectFeedbackFormUrl: ControllerHandler = (req, res, next) => { | ||
export const authAndInjectFeedbackFormUrl: ControllerHandler = ( | ||
req, | ||
res, | ||
next, | ||
) => { | ||
const formId = killEmailMode.feedbackFormid | ||
req.params = { formId: formId } | ||
const sessionUserId = (req.session as AuthedSessionData).user._id | ||
|
||
const logMeta = { | ||
action: 'authAndInjectFeedbackFormUrl', | ||
formId, | ||
method: req.method, | ||
sessionUserId, | ||
...createReqMeta(req), | ||
} | ||
|
||
logger.info({ | ||
message: 'Feedback form injected', | ||
meta: logMeta, | ||
}) | ||
|
||
return next() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters