Skip to content

Commit

Permalink
fix: error
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Jan 3, 2025
1 parent 675c906 commit a3be26f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/common/umami.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import https from 'node:https';
import { napCatVersion } from './version';
import os from 'node:os';

export class UmamiTraceCore {
napcatVersion = napCatVersion;
qqversion = '1.0.0';
Expand All @@ -13,13 +14,14 @@ export class UmamiTraceCore {
workname: string = 'default';
bootTime = Date.now();
cache: string = '';

init(qqversion: string, guid: string, workname: string) {
this.qqversion = qqversion;
this.workname = workname;
let UaList = {
'linux': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/124.0.0.0 Safari/537.36 PTST/240508.140043',
'win32': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.2128.93 Safari/537.36',
'darwin': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
const UaList = {
linux: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/124.0.0.0 Safari/537.36 PTST/240508.140043',
win32: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.2128.93 Safari/537.36',
darwin: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
};

try {
Expand Down Expand Up @@ -50,14 +52,14 @@ export class UmamiTraceCore {
device_platform: os.platform(),
device_arch: os.arch(),
boot_time: new Date(this.bootTime + 8 * 60 * 60 * 1000).toISOString().replace('T', ' ').substring(0, 19),
sys_time: new Date(Date.now() - os.uptime() * 1000 + 8 * 60 * 60 * 1000).toISOString().replace('T', ' ').substring(0, 19)
sys_time: new Date(Date.now() - os.uptime() * 1000 + 8 * 60 * 60 * 1000).toISOString().replace('T', ' ').substring(0, 19),
};
this.sendEvent(
{
website: this.website,
hostname: this.hostname,
referrer: this.referrer,
tittle: 'NapCat ' + this.napcatVersion,
title: 'NapCat ' + this.napcatVersion,
url: `/${this.qqversion}/${this.napcatVersion}/${this.workname}/identify`,
},
data,
Expand All @@ -76,8 +78,8 @@ export class UmamiTraceCore {
language: language || 'en-US',
screen: '1920x1080',
data: {
...data
}
...data,
},
};
this.sendRequest(payload, type);
}
Expand All @@ -87,7 +89,7 @@ export class UmamiTraceCore {
website: this.website,
hostname: this.hostname,
title: 'NapCat ' + this.napcatVersion,
url: `/${this.qqversion}/${this.napcatVersion}/${this.workname}/${eventName}` + (!!data ? `/${data}` : ''),
url: `/${this.qqversion}/${this.napcatVersion}/${this.workname}/${eventName}` + (data ? `/${data}` : ''),
referrer: this.referrer,
};
this.sendRequest(payload);
Expand Down Expand Up @@ -142,4 +144,5 @@ export class UmamiTraceCore {
}
}
}

export const UmamiTrace = new UmamiTraceCore();

0 comments on commit a3be26f

Please sign in to comment.