From 1cac5227d69a46f0a90ef1279264263c79a39b30 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 9 Jul 2020 15:48:28 +0200 Subject: [PATCH] Merge pull request #2958 from overleaf/jel-optimize-zotero Add Optimize variant on Zotero paywall prompt GitOrigin-RevId: 005cf27d40a367e4617c399023204dacb80af8de --- .../src/Features/Project/ProjectController.js | 6 +++++- .../app/src/infrastructure/ExpressLocals.js | 1 + services/web/app/views/layout.pug | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 117030ba49..dc8f5bdd36 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -766,6 +766,9 @@ const ProjectController = { } metrics.inc(metricName) + const enableOptimize = + !!Settings.experimentId && !user.features.zotero + res.render('project/editor', { title: project.name, priority_title: true, @@ -822,7 +825,8 @@ const ProjectController = { allowedImageNames, gitBridgePublicBaseUrl: Settings.gitBridgePublicBaseUrl, wsUrl, - showSupport: Features.hasFeature('support') + showSupport: Features.hasFeature('support'), + gaOptimize: enableOptimize }) timer.done() } diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index 9ec9a1c0e2..914632912d 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -354,6 +354,7 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) { webRouter.use(function(req, res, next) { res.locals.ExposedSettings = { + experimentId: Settings.experimentId, isOverleaf: Settings.overleaf != null, appName: Settings.appName, hasSamlBeta: req.session.samlBeta, diff --git a/services/web/app/views/layout.pug b/services/web/app/views/layout.pug index 811b9e974b..b1f468da6b 100644 --- a/services/web/app/views/layout.pug +++ b/services/web/app/views/layout.pug @@ -43,14 +43,16 @@ html( script(type='text/javascript'). ga('require', '#{gaOptimizeId}') ga('send', 'event', 'pageview', document.title.substring(0, 499), window.location.href.substring(0, 499)) - //- Anti-flicker snippet - style(type='text/css') .async-hide { opacity: 0 !important} - script(type='text/javascript'). - (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; - h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; - (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; - })(window,document.documentElement,'async-hide','dataLayer',4000, - {'#{gaOptimizeId}':true}); + if !experimentId + //- Anti-flicker snippet + //- Only run for tests controlled by Optimize editor + style(type='text/css') .async-hide { opacity: 0 !important} + script(type='text/javascript'). + (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; + h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; + (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; + })(window,document.documentElement,'async-hide','dataLayer',4000, + {'#{gaOptimizeId}':true}); - else script(type='text/javascript').