mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge branch 'sk-handle-analytics-absence'
This commit is contained in:
commit
4e6553ebcc
3 changed files with 20 additions and 4 deletions
|
@ -1,7 +1,14 @@
|
|||
AnalyticsManager = require "./AnalyticsManager"
|
||||
Errors = require "../Errors/Errors"
|
||||
|
||||
|
||||
module.exports = AnalyticsController =
|
||||
recordEvent: (req, res, next) ->
|
||||
AnalyticsManager.recordEvent req.session?.user?._id, req.params.event, req.body, (error) ->
|
||||
return next(error) if error?
|
||||
if error?
|
||||
if error instanceof Errors.ServiceNotConfiguredError
|
||||
# ignore, no-op
|
||||
return res.send(204)
|
||||
else
|
||||
return next(error)
|
||||
res.send 204
|
||||
|
|
|
@ -2,6 +2,7 @@ settings = require "settings-sharelatex"
|
|||
logger = require "logger-sharelatex"
|
||||
_ = require "underscore"
|
||||
request = require "request"
|
||||
Errors = require '../Errors/Errors'
|
||||
|
||||
|
||||
makeRequest = (opts, callback)->
|
||||
|
@ -10,8 +11,7 @@ makeRequest = (opts, callback)->
|
|||
opts.url = "#{settings.apis.analytics.url}#{urlPath}"
|
||||
request opts, callback
|
||||
else
|
||||
callback()
|
||||
|
||||
callback(new Errors.ServiceNotConfiguredError('Analytics service not configured'))
|
||||
|
||||
|
||||
module.exports =
|
||||
|
|
|
@ -5,5 +5,14 @@ NotFoundError = (message) ->
|
|||
return error
|
||||
NotFoundError.prototype.__proto__ = Error.prototype
|
||||
|
||||
|
||||
ServiceNotConfiguredError = (message) ->
|
||||
error = new Error(message)
|
||||
error.name = "ServiceNotConfiguredError"
|
||||
error.__proto__ = ServiceNotConfiguredError.prototype
|
||||
return error
|
||||
|
||||
|
||||
module.exports = Errors =
|
||||
NotFoundError: NotFoundError
|
||||
NotFoundError: NotFoundError
|
||||
ServiceNotConfiguredError: ServiceNotConfiguredError
|
||||
|
|
Loading…
Reference in a new issue