Skip to content

Commit

Permalink
revert: 再也不用umami了
Browse files Browse the repository at this point in the history
  • Loading branch information
MliKiowa committed Jan 5, 2025
1 parent e9db4ae commit fb45c10
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
42 changes: 29 additions & 13 deletions src/common/umami.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,39 @@ export class UmamiTraceCore {
"Host": "umami.napneko.icu",
"Content-Type": "application/json",
"User-Agent": this.ua,
...(this.cache ? { 'x-umami-cache': this.cache } : {})
...(this.cache ? { 'x-umami-cache': this.filterInvalidChars(this.cache) } : {})
}
};

const request = https.request(options, (res) => {
res.on('error', (error) => {

try {
const request = https.request(options, (res) => {
let responseData = '';

res.on('data', (chunk) => {
responseData += chunk;
});

res.on('end', () => {
if (!this.cache) {
this.cache = responseData;
console.log('Umami cache:', this.cache);
}
});

res.on('error', (error) => {
});
});
res.on('data', (data) => {
if (!this.cache) {
this.cache = data.toString();
}

request.on('error', (error) => {
});
}).on('error', () => { });

request.write(JSON.stringify({ type, payload }));
request.end();

request.write(JSON.stringify({ type, payload }));
request.end();
} catch (error) {
}
}

filterInvalidChars(value: string): string {
return value.replace(/[^\x00-\x7F]/g, '');
}

startHeartbeat() {
Expand Down
6 changes: 0 additions & 6 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import os from 'node:os';
import { NodeIKernelMsgListener, NodeIKernelProfileListener } from '@/core/listeners';
import { proxiedListenerOf } from '@/common/proxy-handler';
import { NTQQPacketApi } from './apis/packet';
import { UmamiTrace } from '@/common/umami';
export * from './wrapper';
export * from './types';
export * from './services';
Expand Down Expand Up @@ -155,11 +154,6 @@ export class NapCatCore {
const msgListener = new NodeIKernelMsgListener();

msgListener.onKickedOffLine = (Info: KickedOffLineInfo) => {
if (this.context.workingEnv === NapCatCoreWorkingEnv.Framework) {
UmamiTrace.sendTrace('event/kickoff');
} else {
UmamiTrace.sendTrace('event/kickoff');
}
// 下线通知
this.context.logger.logError('[KickedOffLine] [' + Info.tipsTitle + '] ' + Info.tipsDesc);
this.selfInfo.online = false;
Expand Down
6 changes: 0 additions & 6 deletions src/framework/napcat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { NodeIKernelLoginService } from '@/core/services';
import { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper';
import { InitWebUi, WebUiConfig } from '@/webui';
import { NapCatOneBot11Adapter } from '@/onebot';
import { UmamiTrace } from '@/common/umami';

//Framework ES入口文件
export async function getWebUiUrl() {
Expand All @@ -26,7 +25,6 @@ export async function NCoreInitFramework(
console.log('NapCat Framework App Loading...');

process.on('uncaughtException', (err) => {
UmamiTrace.sendTrace('uncaught/error', err.message);
console.log('[NapCat] [Error] Unhandled Exception:', err.message);
});

Expand All @@ -38,10 +36,6 @@ export async function NCoreInitFramework(
const logger = new LogWrapper(pathWrapper.logsPath);
const basicInfoWrapper = new QQBasicInfoWrapper({ logger });
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVesion());
let guid = loginService.getMachineGuid();
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();
Expand Down
7 changes: 0 additions & 7 deletions src/shell/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ import { InitWebUi } from '@/webui';
import { WebUiDataRuntime } from '@/webui/src/helper/Data';
import { napCatVersion } from '@/common/version';
import { NodeIO3MiscListener } from '@/core/listeners/NodeIO3MiscListener';
import { UmamiTrace } from '@/common/umami';
// NapCat Shell App ES 入口文件
async function handleUncaughtExceptions(logger: LogWrapper) {
process.on('uncaughtException', (err) => {
UmamiTrace.sendTrace('uncaught/error', err.message);
logger.logError('[NapCat] [Error] Unhandled Exception:', err.message);
});
process.on('unhandledRejection', (reason, promise) => {
Expand Down Expand Up @@ -153,7 +151,6 @@ async function handleLogin(
};

loginListener.onQRCodeSessionFailed = (errType: number, errCode: number, errMsg: string) => {
UmamiTrace.sendTrace('qrlogin/error', [errType, errCode, errMsg].toString());
if (!isLogined) {
logger.logError('[Core] [Login] Login Error,ErrType: ', errType, ' ErrCode:', errCode);
if (errType == 1 && errCode == 3) {
Expand All @@ -164,7 +161,6 @@ async function handleLogin(
};

loginListener.onLoginFailed = (...args) => {
UmamiTrace.sendTrace('login/error', args.toString());
logger.logError('[Core] [Login] Login Error , ErrInfo: ', JSON.stringify(args));
};

Expand Down Expand Up @@ -298,10 +294,7 @@ export async function NCoreInitShell() {

const dataTimestape = new Date().getTime().toString();
o3Service.reportAmgomWeather('login', 'a1', [dataTimestape, '0', '0']);
UmamiTrace.init(basicInfoWrapper.getFullQQVesion(), loginService.getMachineGuid(), 'shell');
UmamiTrace.sendTrace('boot/init');
const selfInfo = await handleLogin(loginService, logger, pathWrapper, quickLoginUin, historyLoginList);
UmamiTrace.sendTrace('login/success');
const amgomDataPiece = 'eb1fd6ac257461580dc7438eb099f23aae04ca679f4d88f53072dc56e3bb1129';
o3Service.setAmgomDataPiece(basicInfoWrapper.QQVersionAppid, new Uint8Array(Buffer.from(amgomDataPiece, 'hex')));

Expand Down

0 comments on commit fb45c10

Please sign in to comment.