Commit f9056aa0 authored by aiduck's avatar aiduck

host

parent c1b3a3aa
{
"name": "@tuia/rip",
"version": "1.0.5",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "@tuia/rip",
"version": "1.0.5",
"version": "1.0.6",
"description": "Tools for user behavior recording and playback based on rrweb",
"main": "dist/index.js",
"scripts": {
......@@ -29,7 +29,6 @@
"author": "Dec-F",
"license": "ISC",
"dependencies": {
"formdata-polyfill": "^3.0.19",
"md5": "^2.2.1",
"rrweb": "^0.7.18",
"whatwg-fetch": "^3.0.0"
......
......@@ -6,37 +6,42 @@ class Monitor {
initialized = false;
listenedRoute = false;
tracksWorker = new TracksWorker();
init({ system, userIdentifier, env = "prod", log = false, path = "/" }) {
init({ system, userIdentifier, host = [], env = "prod", log = false, path = "/", }) {
let protocol = document.location.protocol;
if (!system || !userIdentifier) {
console.error("system,userIdentifier是必传的");
let realHost = window.location.host;
if (!system || !userIdentifier || host.length > 0) {
console.error("system,userIdentifier,host是必传的");
}
if (!this.initialized) {
this.tracksWorker.postMessage({
type: "init",
payload: {
path,
system,
userIdentifier,
env,
log,
protocol
},
});
this.initialized = true;
this.record();
} else {
this.reset({ userIdentifier });
}
this.listenOnHash();
this.tracksWorker.onmessage = (event) => {
switch(event.data) {
case "resetRecord":
this.record(); // 开启录制
break;
default:
console.log("unknow action", event.data);
if(!host.includes(realHost)) {
if (!this.initialized) {
this.tracksWorker.postMessage({
type: "init",
payload: {
path,
system,
userIdentifier,
env,
log,
protocol
},
});
this.initialized = true;
this.record();
} else {
this.reset({ userIdentifier });
}
this.listenOnHash();
this.tracksWorker.onmessage = (event) => {
switch(event.data) {
case "resetRecord":
this.record(); // 开启录制
break;
default:
console.log("unknow action", event.data);
}
}
} else {
console.error("当前的系统并不是线上环境,不做特殊录制");
}
}
/**
......
// 数据维护,上报
import md5 from "md5";
import FormData from "formdata-polyfill";
import Counter from "./counter";
import { dataWrapper } from "./utils";
import log from "./log";
......
......@@ -1579,10 +1579,9 @@ for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.npm.taobao.org/for-in/download/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
formdata-polyfill@^3.0.19:
version "3.0.19"
resolved "https://registry.npm.taobao.org/formdata-polyfill/download/formdata-polyfill-3.0.19.tgz#72f517db3a646a5dd8c31af0edf111fd8f1e4cee"
integrity sha1-cvUX2zpkal3Ywxrw7fER/Y8eTO4=
formdata-polyfill@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-2.0.4.tgz#2f5eae8f34b697cdc6b107ace7d617ed5f1fb7c4"
fragment-cache@^0.2.1:
version "0.2.1"
......
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