From 976fbd0220b2a7fdadb37846eb2855f6c2d5954a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 30 Dec 2024 20:27:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=B2=BE=E7=A1=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/umami.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/common/umami.ts b/src/common/umami.ts index b2146003..7f76fb0c 100644 --- a/src/common/umami.ts +++ b/src/common/umami.ts @@ -1,6 +1,6 @@ import https from 'node:https'; import { napCatVersion } from './version'; -import os from 'os'; +import os from 'node:os'; export class UmamiTraceCore { napcatVersion = napCatVersion; qqversion = '1.0.0'; @@ -46,10 +46,20 @@ export class UmamiTraceCore { guid: guid, workname: this.workname, }; - this.sendRequest({ website: this.website, data}, 'identify'); + this.sendEvent( + { + website: this.website, + hostname: this.hostname, + referrer: this.referrer, + tittle: 'NapCat ' + this.napcatVersion, + url: `/${this.qqversion}/${this.napcatVersion}/${this.workname}/identify`, + }, + data, + 'identify' + ); } - sendEvent(event: string | object, data?: object) { + sendEvent(event: string | object, data?: object, type = 'event') { const env = process.env; const language = env.LANG || env.LANGUAGE || env.LC_ALL || env.LC_MESSAGES; const payload = { @@ -58,15 +68,20 @@ export class UmamiTraceCore { referrer: this.referrer, website: this.website, language: language || 'en-US', + screen: '1920x1080', data: { ...data, napcat_version: this.napcatVersion, qq_version: this.qqversion, workname: this.workname, - guid: this.guid + guid: this.guid, + platform: os.platform(), + arch: os.arch(), + cpus: os.cpus(), + uptime: os.uptime(), } }; - this.sendRequest(payload); + this.sendRequest(payload, type); } sendTrace(eventName: string, data: string = '') {