a6a4ceee86
* fixing up typing * better dynamic loader mechanism * buildReqLoaders cleanup * added caching to loaders * ensuring all loaders are async * fe2 plugins error handling fix * feat(shared): true-myth result structures & other auth policy improvements * moving workspaceCore loaders to correct place
31 lines
734 B
TypeScript
31 lines
734 B
TypeScript
import { useMixpanel } from '~/lib/core/composables/mp'
|
|
import type { RouteLocationNormalized } from 'vue-router'
|
|
import type { Optional } from '@speckle/shared'
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
const mp = useMixpanel()
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
|
|
let previousPath: Optional<string> = undefined
|
|
const track = (to: RouteLocationNormalized) => {
|
|
const path = to.path
|
|
if (path === previousPath) return
|
|
|
|
const pathDefinition = getRouteDefinition(to)
|
|
mp.track('Route Visited', {
|
|
path,
|
|
pathDefinition
|
|
})
|
|
previousPath = path
|
|
}
|
|
|
|
// Track init page view
|
|
track(route)
|
|
|
|
// Track page view after navigations
|
|
router.afterEach((to) => {
|
|
track(to)
|
|
})
|
|
})
|