Commit 717ef537 authored by fanxuehui's avatar fanxuehui

feat(types):

parent feb99f13
export interface MProps {
system: string;
userIdentifier: string;
env: "dev" | "prod";
log: boolean;
}
export declare class Monitor {
constructor(props: MProps);
}
\ No newline at end of file
import * as rrweb from "rrweb"; import * as rrweb from "rrweb";
import TracksWorker from "./tracks.worker"; import TracksWorker from "./tracks.worker";
import utils from './utils'; import utils from "./utils";
export default class Monitor { export default class Monitor {
rrwebHandler = null; rrwebHandler = null;
tracksWorker = new TracksWorker(); tracksWorker = new TracksWorker();
constructor(props) { constructor({ system = "unknow", userIdentifier = "unknow", env = "prod", log = false }) {
console.log('初始化'); console.log("初始化");
this.tracksWorker.postMessage({ this.tracksWorker.postMessage({
type: "init", type: "init",
payload: { payload: {
system: props.system, system,
config: props.config userIdentifier,
} env,
log,
},
}); });
} }
resetRrwebHandler() { resetRrwebHandler() {
...@@ -44,7 +46,7 @@ export default class Monitor { ...@@ -44,7 +46,7 @@ export default class Monitor {
} }
/** /**
* 重置 * 重置
* @param {*} event * @param {*} event
*/ */
reset(event) { reset(event) {
this.resetRrwebHandler(); this.resetRrwebHandler();
......
/** /**
* 包装event * 包装event
* @param {*} extraData * @param {*} extraData
* @param {*} event * @param {*} event
*/ */
export const dataWrapper = (extraData, event) => { export const dataWrapper = (extraData, event) => {
return { return {
...extraData, ...extraData,
track: event track: event,
} };
}; };
/** /**
* 是否打印日志 * 是否打印日志
* @param {*} logMes * @param {boolean} log
*/ */
export const log = (log, logMes, logContent) => { export const log = (log, ...rest) => {
if( log) { console.log(rest);
return console.log(logMes, logContent); };
} else {
return;
}
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment