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