Use Piwik integration for Astro

This commit is contained in:
Korbs 2024-05-17 02:10:52 -04:00
parent 1e5eff3a17
commit 42791d3a42
4 changed files with 20 additions and 24 deletions

View file

@ -1,11 +1,12 @@
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import markdoc from '@astrojs/markdoc';
import AutoImport from 'astro-auto-import';
import keystatic from '@keystatic/astro';
import { defineConfig } from 'astro/config'
import react from '@astrojs/react'
import markdoc from '@astrojs/markdoc'
import AutoImport from 'astro-auto-import'
import keystatic from '@keystatic/astro'
import node from '@astrojs/node'
import robotsTxt from 'astro-robots-txt'
import mdx from '@astrojs/mdx';
import mdx from '@astrojs/mdx'
import matomo from 'astro-matomo'
// https://astro.build/config
export default defineConfig({
@ -23,6 +24,17 @@ export default defineConfig({
],
}),
mdx(), // This must initalzied after AutoImport, not before
matomo({
enabled: import.meta.env.PROD, // Only load in production
host: "https://stats.sudovanilla.org/",
setCookieDomain: "*.sudovanilla.org",
trackerUrl: "js/", // defaults to matomo.php
srcUrl: "js/", // defaults to matomo.js
siteId: 1,
heartBeatTimer: 5,
disableCookies: true,
debug: false,
}),
robotsTxt({
policy: [
{ userAgent: 'Googlebot', disallow: '/' },
@ -52,4 +64,4 @@ export default defineConfig({
port: 2014,
host: true
}
});
})

BIN
bun.lockb

Binary file not shown.

View file

@ -26,6 +26,7 @@
"astro": "^4.6.3",
"astro-auto-import": "^0.4.2",
"astro-json-element": "^1.1.4",
"astro-matomo": "^1.6.0",
"astro-robots-txt": "^1.0.0",
"astro-useragent": "^4.0.1",
"axios": "^1.6.8",

View file

@ -35,21 +35,4 @@ if (Astro.url.hostname === "localhost") {
/>
<script type="module" src="/@shoelace-style/shoelace/cdn/shoelace.js"
></script>
{
UsePiwik ? (
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.sudovanilla.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
) : null
}
</head>