完善监控sdk

This commit is contained in:
xiangheng
2024-10-31 13:11:34 +08:00
parent daeea359bc
commit e65b9f6af8
11 changed files with 424 additions and 205 deletions

View File

@@ -1,5 +1,5 @@
import { v1 as uuid_v1 } from "uuid";
import type { LogWithError, Platform,LogWithEnv } from "./types";
import type { LogWithError, IErrorEvent,LogWithEnv } from "./types";
type Uid = string | number;
@@ -15,11 +15,12 @@ class XLog {
private Pid: string = "";
private Uid: Uid = "";
private platform: Platform;
private platform: IErrorEvent;
MessageList: any[] = [];
timer: number;
constructor(props: Props, platform: Platform) {
constructor(props: Props, platform: IErrorEvent) {
this.platform = platform;
if (props) {
props.Dns && (this.Dns = props.Dns);
@@ -33,12 +34,12 @@ class XLog {
// 监听错误
platform.listen((params: LogWithError) => {
console.log('listen',params);
console.log('listenCallback',params);
this.Push(params);
});
setInterval(() => {
this.timer=setInterval(() => {
this.upload();
}, 1000 * 10);
}
@@ -133,6 +134,10 @@ class XLog {
this.platform.delCache("x_message_list");
} catch (error) {}
}
public unListen(){
clearInterval(this.timer)
this.platform.unListen()
}
// public Vue2 = (app: any) => {
// app.prototype.$xLog = this;
// };