diff --git a/common/app/experiments/Experiments.scala b/common/app/experiments/Experiments.scala index 5df5287da19..21a1fe74579 100644 --- a/common/app/experiments/Experiments.scala +++ b/common/app/experiments/Experiments.scala @@ -11,13 +11,23 @@ import java.time.LocalDate object ActiveExperiments extends ExperimentsDefinition { override val allExperiments: Set[Experiment] = Set( - DarkModeWeb, + RemoveLiteFronts, UpdatedHeaderDesign, MastheadWithHighlights, + DarkModeWeb, ) implicit val canCheckExperiment: CanCheckExperiment = new CanCheckExperiment(this) } +object RemoveLiteFronts + extends Experiment( + name = "remove-lite-fronts", + description = "Get the full pressed page of a front instead of the lite version", + owners = Seq(Owner.withEmail("dotcom.platform@theguardian.com")), + sellByDate = LocalDate.of(2024, 10, 30), + participationGroup = Perc0A, + ) + object UpdatedHeaderDesign extends Experiment( name = "updated-header-design", diff --git a/facia/app/controllers/FaciaController.scala b/facia/app/controllers/FaciaController.scala index cf6fabb2db0..e8a2662a800 100644 --- a/facia/app/controllers/FaciaController.scala +++ b/facia/app/controllers/FaciaController.scala @@ -6,6 +6,7 @@ import common._ import conf.Configuration import conf.switches.Switches.InlineEmailStyles import controllers.front._ +import experiments.{ActiveExperiments, RemoveLiteFronts} import http.HttpPreconnections import implicits.GUHeaders import layout.slices._ @@ -139,7 +140,7 @@ trait FaciaController successful(Cached(CacheTime.Facia)(notFound())) } else { frontJsonFapi - .get(path, liteRequestType) + .get(path, requestType) .map(_.fold[CacheableResult](notFound())(FrontHeadline.renderEmailHeadline)) .map(Cached(CacheTime.Facia)) } @@ -180,7 +181,7 @@ trait FaciaController Cached(CacheTime.Facia)(JsonComponent.fromWritable(JsObject(Nil))), ) } else { - frontJsonFapi.get(path, liteRequestType).map { resp => + frontJsonFapi.get(path, requestType).map { resp => Cached(CacheTime.Facia)(JsonComponent.fromWritable(resp match { case Some(pressedPage) => FapiFrontJsonMinimal.get(pressedPage) case None => JsObject(Nil) @@ -220,7 +221,9 @@ trait FaciaController import PressedPage.pressedPageFormat private[controllers] def renderFrontPressResult(path: String)(implicit request: RequestHeader): Future[Result] = { - val futureFaciaPage: Future[Option[(PressedPage, Boolean)]] = frontJsonFapi.get(path, liteRequestType).flatMap { + val NonAdFreeType = if (ActiveExperiments.isParticipating(RemoveLiteFronts)) FullType else LiteType + + val futureFaciaPage: Future[Option[(PressedPage, Boolean)]] = frontJsonFapi.get(path, requestType).flatMap { case Some(faciaPage: PressedPage) => val pageContainsTargetedCollections = TargetedCollections.pageContainsTargetedCollections(faciaPage) val regionalFaciaPage = TargetedCollections.processTargetedCollections( @@ -235,8 +238,8 @@ trait FaciaController List(), ) } - if (faciaPage.collections.isEmpty && liteRequestType == LiteAdFreeType) { - frontJsonFapi.get(path, LiteType).map(_.map(f => (f, false))) + if (faciaPage.collections.isEmpty && (requestType == FullAdFreeType || requestType == LiteAdFreeType)) { + frontJsonFapi.get(path, NonAdFreeType).map(_.map(f => (f, false))) } else Future.successful(Some(regionalFaciaPage, pageContainsTargetedCollections)) case None => Future.successful(None) } @@ -527,6 +530,8 @@ trait FaciaController if (request.isAdFree) FullAdFreeType else FullType def liteRequestType(implicit request: RequestHeader): PressedPageType = if (request.isAdFree) LiteAdFreeType else LiteType + def requestType(implicit request: RequestHeader): PressedPageType = + if (ActiveExperiments.isParticipating(RemoveLiteFronts)) fullRequestType else liteRequestType def ampRsaPublicKey: Action[AnyContent] = { Action { diff --git a/facia/app/services/dotcomrendering/FaciaPicker.scala b/facia/app/services/dotcomrendering/FaciaPicker.scala index 80cce801437..c44aba197b0 100644 --- a/facia/app/services/dotcomrendering/FaciaPicker.scala +++ b/facia/app/services/dotcomrendering/FaciaPicker.scala @@ -2,6 +2,7 @@ package services.dotcomrendering import common.{Edition, GuLogging} import conf.switches.Switches.{DCRFronts, DCRNetworkFronts} +import experiments.{ActiveExperiments, RemoveLiteFronts} import implicits.Requests._ import model.PressedPage import model.facia.PressedCollection @@ -106,6 +107,7 @@ object FaciaPicker extends GuLogging { lazy val dcrCouldRender = checks.values.forall(checkValue => checkValue) lazy val isNetworkFront = faciaPage.isNetworkFront lazy val dcrNetworkFrontsSwitchEnabled = DCRNetworkFronts.isSwitchedOn + lazy val isFullFrontRequest = ActiveExperiments.isParticipating(RemoveLiteFronts) val tier = decideTier( @@ -118,7 +120,7 @@ object FaciaPicker extends GuLogging { dcrNetworkFrontsSwitchEnabled, ) - logTier(faciaPage, dcrCouldRender, checks, tier) + logTier(faciaPage, dcrCouldRender, checks, tier, isFullFrontRequest) tier } @@ -149,6 +151,7 @@ object FaciaPicker extends GuLogging { dcrCouldRender: Boolean, checks: Map[String, Boolean], tier: RenderType, + isFullFrontRequest: Boolean, )(implicit request: RequestHeader): Unit = { val tierReadable = if (tier == RemoteRender) "dotcomcomponents" else "web" val checksToString = checks.map { case (key, value) => @@ -161,6 +164,7 @@ object FaciaPicker extends GuLogging { "dcrCouldRender" -> dcrCouldRender.toString, "isFront" -> "true", "tier" -> tierReadable, + "isFullFrontRequest" -> isFullFrontRequest.toString, ) ++ checksToString DotcomFrontsLogger.logger.logRequest(s"front executing in $tierReadable", properties, faciaPage)