feat: posthog initialization
This commit is contained in:
@@ -6,6 +6,7 @@ import App from './App.vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import dayjs from '@/utils/dayjs'
|
||||
import translationPlugin from './translation'
|
||||
import posthog from './posthog'
|
||||
import { usersStore } from './stores/user'
|
||||
import { sessionStore } from './stores/session'
|
||||
import { initSocket } from './socket'
|
||||
@@ -25,6 +26,7 @@ app.use(FrappeUI)
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
app.use(translationPlugin)
|
||||
app.use(posthog)
|
||||
app.use(pageMetaPlugin)
|
||||
app.provide('$dayjs', dayjs)
|
||||
app.provide('$socket', initSocket())
|
||||
|
||||
24
frontend/src/posthog.js
Normal file
24
frontend/src/posthog.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import posthog from "posthog-js";
|
||||
import { createResource } from 'frappe-ui'
|
||||
|
||||
const apiInfo = createResource({
|
||||
url: 'lms.lms.api.get_posthog_api_key',
|
||||
cache: 'apiInfo',
|
||||
auto: true,
|
||||
onSuccess(data) {
|
||||
return data
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
export default {
|
||||
install(app) {
|
||||
app.config.globalProperties.$posthog = posthog.init(apiInfo.data.project_id, {
|
||||
api_host: apiInfo.data.posthog_host,
|
||||
autocapture: false,
|
||||
capture_pageview: false,
|
||||
capture_pageleave: false,
|
||||
advanced_disable_decide: apiInfo.data.should_record_session,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user