Commit f9056aa0 authored by aiduck's avatar aiduck

host

parent c1b3a3aa
{ {
"name": "@tuia/rip", "name": "@tuia/rip",
"version": "1.0.5", "version": "1.0.6",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
......
{ {
"name": "@tuia/rip", "name": "@tuia/rip",
"version": "1.0.5", "version": "1.0.6",
"description": "Tools for user behavior recording and playback based on rrweb", "description": "Tools for user behavior recording and playback based on rrweb",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
"author": "Dec-F", "author": "Dec-F",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"formdata-polyfill": "^3.0.19",
"md5": "^2.2.1", "md5": "^2.2.1",
"rrweb": "^0.7.18", "rrweb": "^0.7.18",
"whatwg-fetch": "^3.0.0" "whatwg-fetch": "^3.0.0"
......
...@@ -6,37 +6,42 @@ class Monitor { ...@@ -6,37 +6,42 @@ class Monitor {
initialized = false; initialized = false;
listenedRoute = false; listenedRoute = false;
tracksWorker = new TracksWorker(); 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; let protocol = document.location.protocol;
if (!system || !userIdentifier) { let realHost = window.location.host;
console.error("system,userIdentifier是必传的"); if (!system || !userIdentifier || host.length > 0) {
console.error("system,userIdentifier,host是必传的");
} }
if (!this.initialized) { if(!host.includes(realHost)) {
this.tracksWorker.postMessage({ if (!this.initialized) {
type: "init", this.tracksWorker.postMessage({
payload: { type: "init",
path, payload: {
system, path,
userIdentifier, system,
env, userIdentifier,
log, env,
protocol log,
}, protocol
}); },
this.initialized = true; });
this.record(); this.initialized = true;
} else { this.record();
this.reset({ userIdentifier }); } 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);
} }
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 md5 from "md5";
import FormData from "formdata-polyfill";
import Counter from "./counter"; import Counter from "./counter";
import { dataWrapper } from "./utils"; import { dataWrapper } from "./utils";
import log from "./log"; import log from "./log";
......
...@@ -1579,10 +1579,9 @@ for-in@^1.0.2: ...@@ -1579,10 +1579,9 @@ for-in@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.npm.taobao.org/for-in/download/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" resolved "https://registry.npm.taobao.org/for-in/download/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
formdata-polyfill@^3.0.19: formdata-polyfill@^2.0.4:
version "3.0.19" version "2.0.4"
resolved "https://registry.npm.taobao.org/formdata-polyfill/download/formdata-polyfill-3.0.19.tgz#72f517db3a646a5dd8c31af0edf111fd8f1e4cee" resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-2.0.4.tgz#2f5eae8f34b697cdc6b107ace7d617ed5f1fb7c4"
integrity sha1-cvUX2zpkal3Ywxrw7fER/Y8eTO4=
fragment-cache@^0.2.1: fragment-cache@^0.2.1:
version "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