---
const GAID = import.meta.env.PUBLIC_GA4_ID;
const UMAMIId = import.meta.env.PUBLIC_UMAMI_ID;
// const GAID = '';

if (!GAID) {
    // console.error("Google Analytics ID (PUBLIC_GA4_ID) is missing!");
}
---

<!-- GA4 跟踪代码 -->
{GAID && (
    <>
      <script  is:inline async src={`https://www.googletagmanager.com/gtag/js?id=${GAID}`} ></script>
      <script  is:inline define:vars={{ GAID }}>
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', GAID);
      </script>
    </>
)}

<!-- UMAMIId 跟踪代码 -->
{UMAMIId && (
    <script
        async
        defer
        is:inline
        data-website-id={UMAMIId}
        src="https://cloud.umami.is/script.js"
    ></script>
)}

