From adf39dd3d5ba9e9a76c2d31c4bd05b31c748b5f3 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Mon, 23 Sep 2024 10:01:37 +0000 Subject: [PATCH] Add back matomo - was forgotten - and make it activable on-demand, disabled in dev --- dev/zimit_ui_dev/config.json | 6 +++++- ui/package.json | 1 + ui/public/config.json | 6 +++++- ui/src/config.ts | 4 ++++ ui/src/main.ts | 13 +++++++++++++ ui/yarn.lock | 5 +++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/dev/zimit_ui_dev/config.json b/dev/zimit_ui_dev/config.json index 28c13ea..f0b53da 100644 --- a/dev/zimit_ui_dev/config.json +++ b/dev/zimit_ui_dev/config.json @@ -47,5 +47,9 @@ ], "zimit_size_limit": 2147483648, "zimit_time_limit": 5400, - "zimit_refresh_after": 60 + "zimit_refresh_after": 60, + "matomo_enabled": false, + "matomo_host": "", + "matomo_site_id": 0, + "matomo_tracker_file_name": "matomo" } diff --git a/ui/package.json b/ui/package.json index 04ffcd4..271a9c9 100644 --- a/ui/package.json +++ b/ui/package.json @@ -17,6 +17,7 @@ "pinia": "^2.2.2", "vue": "^3.5.6", "vue-i18n": "10.0.1", + "vue-matomo": "^4.2.0", "vue-router": "^4.4.5", "vuetify": "^3.7.1" }, diff --git a/ui/public/config.json b/ui/public/config.json index d7a5d38..0651f52 100644 --- a/ui/public/config.json +++ b/ui/public/config.json @@ -47,5 +47,9 @@ ], "zimit_size_limit": 2147483648, "zimit_time_limit": 5400, - "zimit_refresh_after": 60 + "zimit_refresh_after": 60, + "matomo_enabled": false, + "matomo_host": "", + "matomo_site_id": 0, + "matomo_tracker_file_name": "matomo" } diff --git a/ui/src/config.ts b/ui/src/config.ts index 5802fce..3bbe904 100644 --- a/ui/src/config.ts +++ b/ui/src/config.ts @@ -18,6 +18,10 @@ export type Config = { zimit_size_limit: number zimit_time_limit: number zimit_refresh_after: number + matomo_enabled: boolean + matomo_host: string + matomo_site_id: number + matomo_tracker_file_name: string } async function loadConfig() { diff --git a/ui/src/main.ts b/ui/src/main.ts index f96a4ce..ab5f6f2 100644 --- a/ui/src/main.ts +++ b/ui/src/main.ts @@ -47,6 +47,9 @@ import loadI18n, { i18nPlugin } from './i18n' // config import loadConfig, { configPlugin } from './config' +// Matomo stats +import VueMatomo from 'vue-matomo' + // load translation asynchronously and only then mount the app Promise.all([loadI18n(), loadConfig()]).then(([i18n, config]) => { app.use(vuetify) @@ -54,6 +57,16 @@ Promise.all([loadI18n(), loadConfig()]).then(([i18n, config]) => { app.use(pinia) app.use(i18n) + // activate matomo stats + if (config.matomo_enabled) { + app.use(VueMatomo, { + host: 'https://stats.kiwix.org', + siteId: 11, + trackerFileName: 'matomo', + router: router + }) + } + // provide config app-wide app.provide(constants.config, config) diff --git a/ui/yarn.lock b/ui/yarn.lock index 29db3a4..e9080d3 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -2648,6 +2648,11 @@ vue-i18n@10.0.1: "@intlify/shared" "10.0.1" "@vue/devtools-api" "^6.5.0" +vue-matomo@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/vue-matomo/-/vue-matomo-4.2.0.tgz#d65e369e4ead1d95ef790bef3627512cac3d25e9" + integrity sha512-m5hCw7LH3wPDcERaF4sp/ojR9sEx7Rl8TpOyH/4jjQxMF2DuY/q5pO+i9o5Dx+BXLSa9+IQ0qhAbWYRyESQXmA== + vue-router@^4.4.5: version "4.4.5" resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.4.5.tgz#bdf535e4cf32414ebdea6b4b403593efdb541388"