feat(analytics): Support for Umami (#449)
This commit is contained in:
		
							parent
							
								
									7e42be8e46
								
							
						
					
					
						commit
						e8a04efaf1
					
				
					 2 changed files with 13 additions and 0 deletions
				
			
		| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue