From c200511f86b7c99ceff61813283ba502569cdff4 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Mon, 20 Jul 2020 09:23:20 -0400 Subject: [PATCH] Merge pull request #3016 from overleaf/ta-editor-load-events Fix Editor Load Events GitOrigin-RevId: bb23f17ccab2d53933ad9da870f8ce26fdd169df --- services/web/app/src/Features/Project/ProjectController.js | 7 +++++++ .../js/ide/settings/controllers/SettingsController.js | 5 +---- .../web/test/unit/src/Project/ProjectControllerTests.js | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index e56e8a77f0..b206463522 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -35,6 +35,7 @@ const Features = require('../../infrastructure/Features') const BrandVariationsHandler = require('../BrandVariations/BrandVariationsHandler') const { getUserAffiliations } = require('../Institutions/InstitutionsAPI') const UserController = require('../User/UserController') +const AnalyticsManager = require('../Analytics/AnalyticsManager') const _ssoAvailable = (affiliation, session, linkedInstitutionIds) => { if (!affiliation.institution) return false @@ -773,6 +774,12 @@ const ProjectController = { const enableOptimize = !!Settings.experimentId && !user.features.zotero + if (userId) { + AnalyticsManager.recordEvent(userId, 'project-opened', { + projectId: project._id + }) + } + res.render('project/editor', { title: project.name, priority_title: true, diff --git a/services/web/frontend/js/ide/settings/controllers/SettingsController.js b/services/web/frontend/js/ide/settings/controllers/SettingsController.js index d87537c276..cbe2180086 100644 --- a/services/web/frontend/js/ide/settings/controllers/SettingsController.js +++ b/services/web/frontend/js/ide/settings/controllers/SettingsController.js @@ -192,10 +192,7 @@ export default App.controller('SettingsController', function( } // don't save on initialisation, Angular passes oldRootDoc_id as // undefined in this case. - if ( - typeof rootDoc_id === 'undefined' && - typeof oldRootDoc_id === 'undefined' - ) { + if (typeof oldRootDoc_id === 'undefined') { return } // otherwise only save changes, null values are allowed diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js index 148aa721d2..ed8907791a 100644 --- a/services/web/test/unit/src/Project/ProjectControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectControllerTests.js @@ -178,7 +178,8 @@ describe('ProjectController', function() { getUserAffiliations: this.getUserAffiliations }, '../ThirdPartyDataStore/TpdsProjectFlusher': this.TpdsProjectFlusher, - '../../models/Project': {} + '../../models/Project': {}, + '../Analytics/AnalyticsManager': { recordEvent: () => {} } } })