Commit e8268d8a authored by aiduck's avatar aiduck

修改部分参数

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