feat(analytics): Support for Umami (#449)

This commit is contained in:
Adam Brangenberg 2023-09-04 06:28:57 +02:00 committed by GitHub
parent 50da33ea4d
commit 49d5d56bf4
2 changed files with 13 additions and 0 deletions

View File

@ -12,6 +12,10 @@ export type Analytics =
provider: "google"
tagId: string
}
| {
provider: "umami"
websiteId: string
}
export interface GlobalConfiguration {
pageTitle: string

View File

@ -96,6 +96,15 @@ function addGlobalPageResources(
});`)
} else if (cfg.analytics?.provider === "plausible") {
componentResources.afterDOMLoaded.push(plausibleScript)
} else if (cfg.analytics?.provider === "umami") {
componentResources.afterDOMLoaded.push(`
const umamiScript = document.createElement("script")
umamiScript.src = "https://analytics.umami.is/script.js"
umamiScript["data-website-id"] = "${cfg.analytics.websiteId}"
umamiScript.async = true
document.head.appendChild(umamiScript)
`)
}
if (cfg.enableSPA) {