Commit e8268d8a authored by aiduck's avatar aiduck

修改部分参数

parent 0eb7f34f
......@@ -1489,8 +1489,7 @@
"charenc": {
"version": "0.0.2",
"resolved": "https://registry.npm.taobao.org/charenc/download/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=",
"dev": true
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"chokidar": {
"version": "2.1.6",
......@@ -1759,8 +1758,7 @@
"crypt": {
"version": "0.0.2",
"resolved": "https://registry.npm.taobao.org/crypt/download/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=",
"dev": true
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"crypto-browserify": {
"version": "3.12.0",
......@@ -3000,8 +2998,7 @@
"is-buffer": {
"version": "1.1.6",
"resolved": "http://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz",
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=",
"dev": true
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4="
},
"is-data-descriptor": {
"version": "0.1.4",
......@@ -3263,7 +3260,6 @@
"version": "2.2.1",
"resolved": "https://registry.npm.taobao.org/md5/download/md5-2.2.1.tgz",
"integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=",
"dev": true,
"requires": {
"charenc": "~0.0.1",
"crypt": "~0.0.1",
......@@ -4785,6 +4781,11 @@
}
}
},
"whatwg-fetch": {
"version": "3.0.0",
"resolved": "https://registry.npm.taobao.org/whatwg-fetch/download/whatwg-fetch-3.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwhatwg-fetch%2Fdownload%2Fwhatwg-fetch-3.0.0.tgz",
"integrity": "sha1-/IBORYzEYACbGiuWa8iBfSV4rvs="
},
"which": {
"version": "1.3.1",
"resolved": "http://registry.npm.taobao.org/which/download/which-1.3.1.tgz",
......
......@@ -23,7 +23,9 @@
"license": "ISC",
"dependencies": {
"lodash": "^4.17.15",
"rrweb": "^0.7.18"
"md5": "^2.2.1",
"rrweb": "^0.7.18",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.4.5",
......@@ -32,7 +34,6 @@
"@babel/preset-env": "^7.4.5",
"babel-loader": "^8.0.6",
"cross-env": "^5.2.0",
"md5": "^2.2.1",
"webpack": "^4.35.2",
"worker-loader": "^2.0.0"
}
......
import 'whatwg-fetch';
import utils from './utils';
const common = {
/**
* fetch请求封装
......@@ -10,7 +13,7 @@ const common = {
* isJson(是否设置post请求头contentType为application/json)
* content 自定义请求参数
*/
fetch(action, params = {}, method = 'get', options = {}) {
fetch(action, params = {}, method = 'get', options = {}) {
const token = utils.getCookie('token');
const XCsrfToken = utils.getCookie('csrf_token');
let url = action;
......@@ -45,6 +48,16 @@ const common = {
if (method === 'get') {
url = Object.keys(params).length ? url + '?' + utils.serialize(params) : url;
}
return fetch(url, option)
.then(response => {
if (response.status >= 200 && response.status < 300) {
return response;
} else {
let error = new Error(response.statusText);
error.response = response;
throw error;
}
});
}
}
......
import * as rrweb from "rrweb";
import TracksWorker from "./tracks.worker";
import common from './comment';
export default class Monitor {
rrwebHandler = null;
tracksWorker = new TracksWorker();
// 记录
constructor() {
this.tracksWorker.onmessage = ({ data }) => {
console.log(data);
console.log('local', data);
window.localStorage.setItem("rrevents", JSON.stringify(data));
console.log("local");
// common.fetch('https://manager.tuiatest.cn/homePage/data','get');
};
}
record() {
......
......@@ -13,6 +13,7 @@ onmessage = ({ data: { type, payload } }) => {
switch (type) {
case "record":
// todo : 数据本地存储
console.log(wrapData);
wrapData.push(utils.dataWrapper({
recordKey,
isCdn: false
......@@ -30,6 +31,7 @@ onmessage = ({ data: { type, payload } }) => {
}, 1000);
}
// todo : 数据压缩
// todo : 根据事件类型优先级触发上传策略(click)
if(payload.data.source === 2 && isCdnReturn) {
console.log('点击上上传events', wrapData);
......@@ -50,7 +52,7 @@ onmessage = ({ data: { type, payload } }) => {
events = [];
wrapData = [];
recordKey = '';
isCdnReture = false;
isCdnReturn = false;
const { url, email } = payload;
recordKey = md5(url + email + Date.parse(new Date()));
console.log(url, '分片id', recordKey);
......
......@@ -6,6 +6,10 @@ const utils = {
event
}
},
// 判断是否有值
isNothing(value) {
return value === '' || value === undefined || value === null || (typeof value === 'number' && (isNaN(value) || !isFinite(value)));
},
// 获取token
getCookie(name) {
const regexp = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
......
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