@yysports/tools 2.0.2 → 2.2.1

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.
Files changed (92) hide show
  1. package/dist/Track/Beacon.d.ts +6 -0
  2. package/dist/Track/Beacon.js +58 -0
  3. package/dist/Track/Config.d.ts +11 -0
  4. package/dist/Track/Config.js +34 -0
  5. package/dist/Track/Listener.d.ts +5 -0
  6. package/dist/Track/Listener.js +46 -0
  7. package/dist/Track/Log.d.ts +8 -0
  8. package/dist/Track/Log.js +100 -0
  9. package/dist/Track/Replay.d.ts +6 -0
  10. package/dist/Track/Replay.js +77 -0
  11. package/dist/Track/System.d.ts +5 -0
  12. package/dist/Track/System.js +24 -0
  13. package/dist/Track/User.d.ts +6 -0
  14. package/dist/Track/User.js +29 -0
  15. package/dist/Track/index.d.ts +15 -17
  16. package/dist/Track/index.js +56 -67
  17. package/dist/Utils/auth.d.ts +9 -2
  18. package/dist/Utils/auth.js +80 -20
  19. package/dist/Utils/route.d.ts +11 -3
  20. package/dist/Utils/route.js +49 -56
  21. package/dist/Utils/url.js +3 -13
  22. package/dist/interfaces/track.interface.d.ts +2 -80
  23. package/dist/interfaces/track.interface.js +1 -5
  24. package/lib/Track/Beacon.d.ts +6 -0
  25. package/lib/Track/Beacon.js +73 -0
  26. package/lib/Track/Config.d.ts +11 -0
  27. package/lib/Track/{core/queue.js → Config.js} +23 -27
  28. package/lib/Track/Listener.d.ts +5 -0
  29. package/lib/Track/Listener.js +62 -0
  30. package/lib/Track/Log.d.ts +8 -0
  31. package/lib/Track/Log.js +95 -0
  32. package/lib/Track/Replay.d.ts +6 -0
  33. package/lib/Track/Replay.js +79 -0
  34. package/lib/Track/System.d.ts +5 -0
  35. package/lib/Track/{core/router.js → System.js} +18 -20
  36. package/lib/Track/User.d.ts +6 -0
  37. package/lib/Track/User.js +40 -0
  38. package/lib/Track/index.d.ts +15 -17
  39. package/lib/Track/index.js +45 -39
  40. package/lib/Utils/auth.d.ts +9 -2
  41. package/lib/Utils/auth.js +52 -17
  42. package/lib/Utils/route.d.ts +11 -3
  43. package/lib/Utils/route.js +34 -49
  44. package/lib/Utils/url.js +3 -3
  45. package/lib/interfaces/track.interface.d.ts +2 -80
  46. package/package.json +13 -13
  47. package/dist/Track/core/auth.d.ts +0 -16
  48. package/dist/Track/core/auth.js +0 -83
  49. package/dist/Track/core/constants.d.ts +0 -17
  50. package/dist/Track/core/constants.js +0 -34
  51. package/dist/Track/core/envelope.d.ts +0 -9
  52. package/dist/Track/core/envelope.js +0 -54
  53. package/dist/Track/core/index.d.ts +0 -22
  54. package/dist/Track/core/index.js +0 -23
  55. package/dist/Track/core/instance.d.ts +0 -108
  56. package/dist/Track/core/instance.js +0 -375
  57. package/dist/Track/core/lifecycle.d.ts +0 -18
  58. package/dist/Track/core/lifecycle.js +0 -59
  59. package/dist/Track/core/profile.d.ts +0 -5
  60. package/dist/Track/core/profile.js +0 -30
  61. package/dist/Track/core/queue.d.ts +0 -13
  62. package/dist/Track/core/queue.js +0 -36
  63. package/dist/Track/core/replay.d.ts +0 -17
  64. package/dist/Track/core/replay.js +0 -117
  65. package/dist/Track/core/router.d.ts +0 -6
  66. package/dist/Track/core/router.js +0 -15
  67. package/dist/Track/core/system.d.ts +0 -14
  68. package/dist/Track/core/system.js +0 -36
  69. package/dist/Track/core/transport.d.ts +0 -18
  70. package/dist/Track/core/transport.js +0 -165
  71. package/lib/Track/core/auth.d.ts +0 -16
  72. package/lib/Track/core/auth.js +0 -67
  73. package/lib/Track/core/constants.d.ts +0 -17
  74. package/lib/Track/core/constants.js +0 -65
  75. package/lib/Track/core/envelope.d.ts +0 -9
  76. package/lib/Track/core/envelope.js +0 -61
  77. package/lib/Track/core/index.d.ts +0 -22
  78. package/lib/Track/core/index.js +0 -51
  79. package/lib/Track/core/instance.d.ts +0 -108
  80. package/lib/Track/core/instance.js +0 -266
  81. package/lib/Track/core/lifecycle.d.ts +0 -18
  82. package/lib/Track/core/lifecycle.js +0 -74
  83. package/lib/Track/core/profile.d.ts +0 -5
  84. package/lib/Track/core/profile.js +0 -47
  85. package/lib/Track/core/queue.d.ts +0 -13
  86. package/lib/Track/core/replay.d.ts +0 -17
  87. package/lib/Track/core/replay.js +0 -131
  88. package/lib/Track/core/router.d.ts +0 -6
  89. package/lib/Track/core/system.d.ts +0 -14
  90. package/lib/Track/core/system.js +0 -53
  91. package/lib/Track/core/transport.d.ts +0 -18
  92. package/lib/Track/core/transport.js +0 -128
