mirror of
https://gitlab.com/MisterBiggs/brain-quartz.git
synced 2025-09-18 19:52:44 +00:00
feat(analytics): add support for Vercel Web Analytics provider (#2119)
* feat(analytics): add support for Vercel Web Analytics provider * fix: correct indentation for Vercel analytics provider condition
This commit is contained in:
@@ -47,6 +47,9 @@ export type Analytics =
|
||||
host: string
|
||||
siteId: string
|
||||
}
|
||||
| {
|
||||
provider: "vercel"
|
||||
}
|
||||
|
||||
export interface GlobalConfiguration {
|
||||
pageTitle: string
|
||||
|
@@ -228,6 +228,19 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
|
||||
\`
|
||||
document.head.appendChild(matomoScript);
|
||||
`)
|
||||
} else if (cfg.analytics?.provider === "vercel") {
|
||||
/**
|
||||
* script from {@link https://vercel.com/docs/analytics/quickstart?framework=html#add-the-script-tag-to-your-site|Vercel Docs}
|
||||
*/
|
||||
componentResources.beforeDOMLoaded.push(`
|
||||
window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
|
||||
`)
|
||||
componentResources.afterDOMLoaded.push(`
|
||||
const vercelInsightsScript = document.createElement("script")
|
||||
vercelInsightsScript.src = "/_vercel/insights/script.js"
|
||||
vercelInsightsScript.defer = true
|
||||
document.head.appendChild(vercelInsightsScript)
|
||||
`)
|
||||
}
|
||||
|
||||
if (cfg.enableSPA) {
|
||||
|
Reference in New Issue
Block a user