Aswanth
2025-05-24 6d49d975598cd7f48e2b7347c2b83d8aac6a2f56
fix(analytics): streamline posthog script loading and event capturing (#1974)

1 files modified
8 ■■■■ changed files
quartz/plugins/emitters/componentResources.ts 8 ●●●● patch | view | raw | blame | history
quartz/plugins/emitters/componentResources.ts
@@ -159,14 +159,10 @@
      posthog.init('${cfg.analytics.apiKey}', {
        api_host: '${cfg.analytics.host ?? "https://app.posthog.com"}',
        capture_pageview: false,
      })\`
      posthogScript.onload = () => {
        posthog.capture('$pageview', { path: location.pathname });
      });
        document.addEventListener('nav', () => {
          posthog.capture('$pageview', { path: location.pathname });
        });
      };
      })\`
      document.head.appendChild(posthogScript);
    `)