ee5ae8af62
* explicitly ordering global middlewares * various subscription fixes & WIP project invite middleware * SSR invite accept & toast notifs seem to work * backend support for mixpanel * mixpanel be logic -> shared * minor fix * finissh * lint fix * minor comment adjustments * better adblock handling
26 lines
574 B
TypeScript
26 lines
574 B
TypeScript
import { useMixpanel } from '~/lib/core/composables/mp'
|
|
import type { RouteLocationNormalized } from 'vue-router'
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
const mp = useMixpanel()
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
|
|
const track = (to: RouteLocationNormalized) => {
|
|
const pathDefinition = getRouteDefinition(to)
|
|
const path = to.path
|
|
mp.track('Route Visited', {
|
|
path,
|
|
pathDefinition
|
|
})
|
|
}
|
|
|
|
// Track init page view
|
|
track(route)
|
|
|
|
// Track page view after navigations
|
|
router.afterEach((to) => {
|
|
track(to)
|
|
})
|
|
})
|