@@ -1,39 +1,3 @@
1
- export type LocalRouteItemType = {
2
- access?: string;
3
- name?: string;
4
- parentPath?: string;
5
- path?: string;
6
- routes?: LocalRouteItemType[];
7
- };
8
- export type AuthMenuItemType = {
9
- logAction: any;
10
- name: string;
11
- meta?: {
12
- title: string;
13
- };
14
- permission?: string;
15
- children?: AuthMenuItemType[];
16
- path?: string;
17
- builtIn?: boolean;
18
- };
19
- export type MenuNameMapType = {
20
- [key: string]: string;
21
- };
22
- export interface TrackConfig {
23
- appId: string;
24
- userProfile?: UserProfile;
25
- base?: string;
26
- getAuth?: () => Promise<any>;
27
- menuBuild?: () => Promise<AuthMenuItemType[]>;
28
- menuNameMap?: MenuNameMapType;
29
- routes?: RouteType[];
30
- getDataScopeZonePermissions?: () => Promise<{
31
- zoneId: number;
32
- zoneName: string;
33
- }[]>;
34
- enableReplay?: boolean;
35
- env: 'dev' | 'test' | 'prod';
36
- }
37
1
  export declare enum TrackTypeEnum {
38
2
  error = "\u9519\u8BEF\u4FE1\u606F",
39
3
  visit = "\u9875\u9762\u8BBF\u95EE",
@@ -56,7 +20,7 @@ export interface AuthCenterUserProfile {
56
20
  department?: string;
57
21
  email?: string;
58
22
  gender?: string;
59
- phone?: string;
23
+ phone: string;
60
24
  roles?: string[];
61
25
  accessPage?: string[];
62
26
  orgCode: string;
@@ -75,6 +39,7 @@ export interface AuthCenterUserProfile {
75
39
  }[];
76
40
  }[];
77
41
  };
42
+ authLogMap?: Record<string, string>;
78
43
  }
