Skip to content

Commit

Permalink
Merge pull request #27533 from guardian/ei/reinstate-hb-endpoint
Browse files Browse the repository at this point in the history
Reinstate commercial/api/hb endpoint
  • Loading branch information
emma-imber authored Oct 17, 2024
2 parents 943ca65 + f031d81 commit b27a4af
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions commercial/app/controllers/CommercialControllers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions commercial/app/controllers/PrebidAnalyticsController.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}
3 changes: 3 additions & 0 deletions commercial/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion common/app/http/RequestLoggingFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
1 change: 1 addition & 0 deletions dev-build/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -4345,7 +4345,7 @@ __metadata:
dependenciesMeta:
fsevents:
optional: true
checksum: 10c0/4c155d7754c3e5288f498ef16a77f13d58083d8199fb4ab5441a86ee5799c94ed611d3352fb9658c9edf05100129fffd254c48f4f83f3511afeab89da06739d9
checksum: 10c0/a770d9a5264e4bf94caf615aabbf5e8c69bb8210313086b17dac406692b56a7acebe6c0c2054e170aeca88dd48db5684cb3a643dff210c04ce5ac861f3656cd3
languageName: node
linkType: hard

Expand Down

0 comments on commit b27a4af

Please sign in to comment.