overleaf/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee

16 lines
569 B
CoffeeScript
Raw Normal View History

2016-09-06 04:29:58 -04:00
AnalyticsManager = require "./AnalyticsManager"
Errors = require "../Errors/Errors"
AuthenticationController = require("../Authentication/AuthenticationController")
2016-08-10 11:42:56 -04:00
module.exports = AnalyticsController =
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