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 7e42be8e46
commit e8a04efaf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

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

View file

@ -96,6 +96,15 @@ function addGlobalPageResources(
});`) });`)
} else if (cfg.analytics?.provider === "plausible") { } else if (cfg.analytics?.provider === "plausible") {
componentResources.afterDOMLoaded.push(plausibleScript) 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) { if (cfg.enableSPA) {