Skip to content

Commit

Permalink
Merge pull request #92 from mdunisch/patch-1
Browse files Browse the repository at this point in the history
Fix for Vue 3.1 Migration Build: Better Version-Switch
  • Loading branch information
jordan-boyer authored Jun 15, 2021
2 parents 62f223c + a953ee7 commit 1e3f7dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ function trackMatomoPageView (options, to, from) {
function initMatomo (Vue, options) {
const Matomo = getMatomo()

if (Vue.prototype) {
// Assign matomo to Vue 2
Vue.prototype.$piwik = Matomo
Vue.prototype.$matomo = Matomo
} else {
// Assign matomo to Vue 3
const version = Number(Vue.version.split('.')[0])

if (version > 2) {
Vue.config.globalProperties.$piwik = Matomo
Vue.config.globalProperties.$matomo = Matomo
Vue.provide(matomoKey, Matomo)
} else {
Vue.prototype.$piwik = Matomo
Vue.prototype.$matomo = Matomo
}

if (options.trackInitialView && options.router) {
Expand Down

0 comments on commit 1e3f7dc

Please sign in to comment.