fix:workname

This commit is contained in:
手瓜一十雪
2024-12-30 16:54:40 +08:00
parent fc731b60d5
commit 53851475ea
4 changed files with 20 additions and 17 deletions

View File

@@ -10,9 +10,10 @@ export class UmamiTraceCore {
referrer: string = 'https://trace.napneko.icu/';
hostname: string = 'trace.napneko.icu';
ua: string = '';
init(qqversion: string, guid: string) {
workname: string = 'default';
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',
@@ -42,7 +43,8 @@ export class UmamiTraceCore {
const data = {
napcat_version: this.napcatVersion,
qq_version: this.qqversion,
guid: guid
guid: guid,
workname: this.workname,
};
this.sendRequest({ website: this.website, ...data }, 'identify');
}
@@ -58,6 +60,7 @@ export class UmamiTraceCore {
language: language || 'en-US',
napcat_version: this.napcatVersion,
qq_version: this.qqversion,
workname: this.workname,
...data
};
this.sendRequest(payload);
@@ -68,7 +71,7 @@ export class UmamiTraceCore {
website: this.website,
hostname: this.hostname,
title: 'NapCat ' + this.napcatVersion,
url: `/${this.qqversion}/${this.napcatVersion}/${eventName}` + (!!data ? `?data=${data}` : ''),
url: `/${this.qqversion}/${this.napcatVersion}/${this.workname}/${eventName}` + (!!data ? `?data=${data}` : ''),
referrer: this.referrer,
};
this.sendRequest(payload);
@@ -108,7 +111,7 @@ export class UmamiTraceCore {
this.sendEvent('heartbeat', {
title: 'NapCat ' + this.napcatVersion,
language: process.env.LANG || 'en-US',
url: `/${this.qqversion}/${this.napcatVersion}/heartbeat`,
url: `/${this.qqversion}/${this.napcatVersion}/${this.workname}/heartbeat`,
version: this.napcatVersion,
qq_version: this.qqversion,
user_id: this.guid

View File

@@ -156,9 +156,9 @@ export class NapCatCore {
msgListener.onKickedOffLine = (Info: KickedOffLineInfo) => {
if (this.context.workingEnv === NapCatCoreWorkingEnv.Framework) {
UmamiTrace.sendTrace('framework/kickoff');
UmamiTrace.sendTrace('event/kickoff');
} else {
UmamiTrace.sendTrace('shell/kickoff');
UmamiTrace.sendTrace('event/kickoff');
}
// 下线通知
this.context.logger.logError('[KickedOffLine] [' + Info.tipsTitle + '] ' + Info.tipsDesc);

View File

@@ -26,7 +26,7 @@ export async function NCoreInitFramework(
console.log('NapCat Framework App Loading...');
process.on('uncaughtException', (err) => {
UmamiTrace.sendTrace('framework/error', err.message);
UmamiTrace.sendTrace('uncaught/error', err.message);
console.log('[NapCat] [Error] Unhandled Exception:', err.message);
});
@@ -39,9 +39,9 @@ export async function NCoreInitFramework(
const basicInfoWrapper = new QQBasicInfoWrapper({ logger });
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVesion());
let guid = loginService.getMachineGuid();
UmamiTrace.init(basicInfoWrapper.getFullQQVesion(), guid);
UmamiTrace.sendTrace('framework/boot/init');
UmamiTrace.sendTrace('framework/login/success');
UmamiTrace.init(basicInfoWrapper.getFullQQVesion(), guid,'framework');
UmamiTrace.sendTrace('boot/init');
UmamiTrace.sendTrace('login/success');
//直到登录成功后,执行下一步
const selfInfo = await new Promise<SelfInfo>((resolveSelfInfo) => {
const loginListener = new NodeIKernelLoginListener();

View File

@@ -33,7 +33,7 @@ import { UmamiTrace } from '@/common/umami';
// NapCat Shell App ES 入口文件
async function handleUncaughtExceptions(logger: LogWrapper) {
process.on('uncaughtException', (err) => {
UmamiTrace.sendTrace('framework/error', err.message);
UmamiTrace.sendTrace('uncaught/error', err.message);
logger.logError('[NapCat] [Error] Unhandled Exception:', err.message);
});
process.on('unhandledRejection', (reason, promise) => {
@@ -153,7 +153,7 @@ async function handleLogin(
};
loginListener.onQRCodeSessionFailed = (errType: number, errCode: number, errMsg: string) => {
UmamiTrace.sendTrace('shell/qrlogin/error?', [errType, errCode, errMsg].toString());
UmamiTrace.sendTrace('qrlogin/error', [errType, errCode, errMsg].toString());
if (!isLogined) {
logger.logError('[Core] [Login] Login Error,ErrCode: ', errCode, ' ErrMsg:', errMsg);
if (errType == 1 && errCode == 3) {
@@ -164,7 +164,7 @@ async function handleLogin(
};
loginListener.onLoginFailed = (args) => {
UmamiTrace.sendTrace('shell/login/error', args.toString());
UmamiTrace.sendTrace('login/error', args.toString());
logger.logError('[Core] [Login] Login Error , ErrInfo: ', args.toString());
};
@@ -298,10 +298,10 @@ export async function NCoreInitShell() {
const dataTimestape = new Date().getTime().toString();
o3Service.reportAmgomWeather('login', 'a1', [dataTimestape, '0', '0']);
UmamiTrace.init(basicInfoWrapper.getFullQQVesion(), loginService.getMachineGuid());
UmamiTrace.sendTrace('shell/boot/init');
UmamiTrace.init(basicInfoWrapper.getFullQQVesion(), loginService.getMachineGuid(), 'shell');
UmamiTrace.sendTrace('boot/init');
const selfInfo = await handleLogin(loginService, logger, pathWrapper, quickLoginUin, historyLoginList);
UmamiTrace.sendTrace('shell/login/success');
UmamiTrace.sendTrace('login/success');
const amgomDataPiece = 'eb1fd6ac257461580dc7438eb099f23aae04ca679f4d88f53072dc56e3bb1129';
o3Service.setAmgomDataPiece(basicInfoWrapper.QQVersionAppid, new Uint8Array(Buffer.from(amgomDataPiece, 'hex')));