AnalyticsController.coffee 891 B

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