From 82d946cafac7b8d9d50e90238e4a424f3b0c75b1 Mon Sep 17 00:00:00 2001 From: Jake Lee Kennedy Date: Wed, 4 Dec 2024 10:41:11 +0000 Subject: [PATCH] add 0% test --- common/app/common/configuration.scala | 4 ++++ common/app/experiments/Experiments.scala | 10 ++++++++++ common/app/views/support/JavaScriptPage.scala | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/common/app/common/configuration.scala b/common/app/common/configuration.scala index 924395b0cc50..8dd96adbf022 100644 --- a/common/app/common/configuration.scala +++ b/common/app/common/configuration.scala @@ -521,6 +521,10 @@ class GuardianConfiguration extends GuLogging { lazy val prebidServerUrl = configuration.getStringProperty("commercial.prebid.server.url") getOrElse "http://localhost:8000" + lazy val overrideCommercialBundleUrl: Option[String] = + if (environment.isDev) configuration.getStringProperty("commercial.overrideCommercialBundleUrl") + else None + def getBundlePath = configuration.getMandatoryStringProperty("commercial.bundlePath") } diff --git a/common/app/experiments/Experiments.scala b/common/app/experiments/Experiments.scala index efa1fd813b18..b3f5c3ee5b95 100644 --- a/common/app/experiments/Experiments.scala +++ b/common/app/experiments/Experiments.scala @@ -12,6 +12,7 @@ object ActiveExperiments extends ExperimentsDefinition { override val allExperiments: Set[Experiment] = Set( EuropeBetaFront, + CommercialBundleUpdater, DarkModeWeb, ) implicit val canCheckExperiment: CanCheckExperiment = new CanCheckExperiment(this) @@ -38,3 +39,12 @@ object DarkModeWeb sellByDate = LocalDate.of(2025, 1, 30), participationGroup = Perc0D, ) + +object CommercialBundleUpdater + extends Experiment( + name = "commercial-bundle-updater", + description = "Enable the commercial bundle updater", + owners = Seq(Owner.withGithub("jakeii")), + sellByDate = LocalDate.of(2025, 1, 30), + participationGroup = Perc0B, + ) diff --git a/common/app/views/support/JavaScriptPage.scala b/common/app/views/support/JavaScriptPage.scala index fb235d57a40f..ce64a5bdd39f 100644 --- a/common/app/views/support/JavaScriptPage.scala +++ b/common/app/views/support/JavaScriptPage.scala @@ -14,6 +14,7 @@ import model.dotcomrendering.DotcomRenderingUtils.assetURL import play.api.mvc.RequestHeader import views.support.Commercial.isAdFree import common.CommercialBundle +import experiments.{ActiveExperiments, CommercialBundleUpdater} object JavaScriptPage { @@ -71,9 +72,14 @@ object JavaScriptPage { val ipsos = if (page.metadata.isFront) getScriptTag(page.metadata.id) else getScriptTag(page.metadata.sectionId) - def commercialBundleUrl = JsString( - CommercialBundle.getBundleUrl, - ) + val commercialBundleUrl = + if (ActiveExperiments.isParticipating(CommercialBundleUpdater)(request)) + JsString(CommercialBundle.getBundleUrl) + else + JsString( + Configuration.commercial.overrideCommercialBundleUrl + .getOrElse(assetURL("javascripts/commercial/graun.standalone.commercial.js")), + ) javascriptConfig ++ config ++ commercialMetaData ++ journalismMetaData ++ Map( ("edition", JsString(edition.id)),