Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Matomo records #187

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading REEV...</title>

<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
// Components
// Composables
import { createApp } from 'vue'
import { createApp, nextTick } from 'vue'

// Plugins
import { registerPlugins } from '@/plugins'
Expand All @@ -18,6 +18,9 @@ async function bootstrap() {
await registerPlugins(app)

app.mount('#app')

await nextTick()
window._paq.push(['trackPageView'])
}

bootstrap()
20 changes: 10 additions & 10 deletions frontend/src/plugins/matomo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ async function setupMatomo(app: App, router: any) {
try {
const client = new SettingsClient()
const response = await client.fetchFrontendSettings()
if (!response['matomo_host'] || !response['matomo_site_id']) {
throw new Error('Matomo host and site ID must be set')
if (response['matomo_host'] && response['matomo_site_id']) {
app.use(VueMatomo, {
host: response['matomo_host'],
siteId: response['matomo_site_id'],
router: router,
enableLinkTracking: true,
trackInitialView: true,
requireConsent: true,
disableCookies: true
})
}

app.use(VueMatomo, {
host: response['matomo_host'],
siteId: response['matomo_site_id'],
router: router,
requireConsent: true,
disableCookies: true
})
} catch (error) {
console.error('Failed to initialize Matomo:', error)
}
Expand Down
Loading