From d2b3dccee294a16e1c0235f9cb378ca6d57ce7ef Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 28 Nov 2022 00:12:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E5=88=86=E6=9E=90=E6=8F=92=E4=BB=B6=E4=B8=8A=E6=8A=A5=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=AE=89=E8=A3=85=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/com.msgbyte.posthog/src/index.tsx | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/client/web/plugins/com.msgbyte.posthog/src/index.tsx b/client/web/plugins/com.msgbyte.posthog/src/index.tsx index 63bf5a16..894820f7 100644 --- a/client/web/plugins/com.msgbyte.posthog/src/index.tsx +++ b/client/web/plugins/com.msgbyte.posthog/src/index.tsx @@ -15,12 +15,26 @@ setTimeout(() => { console.log('Report plugin install status'); try { - const storage = JSON.parse( - window.localStorage['$TailchatInstalledPlugins'] - ); + const d = window.localStorage['$TailchatInstalledPlugins']; + if (!d) { + posthog.capture('Report Plugin', { + plugins: [], + pluginNum: 0, + pluginRaw: '', + }); + return; + } + const storage = JSON.parse(d); + const list = storage.rawData; + if (!list || !Array.isArray(list)) { + // 格式不匹配 + return; + } + posthog.capture('Report Plugin', { - plugins: storage.rawData, - pluginNum: Array.isArray(storage.rawData) ? storage.rawData.length : 0, + plugins: list.map((item) => item.name), // 主要收集名称列表 + pluginNum: list.length, + pluginRaw: JSON.stringify(list), // 原始信息 }); } catch (err) { // Ignore error