make GA code configurable

Signed-off-by: MiniDigger <admin@minidigger.me>
This commit is contained in:
MiniDigger 2020-10-08 21:35:15 +02:00
parent 08918b4c07
commit 43db10ca57
3 changed files with 12 additions and 2 deletions

View File

@ -30,6 +30,7 @@ public class HangarConfig {
private final ApplicationHome home = new ApplicationHome(HangarApplication.class);
private String pluginUploadDir = home.getDir().toPath().resolve("work").toString();
private String baseUrl = "https://localhost:8080";
private String gaCode = "";
@NestedConfigurationProperty
public final FakeUserConfig fakeUser;
@ -191,6 +192,14 @@ public class HangarConfig {
this.baseUrl = baseUrl;
}
public String getGaCode() {
return gaCode;
}
public void setGaCode(String gaCode) {
this.gaCode = gaCode;
}
public void checkDebug() {
if (!debug) {
throw new UnsupportedOperationException("this function is supported in debug mode only");

View File

@ -49,6 +49,7 @@ hangar:
auth-url: "http://localhost:8000"
base-url: "http://localhost:8080"
use-webpack: true
ga-code: "UA-38006759-9"
sponsors:
- name: Beer

View File

@ -51,13 +51,13 @@ showFooter: Boolean = true, noContainer: Boolean = false, additionalMeta: Html =
<meta name="theme-color" content="#2980B9">
<#-- google foo -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-38006759-9"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=${config.gaCode}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-38006759-9');
gtag('config', '${config.gaCode}');
</script>
<script type="application/ld+json">
{