Skip to content

Commit b032d6b

Browse files
authored
Merge pull request #78 from openzim/vue_matomo
Add back matomo - was forgotten - and make it activable on-demand, disabled in dev
2 parents 33c54ea + 8be3262 commit b032d6b

File tree

7 files changed

+51
-2
lines changed

7 files changed

+51
-2
lines changed

dev/zimit_ui_dev/config.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,9 @@
4747
],
4848
"zimit_size_limit": 2147483648,
4949
"zimit_time_limit": 5400,
50-
"zimit_refresh_after": 60
50+
"zimit_refresh_after": 60,
51+
"matomo_enabled": false,
52+
"matomo_host": "",
53+
"matomo_site_id": 0,
54+
"matomo_tracker_file_name": "matomo"
5155
}

ui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"pinia": "^2.2.2",
1818
"vue": "^3.5.6",
1919
"vue-i18n": "10.0.1",
20+
"vue-matomo": "^4.2.0",
2021
"vue-router": "^4.4.5",
2122
"vuetify": "^3.7.1"
2223
},

ui/public/config.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,9 @@
4747
],
4848
"zimit_size_limit": 2147483648,
4949
"zimit_time_limit": 5400,
50-
"zimit_refresh_after": 60
50+
"zimit_refresh_after": 60,
51+
"matomo_enabled": false,
52+
"matomo_host": "",
53+
"matomo_site_id": 0,
54+
"matomo_tracker_file_name": "matomo"
5155
}

ui/src/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export type Config = {
1818
zimit_size_limit: number
1919
zimit_time_limit: number
2020
zimit_refresh_after: number
21+
matomo_enabled: boolean
22+
matomo_host: string
23+
matomo_site_id: number
24+
matomo_tracker_file_name: string
2125
}
2226

2327
async function loadConfig() {

ui/src/main.ts

+13
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,26 @@ import loadI18n, { i18nPlugin } from './i18n'
4747
// config
4848
import loadConfig, { configPlugin } from './config'
4949

50+
// Matomo stats
51+
import VueMatomo from 'vue-matomo'
52+
5053
// load translation asynchronously and only then mount the app
5154
Promise.all([loadI18n(), loadConfig()]).then(([i18n, config]) => {
5255
app.use(vuetify)
5356
app.use(router)
5457
app.use(pinia)
5558
app.use(i18n)
5659

60+
// activate matomo stats
61+
if (config.matomo_enabled) {
62+
app.use(VueMatomo, {
63+
host: config.matomo_host,
64+
siteId: config.matomo_site_id,
65+
trackerFileName: config.matomo_tracker_file_name,
66+
router: router
67+
})
68+
}
69+
5770
// provide config app-wide
5871
app.provide(constants.config, config)
5972

ui/src/types/vue-matomo.d.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Declare what we use in vue-matomo (this is far from complete but sufficient for our
2+
usage, so that TypeScript compiler can check what needs to be) */
3+
declare module 'vue-matomo' {
4+
import { PluginFunction } from 'vue'
5+
6+
interface VueMatomoOptions {
7+
host: string
8+
siteId: number
9+
trackerFileName?: string
10+
router: Router
11+
}
12+
13+
const VueMatomo: {
14+
install: PluginFunction<VueMatomoOptions>
15+
}
16+
17+
export default VueMatomo
18+
}

ui/yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,11 @@ vue-i18n@10.0.1:
26482648
"@intlify/shared" "10.0.1"
26492649
"@vue/devtools-api" "^6.5.0"
26502650

2651+
vue-matomo@^4.2.0:
2652+
version "4.2.0"
2653+
resolved "https://registry.yarnpkg.com/vue-matomo/-/vue-matomo-4.2.0.tgz#d65e369e4ead1d95ef790bef3627512cac3d25e9"
2654+
integrity sha512-m5hCw7LH3wPDcERaF4sp/ojR9sEx7Rl8TpOyH/4jjQxMF2DuY/q5pO+i9o5Dx+BXLSa9+IQ0qhAbWYRyESQXmA==
2655+
26512656
vue-router@^4.4.5:
26522657
version "4.4.5"
26532658
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.4.5.tgz#bdf535e4cf32414ebdea6b4b403593efdb541388"

0 commit comments

Comments
 (0)