fix(analytics): streamline posthog script loading and event capturing (#1974)
This commit is contained in:
		@@ -159,14 +159,10 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
 | 
			
		||||
      posthog.init('${cfg.analytics.apiKey}', {
 | 
			
		||||
        api_host: '${cfg.analytics.host ?? "https://app.posthog.com"}',
 | 
			
		||||
        capture_pageview: false,
 | 
			
		||||
      })\`
 | 
			
		||||
      posthogScript.onload = () => {
 | 
			
		||||
      });
 | 
			
		||||
      document.addEventListener('nav', () => {
 | 
			
		||||
        posthog.capture('$pageview', { path: location.pathname });
 | 
			
		||||
      
 | 
			
		||||
        document.addEventListener('nav', () => {
 | 
			
		||||
          posthog.capture('$pageview', { path: location.pathname });
 | 
			
		||||
        });
 | 
			
		||||
      };
 | 
			
		||||
      })\`
 | 
			
		||||
 | 
			
		||||
      document.head.appendChild(posthogScript);
 | 
			
		||||
    `)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user