mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-12 11:30:21 +08:00
去掉收集慢接口,由服务端中间件收集
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { v1 as uuid_v1 } from "uuid";
|
||||
import type { LogWithError, IErrorEvent,ISlow, LogWithEnv } from "../types";
|
||||
|
||||
import type { LogWithError, IErrorEvent, LogWithEnv } from "../types";
|
||||
|
||||
type Uid = string | number;
|
||||
|
||||
type Props = {
|
||||
@@ -44,17 +44,11 @@ class Base {
|
||||
this.SetUid();
|
||||
this.getLocalMessage();
|
||||
|
||||
|
||||
// 监听错误
|
||||
platform.listen((params: LogWithError|ISlow) => {
|
||||
platform.listen((params: LogWithError) => {
|
||||
console.log("listenCallback", params);
|
||||
if(params.Type=='onloadTime'){
|
||||
let slow=params as ISlow;
|
||||
this.uploadSlow(slow);
|
||||
}else{
|
||||
this.Push(params);
|
||||
}
|
||||
|
||||
|
||||
this.Push(params);
|
||||
});
|
||||
|
||||
this.timer = setInterval(() => {
|
||||
@@ -65,9 +59,8 @@ class Base {
|
||||
// 设置用户id
|
||||
public SetUid(uid?: Uid) {
|
||||
if (uid) {
|
||||
this.Uid =String(uid) ;
|
||||
this.Uid = String(uid);
|
||||
this.platform?.setCache("x_err_uid", this.Uid);
|
||||
|
||||
} else {
|
||||
const u_id = this.platform?.getCache("x_err_uid");
|
||||
if (u_id) {
|
||||
@@ -103,7 +96,7 @@ class Base {
|
||||
}
|
||||
}
|
||||
// 记录错误,超出5条时立即上报,否则缓存到本地(等待定时器上报)
|
||||
public Push=(data: LogWithError) =>{
|
||||
public Push = (data: LogWithError) => {
|
||||
this.MessageList.push({
|
||||
...data,
|
||||
ProjectKey: this.Pid,
|
||||
@@ -115,8 +108,8 @@ class Base {
|
||||
} else {
|
||||
this.platform?.setCache("x_err_message_list", this.MessageList);
|
||||
}
|
||||
}
|
||||
public uploadInfo=(envInfo: LogWithEnv) =>{
|
||||
};
|
||||
public uploadInfo = (envInfo: LogWithEnv) => {
|
||||
if (!this.Dns) return; //未设置Dns服务器不上传
|
||||
|
||||
try {
|
||||
@@ -132,24 +125,7 @@ class Base {
|
||||
// 上传失败
|
||||
});
|
||||
} catch (error) {}
|
||||
}
|
||||
public uploadSlow=(envInfo: ISlow) =>{
|
||||
if (!this.Dns) return; //未设置Dns服务器不上传
|
||||
|
||||
try {
|
||||
this.platform
|
||||
?.upload(this.Dns + `/admin/monitor_slow/add`, {
|
||||
ProjectKey: this.Pid,
|
||||
ClientId: this.client_id,
|
||||
UserId: this.Uid,
|
||||
Path: envInfo.Path,
|
||||
Time: envInfo.Time,
|
||||
})
|
||||
.catch((err: any) => {
|
||||
// 上传失败
|
||||
});
|
||||
} catch (error) {}
|
||||
}
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
public upload() {
|
||||
|
Reference in New Issue
Block a user