From fadbbc5070e1a7655c478f8d7382ca7f97828333 Mon Sep 17 00:00:00 2001 From: Dina Hafez Date: Wed, 5 Jun 2024 09:47:40 +0100 Subject: [PATCH] Re-add some of the Ophan code and cleanup --- applications/app/views/videoEmbed.scala.html | 11 +++++++++++ common/app/conf/switches/ABTestSwitches.scala | 4 ++-- common/app/model/meta.scala | 6 ++++++ .../common/modules/analytics/interaction-tracking.js | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/applications/app/views/videoEmbed.scala.html b/applications/app/views/videoEmbed.scala.html index 30a62157e183..2c09651bd8b4 100644 --- a/applications/app/views/videoEmbed.scala.html +++ b/applications/app/views/videoEmbed.scala.html @@ -69,6 +69,17 @@ config: @Html(templates.js.javaScriptConfig(model.SimpleContentPage(video)).body), adBlockers: { onDetect: [] } }; + @* Decide the Ophan PV ID here so we can share it with Google Analytics *@ + guardian.config.ophan = { + // This is duplicated from + // https://github.com/guardian/ophan/blob/master/tracker-js/assets/coffee/ophan/transmit.coffee + // Please do not change this without talking to the Ophan project first. + pageViewId: new Date().getTime().toString(36) + 'xxxxxxxxxxxx'.replace(/x/g, function () { + return Math.floor(Math.random() * 36).toString(36); + }) + }; + @* Find the Ophan browser ID as well, for sharing with GA *@ + @Html(templates.inlineJS.nonBlocking.js.ophanConfig().body) var docClass = document.documentElement.className; diff --git a/common/app/conf/switches/ABTestSwitches.scala b/common/app/conf/switches/ABTestSwitches.scala index e7a839b0793e..12f964550be0 100644 --- a/common/app/conf/switches/ABTestSwitches.scala +++ b/common/app/conf/switches/ABTestSwitches.scala @@ -41,7 +41,7 @@ trait ABTestSwitches { "Test MPU when there is no epic at the end of Article on the page.", owners = Seq(Owner.withEmail("commercial.dev@theguardian.com")), safeState = Off, - sellByDate = Some(LocalDate.of(2024, 7, 31)), + sellByDate = Some(LocalDate.of(2024, 5, 31)), exposeClientSide = true, ) @@ -51,7 +51,7 @@ trait ABTestSwitches { "Show new ad block ask component in ad slots when we detect ad blocker usage", owners = Seq(Owner.withEmail("commercial.dev@theguardian.com")), safeState = Off, - sellByDate = Some(LocalDate.of(2024, 7, 31)), + sellByDate = Some(LocalDate.of(2024, 5, 31)), exposeClientSide = true, ) diff --git a/common/app/model/meta.scala b/common/app/model/meta.scala index b3c7a5c70f34..ede392e585dd 100644 --- a/common/app/model/meta.scala +++ b/common/app/model/meta.scala @@ -14,6 +14,7 @@ import conf.Configuration import conf.cricketPa.CricketTeams import model.liveblog.Blocks import model.meta.{Guardian, LinkedData, PotentialAction, WebPage} +import org.apache.commons.lang3.StringUtils import org.joda.time.DateTime import com.github.nscala_time.time.Implicits._ import play.api.libs.json._ @@ -450,6 +451,11 @@ case class MetaData( .getOrElse(Nil) def iosId(referrer: String): Option[String] = iosType.map(iosType => s"$id?contenttype=$iosType&source=$referrer") + + /** + * Content type, lowercased and with spaces removed. + */ + def normalisedContentType: String = StringUtils.remove(contentType.map(_.name.toLowerCase).getOrElse(""), ' ') } object Page { diff --git a/static/src/javascripts/projects/common/modules/analytics/interaction-tracking.js b/static/src/javascripts/projects/common/modules/analytics/interaction-tracking.js index 9802f66c0043..29676b1143f3 100644 --- a/static/src/javascripts/projects/common/modules/analytics/interaction-tracking.js +++ b/static/src/javascripts/projects/common/modules/analytics/interaction-tracking.js @@ -7,7 +7,7 @@ let loc = document.location; const trackInternalLinkClick = (spec) => { // Store in session storage. - // Omniture will both pick it up on next page load, + // Omniture will pick it up on next page load, // then Omniture will remove it from storage. const storeObj = { path: loc.pathname,