Commit c174b672 authored by aiduck's avatar aiduck

setData

parent 717ef537
......@@ -17,6 +17,9 @@ export default class Monitor {
},
});
}
/**
* 关闭rrweb
*/
resetRrwebHandler() {
this.rrwebHandler && this.rrwebHandler();
}
......@@ -33,6 +36,12 @@ export default class Monitor {
},
});
}
/**
* 路由监听
*/
listenOnHash() {
// console.log(window.onhashchange());
}
/**
* 停止录制
* @memberof Monitor
......
......@@ -18,15 +18,20 @@ class Reporter {
constructor(recordKey) {
this.recordKey = recordKey;
}
// 设置系统名
setSystem(system) {
this.system = system;
}
// 设置配置内容
setConfig(config) {
this.config = config;
this.setEnvironment(config.env);
// 设置参数内容
setData(dataObj) {
console.log(dataObj);
// 设置系统名
this.system = dataObj.system || this.system;
// 设置配置内容
this.config = dataObj.config || this.config;
this.setEnvironment(this.config.env);
// 设置用户标示
this.userIdentifier = dataObj.userInfo || this.userIdentifier;
// 设置当前访问路径
this.path = dataObj.url || this.path;
}
// 设置系统环境变量
setEnvironment(env) {
if (env === 'dev') {
......@@ -35,15 +40,6 @@ class Reporter {
this.environmentUrl = 'http://hunter.dui88.com.cn';
}
}
// 设置用户标示
setUserIdentifier(userIdentifier) {
this.userIdentifier = userIdentifier;
}
// 设置当前访问路径
setPath(url) {
this.path = url
}
// 上传CDN
toCDN(payload) {
this.isUploading = true;
......
......@@ -6,10 +6,9 @@ const reporter = new Reporter("recordKey");
onmessage = ({ data: { type, payload } }) => {
switch (type) {
case "init":
reporter.setSystem(payload.system);
reporter.setConfig(payload.config);
case "init":
log(reporter.config.log, 'init参数', payload);
reporter.setData(payload);
break;
case "record":
// todo : 数据本地存储
......@@ -21,25 +20,22 @@ onmessage = ({ data: { type, payload } }) => {
reporter.toCDN(payload);
}
// todo : 数据压缩
// todo : 根据事件类型优先级触发上传策略(click)
if (payload.data.source === 2 && !reporter.isUploading) {
postMessage({ type: "localData", payload: reporter.bus })
reporter.report(reporter.bus);
}
// todo : 数据超出100条上线,自动上传
if (reporter.bus.length > 100 && !reporter.isUploading) {
postMessage({ type: "localData", payload: reporter.bus })
reporter.report(reporter.bus);
}
break;
case "reset":
// todo : 重置参数,重新生成recordKey
const { url, email, userInfo } = payload;
reporter.setUserIdentifier(userInfo);
reporter.setPath(url);
reporter.setData(payload);
let recordKey = md5(url + email + Date.parse(new Date()));
reporter.reset(recordKey);
log(reporter.config.log, '用户信息', userInfo);
log(reporter.config.log, '分片id', reporter.recordKey);
break;
default:
......
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