Skip to content

Commit

Permalink
fix: 修复精确统计
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Dec 30, 2024
1 parent afd955d commit 976fbd0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/common/umami.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 = '') {
Expand Down

0 comments on commit 976fbd0

Please sign in to comment.