Commit b30763b3 authored by aiduck's avatar aiduck

opt

parent 086f64f7
{
"name": "hunter-rrweb",
"name": "@tuia/rip",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
......
......@@ -12,8 +12,10 @@ export default class Monitor {
payload: {
system,
userIdentifier,
config: {
env,
log,
}
},
});
}
......
......@@ -3,14 +3,18 @@ import Counter from "./counter";
import { dataWrapper, log } from './utils';
class Reporter {
system = ''; // 系统名
// 基础配置
baseInfo = {
system: '',
userIdentifier: '',
path: '',
};
// 系统配置
config = {
env: 'prod',
log: false
}; // 系统配置
environmentUrl = ''; // 环境
userIdentifier = ''; //用户标示
path = ''; // 当前路径
};
environmentUrl = ''; // 环境配置
isUploading = false; // 是否在上传cdn
bus = []; // 上传分片数据
counter = new Counter(); // 计数器和recordKey一起重置
......@@ -20,16 +24,15 @@ class Reporter {
}
// 设置参数内容
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;
// 设置基础信息 系统名 + 用户标示 + 当前访问路径
dataObj.config && delete dataObj.config
this.baseInfo = {
...this.baseInfo,
...dataObj
}
}
// 设置系统环境变量
......
......@@ -7,8 +7,8 @@ const reporter = new Reporter("recordKey");
onmessage = ({ data: { type, payload } }) => {
switch (type) {
case "init":
log(reporter.config.log, 'init参数', payload);
reporter.setData(payload);
log(reporter.config.log, 'init参数', payload);
break;
case "record":
// todo : 数据本地存储
......@@ -31,11 +31,11 @@ onmessage = ({ data: { type, payload } }) => {
break;
case "reset":
// todo : 重置参数,重新生成recordKey
const { url, email, userInfo } = payload;
reporter.setData(payload);
let recordKey = md5(url + email + Date.parse(new Date()));
const { path, email } = payload;
reporter.setData({path});
let recordKey = md5(path + email + Date.parse(new Date()));
reporter.reset(recordKey);
log(reporter.config.log, '用户信息', userInfo);
log(reporter.config.log, 'path', reporter.baseInfo.path);
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