feat: posthog initialization

This commit is contained in:
Jannat Patel
2024-08-07 11:31:58 +05:30
parent 9a0056b6ca
commit a9e93a679b
7 changed files with 114 additions and 40 deletions

24
frontend/src/posthog.js Normal file
View 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,
});
},
};