Merge branch 'main' into alex/sao

This commit is contained in:
AlexandruPopovici
2022-09-30 12:30:48 +03:00
2 changed files with 19 additions and 1 deletions
@@ -3,6 +3,7 @@ import { AppLocalStorage } from '@/utils/localStorage'
import { GlobalEvents } from '@/main/lib/core/helpers/eventHubHelper'
import Vue from 'vue'
import VueRouter from 'vue-router'
import { getMixpanel } from '@/mixpanelManager'
Vue.use(VueRouter)
@@ -398,6 +399,15 @@ router.afterEach((to) => {
Vue.nextTick(() => {
document.title = (to.meta && to.meta.title) || 'Speckle'
})
// Report route to mixpanel
const mp = getMixpanel()
const pathDefinition = to.matched[to.matched.length - 1].path
const path = to.path
mp.track('Route Visited', {
path,
pathDefinition
})
})
export default router
+9 -1
View File
@@ -5,6 +5,8 @@ import { AppLocalStorage } from '@/utils/localStorage'
import md5 from '@/helpers/md5'
import * as ThemeStateManager from '@/main/utils/themeStateManager'
let mixpanelInitialized = false
/**
* Get mixpanel user ID, if user is authenticated and can be identified, or undefined otherwise
*/
@@ -23,6 +25,10 @@ export function getMixpanelServerId(): string {
* Get current mixpanel instance
*/
export function getMixpanel(): OverridedMixpanel {
if (!mixpanelInitialized) {
throw new Error('Attempting to use uninitialized mixpanel instance')
}
return mixpanel
}
@@ -33,7 +39,7 @@ export function initialize(params: {
hostApp: string
hostAppDisplayName: string
}): void {
const mp = getMixpanel()
const mp = mixpanel
const { hostApp, hostAppDisplayName } = params
// Register session
@@ -52,4 +58,6 @@ export function initialize(params: {
// Track app visit
mp.track(`Visit ${hostAppDisplayName}`)
mixpanelInitialized = true
}