Skip to content

Commit

Permalink
Add back matomo - was forgotten - and make it activable on-demand, di…
Browse files Browse the repository at this point in the history
…sabled in dev
  • Loading branch information
benoit74 committed Sep 23, 2024
1 parent 33c54ea commit 8be3262
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 2 deletions.
6 changes: 5 additions & 1 deletion dev/zimit_ui_dev/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
6 changes: 5 additions & 1 deletion ui/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 4 additions & 0 deletions ui/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 13 additions & 0 deletions ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,26 @@ 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)
app.use(router)
app.use(pinia)
app.use(i18n)

// activate matomo stats
if (config.matomo_enabled) {
app.use(VueMatomo, {
host: config.matomo_host,
siteId: config.matomo_site_id,
trackerFileName: config.matomo_tracker_file_name,
router: router
})
}

// provide config app-wide
app.provide(constants.config, config)

Expand Down
18 changes: 18 additions & 0 deletions ui/src/types/vue-matomo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Declare what we use in vue-matomo (this is far from complete but sufficient for our
usage, so that TypeScript compiler can check what needs to be) */
declare module 'vue-matomo' {
import { PluginFunction } from 'vue'

interface VueMatomoOptions {
host: string
siteId: number
trackerFileName?: string
router: Router
}

const VueMatomo: {
install: PluginFunction<VueMatomoOptions>
}

export default VueMatomo
}
5 changes: 5 additions & 0 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,11 @@ [email protected]:
"@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"
Expand Down

0 comments on commit 8be3262

Please sign in to comment.