From 9fa858bbd6c59b69795cea72cd04f6d45622d7dd Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Wed, 6 Nov 2019 10:55:12 +0100 Subject: [PATCH] Analytics disabled via Features.js (#2296) GitOrigin-RevId: b3649bf8e6ef4eb37dee38ca7c6709a282904388 --- .../web/app/src/Features/Analytics/AnalyticsController.js | 7 +++++++ services/web/app/src/infrastructure/Features.js | 1 + 2 files changed, 8 insertions(+) diff --git a/services/web/app/src/Features/Analytics/AnalyticsController.js b/services/web/app/src/Features/Analytics/AnalyticsController.js index 6d00c61772..c27576199c 100644 --- a/services/web/app/src/Features/Analytics/AnalyticsController.js +++ b/services/web/app/src/Features/Analytics/AnalyticsController.js @@ -3,9 +3,13 @@ const Errors = require('../Errors/Errors') const AuthenticationController = require('../Authentication/AuthenticationController') const InstitutionsAPI = require('../Institutions/InstitutionsAPI') const GeoIpLookup = require('../../infrastructure/GeoIpLookup') +const Features = require('../../infrastructure/Features') module.exports = { updateEditingSession(req, res, next) { + if (!Features.hasFeature('analytics')) { + return res.send(204) + } const userId = AuthenticationController.getLoggedInUserId(req) const { projectId } = req.params let countryCode = null @@ -28,6 +32,9 @@ module.exports = { }, recordEvent(req, res, next) { + if (!Features.hasFeature('analytics')) { + return res.send(204) + } const userId = AuthenticationController.getLoggedInUserId(req) || req.sessionID AnalyticsManager.recordEvent(userId, req.params.event, req.body, error => diff --git a/services/web/app/src/infrastructure/Features.js b/services/web/app/src/infrastructure/Features.js index 1249be9dba..bc7957d35a 100644 --- a/services/web/app/src/infrastructure/Features.js +++ b/services/web/app/src/infrastructure/Features.js @@ -41,6 +41,7 @@ module.exports = Features = { case 'templates-server-pro': return Settings.overleaf == null case 'affiliations': + case 'analytics': // Checking both properties is needed for the time being to allow // enabling the feature in web-api and disabling in Server Pro // see https://github.com/overleaf/web-internal/pull/2127