Skip to content

Commit

Permalink
APSR-1767 - Add GTM script to redoc view page (hmrc#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndySpaven authored Dec 14, 2023
1 parent 0fa27c2 commit b9aee93
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ trait ApplicationConfig {

def oasFetchResolvedMaxDuration: Long
def oasFetchResolvedUsingHttps: Boolean

def trackingConsentUrl: String
def gtmContainer: String
}

@Singleton
Expand Down Expand Up @@ -117,4 +120,9 @@ class ApplicationConfigImpl @Inject() (config: Configuration)
}
}

// Needed for GTM on the redoc rendered page
val trackingConsentUrl: String =
config.get[String]("tracking-consent-frontend.url")

val gtmContainer: String = config.get[String]("tracking-consent-frontend.gtm.container")
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import uk.gov.hmrc.apidocumentation.models._
import uk.gov.hmrc.apidocumentation.services.{ApiDefinitionService, LoggedInUserService, NavigationService}
import uk.gov.hmrc.apidocumentation.util.ApplicationLogger
import uk.gov.hmrc.apidocumentation.views.html._
import play.api.i18n.MessagesProvider

@Singleton
class OpenApiDocumentationController @Inject() (
Expand Down Expand Up @@ -74,7 +75,7 @@ class OpenApiDocumentationController @Inject() (
sidebarLinks = navigationService.sidebarNavigation()
)

private def doRenderApiDocumentation(service: ServiceName, version: ApiVersionNbr, apiOption: Option[ExtendedApiDefinition])(implicit request: Request[AnyContent]): Future[Result] = {
private def doRenderApiDocumentation(service: ServiceName, version: ApiVersionNbr, apiOption: Option[ExtendedApiDefinition])(implicit request: Request[AnyContent], messagesProvider: MessagesProvider): Future[Result] = {
def renderDocumentationPage(apiName: String): Future[Result] = {
successful(Ok(openApiViewRedoc(service, version, apiName)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@
@import views.html.helper.CSPNonce
@import uk.gov.hmrc.apiplatform.modules.apis.domain.models._
@import uk.gov.hmrc.apiplatform.modules.common.domain.models._
@import uk.gov.hmrc.apidocumentation.config._

@this()

@(serviceName: ServiceName, version: ApiVersionNbr, apiName: String)(implicit requestHeader: RequestHeader)
@(serviceName: ServiceName, version: ApiVersionNbr, apiName: String)(implicit requestHeader: RequestHeader, appConfig: ApplicationConfig, messages: Messages)

<!--[if !IE]>-->
<script
src="@appConfig.trackingConsentUrl"
id="tracking-consent-script-tag"
data-gtm-container="@appConfig.gtmContainer"
data-language="@messages.lang.code"
></script>
<!--<![endif]-->

<head>
<title>@apiName - HMRC Developer Hub - GOV.UK</title>
Expand Down
5 changes: 3 additions & 2 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ oasFetchResolvedUsingHttps = false
apidocumentation.base.url = "http://localhost:9680"

tracking-consent-frontend {
gtm.container = "b"
cookie-settings-path = "tracking-consent/cookie-settings"
gtm.container = "b"
url = "http://localhost:12345/tracking-consent/tracking.js"
cookie-settings-path = "tracking-consent/cookie-settings"
}

urls {
Expand Down

0 comments on commit b9aee93

Please sign in to comment.