diff --git a/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee b/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee index 5166bd2765..a57118723e 100644 --- a/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee +++ b/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee @@ -4,25 +4,25 @@ AuthenticationController = require("../Authentication/AuthenticationController") module.exports = AnalyticsController = updateEditingSession: (req, res, next) -> - userId = AuthenticationController.getLoggedInUserId(req) or req.sessionID + userId = AuthenticationController.getLoggedInUserId(req) projectId = req.params.projectId - AnalyticsManager.updateEditingSession userId, projectId, {}, (error) -> - if error instanceof Errors.ServiceNotConfiguredError - # ignore, no-op - return res.send(204) - else if error? - return next(error) - else - return res.send 204 + if userId? + AnalyticsManager.updateEditingSession userId, projectId, {}, (error) -> + respondWith(error, res, next) + else + res.send 204 recordEvent: (req, res, next) -> user_id = AuthenticationController.getLoggedInUserId(req) or req.sessionID AnalyticsManager.recordEvent user_id, req.params.event, req.body, (error) -> - if error instanceof Errors.ServiceNotConfiguredError - # ignore, no-op - return res.send(204) - else if error? - return next(error) - else - return res.send 204 + respondWith(error, res, next) + +respondWith = (error, res, next) -> + if error instanceof Errors.ServiceNotConfiguredError + # ignore, no-op + res.send(204) + else if error? + next(error) + else + res.send 204