@yysports/tools 2.0.2 → 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 -17
- package/dist/Track/index.js +56 -67
- 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 -17
- package/lib/Track/index.js +45 -39
- 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 -17
- package/dist/Track/core/constants.js +0 -34
- package/dist/Track/core/envelope.d.ts +0 -9
- package/dist/Track/core/envelope.js +0 -54
- package/dist/Track/core/index.d.ts +0 -22
- package/dist/Track/core/index.js +0 -23
- package/dist/Track/core/instance.d.ts +0 -108
- package/dist/Track/core/instance.js +0 -375
- 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 -165
- 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 -17
- package/lib/Track/core/constants.js +0 -65
- package/lib/Track/core/envelope.d.ts +0 -9
- package/lib/Track/core/envelope.js +0 -61
- package/lib/Track/core/index.d.ts +0 -22
- package/lib/Track/core/index.js +0 -51
- package/lib/Track/core/instance.d.ts +0 -108
- package/lib/Track/core/instance.js +0 -266
- 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 -128
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 路由辅助:基于 base 前缀规范化路径,并从 routesMap 提取模块层级
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export function getFormattedPath(config) {
|
|
6
|
-
var _config$base = config.base,
|
|
7
|
-
base = _config$base === void 0 ? '/' : _config$base;
|
|
8
|
-
var pathname = typeof location !== 'undefined' ? location.pathname : '';
|
|
9
|
-
// 确保只剥离一次 base 前缀
|
|
10
|
-
return pathname.replace(base, '/');
|
|
11
|
-
}
|
|
12
|
-
export function getPageModules(config, routesMap) {
|
|
13
|
-
var ri = routesMap.get(getFormattedPath(config));
|
|
14
|
-
return (ri === null || ri === void 0 ? void 0 : ri.module) || [];
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 系统/运行环境信息采集:IMEI 生成 + 视口 + 当前 URL 等。
|
|
3
|
-
*/
|
|
4
|
-
import { SystemProfile } from '../../interfaces/track.interface';
|
|
5
|
-
/**
|
|
6
|
-
* 确保存在一个持久化 IMEI(匿名设备标识)
|
|
7
|
-
* - 优先 localStorage
|
|
8
|
-
* - 不可用时降级随机字符串
|
|
9
|
-
*/
|
|
10
|
-
export declare function ensureIMEI(): string;
|
|
11
|
-
/**
|
|
12
|
-
* 收集系统(会话)级别指标:窗口尺寸 / URL / 时间戳 / IMEI
|
|
13
|
-
*/
|
|
14
|
-
export declare function getSystemProfile(): SystemProfile;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 系统/运行环境信息采集:IMEI 生成 + 视口 + 当前 URL 等。
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { generateRandomString } from "../../Utils";
|
|
6
|
-
var IMEI_KEY = '__IMEI__';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 确保存在一个持久化 IMEI(匿名设备标识)
|
|
10
|
-
* - 优先 localStorage
|
|
11
|
-
* - 不可用时降级随机字符串
|
|
12
|
-
*/
|
|
13
|
-
export function ensureIMEI() {
|
|
14
|
-
try {
|
|
15
|
-
var val = localStorage.getItem(IMEI_KEY);
|
|
16
|
-
if (val) return val;
|
|
17
|
-
var imei = generateRandomString(16);
|
|
18
|
-
localStorage.setItem(IMEI_KEY, imei);
|
|
19
|
-
return imei;
|
|
20
|
-
} catch (_unused) {
|
|
21
|
-
return generateRandomString(16);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 收集系统(会话)级别指标:窗口尺寸 / URL / 时间戳 / IMEI
|
|
27
|
-
*/
|
|
28
|
-
export function getSystemProfile() {
|
|
29
|
-
return {
|
|
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: new Date(),
|
|
34
|
-
IMEI: ensureIMEI()
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { TrackConfig } from '../../interfaces/track.interface';
|
|
2
|
-
/**
|
|
3
|
-
* sendBeacon 包装:
|
|
4
|
-
* - 统一 JSON 序列化
|
|
5
|
-
* - debug 输出
|
|
6
|
-
* - 失败仅打印(不抛错,避免影响业务)
|
|
7
|
-
*/
|
|
8
|
-
export declare function beaconSend(url: string, payload: object | any[]): void;
|
|
9
|
-
/**
|
|
10
|
-
* 上报当前应用版本:避免重复上报,通过 localStorage 绑定 appId 做缓存
|
|
11
|
-
*/
|
|
12
|
-
export declare function reportAppVersion(config: TrackConfig): void;
|
|
13
|
-
/** 批量上报日志事件数组 */
|
|
14
|
-
export declare function reportBatch(config: TrackConfig, batch: any[]): void;
|
|
15
|
-
/** 上报单条 API 日志(独立通道) */
|
|
16
|
-
export declare function reportApiLog(config: TrackConfig, apiLog: any, envelope: any): void;
|
|
17
|
-
/** 上报单条错误日志到专用端点 */
|
|
18
|
-
export declare function reportError(config: TrackConfig, envelope: any, replayPayload?: any): Promise<void>;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
/**
|
|
5
|
-
* 传输层:统一封装 sendBeacon 调用与批量 / 版本上报逻辑。
|
|
6
|
-
*/
|
|
7
|
-
import { version } from "../../../package.json";
|
|
8
|
-
import { APP_VERSION_ENDPOINT, DEV_DOMAIN, ERROR_REPLAY_ENDPOINT, ERROR_TRACK_ENDPOINT, PROD_DOMAIN, TEST_DOMAIN, TRACK_ENDPOINT } from "./constants";
|
|
9
|
-
|
|
10
|
-
/** 根据 TrackConfig.env 解析要使用的域名(兼容向后默认 test) */
|
|
11
|
-
function resolveDomain(config) {
|
|
12
|
-
var env = config && config.env || 'test';
|
|
13
|
-
switch (env) {
|
|
14
|
-
case 'dev':
|
|
15
|
-
return DEV_DOMAIN;
|
|
16
|
-
case 'prod':
|
|
17
|
-
return PROD_DOMAIN;
|
|
18
|
-
case 'test':
|
|
19
|
-
default:
|
|
20
|
-
return TEST_DOMAIN;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 包装fetch,方便async/await调用
|
|
26
|
-
* @param url
|
|
27
|
-
* @param options
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
function fetchWrapper(_x, _x2) {
|
|
31
|
-
return _fetchWrapper.apply(this, arguments);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* sendBeacon 包装:
|
|
35
|
-
* - 统一 JSON 序列化
|
|
36
|
-
* - debug 输出
|
|
37
|
-
* - 失败仅打印(不抛错,避免影响业务)
|
|
38
|
-
*/
|
|
39
|
-
function _fetchWrapper() {
|
|
40
|
-
_fetchWrapper = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, options) {
|
|
41
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
42
|
-
while (1) switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
45
|
-
fetch(url, options).then(function (response) {
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
throw new Error("Network response was not ok: ".concat(response.statusText));
|
|
48
|
-
}
|
|
49
|
-
return response.json();
|
|
50
|
-
}).then(function (data) {
|
|
51
|
-
return resolve(data);
|
|
52
|
-
}).catch(function (error) {
|
|
53
|
-
return reject(error);
|
|
54
|
-
});
|
|
55
|
-
}));
|
|
56
|
-
case 1:
|
|
57
|
-
case "end":
|
|
58
|
-
return _context.stop();
|
|
59
|
-
}
|
|
60
|
-
}, _callee);
|
|
61
|
-
}));
|
|
62
|
-
return _fetchWrapper.apply(this, arguments);
|
|
63
|
-
}
|
|
64
|
-
export function beaconSend(url, payload) {
|
|
65
|
-
try {
|
|
66
|
-
// 只允许对象或数组
|
|
67
|
-
if (!Array.isArray(payload) && (_typeof(payload) !== 'object' || payload === null)) {
|
|
68
|
-
throw new Error('Payload must be an object or array');
|
|
69
|
-
}
|
|
70
|
-
var body = new Blob([JSON.stringify(payload)], {
|
|
71
|
-
type: 'application/json'
|
|
72
|
-
});
|
|
73
|
-
navigator.sendBeacon(url, body);
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.warn('[track:debug] beacon failed', err, url, payload);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* 上报当前应用版本:避免重复上报,通过 localStorage 绑定 appId 做缓存
|
|
81
|
-
*/
|
|
82
|
-
export function reportAppVersion(config) {
|
|
83
|
-
var appId = config.appId;
|
|
84
|
-
var domain = resolveDomain(config);
|
|
85
|
-
var storageKey = "__Track__".concat(appId);
|
|
86
|
-
try {
|
|
87
|
-
var cached = localStorage.getItem(storageKey);
|
|
88
|
-
if (cached) {
|
|
89
|
-
try {
|
|
90
|
-
var _ref = JSON.parse(cached),
|
|
91
|
-
v = _ref.v;
|
|
92
|
-
if (v === version) {
|
|
93
|
-
console.debug('[track:debug] skip version report (same)', version);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
} catch (_unused) {
|
|
97
|
-
/* ignore parse error */
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
localStorage.setItem(storageKey, JSON.stringify({
|
|
101
|
-
v: version,
|
|
102
|
-
t: new Date().toLocaleString()
|
|
103
|
-
}));
|
|
104
|
-
} catch (_unused2) {
|
|
105
|
-
/* storage not available */
|
|
106
|
-
}
|
|
107
|
-
beaconSend("".concat(domain).concat(APP_VERSION_ENDPOINT), {
|
|
108
|
-
appId: appId,
|
|
109
|
-
version: version
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** 批量上报日志事件数组 */
|
|
114
|
-
export function reportBatch(config, batch) {
|
|
115
|
-
if (!batch.length) return;
|
|
116
|
-
var domain = resolveDomain(config);
|
|
117
|
-
beaconSend("".concat(domain).concat(TRACK_ENDPOINT), batch);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** 上报单条 API 日志(独立通道) */
|
|
121
|
-
export function reportApiLog(config, apiLog, envelope) {
|
|
122
|
-
var domain = resolveDomain(config);
|
|
123
|
-
beaconSend("".concat(domain).concat(TRACK_ENDPOINT), [envelope]);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** 上报单条错误日志到专用端点 */
|
|
127
|
-
export function reportError(_x3, _x4, _x5) {
|
|
128
|
-
return _reportError.apply(this, arguments);
|
|
129
|
-
}
|
|
130
|
-
function _reportError() {
|
|
131
|
-
_reportError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(config, envelope, replayPayload) {
|
|
132
|
-
var domain, _yield$fetchWrapper, id;
|
|
133
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
134
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
135
|
-
case 0:
|
|
136
|
-
domain = resolveDomain(config);
|
|
137
|
-
_context2.next = 3;
|
|
138
|
-
return fetchWrapper("".concat(domain).concat(ERROR_TRACK_ENDPOINT), {
|
|
139
|
-
method: 'POST',
|
|
140
|
-
headers: {
|
|
141
|
-
'Content-Type': 'application/json'
|
|
142
|
-
},
|
|
143
|
-
body: JSON.stringify(envelope)
|
|
144
|
-
});
|
|
145
|
-
case 3:
|
|
146
|
-
_yield$fetchWrapper = _context2.sent;
|
|
147
|
-
id = _yield$fetchWrapper.data;
|
|
148
|
-
if (id && replayPayload) {
|
|
149
|
-
// 将replayPayload以文本方式上传,不经过序列化
|
|
150
|
-
fetchWrapper("".concat(domain).concat(ERROR_REPLAY_ENDPOINT).concat(id), {
|
|
151
|
-
method: 'POST',
|
|
152
|
-
headers: {
|
|
153
|
-
'Content-Type': 'text/plain'
|
|
154
|
-
},
|
|
155
|
-
body: JSON.stringify(replayPayload)
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
case 6:
|
|
159
|
-
case "end":
|
|
160
|
-
return _context2.stop();
|
|
161
|
-
}
|
|
162
|
-
}, _callee2);
|
|
163
|
-
}));
|
|
164
|
-
return _reportError.apply(this, arguments);
|
|
165
|
-
}
|
package/lib/Track/core/auth.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AuthCenterUserProfile, RouteMapValueType, TrackConfig } from '../../interfaces/track.interface';
|
|
2
|
-
export interface AuthInitResult {
|
|
3
|
-
authCenterUserProfile: AuthCenterUserProfile;
|
|
4
|
-
routesMap: Map<string, RouteMapValueType>;
|
|
5
|
-
authMap: Map<string, string>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* 初始化权限 / 菜单 / 路由配置信息
|
|
9
|
-
* 1. 并行请求:用户权限(getAuth) / 菜单(menuBuild) / 数据域权限(getDataScopeZonePermissions)
|
|
10
|
-
* 2. 生成 routesMap 以及可访问页面 accessPage
|
|
11
|
-
* 3. 生成 authMap(按钮/操作编码 -> 中文描述)
|
|
12
|
-
* 4. 组织返回 AuthCenterUserProfile
|
|
13
|
-
* @param config TrackConfig
|
|
14
|
-
* @returns {AuthInitResult}
|
|
15
|
-
*/
|
|
16
|
-
export declare function initAuthCenterData(config: TrackConfig): Promise<AuthInitResult>;
|
package/lib/Track/core/auth.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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/core/auth.ts
|
|
20
|
-
var auth_exports = {};
|
|
21
|
-
__export(auth_exports, {
|
|
22
|
-
initAuthCenterData: () => initAuthCenterData
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(auth_exports);
|
|
25
|
-
var import_Utils = require("../../Utils");
|
|
26
|
-
async function initAuthCenterData(config) {
|
|
27
|
-
const {
|
|
28
|
-
getAuth,
|
|
29
|
-
menuBuild,
|
|
30
|
-
getDataScopeZonePermissions,
|
|
31
|
-
menuNameMap,
|
|
32
|
-
routes
|
|
33
|
-
} = config;
|
|
34
|
-
const tasks = [getAuth == null ? void 0 : getAuth(), menuBuild == null ? void 0 : menuBuild(), getDataScopeZonePermissions == null ? void 0 : getDataScopeZonePermissions()];
|
|
35
|
-
const [authInfo = {}, menuData = [], dataScopeZonePermissions] = await Promise.all(tasks.map((t) => t ?? Promise.resolve()));
|
|
36
|
-
const { user = {}, roles = [] } = authInfo || {};
|
|
37
|
-
const { roles: dataScopeRoles, ...restUser } = user;
|
|
38
|
-
const isAdmin = roles.includes("admin");
|
|
39
|
-
const accessPage = [];
|
|
40
|
-
let routesMap = /* @__PURE__ */ new Map();
|
|
41
|
-
if (routes) {
|
|
42
|
-
routesMap = (0, import_Utils.getRoutesMap)(routes, menuNameMap);
|
|
43
|
-
routesMap.forEach(({ access }) => {
|
|
44
|
-
if (!access.length)
|
|
45
|
-
return;
|
|
46
|
-
if (isAdmin)
|
|
47
|
-
accessPage.push(...access);
|
|
48
|
-
else
|
|
49
|
-
access.forEach((k) => roles.includes(k) && accessPage.push(k));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const authMap = (0, import_Utils.getAuthMapByAuthCenter)(menuData);
|
|
53
|
-
const profile = {
|
|
54
|
-
...restUser,
|
|
55
|
-
dataScopeRoles,
|
|
56
|
-
roles,
|
|
57
|
-
accessPage,
|
|
58
|
-
isAdmin
|
|
59
|
-
};
|
|
60
|
-
if (dataScopeZonePermissions)
|
|
61
|
-
Object.assign(profile, { dataScopeZonePermissions });
|
|
62
|
-
return { authCenterUserProfile: profile, routesMap, authMap };
|
|
63
|
-
}
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
0 && (module.exports = {
|
|
66
|
-
initAuthCenterData
|
|
67
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Track 常量定义
|
|
3
|
-
* 集中维护埋点内部所需的可配置默认值、端点等信息。
|
|
4
|
-
*/
|
|
5
|
-
export declare const DEFAULT_FLUSH_THRESHOLD = 5;
|
|
6
|
-
export declare const DEFAULT_MAX_WAIT_MS = 5000;
|
|
7
|
-
export declare const TRACK_ENDPOINT = "/pousheng-guard/api/track";
|
|
8
|
-
export declare const APP_VERSION_ENDPOINT = "/pousheng-guard/api/apps/version/update";
|
|
9
|
-
export declare const ERROR_TRACK_ENDPOINT = "/pousheng-guard/api/track/error";
|
|
10
|
-
export declare const ERROR_REPLAY_ENDPOINT = "/pousheng-guard/api/track/error-replay/";
|
|
11
|
-
export declare const DEFAULT_REPLAY_CHECKOUT_NMS: number;
|
|
12
|
-
export declare const DEFAULT_REPLAY_MAX_EVENTS = 1000;
|
|
13
|
-
export declare const DEFAULT_REPLAY_MAX_BYTES: number;
|
|
14
|
-
export declare const DEFAULT_ERROR_THROTTLE_MS = 3000;
|
|
15
|
-
export declare const DEV_DOMAIN = "//track-t.yysports.com";
|
|
16
|
-
export declare const TEST_DOMAIN = "//track-t.yysports.com";
|
|
17
|
-
export declare const PROD_DOMAIN = "//track.yysports.com";
|
|
@@ -1,65 +0,0 @@
|
|
|
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/core/constants.ts
|
|
20
|
-
var constants_exports = {};
|
|
21
|
-
__export(constants_exports, {
|
|
22
|
-
APP_VERSION_ENDPOINT: () => APP_VERSION_ENDPOINT,
|
|
23
|
-
DEFAULT_ERROR_THROTTLE_MS: () => DEFAULT_ERROR_THROTTLE_MS,
|
|
24
|
-
DEFAULT_FLUSH_THRESHOLD: () => DEFAULT_FLUSH_THRESHOLD,
|
|
25
|
-
DEFAULT_MAX_WAIT_MS: () => DEFAULT_MAX_WAIT_MS,
|
|
26
|
-
DEFAULT_REPLAY_CHECKOUT_NMS: () => DEFAULT_REPLAY_CHECKOUT_NMS,
|
|
27
|
-
DEFAULT_REPLAY_MAX_BYTES: () => DEFAULT_REPLAY_MAX_BYTES,
|
|
28
|
-
DEFAULT_REPLAY_MAX_EVENTS: () => DEFAULT_REPLAY_MAX_EVENTS,
|
|
29
|
-
DEV_DOMAIN: () => DEV_DOMAIN,
|
|
30
|
-
ERROR_REPLAY_ENDPOINT: () => ERROR_REPLAY_ENDPOINT,
|
|
31
|
-
ERROR_TRACK_ENDPOINT: () => ERROR_TRACK_ENDPOINT,
|
|
32
|
-
PROD_DOMAIN: () => PROD_DOMAIN,
|
|
33
|
-
TEST_DOMAIN: () => TEST_DOMAIN,
|
|
34
|
-
TRACK_ENDPOINT: () => TRACK_ENDPOINT
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(constants_exports);
|
|
37
|
-
var DEFAULT_FLUSH_THRESHOLD = 5;
|
|
38
|
-
var DEFAULT_MAX_WAIT_MS = 5e3;
|
|
39
|
-
var TRACK_ENDPOINT = "/pousheng-guard/api/track";
|
|
40
|
-
var APP_VERSION_ENDPOINT = "/pousheng-guard/api/apps/version/update";
|
|
41
|
-
var ERROR_TRACK_ENDPOINT = "/pousheng-guard/api/track/error";
|
|
42
|
-
var ERROR_REPLAY_ENDPOINT = "/pousheng-guard/api/track/error-replay/";
|
|
43
|
-
var DEFAULT_REPLAY_CHECKOUT_NMS = 5 * 60 * 1e3;
|
|
44
|
-
var DEFAULT_REPLAY_MAX_EVENTS = 1e3;
|
|
45
|
-
var DEFAULT_REPLAY_MAX_BYTES = 1024 * 1024;
|
|
46
|
-
var DEFAULT_ERROR_THROTTLE_MS = 3e3;
|
|
47
|
-
var DEV_DOMAIN = "//track-t.yysports.com";
|
|
48
|
-
var TEST_DOMAIN = "//track-t.yysports.com";
|
|
49
|
-
var PROD_DOMAIN = "//track.yysports.com";
|
|
50
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
-
0 && (module.exports = {
|
|
52
|
-
APP_VERSION_ENDPOINT,
|
|
53
|
-
DEFAULT_ERROR_THROTTLE_MS,
|
|
54
|
-
DEFAULT_FLUSH_THRESHOLD,
|
|
55
|
-
DEFAULT_MAX_WAIT_MS,
|
|
56
|
-
DEFAULT_REPLAY_CHECKOUT_NMS,
|
|
57
|
-
DEFAULT_REPLAY_MAX_BYTES,
|
|
58
|
-
DEFAULT_REPLAY_MAX_EVENTS,
|
|
59
|
-
DEV_DOMAIN,
|
|
60
|
-
ERROR_REPLAY_ENDPOINT,
|
|
61
|
-
ERROR_TRACK_ENDPOINT,
|
|
62
|
-
PROD_DOMAIN,
|
|
63
|
-
TEST_DOMAIN,
|
|
64
|
-
TRACK_ENDPOINT
|
|
65
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 事件包构建与采样控制
|
|
3
|
-
*/
|
|
4
|
-
import { TrackConfig, TrackEventEnvelope, TrackType, UserProfile } from '../../interfaces/track.interface';
|
|
5
|
-
/**
|
|
6
|
-
* 构建事件信封(统一字段拼装)
|
|
7
|
-
* - systemProfile + user + type + appId + 序列化后的log
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildEnvelope(config: TrackConfig, user: UserProfile, type: TrackType, log: any): TrackEventEnvelope;
|
|
@@ -1,61 +0,0 @@
|
|
|
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/core/envelope.ts
|
|
20
|
-
var envelope_exports = {};
|
|
21
|
-
__export(envelope_exports, {
|
|
22
|
-
buildEnvelope: () => buildEnvelope
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(envelope_exports);
|
|
25
|
-
var import_system = require("./system");
|
|
26
|
-
function buildEnvelope(config, user, type, log) {
|
|
27
|
-
const trackData = {
|
|
28
|
-
...(0, import_system.getSystemProfile)(),
|
|
29
|
-
...user,
|
|
30
|
-
type,
|
|
31
|
-
appId: config.appId
|
|
32
|
-
};
|
|
33
|
-
if (typeof log === "string") {
|
|
34
|
-
trackData.log = log;
|
|
35
|
-
}
|
|
36
|
-
if (typeof log === "object") {
|
|
37
|
-
let copyLog = {};
|
|
38
|
-
switch (type) {
|
|
39
|
-
case "visit":
|
|
40
|
-
case "event":
|
|
41
|
-
const { module: module2, content, ...rest } = log;
|
|
42
|
-
copyLog = rest;
|
|
43
|
-
Object.assign(trackData, { module: module2, content });
|
|
44
|
-
break;
|
|
45
|
-
case "error":
|
|
46
|
-
Object.assign(trackData, { log: JSON.stringify(log) });
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
copyLog = log;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
if (Object.keys(copyLog).length > 0) {
|
|
53
|
-
trackData.log = JSON.stringify(copyLog);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return trackData;
|
|
57
|
-
}
|
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
-
0 && (module.exports = {
|
|
60
|
-
buildEnvelope
|
|
61
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Barrel exports for Track core modules.
|
|
3
|
-
*
|
|
4
|
-
* Purpose:
|
|
5
|
-
* - Provide a single import surface for core primitives (TrackerInstance, queue,
|
|
6
|
-
* replay, transport, lifecycle, etc.).
|
|
7
|
-
* - Make future reorganization easier without touching external callers.
|
|
8
|
-
*
|
|
9
|
-
* Note: this file only re-exports existing modules and does not change runtime
|
|
10
|
-
* behavior. Existing import paths that reference specific files (e.g.
|
|
11
|
-
* './core/instance') will continue to work.
|
|
12
|
-
*/
|
|
13
|
-
export { TrackerInstance } from './instance';
|
|
14
|
-
export { TrackQueue } from './queue';
|
|
15
|
-
export { ReplayManager } from './replay';
|
|
16
|
-
export { LifecycleManager } from './lifecycle';
|
|
17
|
-
export * from './transport';
|
|
18
|
-
export * from './auth';
|
|
19
|
-
export * from './envelope';
|
|
20
|
-
export * from './profile';
|
|
21
|
-
export * from './router';
|
|
22
|
-
export * from './constants';
|
package/lib/Track/core/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/Track/core/index.ts
|
|
21
|
-
var core_exports = {};
|
|
22
|
-
__export(core_exports, {
|
|
23
|
-
LifecycleManager: () => import_lifecycle.LifecycleManager,
|
|
24
|
-
ReplayManager: () => import_replay.ReplayManager,
|
|
25
|
-
TrackQueue: () => import_queue.TrackQueue,
|
|
26
|
-
TrackerInstance: () => import_instance.TrackerInstance
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(core_exports);
|
|
29
|
-
var import_instance = require("./instance");
|
|
30
|
-
var import_queue = require("./queue");
|
|
31
|
-
var import_replay = require("./replay");
|
|
32
|
-
var import_lifecycle = require("./lifecycle");
|
|
33
|
-
__reExport(core_exports, require("./transport"), module.exports);
|
|
34
|
-
__reExport(core_exports, require("./auth"), module.exports);
|
|
35
|
-
__reExport(core_exports, require("./envelope"), module.exports);
|
|
36
|
-
__reExport(core_exports, require("./profile"), module.exports);
|
|
37
|
-
__reExport(core_exports, require("./router"), module.exports);
|
|
38
|
-
__reExport(core_exports, require("./constants"), module.exports);
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
LifecycleManager,
|
|
42
|
-
ReplayManager,
|
|
43
|
-
TrackQueue,
|
|
44
|
-
TrackerInstance,
|
|
45
|
-
...require("./transport"),
|
|
46
|
-
...require("./auth"),
|
|
47
|
-
...require("./envelope"),
|
|
48
|
-
...require("./profile"),
|
|
49
|
-
...require("./router"),
|
|
50
|
-
...require("./constants")
|
|
51
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TrackerInstance - 多实例核心组合:权限初始化 + 队列 + 采样 + 生命周期
|
|
3
|
-
*/
|
|
4
|
-
import { AuthCenterUserProfile, CustomizeProfile, ErrorProfile, TrackConfig, UserProfile } from '../../interfaces/track.interface';
|
|
5
|
-
export declare class TrackerInstance {
|
|
6
|
-
private config;
|
|
7
|
-
private userProfile;
|
|
8
|
-
private authCenterUserProfile;
|
|
9
|
-
private routesMap;
|
|
10
|
-
private authMap;
|
|
11
|
-
private queue;
|
|
12
|
-
private internal;
|
|
13
|
-
private replay?;
|
|
14
|
-
private lifecycle?;
|
|
15
|
-
/**
|
|
16
|
-
* 构造函数:合并配置 + 参数校验
|
|
17
|
-
*/
|
|
18
|
-
constructor(cfg: TrackConfig);
|
|
19
|
-
/**
|
|
20
|
-
* 初始化:
|
|
21
|
-
* 1. 拉取权限/菜单/数据域信息
|
|
22
|
-
* 2. 合并用户画像(优先 AuthCenter,再叠加外部传入)
|
|
23
|
-
* 3. 挂载生命周期监听(visibilitychange / error)
|
|
24
|
-
* 4. 上报版本信息 & 启动定时 flush
|
|
25
|
-
*/
|
|
26
|
-
init(): Promise<AuthCenterUserProfile>;
|
|
27
|
-
/**
|
|
28
|
-
* Flush:
|
|
29
|
-
* - 取出队列中全部事件
|
|
30
|
-
*/
|
|
31
|
-
flush(): void;
|
|
32
|
-
/**
|
|
33
|
-
* 销毁:清理定时器 & 事件监听,并 flush 剩余数据
|
|
34
|
-
*/
|
|
35
|
-
destroy(): void;
|
|
36
|
-
/**
|
|
37
|
-
* 事件日志:
|
|
38
|
-
* - 支持传入字符串(自动映射为 authMap 描述)或对象
|
|
39
|
-
* - 自动补全 module(基于当前路由)
|
|
40
|
-
*/
|
|
41
|
-
eventLog(eventLog: CustomizeProfile | string): void;
|
|
42
|
-
/**
|
|
43
|
-
* 访问日志:
|
|
44
|
-
* - 默认按当前路由模块组装文案
|
|
45
|
-
* - 若路由标记 isRedirect 则跳过(避免中转页统计)
|
|
46
|
-
*/
|
|
47
|
-
visitLog(visitLog?: CustomizeProfile): void;
|
|
48
|
-
/**
|
|
49
|
-
* 错误日志:force = true 不受采样率影响
|
|
50
|
-
*/
|
|
51
|
-
errorLog(error: ErrorProfile): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* API 日志:直接即时上报(不进入公共队列)
|
|
54
|
-
*/
|
|
55
|
-
apiLog(apiLog: any): void;
|
|
56
|
-
/**
|
|
57
|
-
* 动态更新用户画像(不会重置已有字段)
|
|
58
|
-
*/
|
|
59
|
-
setUserProfile(patch: Partial<UserProfile>): void;
|
|
60
|
-
/** 获取当前实例配置副本(避免外部直接修改内部对象) */
|
|
61
|
-
getConfig(): {
|
|
62
|
-
appId: string;
|
|
63
|
-
userProfile?: UserProfile | undefined;
|
|
64
|
-
base?: string | undefined;
|
|
65
|
-
getAuth?: (() => Promise<any>) | undefined;
|
|
66
|
-
menuBuild?: (() => Promise<import("../../interfaces/track.interface").AuthMenuItemType[]>) | undefined;
|
|
67
|
-
menuNameMap?: import("../../interfaces/track.interface").MenuNameMapType | undefined;
|
|
68
|
-
routes?: import("../../interfaces/track.interface").RouteType[] | undefined;
|
|
69
|
-
getDataScopeZonePermissions?: (() => Promise<{
|
|
70
|
-
zoneId: number;
|
|
71
|
-
zoneName: string;
|
|
72
|
-
}[]>) | undefined;
|
|
73
|
-
enableReplay?: boolean | undefined;
|
|
74
|
-
env: "test" | "dev" | "prod";
|
|
75
|
-
};
|
|
76
|
-
/** 配置校验:缺少关键字段直接抛错 */
|
|
77
|
-
private validate;
|
|
78
|
-
/**
|
|
79
|
-
* 合并用户画像:
|
|
80
|
-
* - 若权限中心未返回 userName,则只使用外部提供
|
|
81
|
-
* - 否则使用 AuthCenter 信息并叠加外部 patch
|
|
82
|
-
*/
|
|
83
|
-
private mergeUserProfile;
|
|
84
|
-
/**
|
|
85
|
-
* 入队封装:
|
|
86
|
-
* - 全量采样
|
|
87
|
-
* - 生成 envelope
|
|
88
|
-
* - 触发阈值自动 flush
|
|
89
|
-
*/
|
|
90
|
-
private enqueue;
|
|
91
|
-
/** 获取当前路径(剥离 base 前缀) */
|
|
92
|
-
private getFormatPath;
|
|
93
|
-
/** 获取当前页面的模块层级(由 routesMap 提供) */
|
|
94
|
-
private getPageModules;
|
|
95
|
-
/** 挂载浏览器事件监听 */
|
|
96
|
-
private mountLifecycle;
|
|
97
|
-
/** 启动/重置周期性 flush 计时器 */
|
|
98
|
-
private scheduleFlushTimer;
|
|
99
|
-
/** 校验 module 是否有效(非空且非纯空白) */
|
|
100
|
-
private isValidModule;
|
|
101
|
-
/** 获取过滤后的模块层级(去除空项和空白) */
|
|
102
|
-
private getFilteredModules;
|
|
103
|
-
/** 若日志缺少 module,则尝试用路由模块补齐;返回是否有效 */
|
|
104
|
-
private fillModuleIfMissing;
|
|
105
|
-
private maybeStartReplay;
|
|
106
|
-
private stopReplay;
|
|
107
|
-
private buildReplayAttachment;
|
|
108
|
-
}
|