remplacement de matomo par umami

This commit is contained in:
Valentin 2024-06-27 22:39:57 +02:00
parent c8c86b2ac0
commit ca3a94d207
5 changed files with 39 additions and 51 deletions

View File

@ -78,11 +78,11 @@ Branch filter prod
Authorization Header generate a safe string using : openssl rand -base64 32
```
4. Setup Matomo tracking
4. Setup Umami tracking
Add a new website to track from the Matomo interface as an admin user
Add a new website to track from the Umami interface as an admin user
All website → Add a new Website → Website
Settings → Add Website
## Ref

View File

@ -1,19 +0,0 @@
// https://romangeber.com/blog/tech/nuxt3_matomo_integration
import VueMatomo from "vue-matomo";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueMatomo, {
debug: false,
host: '',
siteId: 0,
router: nuxtApp.$router,
enableHeartBeatTimer: true,
heartBeatTimerInterval: 5,
enableLinkTracking: true,
requireConsent: false,
trackInitialView: true,
disableCookies: true,
requireCookieConsent: false,
});
});

View File

@ -1,24 +0,0 @@
#!/bin/bash
echo -e "${PURPLE}${BOLD}Add a new website to track from the Matomo interface as an admin user${RESET}"
echo -e "${PURPLE}${BOLD}All website → Add a new Website → Website${RESET}"
echo -e "${PURPLE}${BOLD}Fill in the following informations :${RESET}"
echo -e "${BLUE}${BOLD}Website name : ${RESET}${BLUE}${DOMAIN_NAME}${RESET}"
echo -e "${BLUE}${BOLD}Urls : ${RESET}${BLUE}https://${DOMAIN_NAME}/${RESET}"
echo -e "${PURPLE}${BOLD}Enter the Matomo instance URL :${RESET}"
echo -e "${PURPLE} ie : matomo.example.com${RESET}"
read matomo_url
echo -e "${PURPLE}${BOLD}Find the website ID at the following URL${RESET}"
echo -e "${BLUE}https://${matomo_url}/index.php?module=SitesManager${RESET}"
echo -e "${PURPLE}${BOLD}Enter the Website ID :${RESET}"
read matomo_website_id
mkdir -p ${FRONT_DIRECTORY}/plugins
cp assets/matomo-plugin.client.js ${FRONT_DIRECTORY}/plugins
chown -R www-data:www-data ${FRONT_DIRECTORY}/plugins
su -s /bin/bash -c "cd ${FRONT_DIRECTORY} &&\
npm install --save vue-matomo" www-data
sed -i "s/host: ''/host: 'https\:\/\/$matomo_url'/" "$FRONT_DIRECTORY/plugins/matomo-plugin.client.js"
sed -i "s/siteId: 0/siteId: $matomo_website_id/" "$FRONT_DIRECTORY/plugins/matomo-plugin.client.js"

31
bin/setup_umami.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
echo -e "${PURPLE}${BOLD}Add a new website to track from the Umami interface as an admin user${RESET}"
echo -e "${PURPLE}${BOLD}Settings → Add Website${RESET}"
echo -e "${PURPLE}${BOLD}Enter the Umami instance URL :${RESET}"
echo -e "${PURPLE} ie : umami.example.com${RESET}"
read umami_url
echo -e "${PURPLE}${BOLD}Enter the Website ID :${RESET}"
read umami_website_id
script_snippet="head: {
script: [
{
src: 'https://$umami_url',
defer: true,
'data-website-id': '$umami_website_id'
}
]
}"
if ! grep -q "$script_snippet" nuxt.config.ts; then
if grep -q "app: {" nuxt.config.ts; then
sed -i "/app: {/a \ $script_snippet" nuxt.config.ts
else
sed -i '$d' nuxt.config.ts
echo "app: {
$script_snippet
}
})" >> nuxt.config.ts
fi
fi

View File

@ -8,9 +8,9 @@
## CADDYFILE EN JSON
## MÀJ
## reboot a running system
## MATOMO
## NODE EXPORTER
## setup webhook : get auth header
## EMAIL CAMPAIGN
## https://docs.directus.io/guides/extensions/operations-bulk-email-sendgrid.html
. bin/functions.sh
. bin/variables.sh
@ -118,10 +118,10 @@ read answer
if [[ "$answer" == "y" ]]; then
. bin/install_nuxt_front.sh
echo -e "${PURPLE}${BOLD}Track with Matomo ? (y/N) ${RESET}"
echo -e "${PURPLE}${BOLD}Track with Umami ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
. bin/setup_matomo.sh
. bin/setup_umami.sh
fi
. bin/generate_static_front.sh