overleaf/services/web/app/src/Features/SplitTests/SplitTestMiddleware.js
Tim Down 35480a3c7d Merge pull request #7545 from overleaf/td-split-test-data-sentry
Record split-test state in Sentry metadata from web clients

GitOrigin-RevId: 66dd195c546bd9fb0aedac52844200846c5012ca
2022-04-25 08:04:45 +00:00

22 lines
584 B
JavaScript

const SplitTestHandler = require('./SplitTestHandler')
const logger = require('@overleaf/logger')
function loadAssignmentsInLocals(splitTestNames) {
return async function (req, res, next) {
try {
for (const splitTestName of splitTestNames) {
await SplitTestHandler.promises.getAssignment(req, res, splitTestName)
}
} catch (error) {
logger.error(
{ err: error, splitTestNames },
'Failed to load split test assignments in express locals in middleware'
)
}
next()
}
}
module.exports = {
loadAssignmentsInLocals,
}