Merge pull request #565 from specklesystems/analytics
feat(frontend): various tweaks
This commit is contained in:
@@ -80,7 +80,7 @@ export async function getTokenFromAccessCode(accessCode) {
|
||||
* Signs out the current session
|
||||
* @return {null}
|
||||
*/
|
||||
export async function signOut() {
|
||||
export async function signOut(mixpanelInstance) {
|
||||
await fetch('/auth/logout', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -96,9 +96,16 @@ export async function signOut() {
|
||||
localStorage.removeItem('RefreshToken')
|
||||
localStorage.removeItem('suuid')
|
||||
localStorage.removeItem('uuid')
|
||||
localStorage.removeItem('distinct_id')
|
||||
localStorage.removeItem('stcount')
|
||||
localStorage.removeItem('onboarding')
|
||||
|
||||
window.location = '/'
|
||||
|
||||
if (mixpanelInstance) {
|
||||
mixpanelInstance.track('Log Out', { type: 'action', hostApp: 'web' })
|
||||
mixpanelInstance.reset()
|
||||
}
|
||||
}
|
||||
|
||||
export async function refreshToken() {
|
||||
|
||||
@@ -144,6 +144,8 @@ export default {
|
||||
}
|
||||
|
||||
this.$mixpanel.track('Visit Web App')
|
||||
|
||||
this.$mixpanel.register({ server_id: this.$mixpanelServerId })
|
||||
},
|
||||
methods: {
|
||||
switchTheme() {
|
||||
|
||||
@@ -67,7 +67,7 @@ export default {
|
||||
})
|
||||
.then(() => {
|
||||
this.isLoading = false
|
||||
signOut()
|
||||
signOut(this.$mixpanel)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -72,8 +72,7 @@ export default {
|
||||
this.$apollo.queries.user.refetch()
|
||||
},
|
||||
signOut() {
|
||||
this.$mixpanel.track('Log Out', { type: 'action', hostApp: 'web' })
|
||||
signOut()
|
||||
signOut(this.$mixpanel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
signOut() {
|
||||
signOut()
|
||||
signOut(this.$mixpanel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
})
|
||||
.then(() => {
|
||||
this.isLoading = false
|
||||
signOut()
|
||||
signOut(this.$mixpanel)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import Vue from 'vue'
|
||||
import crypto from 'crypto'
|
||||
|
||||
Vue.prototype.$userId = function () {
|
||||
return localStorage.getItem('uuid')
|
||||
@@ -8,6 +9,14 @@ Vue.prototype.$mixpanelId = function () {
|
||||
return localStorage.getItem('distinct_id')
|
||||
}
|
||||
|
||||
Vue.prototype.$mixpanelServerId = function () {
|
||||
return crypto
|
||||
.createHash('md5')
|
||||
.update(window.location.hostname.toLowerCase())
|
||||
.digest('hex')
|
||||
.toUpperCase()
|
||||
}
|
||||
|
||||
Vue.prototype.$loggedIn = function () {
|
||||
return localStorage.getItem('uuid') !== null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user