@yysports/tools 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Track/Beacon.d.ts +6 -0
- package/dist/Track/Beacon.js +58 -0
- package/dist/Track/Config.d.ts +11 -0
- package/dist/Track/Config.js +34 -0
- package/dist/Track/Listener.d.ts +5 -0
- package/dist/Track/Listener.js +46 -0
- package/dist/Track/Log.d.ts +8 -0
- package/dist/Track/Log.js +100 -0
- package/dist/Track/Replay.d.ts +6 -0
- package/dist/Track/Replay.js +77 -0
- package/dist/Track/System.d.ts +5 -0
- package/dist/Track/System.js +24 -0
- package/dist/Track/User.d.ts +6 -0
- package/dist/Track/User.js +29 -0
- package/dist/Track/index.d.ts +15 -20
- package/dist/Track/index.js +40 -164
- package/dist/Utils/auth.d.ts +9 -2
- package/dist/Utils/auth.js +80 -20
- package/dist/Utils/route.d.ts +11 -3
- package/dist/Utils/route.js +49 -56
- package/dist/Utils/url.js +3 -13
- package/dist/interfaces/track.interface.d.ts +1 -80
- package/dist/interfaces/track.interface.js +1 -5
- package/lib/Track/Beacon.d.ts +6 -0
- package/lib/Track/Beacon.js +73 -0
- package/lib/Track/Config.d.ts +11 -0
- package/lib/Track/{core/queue.js → Config.js} +23 -27
- package/lib/Track/Listener.d.ts +5 -0
- package/lib/Track/Listener.js +62 -0
- package/lib/Track/Log.d.ts +8 -0
- package/lib/Track/Log.js +95 -0
- package/lib/Track/Replay.d.ts +6 -0
- package/lib/Track/Replay.js +79 -0
- package/lib/Track/System.d.ts +5 -0
- package/lib/Track/{core/router.js → System.js} +18 -20
- package/lib/Track/User.d.ts +6 -0
- package/lib/Track/User.js +40 -0
- package/lib/Track/index.d.ts +15 -20
- package/lib/Track/index.js +39 -91
- package/lib/Utils/auth.d.ts +9 -2
- package/lib/Utils/auth.js +52 -17
- package/lib/Utils/route.d.ts +11 -3
- package/lib/Utils/route.js +34 -49
- package/lib/Utils/url.js +3 -3
- package/lib/interfaces/track.interface.d.ts +1 -80
- package/package.json +13 -13
- package/dist/Track/core/auth.d.ts +0 -16
- package/dist/Track/core/auth.js +0 -83
- package/dist/Track/core/constants.d.ts +0 -14
- package/dist/Track/core/constants.js +0 -25
- package/dist/Track/core/envelope.d.ts +0 -9
- package/dist/Track/core/envelope.js +0 -54
- package/dist/Track/core/instance.d.ts +0 -108
- package/dist/Track/core/instance.js +0 -365
- package/dist/Track/core/lifecycle.d.ts +0 -18
- package/dist/Track/core/lifecycle.js +0 -59
- package/dist/Track/core/profile.d.ts +0 -5
- package/dist/Track/core/profile.js +0 -30
- package/dist/Track/core/queue.d.ts +0 -13
- package/dist/Track/core/queue.js +0 -36
- package/dist/Track/core/replay.d.ts +0 -17
- package/dist/Track/core/replay.js +0 -117
- package/dist/Track/core/router.d.ts +0 -6
- package/dist/Track/core/router.js +0 -15
- package/dist/Track/core/system.d.ts +0 -14
- package/dist/Track/core/system.js +0 -36
- package/dist/Track/core/transport.d.ts +0 -18
- package/dist/Track/core/transport.js +0 -151
- package/lib/Track/core/auth.d.ts +0 -16
- package/lib/Track/core/auth.js +0 -67
- package/lib/Track/core/constants.d.ts +0 -14
- package/lib/Track/core/constants.js +0 -56
- package/lib/Track/core/envelope.d.ts +0 -9
- package/lib/Track/core/envelope.js +0 -61
- package/lib/Track/core/instance.d.ts +0 -108
- package/lib/Track/core/instance.js +0 -257
- package/lib/Track/core/lifecycle.d.ts +0 -18
- package/lib/Track/core/lifecycle.js +0 -74
- package/lib/Track/core/profile.d.ts +0 -5
- package/lib/Track/core/profile.js +0 -47
- package/lib/Track/core/queue.d.ts +0 -13
- package/lib/Track/core/replay.d.ts +0 -17
- package/lib/Track/core/replay.js +0 -131
- package/lib/Track/core/router.d.ts +0 -6
- package/lib/Track/core/system.d.ts +0 -14
- package/lib/Track/core/system.js +0 -53
- package/lib/Track/core/transport.d.ts +0 -18
- package/lib/Track/core/transport.js +0 -115
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Track/Beacon.ts
|
|
30
|
+
var Beacon_exports = {};
|
|
31
|
+
__export(Beacon_exports, {
|
|
32
|
+
default: () => Beacon
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Beacon_exports);
|
|
35
|
+
var import_package = require("../../package.json");
|
|
36
|
+
var import_Config = __toESM(require("./Config"));
|
|
37
|
+
var Beacon = class {
|
|
38
|
+
// 加入Beacon消息队列,检测超过5条记录时自动发送
|
|
39
|
+
static push(data) {
|
|
40
|
+
this._queue.push(data);
|
|
41
|
+
if (this._queue.length >= 5) {
|
|
42
|
+
this.send();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// 发送Beacon消息
|
|
46
|
+
static send(data, api = "/pousheng-guard/api/track") {
|
|
47
|
+
const sendData = data ? data : this._queue.splice(0, 5);
|
|
48
|
+
if (!sendData || Array.isArray(sendData) && sendData.length === 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const blob = new Blob([JSON.stringify(sendData)], {
|
|
52
|
+
type: "application/json"
|
|
53
|
+
});
|
|
54
|
+
navigator == null ? void 0 : navigator.sendBeacon(`${import_Config.default.data.domain}${api}`, blob);
|
|
55
|
+
}
|
|
56
|
+
// 更新Track版本号
|
|
57
|
+
static updateVersion() {
|
|
58
|
+
const storageKey = `__TrackVersion__`;
|
|
59
|
+
const cachedVersion = localStorage.getItem(storageKey);
|
|
60
|
+
if (cachedVersion !== import_package.version) {
|
|
61
|
+
this.send(
|
|
62
|
+
{
|
|
63
|
+
appId: import_Config.default.data.appId,
|
|
64
|
+
version: import_package.version
|
|
65
|
+
},
|
|
66
|
+
"/pousheng-guard/api/apps/version/update"
|
|
67
|
+
);
|
|
68
|
+
localStorage.setItem(storageKey, import_package.version);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// 消息队列
|
|
73
|
+
Beacon._queue = [];
|
|
@@ -16,34 +16,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/Track/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
19
|
+
// src/Track/Config.ts
|
|
20
|
+
var Config_exports = {};
|
|
21
|
+
__export(Config_exports, {
|
|
22
|
+
default: () => Config
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
module.exports = __toCommonJS(Config_exports);
|
|
25
|
+
var Config = class {
|
|
26
|
+
static validate(config) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (!((_a = config.appId) == null ? void 0 : _a.trim())) {
|
|
29
|
+
throw new Error("Config: appId is required");
|
|
30
|
+
}
|
|
31
|
+
if (!((_b = config.domain) == null ? void 0 : _b.trim())) {
|
|
32
|
+
throw new Error("Config: domain is required");
|
|
33
|
+
}
|
|
34
|
+
Object.assign(this._data, config);
|
|
28
35
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.items.push(item);
|
|
32
|
-
}
|
|
33
|
-
/** 当前元素数量 */
|
|
34
|
-
size() {
|
|
35
|
-
return this.items.length;
|
|
36
|
-
}
|
|
37
|
-
/** 取出并清空所有元素(返回快照) */
|
|
38
|
-
drain() {
|
|
39
|
-
if (!this.items.length)
|
|
40
|
-
return [];
|
|
41
|
-
const copy = this.items.slice();
|
|
42
|
-
this.items.length = 0;
|
|
43
|
-
return copy;
|
|
36
|
+
static get data() {
|
|
37
|
+
return this._data;
|
|
44
38
|
}
|
|
45
39
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
Config._data = {
|
|
41
|
+
appId: "",
|
|
42
|
+
domain: "",
|
|
43
|
+
autoReportError: true,
|
|
44
|
+
enableReplay: true
|
|
45
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Track/Listener.ts
|
|
30
|
+
var Listener_exports = {};
|
|
31
|
+
__export(Listener_exports, {
|
|
32
|
+
default: () => Listener
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Listener_exports);
|
|
35
|
+
var import_Beacon = __toESM(require("./Beacon"));
|
|
36
|
+
var import_Config = __toESM(require("./Config"));
|
|
37
|
+
var import_Log = __toESM(require("./Log"));
|
|
38
|
+
var Listener = class {
|
|
39
|
+
static run() {
|
|
40
|
+
if (this._loaded || !import_Config.default.data.autoReportError) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
window.addEventListener("error", (event) => {
|
|
44
|
+
if (this._reporter) {
|
|
45
|
+
clearTimeout(this._reporter);
|
|
46
|
+
}
|
|
47
|
+
this._reporter = setTimeout(() => {
|
|
48
|
+
import_Beacon.default.send();
|
|
49
|
+
import_Log.default.errorLog(event.message);
|
|
50
|
+
this._reporter = null;
|
|
51
|
+
}, 1e3);
|
|
52
|
+
});
|
|
53
|
+
document.addEventListener("visibilitychange", () => {
|
|
54
|
+
if ((document == null ? void 0 : document.visibilityState) === "hidden") {
|
|
55
|
+
import_Beacon.default.send();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this._loaded = true;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Listener._loaded = false;
|
|
62
|
+
Listener._reporter = null;
|
package/lib/Track/Log.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Track/Log.ts
|
|
30
|
+
var Log_exports = {};
|
|
31
|
+
__export(Log_exports, {
|
|
32
|
+
default: () => Log
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Log_exports);
|
|
35
|
+
var import_Beacon = __toESM(require("./Beacon"));
|
|
36
|
+
var import_Config = __toESM(require("./Config"));
|
|
37
|
+
var import_Replay = __toESM(require("./Replay"));
|
|
38
|
+
var import_System = __toESM(require("./System"));
|
|
39
|
+
var import_User = __toESM(require("./User"));
|
|
40
|
+
var Log = class {
|
|
41
|
+
// 上报日志的公共属性
|
|
42
|
+
static _commonProps() {
|
|
43
|
+
return {
|
|
44
|
+
...import_User.default.profile,
|
|
45
|
+
...import_System.default.profile,
|
|
46
|
+
appId: import_Config.default.data.appId,
|
|
47
|
+
module: this._module
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static visitLog(module2) {
|
|
51
|
+
this._module = module2;
|
|
52
|
+
const lastModule = this._module.split("-").pop();
|
|
53
|
+
import_Beacon.default.push({
|
|
54
|
+
...this._commonProps(),
|
|
55
|
+
type: "visit",
|
|
56
|
+
content: `访问页面:${lastModule}`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
static eventLog(content) {
|
|
60
|
+
import_Beacon.default.push({
|
|
61
|
+
...this._commonProps(),
|
|
62
|
+
type: "event",
|
|
63
|
+
content
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
static async errorLog(message) {
|
|
67
|
+
const res = await fetch(
|
|
68
|
+
`${import_Config.default.data.domain}/pousheng-guard/api/track/error`,
|
|
69
|
+
{
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json"
|
|
73
|
+
},
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
...this._commonProps(),
|
|
76
|
+
type: "error",
|
|
77
|
+
log: JSON.stringify({ message })
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
const { data: id } = await res.json();
|
|
82
|
+
if (import_Config.default.data.autoReportError) {
|
|
83
|
+
import_Replay.default.reportSnapshot(id);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static apiLog(log) {
|
|
87
|
+
import_Beacon.default.push({
|
|
88
|
+
...this._commonProps(),
|
|
89
|
+
type: "api",
|
|
90
|
+
log
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
// 当前模块
|
|
95
|
+
Log._module = "";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Track/Replay.ts
|
|
30
|
+
var Replay_exports = {};
|
|
31
|
+
__export(Replay_exports, {
|
|
32
|
+
default: () => Replay
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Replay_exports);
|
|
35
|
+
var import_record = require("@rrweb/record");
|
|
36
|
+
var import_rrweb_plugin_console_record = require("@rrweb/rrweb-plugin-console-record");
|
|
37
|
+
var import_Config = __toESM(require("./Config"));
|
|
38
|
+
var Replay = class {
|
|
39
|
+
static run() {
|
|
40
|
+
if (this._stop || !import_Config.default.data.enableReplay) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
this._stop = (0, import_record.record)({
|
|
45
|
+
emit: (e) => {
|
|
46
|
+
this._events.push(e);
|
|
47
|
+
const over = this._events.length - 1e3;
|
|
48
|
+
if (over > 0)
|
|
49
|
+
this._events.splice(0, over);
|
|
50
|
+
},
|
|
51
|
+
plugins: [
|
|
52
|
+
(0, import_rrweb_plugin_console_record.getRecordConsolePlugin)({
|
|
53
|
+
level: ["log", "info", "warn", "error", "debug"]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
} catch (err) {
|
|
58
|
+
this._stop = void 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// 快照
|
|
62
|
+
static async reportSnapshot(errorId) {
|
|
63
|
+
if (!this._stop) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await fetch(
|
|
67
|
+
`${import_Config.default.data.domain}/pousheng-guard/api/track/error-replay/${errorId}`,
|
|
68
|
+
{
|
|
69
|
+
method: "POST",
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "text/plain"
|
|
72
|
+
},
|
|
73
|
+
body: JSON.stringify(this._events)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
this._events = [];
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
Replay._events = [];
|
|
@@ -16,24 +16,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/Track/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
22
|
-
|
|
23
|
-
getPageModules: () => getPageModules
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(router_exports);
|
|
26
|
-
function getFormattedPath(config) {
|
|
27
|
-
const { base = "/" } = config;
|
|
28
|
-
const pathname = typeof location !== "undefined" ? location.pathname : "";
|
|
29
|
-
return pathname.replace(base, "/");
|
|
30
|
-
}
|
|
31
|
-
function getPageModules(config, routesMap) {
|
|
32
|
-
const ri = routesMap.get(getFormattedPath(config));
|
|
33
|
-
return (ri == null ? void 0 : ri.module) || [];
|
|
34
|
-
}
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
getFormattedPath,
|
|
38
|
-
getPageModules
|
|
19
|
+
// src/Track/System.ts
|
|
20
|
+
var System_exports = {};
|
|
21
|
+
__export(System_exports, {
|
|
22
|
+
default: () => System
|
|
39
23
|
});
|
|
24
|
+
module.exports = __toCommonJS(System_exports);
|
|
25
|
+
var import_Utils = require("../Utils");
|
|
26
|
+
var System = class {
|
|
27
|
+
static get profile() {
|
|
28
|
+
return {
|
|
29
|
+
IMEI: this.IMEI,
|
|
30
|
+
innerHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
31
|
+
innerWidth: typeof window !== "undefined" ? window.innerWidth : 0,
|
|
32
|
+
href: typeof location !== "undefined" ? location.href : "",
|
|
33
|
+
systemTime: /* @__PURE__ */ new Date()
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
System.IMEI = (0, import_Utils.generateRandomString)(6);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Track/User.ts
|
|
20
|
+
var User_exports = {};
|
|
21
|
+
__export(User_exports, {
|
|
22
|
+
default: () => User
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(User_exports);
|
|
25
|
+
var User = class {
|
|
26
|
+
static setUserProfile(profile) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (!((_a = profile.userId) == null ? void 0 : _a.trim())) {
|
|
29
|
+
throw new Error("UserProfile: userId is required");
|
|
30
|
+
}
|
|
31
|
+
if (!((_b = profile.userName) == null ? void 0 : _b.trim())) {
|
|
32
|
+
throw new Error("UserProfile: userName is required");
|
|
33
|
+
}
|
|
34
|
+
this._profile = profile;
|
|
35
|
+
}
|
|
36
|
+
static get profile() {
|
|
37
|
+
return this._profile;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
User._profile = null;
|
package/lib/Track/index.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
visitLog:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
setUserProfile: (profile: Parameters<TrackerInstance['setUserProfile']>[0]) => void;
|
|
17
|
-
getConfig: () => TrackConfig;
|
|
18
|
-
};
|
|
19
|
-
declare const Track: TrackAPI;
|
|
20
|
-
export default Track;
|
|
1
|
+
import { UserProfile } from '../interfaces/track.interface';
|
|
2
|
+
import { IConfig } from './Config';
|
|
3
|
+
import Log from './Log';
|
|
4
|
+
export default class Track {
|
|
5
|
+
static init(cfg: IConfig): void;
|
|
6
|
+
static setUserProfile(profile: UserProfile): void;
|
|
7
|
+
static get config(): IConfig;
|
|
8
|
+
static get userProfile(): UserProfile | null;
|
|
9
|
+
static get systemProfile(): import("../interfaces/track.interface").SystemProfile;
|
|
10
|
+
static run(): void;
|
|
11
|
+
static visitLog: typeof Log.visitLog;
|
|
12
|
+
static eventLog: typeof Log.eventLog;
|
|
13
|
+
static errorLog: typeof Log.errorLog;
|
|
14
|
+
static apiLog: typeof Log.apiLog;
|
|
15
|
+
}
|