AnalyticsController.coffee 970 B

12345678910111213141516171819202122232425262728
  1. AnalyticsManager = require "./AnalyticsManager"
  2. Errors = require "../Errors/Errors"
  3. AuthenticationController = require("../Authentication/AuthenticationController")
  4. module.exports = AnalyticsController =
  5. updateEditSession: (req, res, next) ->
  6. userId = AuthenticationController.getLoggedInUserId(req) or req.sessionID
  7. projectId = req.params.projectId
  8. AnalyticsManager.updateEditSession userId, projectId, {}, (error) ->
  9. if error instanceof Errors.ServiceNotConfiguredError
  10. # ignore, no-op
  11. return res.send(204)
  12. else if error?
  13. return next(error)
  14. else
  15. return res.send 204
  16. recordEvent: (req, res, next) ->
  17. user_id = AuthenticationController.getLoggedInUserId(req) or req.sessionID
  18. AnalyticsManager.recordEvent user_id, req.params.event, req.body, (error) ->
  19. if error instanceof Errors.ServiceNotConfiguredError
  20. # ignore, no-op
  21. return res.send(204)
  22. else if error?
  23. return next(error)
  24. else
  25. return res.send 204