feat(analytics): Tinylytics support (#1118)
* add tinylytics support * fix formatting * add trailing semicolon for consistency
This commit is contained in:
parent
aee9145691
commit
d03fdc235a
3 changed files with 14 additions and 1 deletions
|
@ -30,6 +30,10 @@ export type Analytics =
|
|||
apiKey: string
|
||||
host?: string
|
||||
}
|
||||
| {
|
||||
provider: "tinylytics"
|
||||
siteId: string
|
||||
}
|
||||
|
||||
export interface GlobalConfiguration {
|
||||
pageTitle: string
|
||||
|
|
|
@ -136,6 +136,14 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
|
|||
posthog.init('${cfg.analytics.apiKey}',{api_host:'${cfg.analytics.host ?? "https://app.posthog.com"}'})\`
|
||||
document.head.appendChild(posthogScript)
|
||||
`)
|
||||
} else if (cfg.analytics?.provider === "tinylytics") {
|
||||
const siteId = cfg.analytics.siteId
|
||||
componentResources.afterDOMLoaded.push(`
|
||||
const tinylyticsScript = document.createElement("script")
|
||||
tinylyticsScript.src = "https://tinylytics.app/embed/${siteId}.js"
|
||||
tinylyticsScript.defer = true
|
||||
document.head.appendChild(tinylyticsScript)
|
||||
`)
|
||||
}
|
||||
|
||||
if (cfg.enableSPA) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue