2016-09-06 08:29:58 +00:00
|
|
|
AnalyticsManager = require "./AnalyticsManager"
|
2017-03-21 10:57:39 +00:00
|
|
|
Errors = require "../Errors/Errors"
|
2017-03-27 08:42:38 +00:00
|
|
|
AuthenticationController = require("../Authentication/AuthenticationController")
|
2016-08-10 15:42:56 +00:00
|
|
|
|
|
|
|
module.exports = AnalyticsController =
|
|
|
|
recordEvent: (req, res, next) ->
|
2017-03-08 17:51:35 +00:00
|
|
|
user_id = AuthenticationController.getLoggedInUserId(req) or req.sessionID
|
|
|
|
AnalyticsManager.recordEvent user_id, req.params.event, req.body, (error) ->
|
2017-03-27 08:42:38 +00:00
|
|
|
if error instanceof Errors.ServiceNotConfiguredError
|
|
|
|
# ignore, no-op
|
|
|
|
return res.send(204)
|
|
|
|
else if error?
|
|
|
|
return next(error)
|
|
|
|
else
|
|
|
|
return res.send 204
|