diff --git a/commercial/app/controllers/CommercialControllers.scala b/commercial/app/controllers/CommercialControllers.scala index 9533b212e3f..3dc6767bde6 100644 --- a/commercial/app/controllers/CommercialControllers.scala +++ b/commercial/app/controllers/CommercialControllers.scala @@ -25,6 +25,7 @@ trait CommercialControllers { lazy val piggybackPixelController = wire[PiggybackPixelController] lazy val cmpDataController = wire[CmpDataController] lazy val adsDotTextFileController = wire[AdsDotTextViewController] + lazy val prebidAnalyticsController = wire[PrebidAnalyticsController] lazy val passbackController = wire[PassbackController] lazy val ampIframeHtmlController = wire[AmpIframeHtmlController] lazy val nonRefreshableLineItemsController = wire[nonRefreshableLineItemsController] diff --git a/commercial/app/controllers/PrebidAnalyticsController.scala b/commercial/app/controllers/PrebidAnalyticsController.scala new file mode 100644 index 00000000000..788511f6701 --- /dev/null +++ b/commercial/app/controllers/PrebidAnalyticsController.scala @@ -0,0 +1,18 @@ +package commercial.controllers + +import common.GuLogging +import conf.Configuration.commercial.prebidAnalyticsStream +import conf.switches.Switches +import play.api.mvc._ + +import scala.concurrent.ExecutionContext + +class PrebidAnalyticsController(val controllerComponents: ControllerComponents) extends BaseController with GuLogging { + + private implicit val ec: ExecutionContext = controllerComponents.executionContext + + def insert(): Action[String] = + Action(parse.text) { implicit request => + Analytics.storeJsonBody(Switches.prebidAnalytics, prebidAnalyticsStream, log)(request.body) + } +} diff --git a/commercial/conf/routes b/commercial/conf/routes index f84e2e8c647..39858ed971d 100644 --- a/commercial/conf/routes +++ b/commercial/conf/routes @@ -41,6 +41,9 @@ GET /commercial/cmp/shortvendorlist.json GET /ads.txt commercial.controllers.AdsDotTextViewController.renderTextFile() GET /app-ads.txt commercial.controllers.AdsDotTextViewController.renderAppTextFile() +# Analytics +POST /commercial/api/hb commercial.controllers.PrebidAnalyticsController.insert() + # Passbacks GET /commercial/ias-passback/:size commercial.controllers.PassbackController.renderIasPassback(size) diff --git a/common/app/http/RequestLoggingFilter.scala b/common/app/http/RequestLoggingFilter.scala index b9920a9e420..e2e95a3732b 100644 --- a/common/app/http/RequestLoggingFilter.scala +++ b/common/app/http/RequestLoggingFilter.scala @@ -29,7 +29,8 @@ class RequestLoggingFilter(implicit val mat: Materializer, executionContext: Exe case _ => "" } } - if (rh.method != "POST") { + // don't log uncacheable /commercial/api/hb POST requests due to the volume of them + if (rh.method != "POST" || rh.path != "/commercial/api/hb") { requestLogger.withResponse(response).info(s"${rh.method} ${rh.uri}$additionalInfo") } case Failure(error) => diff --git a/dev-build/conf/routes b/dev-build/conf/routes index 345d8527ebd..68244268ba1 100644 --- a/dev-build/conf/routes +++ b/dev-build/conf/routes @@ -275,6 +275,7 @@ GET /commercial/non-refreshable-line-items.json GET /ads.txt commercial.controllers.AdsDotTextViewController.renderTextFile() GET /app-ads.txt commercial.controllers.AdsDotTextViewController.renderAppTextFile() GET /commercial/ias-passback/:size commercial.controllers.PassbackController.renderIasPassback(size) +POST /commercial/api/hb commercial.controllers.PrebidAnalyticsController.insert() # Commercial Admin GET /commercial controllers.admin.CommercialController.renderCommercialMenu() diff --git a/package.json b/package.json index c421369bee9..473903de0d2 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@emotion/react": "11.11.1", "@emotion/styled": "^10.0.27", "@guardian/ab-core": "8.0.0", - "@guardian/commercial": "23.0.0", + "@guardian/commercial": "23.1.0", "@guardian/core-web-vitals": "6.0.0", "@guardian/eslint-config-typescript": "9.0.1", "@guardian/identity-auth": "3.0.0", diff --git a/yarn.lock b/yarn.lock index 0bed09c3a92..f86cd0fdda1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4039,12 +4039,12 @@ __metadata: languageName: node linkType: hard -"@guardian/commercial@npm:23.0.0": - version: 23.0.0 - resolution: "@guardian/commercial@npm:23.0.0" +"@guardian/commercial@npm:23.1.0": + version: 23.1.0 + resolution: "@guardian/commercial@npm:23.1.0" dependencies: "@changesets/cli": "npm:^2.26.2" - "@guardian/prebid.js": "npm:8.52.0-6" + "@guardian/prebid.js": "npm:8.52.0-7" "@octokit/core": "npm:^6.1.2" fastdom: "npm:^1.0.11" lodash-es: "npm:^4.17.21" @@ -4059,7 +4059,7 @@ __metadata: "@guardian/libs": ^19.1.0 "@guardian/source": ^8.0.0 typescript: ~5.5.3 - checksum: 10c0/bffbd458eccc1c126c9c9ad126fc826d7caab6870e9b55202e3218e8b74c209ea253ec921c3f97c48db56b54d507a9c04c7bb4573ec1150140cf277ec1ac20e1 + checksum: 10c0/33104cc9313131b30d06f94419c188363449455d58b1257857ca6399e880e268d50ec2f405a9a9b5b9c6b0d7506360f1b8a552dc7cca93653f7e4fb64d425fe5 languageName: node linkType: hard @@ -4132,7 +4132,7 @@ __metadata: "@emotion/react": "npm:11.11.1" "@emotion/styled": "npm:^10.0.27" "@guardian/ab-core": "npm:8.0.0" - "@guardian/commercial": "npm:23.0.0" + "@guardian/commercial": "npm:23.1.0" "@guardian/core-web-vitals": "npm:6.0.0" "@guardian/eslint-config-typescript": "npm:9.0.1" "@guardian/identity-auth": "npm:3.0.0" @@ -4320,9 +4320,9 @@ __metadata: languageName: node linkType: hard -"@guardian/prebid.js@npm:8.52.0-6": - version: 8.52.0-6 - resolution: "@guardian/prebid.js@npm:8.52.0-6" +"@guardian/prebid.js@npm:8.52.0-7": + version: 8.52.0-7 + resolution: "@guardian/prebid.js@npm:8.52.0-7" dependencies: "@babel/core": "npm:^7.23.2" "@babel/plugin-transform-runtime": "npm:^7.18.9" @@ -4345,7 +4345,7 @@ __metadata: dependenciesMeta: fsevents: optional: true - checksum: 10c0/4c155d7754c3e5288f498ef16a77f13d58083d8199fb4ab5441a86ee5799c94ed611d3352fb9658c9edf05100129fffd254c48f4f83f3511afeab89da06739d9 + checksum: 10c0/a770d9a5264e4bf94caf615aabbf5e8c69bb8210313086b17dac406692b56a7acebe6c0c2054e170aeca88dd48db5684cb3a643dff210c04ce5ac861f3656cd3 languageName: node linkType: hard