diff --git a/common/app/experiments/Experiments.scala b/common/app/experiments/Experiments.scala index b25bb979327..6604427ed1b 100644 --- a/common/app/experiments/Experiments.scala +++ b/common/app/experiments/Experiments.scala @@ -16,7 +16,6 @@ object ActiveExperiments extends ExperimentsDefinition { UpdatedHeaderDesign, UpdateLogoAdPartner, MastheadWithHighlights, - AffiliateLinksDCR, ) implicit val canCheckExperiment: CanCheckExperiment = new CanCheckExperiment(this) } @@ -58,15 +57,6 @@ object UpdateLogoAdPartner participationGroup = Perc0A, ) -object AffiliateLinksDCR - extends Experiment( - name = "affiliate-links-dcr", - description = "Display affiliate links on all eligible DCR articles", - owners = Seq(Owner.withGithub("commercial.dev@theguardian.com")), - sellByDate = LocalDate.of(2024, 7, 30), - participationGroup = Perc0E, - ) - object DCRTagPages extends Experiment( name = "dcr-tag-pages", diff --git a/common/app/model/dotcomrendering/DotcomBlocksRenderingDataModel.scala b/common/app/model/dotcomrendering/DotcomBlocksRenderingDataModel.scala index 65c90d5e409..6edc08e8aa5 100644 --- a/common/app/model/dotcomrendering/DotcomBlocksRenderingDataModel.scala +++ b/common/app/model/dotcomrendering/DotcomBlocksRenderingDataModel.scala @@ -69,7 +69,7 @@ object DotcomBlocksRenderingDataModel { bodyBlocks: Seq[APIBlock], ): DotcomBlocksRenderingDataModel = { val content = page.item - val shouldAddAffiliateLinks = DotcomRenderingUtils.shouldAddAffiliateLinks(content)(request) + val shouldAddAffiliateLinks = DotcomRenderingUtils.shouldAddAffiliateLinks(content) val contentDateTimes = DotcomRenderingUtils.contentDateTimes(content) val edition = Edition(request) diff --git a/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala b/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala index fe97e8df2d9..f1f280ab99c 100644 --- a/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala +++ b/common/app/model/dotcomrendering/DotcomRenderingDataModel.scala @@ -487,7 +487,7 @@ object DotcomRenderingDataModel { blocks.exists(block => DotcomRenderingUtils.stringContainsAffiliateableLinks(block.bodyHtml)) } - val shouldAddAffiliateLinks = DotcomRenderingUtils.shouldAddAffiliateLinks(content)(request) + val shouldAddAffiliateLinks = DotcomRenderingUtils.shouldAddAffiliateLinks(content) val shouldAddDisclaimer = hasAffiliateLinks(bodyBlocks) val contentDateTimes: ArticleDateTimes = ArticleDateTimes( diff --git a/common/app/model/dotcomrendering/DotcomRenderingUtils.scala b/common/app/model/dotcomrendering/DotcomRenderingUtils.scala index 1f6875d6fd2..ebc6170089b 100644 --- a/common/app/model/dotcomrendering/DotcomRenderingUtils.scala +++ b/common/app/model/dotcomrendering/DotcomRenderingUtils.scala @@ -242,15 +242,16 @@ object DotcomRenderingUtils { } } - def shouldAddAffiliateLinks(content: ContentType)(implicit request: RequestHeader): Boolean = { + def shouldAddAffiliateLinks(content: ContentType): Boolean = { val contentHtml = Jsoup.parse(content.fields.body) val bodyElements = contentHtml.select("body").first().children() + /** - * On smaller devices, the disclaimer is inserted before paragraph 2 of the article body and floats left. - * This logic ensures there are two clear paragraphs of text at the top of the article. - * We don't support inserting the disclaimer next to other element types. - * It also ensures the second paragraph is long enough to accommodate the disclaimer appearing alongside it. - */ + * On smaller devices, the disclaimer is inserted before paragraph 2 of the article body and floats left. + * This logic ensures there are two clear paragraphs of text at the top of the article. + * We don't support inserting the disclaimer next to other element types. + * It also ensures the second paragraph is long enough to accommodate the disclaimer appearing alongside it. + */ if (bodyElements.size >= 2) { val firstEl = bodyElements.get(0) val secondEl = bodyElements.get(1) diff --git a/common/app/views/support/HtmlCleaner.scala b/common/app/views/support/HtmlCleaner.scala index a6a1d829b90..61185dae588 100644 --- a/common/app/views/support/HtmlCleaner.scala +++ b/common/app/views/support/HtmlCleaner.scala @@ -6,7 +6,6 @@ import common.{Edition, GuLogging, LinkTo} import conf.Configuration.affiliateLinks._ import conf.Configuration.site.host import conf.switches.Switches._ -import experiments.{ActiveExperiments, AffiliateLinksDCR} import layout.ContentWidths import layout.ContentWidths._ import model._ @@ -873,8 +872,7 @@ case class AffiliateLinksCleaner( appendDisclaimer: Option[Boolean] = None, tags: List[String], publishedDate: Option[DateTime], -)(implicit request: RequestHeader) - extends HtmlCleaner +) extends HtmlCleaner with GuLogging { override def clean(document: Document): Document = { @@ -943,15 +941,15 @@ object AffiliateLinksCleaner { alwaysOffTags: Set[String], tagPaths: List[String], firstPublishedDate: Option[DateTime], - )(implicit request: RequestHeader): Boolean = { + ): Boolean = { val publishedCutOffDate = new DateTime(2020, 8, 14, 0, 0) // Never include affiliate links if it is tagged with an always off tag, or if it was published before our cut off date. // The cut off date is temporary while we are working on improving the compliance of affiliate links. if ( - !contentHasAlwaysOffTag(tagPaths, alwaysOffTags) && (firstPublishedDate.exists( + !contentHasAlwaysOffTag(tagPaths, alwaysOffTags) && firstPublishedDate.exists( _.isBefore(publishedCutOffDate), - ) || ActiveExperiments.isParticipating(AffiliateLinksDCR)) + ) ) { if (showAffiliateLinks.isDefined) { showAffiliateLinks.contains(true) diff --git a/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala b/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala index a24fc06dc8c..82967ac52d9 100644 --- a/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala +++ b/common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala @@ -1,10 +1,8 @@ package views.support.cleaner import conf.Configuration -import conf.switches.Switches.ServerSideExperiments import org.joda.time.DateTime import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -import play.api.test.FakeRequest import views.support.AffiliateLinksCleaner._ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { @@ -18,7 +16,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { } "shouldAddAffiliateLinks" should "correctly determine when to add affiliate links" in { - val fakeTestControlRequest = FakeRequest().withHeaders("X-GU-Experiment-0perc-E" -> "control") val supportedSections = Set("film", "books", "fashion") val oldPublishedDate = Some(new DateTime(2020, 8, 13, 0, 0)) val newPublishedDate = Some(new DateTime(2020, 8, 15, 0, 0)) @@ -32,7 +29,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List.empty, oldPublishedDate, - )(fakeTestControlRequest) should be(false) + ) should be(false) shouldAddAffiliateLinks( switchedOn = true, "film", @@ -42,7 +39,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List.empty, oldPublishedDate, - )(fakeTestControlRequest) should be(true) + ) should be(true) shouldAddAffiliateLinks( switchedOn = true, "film", @@ -52,7 +49,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List.empty, oldPublishedDate, - )(fakeTestControlRequest) should be(false) + ) should be(false) shouldAddAffiliateLinks( switchedOn = true, "news", @@ -62,7 +59,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List.empty, oldPublishedDate, - )(fakeTestControlRequest) should be(true) + ) should be(true) shouldAddAffiliateLinks( switchedOn = true, "news", @@ -72,7 +69,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List("bereavement"), oldPublishedDate, - )(fakeTestControlRequest) should be(false) + ) should be(false) shouldAddAffiliateLinks( switchedOn = true, "news", @@ -82,7 +79,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List("tech"), oldPublishedDate, - )(fakeTestControlRequest) should be(false) + ) should be(false) shouldAddAffiliateLinks( switchedOn = true, "fashion", @@ -92,7 +89,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List("tech"), oldPublishedDate, - )(fakeTestControlRequest) should be(true) + ) should be(true) shouldAddAffiliateLinks( switchedOn = true, "fashion", @@ -102,7 +99,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set("bereavement"), List("bereavement"), oldPublishedDate, - )(fakeTestControlRequest) should be(false) + ) should be(false) shouldAddAffiliateLinks( switchedOn = true, "fashion", @@ -112,7 +109,7 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set("bereavement"), List("tech"), oldPublishedDate, - )(fakeTestControlRequest) should be(true) + ) should be(true) shouldAddAffiliateLinks( switchedOn = true, "film", @@ -122,6 +119,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers { Set.empty, List.empty, newPublishedDate, - )(fakeTestControlRequest) should be(true) + ) should be(true) } }