79
44
  export interface SystemProfile {
80
45
  IMEI: string;
@@ -83,46 +48,3 @@ export interface SystemProfile {
83
48
  href: string;
84
49
  systemTime: Date;
85
50
  }
86
- export interface CustomizeProfile {
87
- content: string;
88
- module: string;
89
- }
90
- export interface ErrorProfile {
91
- fileName: string;
92
- message: string;
93
- }
94
- export type RouteType = {
95
- path?: string;
96
- redirect?: string;
97
- name?: string;
98
- access?: string;
99
- routes?: RouteType[];
100
- [key: string]: any;
101
- };
102
- export type RouteMapValueType = {
103
- access: string[];
104
- name: string[];
105
- module: string[];
106
- isRedirect: boolean;
107
- };
108
- export type AuthDataType = {
109
- children: AuthDataType[];
110
- name?: string;
111
- logAction?: string;
112
- permission?: string;
113
- meta?: {
114
- title: string;
115
- };
116
- };
117
- export interface TrackEventEnvelope extends SystemProfile, UserProfile, CustomizeProfile {
118
- appId: string;
119
- type: TrackType;
120
- /**
121
- * V2.0.0 版本后为非必填字段,如需传入请使用JSON.stringify格式化为字符串
122
- */
123
- log?: string;
124
- /**
125
- * V2.0.0 版本后为非必填字段,错误类型时携带回放片段
126
- */
127
- replay?: string;
128
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yysports/tools",
3
- "version": "2.0.2",
3
+ "version": "2.2.1",
4
4
  "description": "常用工具函数库",
5
5
  "homepage": "https://git.pousheng.com/sport-service-department/pousheng-guard/yysports_tools#readme",
6
6
  "bugs": {
@@ -30,7 +30,7 @@
30
30
  "docs:build": "dumi build",
31
31
  "doctor": "father doctor",
32
32
  "lint": "npm run lint:es && npm run lint:css",
33
- "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
33
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\" --allow-empty-input",
34
34
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
35
35
  "prepare": "husky install && dumi setup",
36
36
  "prepublishOnly": "father doctor && npm run build",
@@ -60,30 +60,30 @@
60
60
  ]
61
61
  },
62
62
  "dependencies": {
63
- "@babel/runtime": "^7.28.3",
63
+ "@babel/runtime": "^7.28.4",
64
64
  "@rrweb/record": "2.0.0-alpha.18",
65
65
  "@rrweb/rrweb-plugin-console-record": "2.0.0-alpha.18",
66
66
  "image-conversion": "^2.1.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@ant-design/pro-components": "^2.8.10",
70
- "@commitlint/cli": "^19.8.1",
71
- "@commitlint/config-conventional": "^19.8.1",
72
- "@types/react": "^18.3.24",
70
+ "@commitlint/cli": "^20.1.0",
71
+ "@commitlint/config-conventional": "^20.0.0",
72
+ "@types/react": "^18.3.26",
73
73
  "@types/react-dom": "^18.3.7",
74
- "@umijs/lint": "^4.4.12",
75
- "antd": "^5.27.1",
74
+ "@umijs/lint": "^4.5.3",
75
+ "antd": "^5.28.1",
76
76
  "dumi": "^2.4.21",
77
- "eslint": "^9.34.0",
78
- "father": "^4.6.3",
77
+ "eslint": "^8.57.1",
78
+ "father": "^4.6.7",
79
79
  "husky": "^9.1.7",
80
- "lint-staged": "^16.1.5",
80
+ "lint-staged": "^16.2.6",
81
81
  "prettier": "^3.6.2",
82
- "prettier-plugin-organize-imports": "^4.2.0",
82
+ "prettier-plugin-organize-imports": "^4.3.0",
83
83
  "prettier-plugin-packagejson": "^2.5.19",
84
84
  "react": "^18.3.1",
85
85
  "react-dom": "^18.3.1",
86
- "stylelint": "^16.23.1"
86
+ "stylelint": "^16.25.0"
87
87
  },
88
88
  "publishConfig": {
89
89
  "access": "public"
@@ -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>;
@@ -1,83 +0,0 @@
1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
- var _excluded = ["roles"];
8
- /**
9
- * 权限中心 / 菜单 / 数据权限初始化逻辑
10
- */
11
- import { getAuthMapByAuthCenter, getRoutesMap } from "../../Utils";
12
- /**
13
- * 初始化权限 / 菜单 / 路由配置信息
14
- * 1. 并行请求:用户权限(getAuth) / 菜单(menuBuild) / 数据域权限(getDataScopeZonePermissions)
15
- * 2. 生成 routesMap 以及可访问页面 accessPage
16
- * 3. 生成 authMap(按钮/操作编码 -> 中文描述)
17
- * 4. 组织返回 AuthCenterUserProfile
18
- * @param config TrackConfig
19
- * @returns {AuthInitResult}
20
- */
21
- export function initAuthCenterData(_x) {
22
- return _initAuthCenterData.apply(this, arguments);
23
- }
24
- function _initAuthCenterData() {
25
- _initAuthCenterData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config) {
26
- var getAuth, menuBuild, getDataScopeZonePermissions, menuNameMap, routes, tasks, _yield$Promise$all, _yield$Promise$all2, _yield$Promise$all2$, authInfo, _yield$Promise$all2$2, menuData, dataScopeZonePermissions, _ref, _ref$user, user, _ref$roles, roles, _ref2, dataScopeRoles, restUser, isAdmin, accessPage, routesMap, authMap, profile;
27
- return _regeneratorRuntime().wrap(function _callee$(_context) {
28
- while (1) switch (_context.prev = _context.next) {
29
- case 0:
30
- getAuth = config.getAuth, menuBuild = config.menuBuild, getDataScopeZonePermissions = config.getDataScopeZonePermissions, menuNameMap = config.menuNameMap, routes = config.routes; // 并行触发三个可选任务(若未提供则使用 resolved Promise)
31
- tasks = [getAuth === null || getAuth === void 0 ? void 0 : getAuth(), menuBuild === null || menuBuild === void 0 ? void 0 : menuBuild(), getDataScopeZonePermissions === null || getDataScopeZonePermissions === void 0 ? void 0 : getDataScopeZonePermissions()];
32
- _context.next = 4;
33
- return Promise.all(tasks.map(function (t) {
34
- return t !== null && t !== void 0 ? t : Promise.resolve();
35
- }));
36
- case 4:
37
- _yield$Promise$all = _context.sent;
38
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
39
- _yield$Promise$all2$ = _yield$Promise$all2[0];
40
- authInfo = _yield$Promise$all2$ === void 0 ? {} : _yield$Promise$all2$;
41
- _yield$Promise$all2$2 = _yield$Promise$all2[1];
42
- menuData = _yield$Promise$all2$2 === void 0 ? [] : _yield$Promise$all2$2;
43
- dataScopeZonePermissions = _yield$Promise$all2[2];
44
- _ref = authInfo || {}, _ref$user = _ref.user, user = _ref$user === void 0 ? {} : _ref$user, _ref$roles = _ref.roles, roles = _ref$roles === void 0 ? [] : _ref$roles;
45
- _ref2 = user, dataScopeRoles = _ref2.roles, restUser = _objectWithoutProperties(_ref2, _excluded);
46
- isAdmin = roles.includes('admin');
47
- accessPage = [];
48
- routesMap = new Map();
49
- if (routes) {
50
- routesMap = getRoutesMap(routes, menuNameMap);
51
- routesMap.forEach(function (_ref3) {
52
- var access = _ref3.access;
53
- if (!access.length) return;
54
- if (isAdmin) accessPage.push.apply(accessPage, _toConsumableArray(access));else access.forEach(function (k) {
55
- return roles.includes(k) && accessPage.push(k);
56
- });
57
- });
58
- }
59
- authMap = getAuthMapByAuthCenter(menuData);
60
- profile = _objectSpread(_objectSpread({}, restUser), {}, {
61
- dataScopeRoles: dataScopeRoles,
62
- roles: roles,
63
- accessPage: accessPage,
64
- isAdmin: isAdmin
65
- });
66
- if (dataScopeZonePermissions)
67
- // 合并数据域区权限结构
68
- Object.assign(profile, {
69
- dataScopeZonePermissions: dataScopeZonePermissions
70
- });
71
- return _context.abrupt("return", {
72
- authCenterUserProfile: profile,
73
- routesMap: routesMap,
74
- authMap: authMap
75
- });
76
- case 21:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee);
81
- }));
82
- return _initAuthCenterData.apply(this, arguments);
83
- }
@@ -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,34 +0,0 @@
1
- /**
2
- * Track 常量定义
3
- * 集中维护埋点内部所需的可配置默认值、端点等信息。
4
- */
5
-
6
- // 队列长度达到该阈值触发自动 flush
7
- export var DEFAULT_FLUSH_THRESHOLD = 5;
8
-
9
- // 最大等待时间(毫秒)默认值,用于定时 flush
10
- export var DEFAULT_MAX_WAIT_MS = 5000;
11
-
12
- // 后端统一接口路径片段
13
- export var TRACK_ENDPOINT = '/pousheng-guard/api/track';
14
- export var APP_VERSION_ENDPOINT = '/pousheng-guard/api/apps/version/update';
15
- export var ERROR_TRACK_ENDPOINT = '/pousheng-guard/api/track/error';
16
- export var ERROR_REPLAY_ENDPOINT = '/pousheng-guard/api/track/error-replay/';
17
-
18
- // rrweb 默认参数
19
- export var DEFAULT_REPLAY_CHECKOUT_NMS = 5 * 60 * 1000; // 5min
20
- export var DEFAULT_REPLAY_MAX_EVENTS = 1000;
21
- // 默认最大携带体积:1MB(避免截断 FullSnapshot 导致无法回放)
22
- export var DEFAULT_REPLAY_MAX_BYTES = 1024 * 1024; // 1MB
23
-
24
- // 错误节流默认窗口(毫秒)
25
- export var DEFAULT_ERROR_THROTTLE_MS = 3000;
26
-
27
- // 开发环境域名
28
- export var DEV_DOMAIN = '//track-t.yysports.com';
29
-
30
- // 测试环境域名
31
- export var TEST_DOMAIN = '//track-t.yysports.com';
32
-
33
- // 生产环境域名
34
- export var PROD_DOMAIN = '//track.yysports.com';
@@ -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,54 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _typeof from "@babel/runtime/helpers/esm/typeof";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
- var _excluded = ["module", "content"];
5
- /**
6
- * 事件包构建与采样控制
7
- */
8
-
9
- import { getSystemProfile } from "./system";
10
-
11
- // 全量采样:不再基于采样率过滤事件
12
-
13
- /**
14
- * 构建事件信封(统一字段拼装)
15
- * - systemProfile + user + type + appId + 序列化后的log
16
- */
17
- export function buildEnvelope(config, user, type, log) {
18
- var trackData = _objectSpread(_objectSpread(_objectSpread({}, getSystemProfile()), user), {}, {
19
- type: type,
20
- appId: config.appId
21
- });
22
- if (typeof log === 'string') {
23
- trackData.log = log; // 字符串直接赋值
24
- }
25
- if (_typeof(log) === 'object') {
26
- var copyLog = {};
27
- switch (type) {
28
- case 'visit':
29
- case 'event':
30
- var module = log.module,
31
- content = log.content,
32
- rest = _objectWithoutProperties(log, _excluded);
33
- copyLog = rest; // 解构后移除 module 字段
34
- Object.assign(trackData, {
35
- module: module,
36
- content: content
37
- });
38
- break;
39
- case 'error':
40
- Object.assign(trackData, {
41
- log: JSON.stringify(log)
42
- });
43
- break;
44
- default:
45
- // 对于其他类型,保持 log 不变
46
- copyLog = log;
47
- break;
48
- }
49
- if (Object.keys(copyLog).length > 0) {
50
- trackData.log = JSON.stringify(copyLog);
51
- }
52
- }
53
- return trackData;
54
- }
@@ -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';
@@ -1,23 +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
-
14
- export { TrackerInstance } from "./instance";
15
- export { TrackQueue } from "./queue";
16
- export { ReplayManager } from "./replay";
17
- export { LifecycleManager } from "./lifecycle";
18
- export * from "./transport";
19
- export * from "./auth";
20
- export * from "./envelope";
21
- export * from "./profile";
22
- export * from "./router";
23
- export * from "./constants";
@@ -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
- }