feat: add frontend analytics tracking

This commit is contained in:
2026-05-17 10:18:56 +08:00
parent 3decff526a
commit 1016111d19
11 changed files with 583 additions and 10 deletions
+5
View File
@@ -3,6 +3,7 @@ import { ref } from 'vue'
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { useAppStore } from './stores/app.js'
import { logRuntimeEnv } from './services/request.js'
import analytics from './services/analytics.js'
const statusBarHeight = ref(0)
const safeAreaTop = ref(0)
@@ -10,6 +11,7 @@ const safeAreaBottom = ref(0)
onLaunch(async () => {
console.log('App Launch')
analytics.initAnalytics()
logRuntimeEnv('app:onLaunch')
const store = useAppStore()
await store.initialize()
@@ -25,10 +27,13 @@ onLaunch(async () => {
onShow(() => {
console.log('App Show')
analytics.track('app_show', {}, { eventType: 'app' })
})
onHide(() => {
console.log('App Hide')
analytics.track('app_hide', {}, { eventType: 'app' })
analytics.flush()
})
</script>