Support more analytic tools

This commit is contained in:
Korbs 2024-06-10 21:38:01 -04:00
parent 5040cca114
commit 0bd86b9bcd

View file

@ -8,7 +8,15 @@ import {
PLAUSIBLE_SRC, PLAUSIBLE_SRC,
UMAMI_ID, UMAMI_ID,
UMAMI_SRC, UMAMI_SRC,
AMPLITUDE_APIKEY AMPLITUDE_APIKEY,
METRICAL_APP,
FATHOM_SITE,
FATHOM_SRC,
MINIAML_ID,
SWETRIX_SRC,
SWETRIX_API,
SWETRIX_PROJECT_ID,
SIMPLEANALYTICS_DOMAIN
} from '@utils/GetConfig' } from '@utils/GetConfig'
// Get Astro Analytics // Get Astro Analytics
@ -21,22 +29,40 @@ import {
Amplitude, Amplitude,
Matomo, Matomo,
MinimalAnalytics MinimalAnalytics
} from 'astro-analytics'; } from 'astro-analytics'
--- ---
<!-- https://gist.sudovanilla.org/Korbs/fac0f5b99a6e43679c1d38d614721b5e --> <!-- https://gist.sudovanilla.org/Korbs/fac0f5b99a6e43679c1d38d614721b5e -->
{ {
()=> { ()=> {
if (ANALYTICS === "None") { if (ANALYTICS === "None") {
return null return null
} else if (ANALYTICS === "Plausible") { } else if (ANALYTICS === "Plausible") {
<Plausible domain={PLAUSIBLE_DOMAIN} src={PLAUSIBLE_SRC + "/yoursript.js"} /> <Plausible domain={PLAUSIBLE_DOMAIN} src={PLAUSIBLE_SRC + "/yoursript.js"} />
} else if (ANALYTICS === "Umami") { } else if (ANALYTICS === "Umami") {
<Umami id="4fb7fa4c-5b46-438d-94b3-3a8fb9bc2e8b" src={UMAMI_SRC + "/umami.js"} /> <Umami id="4fb7fa4c-5b46-438d-94b3-3a8fb9bc2e8b" src={UMAMI_SRC + "/umami.js"} />
} else if (ANALYTICS === "Amplitude") { } else if (ANALYTICS === "Amplitude") {
<Amplitude apiKey={AMPLITUDE_APIKEY} /> <Amplitude apiKey={AMPLITUDE_APIKEY} />
} else if (ANALYTICS === "Matomo") { } else if (ANALYTICS === "Matomo") {
<Matomo id={MATOMO_ID} src={MATOMO_SRC} /> <Matomo id={MATOMO_ID} src={MATOMO_SRC} />
} } else if (ANALYTICS === "Metrical") {
<Metrical app={METRICAL_APP} />
} else if (ANALYTICS === "Fathom") {
<Fathom site={FATHOM_SITE} src={FATHOM_SRC} />
} else if (ANALYTICS === "MinimalAnalytics") {
<MinimalAnalytics id={MINIAML_ID} />
} else if (ANALYTICS === "Swetrix") {
<script is:inline src={SWETRIX_SRC} defer></script>
<script is:inline>
document.addEventListener('DOMContentLoaded', function () {
swetrix.init({SWETRIX_PROJECT_ID})
swetrix.trackViews()
})
</script>
<noscript><img src={SWETRIX_API + '/log/noscript?pid=' + SWETRIX_PROJECT_ID} alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
} else if (ANALYTICS === "Simple Analytics") {
<script is:inline async defer data-hostname={SIMPLEANALYTICS_DOMAIN} src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<noscript><img src={'https://queue.simpleanalyticscdn.com/noscript.gif?hostname=' + SIMPLEANALYTICS_DOMAIN} alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
} }
} }
}