Commit c174b672 authored by aiduck's avatar aiduck

setData

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