diff --git a/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee b/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee index f9431a0f5c..1f2466674c 100644 --- a/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee +++ b/services/web/app/coffee/Features/Analytics/AnalyticsController.coffee @@ -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 diff --git a/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee b/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee index 9f34d6d9d1..66d2818032 100644 --- a/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee +++ b/services/web/app/coffee/Features/Analytics/AnalyticsManager.coffee @@ -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 = diff --git a/services/web/app/coffee/Features/Errors/Errors.coffee b/services/web/app/coffee/Features/Errors/Errors.coffee index 0bbff1f19b..92228f7b0b 100644 --- a/services/web/app/coffee/Features/Errors/Errors.coffee +++ b/services/web/app/coffee/Features/Errors/Errors.coffee @@ -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 \ No newline at end of file + NotFoundError: NotFoundError + ServiceNotConfiguredError: ServiceNotConfiguredError