From 4cecc6383afc3090f4a0ffefeb52d62c87c96235 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 5 Oct 2021 14:11:03 +0200 Subject: [PATCH] Merge pull request #5361 from overleaf/jpa-fix-cdn-load-test [web] rework the loading process for the CDN load test GitOrigin-RevId: dd14ca29668e88944457e03ffd8c921e2ce93929 --- services/web/app/views/layout.pug | 2 -- services/web/frontend/js/cdn-load-test.js | 12 +++++++----- services/web/frontend/js/main.js | 1 + services/web/frontend/js/marketing.js | 1 + services/web/webpack.config.js | 1 - 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/services/web/app/views/layout.pug b/services/web/app/views/layout.pug index 2f5d1fb152..f9dae17e71 100644 --- a/services/web/app/views/layout.pug +++ b/services/web/app/views/layout.pug @@ -135,5 +135,3 @@ html( //- Set query param, server will not set CDN url window.location.search += "&nocdn=true"; } - if hasFeature('saas') - script(type="text/javascript", nonce=scriptNonce, src=buildJsPath('cdn-load-test.js')) diff --git a/services/web/frontend/js/cdn-load-test.js b/services/web/frontend/js/cdn-load-test.js index dcb2e980b0..a89a4e2bb3 100644 --- a/services/web/frontend/js/cdn-load-test.js +++ b/services/web/frontend/js/cdn-load-test.js @@ -1,7 +1,9 @@ import { captureMessage } from './infrastructure/error-reporter' -var cdnLoadTest = document.createElement('img') -cdnLoadTest.addEventListener('error', function (event) { - captureMessage('CDN test image load error (cdn.overleaf.net)') -}) -cdnLoadTest.src = 'https://cdn.overleaf.net/img/1p.gif' +if (window.ExposedSettings.isOverleaf) { + const cdnLoadTest = document.createElement('img') + cdnLoadTest.addEventListener('error', function () { + captureMessage('CDN test image load error (cdn.overleaf.net)') + }) + cdnLoadTest.src = 'https://cdn.overleaf.net/img/1p.gif' +} diff --git a/services/web/frontend/js/main.js b/services/web/frontend/js/main.js index b135bc5c5c..5dace05cea 100644 --- a/services/web/frontend/js/main.js +++ b/services/web/frontend/js/main.js @@ -52,6 +52,7 @@ import './services/validateCaptcha' import './services/validateCaptchaV3' import './filters/formatDate' import '../../modules/modules-main.js' +import './cdn-load-test' angular.module('SharelatexApp').config(function ($locationProvider) { try { return $locationProvider.html5Mode({ diff --git a/services/web/frontend/js/marketing.js b/services/web/frontend/js/marketing.js index 2deb67cb38..bdf85d2a84 100644 --- a/services/web/frontend/js/marketing.js +++ b/services/web/frontend/js/marketing.js @@ -1,6 +1,7 @@ import './utils/webpack-public-path' import 'jquery' import 'bootstrap' +import './cdn-load-test' import './features/form-helpers/hydrate-form' import './features/link-helpers/slow-link' import './features/bookmarkable-tab' diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index e19fdfa9cb..d054ff93a8 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -12,7 +12,6 @@ const entryPoints = { serviceWorker: './frontend/js/serviceWorker.js', main: './frontend/js/main.js', ide: './frontend/js/ide.js', - 'cdn-load-test': './frontend/js/cdn-load-test.js', marketing: './frontend/js/marketing.js', style: './frontend/stylesheets/style.less', 'ieee-style': './frontend/stylesheets/ieee-style.less',