mirror of https://github.com/msgbyte/tailchat
feat: 增加posthog插件用于进行基本的信息统计
parent
218181d921
commit
1cd533f8ce
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"label": "posthog",
|
||||||
|
"name": "com.msgbyte.posthog",
|
||||||
|
"url": "/plugins/com.msgbyte.posthog/index.js",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"author": "moonrailgun",
|
||||||
|
"description": "Posthog 数据统计",
|
||||||
|
"requireRestart": true
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "@plugins/com.msgbyte.posthog",
|
||||||
|
"main": "src/index.tsx",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "Posthog 数据统计",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"sync:declaration": "tailchat declaration github"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"posthog-js": "^1.35.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/styled-components": "^5.1.26",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"styled-components": "^5.3.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
import posthog from 'posthog-js';
|
||||||
|
|
||||||
|
posthog.init('phc_xRCv3qbbOBMQkz31kbYMngXxn7Ey5JMu0BZIFktO6km', {
|
||||||
|
api_host: 'https://app.posthog.com',
|
||||||
|
autocapture: false, // 关闭autocapture以节约事件用量
|
||||||
|
disable_session_recording: true, // 关闭自动录屏(不需要且一直报错)
|
||||||
|
});
|
||||||
|
|
||||||
|
const PLUGIN_NAME = 'posthog';
|
||||||
|
|
||||||
|
console.log(`Plugin ${PLUGIN_NAME} is loaded`);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log('Report plugin install status');
|
||||||
|
|
||||||
|
const storage = JSON.parse(window.localStorage['$TailchatInstalledPlugins']);
|
||||||
|
try {
|
||||||
|
posthog.capture('Report Plugin', {
|
||||||
|
plugins: storage.rawData,
|
||||||
|
pluginNum: Array.isArray(storage.rawData) ? storage.rawData.length : 0,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
posthog.capture('Report Plugin error', {
|
||||||
|
err: String(err),
|
||||||
|
storage,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"jsx": "react",
|
||||||
|
"importsNotUsedAsValues": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
declare module '@capital/common';
|
||||||
|
declare module '@capital/component';
|
||||||
Loading…
Reference in New Issue