@antglobal/rlog-sdk 0.0.1755855517-dev.10 → 0.0.1755855517-dev.11
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/README.md +48 -8
- package/dist/esm/index.d.ts +10 -46
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +27 -70
- package/dist/esm/lib/api.d.ts.map +1 -1
- package/dist/esm/lib/api.js +19 -13
- package/dist/esm/lib/config.d.ts +1 -8
- package/dist/esm/lib/config.d.ts.map +1 -1
- package/dist/esm/lib/config.js +18 -18
- package/dist/esm/lib/error-trigger.d.ts +1 -3
- package/dist/esm/lib/error-trigger.d.ts.map +1 -1
- package/dist/esm/lib/error-trigger.js +1 -8
- package/dist/esm/lib/error.d.ts.map +1 -1
- package/dist/esm/lib/error.js +8 -40
- package/dist/esm/lib/init.d.ts.map +1 -1
- package/dist/esm/lib/init.js +4 -12
- package/dist/esm/lib/net.d.ts +5 -0
- package/dist/esm/lib/net.d.ts.map +1 -1
- package/dist/esm/lib/net.js +8 -0
- package/dist/esm/lib/router-monitor.d.ts.map +1 -1
- package/dist/esm/lib/router-monitor.js +10 -36
- package/dist/esm/lib/rrweb.d.ts.map +1 -1
- package/dist/esm/lib/rrweb.js +8 -8
- package/dist/esm/lib/uploader.d.ts.map +1 -1
- package/dist/esm/lib/uploader.js +27 -19
- package/dist/lib/index.d.ts +10 -46
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +9 -58
- package/dist/lib/lib/api.d.ts.map +1 -1
- package/dist/lib/lib/api.js +19 -13
- package/dist/lib/lib/config.d.ts +1 -8
- package/dist/lib/lib/config.d.ts.map +1 -1
- package/dist/lib/lib/config.js +18 -18
- package/dist/lib/lib/error-trigger.d.ts +1 -3
- package/dist/lib/lib/error-trigger.d.ts.map +1 -1
- package/dist/lib/lib/error-trigger.js +1 -8
- package/dist/lib/lib/error.d.ts.map +1 -1
- package/dist/lib/lib/error.js +8 -40
- package/dist/lib/lib/init.d.ts.map +1 -1
- package/dist/lib/lib/init.js +3 -11
- package/dist/lib/lib/net.d.ts +5 -0
- package/dist/lib/lib/net.d.ts.map +1 -1
- package/dist/lib/lib/net.js +9 -0
- package/dist/lib/lib/router-monitor.d.ts.map +1 -1
- package/dist/lib/lib/router-monitor.js +10 -36
- package/dist/lib/lib/rrweb.d.ts.map +1 -1
- package/dist/lib/lib/rrweb.js +8 -8
- package/dist/lib/lib/uploader.d.ts.map +1 -1
- package/dist/lib/lib/uploader.js +27 -19
- package/dist/rlog-sdk.min.js +1 -1
- package/package.json +1 -1
package/dist/esm/lib/error.js
CHANGED
|
@@ -25,44 +25,28 @@ export function getErrorTrigger() {
|
|
|
25
25
|
|
|
26
26
|
// 错误数据发送函数 - 使用 rrweb 的自定义事件功能
|
|
27
27
|
export var sendErrorToAnalytics = function sendErrorToAnalytics(data) {
|
|
28
|
-
var config = getConfig();
|
|
29
|
-
|
|
30
|
-
// 如果错误处理未启用,直接返回
|
|
31
|
-
if (!config.error) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
28
|
// 使用 rrweb 的自定义事件功能上报错误
|
|
36
29
|
try {
|
|
37
30
|
record.addCustomEvent('custom-error-event', data);
|
|
38
31
|
} catch (error) {
|
|
39
32
|
// 降级方案:直接控制台输出
|
|
40
|
-
logger.
|
|
33
|
+
logger.error('Error captured', data);
|
|
41
34
|
}
|
|
42
35
|
|
|
43
36
|
// 错误采集模式下,通知错误触发器
|
|
37
|
+
var config = getConfig();
|
|
44
38
|
if (config.captureMode === 'error' && errorTriggerInstance) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
detail: data
|
|
52
|
-
});
|
|
53
|
-
}
|
|
39
|
+
errorTriggerInstance.onError({
|
|
40
|
+
type: data.type,
|
|
41
|
+
message: data.message || data.type,
|
|
42
|
+
timestamp: data.timestamp || Date.now(),
|
|
43
|
+
detail: data
|
|
44
|
+
});
|
|
54
45
|
}
|
|
55
46
|
};
|
|
56
47
|
|
|
57
48
|
// 初始化错误处理
|
|
58
49
|
export function initErrorHandler() {
|
|
59
|
-
var config = getConfig();
|
|
60
|
-
|
|
61
|
-
// 如果错误处理未启用,不注册任何事件监听器
|
|
62
|
-
if (!config.error) {
|
|
63
|
-
logger.log('Error handling is disabled by config');
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
50
|
logger.log('Error handling is enabled');
|
|
67
51
|
|
|
68
52
|
// JavaScript 运行时错误处理
|
|
@@ -213,20 +197,4 @@ export function cleanupErrorHandler() {
|
|
|
213
197
|
// 清空监听器数组
|
|
214
198
|
eventListeners.length = 0;
|
|
215
199
|
logger.log('Error handlers cleaned up successfully');
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* 将内部错误类型映射到 ErrorTrigger 的错误类型
|
|
220
|
-
*/
|
|
221
|
-
function mapErrorType(internalType) {
|
|
222
|
-
switch (internalType) {
|
|
223
|
-
case 'JS_ERROR':
|
|
224
|
-
return 'js';
|
|
225
|
-
case 'PROMISE_REJECTION':
|
|
226
|
-
return 'promise';
|
|
227
|
-
case 'RESOURCE_ERROR':
|
|
228
|
-
return 'resource';
|
|
229
|
-
default:
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/lib/init.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,EACrC,OAAO,GAAE,MAAuB,GAC/B,IAAI,CAiDN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/lib/init.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,EACrC,OAAO,GAAE,MAAuB,GAC/B,IAAI,CAiDN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CA0DN"}
|
package/dist/esm/lib/init.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { startRecord, stopRecord } from "./rrweb";
|
|
2
|
-
import { initConfigManager, getConfig
|
|
2
|
+
import { initConfigManager, getConfig } from "./config";
|
|
3
3
|
import { startUploadLoop, resetUploadLoop, cancelUploadLoop } from "./uploader";
|
|
4
4
|
import { initRouterMonitor, stopRouterMonitor } from "./router-monitor";
|
|
5
5
|
import { initErrorHandler, cleanupErrorHandler, setErrorTrigger } from "./error";
|
|
@@ -107,22 +107,14 @@ export function initRLog(serv, appId, cdnConfigUrl) {
|
|
|
107
107
|
}
|
|
108
108
|
var isErrorMode = config.captureMode === 'error';
|
|
109
109
|
if (isErrorMode) {
|
|
110
|
-
var _config$errorCapture, _config$errorCapture2
|
|
110
|
+
var _config$errorCapture, _config$errorCapture2;
|
|
111
111
|
// ===== 错误采集模式初始化 =====
|
|
112
112
|
logger.log('Initializing in error capture mode');
|
|
113
113
|
|
|
114
|
-
// 强制启用错误监听
|
|
115
|
-
if (!config.error) {
|
|
116
|
-
updateConfig({
|
|
117
|
-
error: true
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
114
|
// 创建 ErrorTrigger 实例(只负责状态切换)
|
|
122
115
|
errorTriggerInstance = new ErrorTrigger({
|
|
123
116
|
beforeDuration: (_config$errorCapture = config.errorCapture) === null || _config$errorCapture === void 0 ? void 0 : _config$errorCapture.beforeDuration,
|
|
124
|
-
afterDuration: (_config$errorCapture2 = config.errorCapture) === null || _config$errorCapture2 === void 0 ? void 0 : _config$errorCapture2.afterDuration
|
|
125
|
-
triggerErrors: (_config$errorCapture3 = config.errorCapture) === null || _config$errorCapture3 === void 0 ? void 0 : _config$errorCapture3.triggerErrors
|
|
117
|
+
afterDuration: (_config$errorCapture2 = config.errorCapture) === null || _config$errorCapture2 === void 0 ? void 0 : _config$errorCapture2.afterDuration
|
|
126
118
|
});
|
|
127
119
|
|
|
128
120
|
// 将 errorTrigger 注入到 error 和 net 模块
|
|
@@ -141,7 +133,7 @@ export function initRLog(serv, appId, cdnConfigUrl) {
|
|
|
141
133
|
// 初始化路由监控
|
|
142
134
|
initRouterMonitor(config.routerMonitor);
|
|
143
135
|
|
|
144
|
-
//
|
|
136
|
+
// 初始化错误处理(全量模式和错误模式都启用)
|
|
145
137
|
initErrorHandler();
|
|
146
138
|
}).catch(function (error) {
|
|
147
139
|
logger.error('Failed to initialize SDK', error);
|
package/dist/esm/lib/net.d.ts
CHANGED
|
@@ -34,4 +34,9 @@ export declare function getSdkLogEndpoint(): string | null;
|
|
|
34
34
|
* @param headers 需要添加的自定义请求头对象
|
|
35
35
|
*/
|
|
36
36
|
export declare function setCustomHeaders(headers: Record<string, string>): void;
|
|
37
|
+
/**
|
|
38
|
+
* 获取当前设置的自定义请求头
|
|
39
|
+
* @returns 当前自定义请求头的副本
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCustomHeaders(): Record<string, string>;
|
|
37
42
|
//# sourceMappingURL=net.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../../src/lib/net.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAM/C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAErE;AA2ID,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgBpD;AAUD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,MAAM,QAkPxC;AAGD,wBAAgB,UAAU,IAAI,IAAI,CAYjC;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAQrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAOrD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAsBxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAEjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEtE"}
|
|
1
|
+
{"version":3,"file":"net.d.ts","sourceRoot":"","sources":["../../../src/lib/net.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAM/C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAErE;AA2ID,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgBpD;AAUD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,MAAM,QAkPxC;AAGD,wBAAgB,UAAU,IAAI,IAAI,CAYjC;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAQrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAOrD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAsBxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAEjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEtE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzD"}
|
package/dist/esm/lib/net.js
CHANGED
|
@@ -478,4 +478,12 @@ export function getSdkLogEndpoint() {
|
|
|
478
478
|
*/
|
|
479
479
|
export function setCustomHeaders(headers) {
|
|
480
480
|
Object.assign(customHeaders, headers);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* 获取当前设置的自定义请求头
|
|
485
|
+
* @returns 当前自定义请求头的副本
|
|
486
|
+
*/
|
|
487
|
+
export function getCustomHeaders() {
|
|
488
|
+
return _objectSpread({}, customHeaders);
|
|
481
489
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-monitor.d.ts","sourceRoot":"","sources":["../../../src/lib/router-monitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,UAAU,CAAC;AAIrD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"router-monitor.d.ts","sourceRoot":"","sources":["../../../src/lib/router-monitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,UAAU,CAAC;AAIrD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAAC;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA2ID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,CAAC,GAAG,IAAI,CAuB3E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,QAkCpE;AAED;;GAEG;AACH,wBAAgB,mBAAmB;;;;EAMlC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,QAG1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,SAyBhC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -30,39 +27,18 @@ var originalReplaceState = null;
|
|
|
30
27
|
* 获取当前路由
|
|
31
28
|
*/
|
|
32
29
|
function getCurrentRoute() {
|
|
33
|
-
var _routerConfig;
|
|
34
30
|
if (typeof window === 'undefined') return '';
|
|
35
31
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// 应用自定义匹配规则
|
|
40
|
-
if ((_routerConfig = routerConfig) !== null && _routerConfig !== void 0 && _routerConfig.customMatchers) {
|
|
41
|
-
var _iterator = _createForOfIteratorHelper(routerConfig.customMatchers),
|
|
42
|
-
_step;
|
|
43
|
-
try {
|
|
44
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
|
-
var matcher = _step.value;
|
|
46
|
-
var pattern = typeof matcher.pattern === 'string' ? new RegExp(matcher.pattern) : matcher.pattern;
|
|
47
|
-
if (pattern.test(fullPath)) {
|
|
48
|
-
return matcher.name || fullPath;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} catch (err) {
|
|
52
|
-
_iterator.e(err);
|
|
53
|
-
} finally {
|
|
54
|
-
_iterator.f();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return fullPath;
|
|
32
|
+
// 使用完整路径
|
|
33
|
+
return window.location.pathname + window.location.search + window.location.hash;
|
|
58
34
|
}
|
|
59
35
|
|
|
60
36
|
/**
|
|
61
37
|
* 检查路由是否应该被忽略
|
|
62
38
|
*/
|
|
63
39
|
function shouldIgnoreRoute(route) {
|
|
64
|
-
var
|
|
65
|
-
if (!((
|
|
40
|
+
var _routerConfig;
|
|
41
|
+
if (!((_routerConfig = routerConfig) !== null && _routerConfig !== void 0 && _routerConfig.ignoreRoutes)) return false;
|
|
66
42
|
return routerConfig.ignoreRoutes.some(function (pattern) {
|
|
67
43
|
if (typeof pattern === 'string') {
|
|
68
44
|
return route.includes(pattern);
|
|
@@ -78,8 +54,8 @@ function shouldIgnoreRoute(route) {
|
|
|
78
54
|
* 上报路由变化事件
|
|
79
55
|
*/
|
|
80
56
|
function reportRouteChange(from, to, method) {
|
|
81
|
-
var
|
|
82
|
-
if (!((
|
|
57
|
+
var _routerConfig2;
|
|
58
|
+
if (!((_routerConfig2 = routerConfig) !== null && _routerConfig2 !== void 0 && _routerConfig2.enable) || shouldIgnoreRoute(to)) {
|
|
83
59
|
return;
|
|
84
60
|
}
|
|
85
61
|
var event = {
|
|
@@ -172,15 +148,14 @@ function handleHashChange() {
|
|
|
172
148
|
* @param config 新的配置对象
|
|
173
149
|
*/
|
|
174
150
|
export function updateRouterConfig(config) {
|
|
175
|
-
var _defaultConfig$enable, _defaultConfig$trackH, _defaultConfig$trackH2, _defaultConfig$trackP, _defaultConfig$ignore
|
|
151
|
+
var _defaultConfig$enable, _defaultConfig$trackH, _defaultConfig$trackH2, _defaultConfig$trackP, _defaultConfig$ignore;
|
|
176
152
|
var defaultConfig = getConfig().routerMonitor || {};
|
|
177
153
|
var newConfig = _objectSpread({
|
|
178
154
|
enable: (_defaultConfig$enable = defaultConfig.enable) !== null && _defaultConfig$enable !== void 0 ? _defaultConfig$enable : false,
|
|
179
155
|
trackHashChange: (_defaultConfig$trackH = defaultConfig.trackHashChange) !== null && _defaultConfig$trackH !== void 0 ? _defaultConfig$trackH : true,
|
|
180
156
|
trackHistoryChange: (_defaultConfig$trackH2 = defaultConfig.trackHistoryChange) !== null && _defaultConfig$trackH2 !== void 0 ? _defaultConfig$trackH2 : true,
|
|
181
157
|
trackPageStayTime: (_defaultConfig$trackP = defaultConfig.trackPageStayTime) !== null && _defaultConfig$trackP !== void 0 ? _defaultConfig$trackP : true,
|
|
182
|
-
ignoreRoutes: (_defaultConfig$ignore = defaultConfig.ignoreRoutes) !== null && _defaultConfig$ignore !== void 0 ? _defaultConfig$ignore : []
|
|
183
|
-
customMatchers: (_defaultConfig$custom = defaultConfig.customMatchers) !== null && _defaultConfig$custom !== void 0 ? _defaultConfig$custom : []
|
|
158
|
+
ignoreRoutes: (_defaultConfig$ignore = defaultConfig.ignoreRoutes) !== null && _defaultConfig$ignore !== void 0 ? _defaultConfig$ignore : []
|
|
184
159
|
}, config || {});
|
|
185
160
|
|
|
186
161
|
// 如果配置发生变化,重新初始化
|
|
@@ -199,7 +174,7 @@ export function updateRouterConfig(config) {
|
|
|
199
174
|
* 初始化路由监控
|
|
200
175
|
*/
|
|
201
176
|
export function initRouterMonitor(config) {
|
|
202
|
-
var _defaultConfig$enable2, _defaultConfig$trackH3, _defaultConfig$trackH4, _defaultConfig$trackP2, _defaultConfig$ignore2
|
|
177
|
+
var _defaultConfig$enable2, _defaultConfig$trackH3, _defaultConfig$trackH4, _defaultConfig$trackP2, _defaultConfig$ignore2;
|
|
203
178
|
if (isInitialized || typeof window === 'undefined') return;
|
|
204
179
|
|
|
205
180
|
// 合并配置
|
|
@@ -209,8 +184,7 @@ export function initRouterMonitor(config) {
|
|
|
209
184
|
trackHashChange: (_defaultConfig$trackH3 = defaultConfig.trackHashChange) !== null && _defaultConfig$trackH3 !== void 0 ? _defaultConfig$trackH3 : true,
|
|
210
185
|
trackHistoryChange: (_defaultConfig$trackH4 = defaultConfig.trackHistoryChange) !== null && _defaultConfig$trackH4 !== void 0 ? _defaultConfig$trackH4 : true,
|
|
211
186
|
trackPageStayTime: (_defaultConfig$trackP2 = defaultConfig.trackPageStayTime) !== null && _defaultConfig$trackP2 !== void 0 ? _defaultConfig$trackP2 : true,
|
|
212
|
-
ignoreRoutes: (_defaultConfig$ignore2 = defaultConfig.ignoreRoutes) !== null && _defaultConfig$ignore2 !== void 0 ? _defaultConfig$ignore2 : []
|
|
213
|
-
customMatchers: (_defaultConfig$custom2 = defaultConfig.customMatchers) !== null && _defaultConfig$custom2 !== void 0 ? _defaultConfig$custom2 : []
|
|
187
|
+
ignoreRoutes: (_defaultConfig$ignore2 = defaultConfig.ignoreRoutes) !== null && _defaultConfig$ignore2 !== void 0 ? _defaultConfig$ignore2 : []
|
|
214
188
|
}, config || {});
|
|
215
189
|
|
|
216
190
|
// 如果未启用,直接返回
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrweb.d.ts","sourceRoot":"","sources":["../../../src/lib/rrweb.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,YAKtB,CAAC;AAEF,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"rrweb.d.ts","sourceRoot":"","sources":["../../../src/lib/rrweb.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,YAKtB,CAAC;AAEF,eAAO,MAAM,WAAW,YAuFvB,CAAC"}
|
package/dist/esm/lib/rrweb.js
CHANGED
|
@@ -58,19 +58,19 @@ export var startRecord = function startRecord() {
|
|
|
58
58
|
stopRecordFn = rrweb.record({
|
|
59
59
|
emit: function emit(event) {
|
|
60
60
|
// you should use console.log in this way to avoid errors.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
// const defaultLog = (console.log as any)['__rrweb_original__']
|
|
62
|
+
// ? (console.log as any)['__rrweb_original__']
|
|
63
|
+
// : console.log;
|
|
64
|
+
// if (event.type !== rrweb.EventType.IncrementalSnapshot) {
|
|
65
|
+
// // 过滤不打印出增量更新的日志
|
|
66
|
+
// defaultLog('event', event);
|
|
67
|
+
// }
|
|
66
68
|
|
|
67
69
|
// 统一写入 Storage(full 和 error 模式共用)
|
|
68
70
|
storage.push(deviceId, event);
|
|
69
71
|
},
|
|
70
72
|
recordCanvas: true,
|
|
71
|
-
sampling:
|
|
72
|
-
canvas: config.samplingRate
|
|
73
|
-
}, config.sampling || {}),
|
|
73
|
+
sampling: config.sampling,
|
|
74
74
|
checkoutEveryNms: config.checkoutEveryNms,
|
|
75
75
|
ignoreClass: config.ignoreClass,
|
|
76
76
|
blockClass: config.blockClass,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../src/lib/uploader.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAE9D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE/D;AAyGD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../src/lib/uploader.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAE9D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE/D;AAyGD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAmIjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
package/dist/esm/lib/uploader.js
CHANGED
|
@@ -186,7 +186,7 @@ function _handleUploadFailure() {
|
|
|
186
186
|
export function startUploadLoop(serv, appId) {
|
|
187
187
|
var push = /*#__PURE__*/function () {
|
|
188
188
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
189
|
-
var currentConfig, isErrorMode, events, windowStart, config, consumeOnly, result, batchKey, maxRetryCount, _batchKey, currentCount, shouldStop;
|
|
189
|
+
var currentConfig, isErrorMode, events, windowStart, config, consumeOnly, result, batchKey, lastEvent, maxRetryCount, _batchKey, currentCount, shouldStop;
|
|
190
190
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
191
191
|
while (1) switch (_context.prev = _context.next) {
|
|
192
192
|
case 0:
|
|
@@ -228,17 +228,19 @@ export function startUploadLoop(serv, appId) {
|
|
|
228
228
|
_context.prev = 14;
|
|
229
229
|
isUploading = true;
|
|
230
230
|
windowStart = 0;
|
|
231
|
-
if (!
|
|
231
|
+
if (!isErrorMode) {
|
|
232
232
|
_context.next = 25;
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
// 错误模式:按时间范围提取事件
|
|
236
|
-
|
|
236
|
+
// 如果 errorModeWindowStart > 0,使用该值;否则从当前时间开始提取新事件
|
|
237
|
+
windowStart = errorModeWindowStart > 0 ? errorModeWindowStart : Date.now();
|
|
237
238
|
_context.next = 21;
|
|
238
239
|
return storage.pullByTimeRange(getDeviceId(), windowStart, Date.now());
|
|
239
240
|
case 21:
|
|
240
241
|
events = _context.sent;
|
|
241
|
-
//
|
|
242
|
+
// 重置窗口起点为 0,下次上传时会从当前时间开始
|
|
243
|
+
// 但如果本次有事件上传成功,会更新为最后事件的时间戳
|
|
242
244
|
errorModeWindowStart = 0;
|
|
243
245
|
_context.next = 28;
|
|
244
246
|
break;
|
|
@@ -277,7 +279,7 @@ export function startUploadLoop(serv, appId) {
|
|
|
277
279
|
case 41:
|
|
278
280
|
result = _context.sent;
|
|
279
281
|
if (!result.success) {
|
|
280
|
-
_context.next =
|
|
282
|
+
_context.next = 53;
|
|
281
283
|
break;
|
|
282
284
|
}
|
|
283
285
|
// 上传成功,重置失败计数
|
|
@@ -285,51 +287,57 @@ export function startUploadLoop(serv, appId) {
|
|
|
285
287
|
uploadFailureCount.delete(batchKey);
|
|
286
288
|
|
|
287
289
|
// 错误模式:上传成功后移除已上传的事件
|
|
288
|
-
if (!(isErrorMode && windowStart > 0)) {
|
|
289
|
-
_context.next =
|
|
290
|
+
if (!(isErrorMode && windowStart > 0 && events.length > 0)) {
|
|
291
|
+
_context.next = 50;
|
|
290
292
|
break;
|
|
291
293
|
}
|
|
292
294
|
_context.next = 48;
|
|
293
295
|
return storage.removeByTimeRange(getDeviceId(), windowStart);
|
|
294
296
|
case 48:
|
|
297
|
+
// 更新窗口起点为最后一个事件的时间戳,避免下次重复提取
|
|
298
|
+
lastEvent = events[events.length - 1];
|
|
299
|
+
if (lastEvent && lastEvent.timestamp) {
|
|
300
|
+
errorModeWindowStart = lastEvent.timestamp;
|
|
301
|
+
}
|
|
302
|
+
case 50:
|
|
295
303
|
// 全量模式:pull 已经自动移除了
|
|
296
304
|
|
|
297
305
|
isUploading = false;
|
|
298
|
-
_context.next =
|
|
306
|
+
_context.next = 62;
|
|
299
307
|
break;
|
|
300
|
-
case
|
|
308
|
+
case 53:
|
|
301
309
|
isUploading = false;
|
|
302
310
|
|
|
303
311
|
// 获取最大重试次数,默认3次
|
|
304
312
|
maxRetryCount = config.maxRetryCount || 3; // 记录失败次数
|
|
305
313
|
_batchKey = "".concat(appId, "_").concat(getDeviceId());
|
|
306
314
|
currentCount = uploadFailureCount.get(_batchKey) || 0; // 处理上传失败
|
|
307
|
-
_context.next =
|
|
315
|
+
_context.next = 59;
|
|
308
316
|
return handleUploadFailure(events, result.error, appId, serv, maxRetryCount, currentCount);
|
|
309
|
-
case
|
|
317
|
+
case 59:
|
|
310
318
|
shouldStop = _context.sent;
|
|
311
319
|
if (!shouldStop) {
|
|
312
|
-
_context.next =
|
|
320
|
+
_context.next = 62;
|
|
313
321
|
break;
|
|
314
322
|
}
|
|
315
323
|
return _context.abrupt("return");
|
|
316
|
-
case 60:
|
|
317
|
-
_context.next = 66;
|
|
318
|
-
break;
|
|
319
324
|
case 62:
|
|
320
|
-
_context.
|
|
325
|
+
_context.next = 68;
|
|
326
|
+
break;
|
|
327
|
+
case 64:
|
|
328
|
+
_context.prev = 64;
|
|
321
329
|
_context.t0 = _context["catch"](14);
|
|
322
330
|
isUploading = false;
|
|
323
331
|
logger.error('Error in upload loop:', _context.t0);
|
|
324
|
-
case
|
|
332
|
+
case 68:
|
|
325
333
|
setTimeout(function () {
|
|
326
334
|
push();
|
|
327
335
|
}, currentConfig.uploadInterval);
|
|
328
|
-
case
|
|
336
|
+
case 69:
|
|
329
337
|
case "end":
|
|
330
338
|
return _context.stop();
|
|
331
339
|
}
|
|
332
|
-
}, _callee, null, [[14,
|
|
340
|
+
}, _callee, null, [[14, 64]]);
|
|
333
341
|
}));
|
|
334
342
|
return function push() {
|
|
335
343
|
return _ref.apply(this, arguments);
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { setCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getSdkLogEndpoint, getWhiteListUrls, shouldRecordUrl } from './lib/net';
|
|
1
|
+
import { setCustomHeaders, getCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getSdkLogEndpoint, getWhiteListUrls, shouldRecordUrl } from './lib/net';
|
|
2
2
|
import { forceResetUploadState } from './lib/uploader';
|
|
3
3
|
import { updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor } from './lib/router-monitor';
|
|
4
4
|
import { getConfig } from './lib/config';
|
|
@@ -8,66 +8,30 @@ type Params = {
|
|
|
8
8
|
appId: string;
|
|
9
9
|
cdnConfigUrl?: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
declare function init(param: Params): {
|
|
12
12
|
cancel: (options?: {
|
|
13
13
|
clearData?: boolean;
|
|
14
14
|
}) => void;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
declare function cancelRecord(options?: {
|
|
17
17
|
clearData?: boolean;
|
|
18
18
|
}): void;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 获取当前是否处于只采集不上报模式
|
|
27
|
-
* @returns 是否启用只采集不上报模式
|
|
28
|
-
*/
|
|
29
|
-
export declare function isConsumeOnlyMode(): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* 切换只采集不上报模式
|
|
32
|
-
*/
|
|
33
|
-
export declare function toggleConsumeOnlyMode(): boolean;
|
|
34
|
-
export { updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor, };
|
|
35
|
-
export { setCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getWhiteListUrls, getSdkLogEndpoint, };
|
|
36
|
-
export { cleanupErrorHandler };
|
|
37
|
-
/**
|
|
38
|
-
* 手动触发错误上报(用于业务自定义错误)
|
|
39
|
-
* 仅在错误采集模式(captureMode: 'error')下有效。
|
|
40
|
-
* @param error 错误信息,可以是 Error 对象或自定义描述字符串
|
|
41
|
-
*/
|
|
42
|
-
export declare function reportError(error: Error | string): void;
|
|
43
|
-
export declare const debug: {
|
|
44
|
-
/**
|
|
45
|
-
* 获取存储适配器类型
|
|
46
|
-
*/
|
|
19
|
+
declare function addCustomEvent(tagName: string, payload: any): void;
|
|
20
|
+
declare function setConsumeOnlyMode(enable: boolean): void;
|
|
21
|
+
declare function isConsumeOnlyMode(): boolean;
|
|
22
|
+
declare function toggleConsumeOnlyMode(): boolean;
|
|
23
|
+
declare function reportError(error: Error | string): void;
|
|
24
|
+
declare const debug: {
|
|
47
25
|
getStorageAdapterType(): string;
|
|
48
|
-
/**
|
|
49
|
-
* 获取设备ID
|
|
50
|
-
*/
|
|
51
26
|
getDeviceId: () => string;
|
|
52
|
-
/**
|
|
53
|
-
* 重置上传状态
|
|
54
|
-
*/
|
|
55
27
|
resetUploadState: typeof forceResetUploadState;
|
|
56
|
-
/**
|
|
57
|
-
* 获取存储状态
|
|
58
|
-
*/
|
|
59
28
|
getStorageState(): Promise<{
|
|
60
29
|
adapterType: string;
|
|
61
30
|
eventCount: number;
|
|
62
31
|
}>;
|
|
63
|
-
/**
|
|
64
|
-
* 清空存储数据
|
|
65
|
-
*/
|
|
66
32
|
clearStorage(): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* 检查URL是否应该被记录(白名单且不在黑名单中)
|
|
69
|
-
*/
|
|
70
33
|
shouldRecordUrl: typeof shouldRecordUrl;
|
|
71
34
|
getConfig: typeof getConfig;
|
|
72
35
|
};
|
|
36
|
+
export { init, cancelRecord, addCustomEvent, setConsumeOnlyMode, isConsumeOnlyMode, toggleConsumeOnlyMode, updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor, setCustomHeaders, getCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getWhiteListUrls, getSdkLogEndpoint, reportError, cleanupErrorHandler, debug, };
|
|
73
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAgB,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AAGnE,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAgB,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AAGnE,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,iBAAS,IAAI,CAAC,KAAK,EAAE,MAAM;uBAIL;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;EAI5C;AAED,iBAAS,YAAY,CAAC,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,QAK1D;AAED,iBAAS,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAEpD;AAED,iBAAS,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAGjD;AAED,iBAAS,iBAAiB,IAAI,OAAO,CAKpC;AAED,iBAAS,qBAAqB,IAAI,OAAO,CAIxC;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAkChD;AAED,QAAA,MAAM,KAAK;6BACgB,MAAM;;;;;;;;;;CAehC,CAAC;AAGF,OAAO,EAEL,IAAI,EACJ,YAAY,EAEZ,cAAc,EAEd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EAErB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAEjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAEjB,WAAW,EACX,mBAAmB,EAEnB,KAAK,GACN,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -24,6 +24,12 @@ Object.defineProperty(exports, "getCurrentRouteInfo", {
|
|
|
24
24
|
return _routerMonitor.getCurrentRouteInfo;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
Object.defineProperty(exports, "getCustomHeaders", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function get() {
|
|
30
|
+
return _net.getCustomHeaders;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
27
33
|
Object.defineProperty(exports, "getSdkLogEndpoint", {
|
|
28
34
|
enumerable: true,
|
|
29
35
|
get: function get() {
|
|
@@ -93,7 +99,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
93
99
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
94
100
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
95
101
|
function init(param) {
|
|
96
|
-
// 初始化 RLog SDK
|
|
97
102
|
(0, _init.initRLog)(param.serv, param.appId, param.cdnConfigUrl);
|
|
98
103
|
return {
|
|
99
104
|
cancel: function cancel() {
|
|
@@ -102,8 +107,6 @@ function init(param) {
|
|
|
102
107
|
}
|
|
103
108
|
};
|
|
104
109
|
}
|
|
105
|
-
|
|
106
|
-
// 单独导出 cancelRecord 方法
|
|
107
110
|
function cancelRecord() {
|
|
108
111
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
109
112
|
_logger.default.warn('Please use rlog.cancel() from initialized instance instead of standalone cancelRecord()');
|
|
@@ -112,46 +115,20 @@ function cancelRecord() {
|
|
|
112
115
|
function addCustomEvent(tagName, payload) {
|
|
113
116
|
_rrweb.record.addCustomEvent(tagName, payload);
|
|
114
117
|
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 设置只采集不上报模式
|
|
118
|
-
* @param enable 是否启用只采集不上报模式
|
|
119
|
-
*/
|
|
120
118
|
function setConsumeOnlyMode(enable) {
|
|
121
119
|
(0, _config.updateConfig)({
|
|
122
120
|
consumeOnly: enable
|
|
123
121
|
});
|
|
124
122
|
_logger.default.log("Consume only mode ".concat(enable ? 'enabled' : 'disabled'));
|
|
125
123
|
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 获取当前是否处于只采集不上报模式
|
|
129
|
-
* @returns 是否启用只采集不上报模式
|
|
130
|
-
*/
|
|
131
124
|
function isConsumeOnlyMode() {
|
|
132
125
|
return sessionStorage.getItem('RLOG_CONSUME_ONLY') === 'YES' || !!(0, _config.getConfig)().consumeOnly;
|
|
133
126
|
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 切换只采集不上报模式
|
|
137
|
-
*/
|
|
138
127
|
function toggleConsumeOnlyMode() {
|
|
139
128
|
var newMode = !(0, _config.getConfig)().consumeOnly;
|
|
140
129
|
setConsumeOnlyMode(newMode);
|
|
141
130
|
return newMode;
|
|
142
131
|
}
|
|
143
|
-
|
|
144
|
-
// 路由监控相关API
|
|
145
|
-
|
|
146
|
-
// 网络监控相关函数
|
|
147
|
-
|
|
148
|
-
// 错误处理相关函数
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 手动触发错误上报(用于业务自定义错误)
|
|
152
|
-
* 仅在错误采集模式(captureMode: 'error')下有效。
|
|
153
|
-
* @param error 错误信息,可以是 Error 对象或自定义描述字符串
|
|
154
|
-
*/
|
|
155
132
|
function reportError(error) {
|
|
156
133
|
var config = (0, _config.getConfig)();
|
|
157
134
|
if (config.captureMode !== 'error') {
|
|
@@ -165,8 +142,6 @@ function reportError(error) {
|
|
|
165
142
|
}
|
|
166
143
|
var message = typeof error === 'string' ? error : error.message;
|
|
167
144
|
var stack = _typeof(error) === 'object' && error.stack ? error.stack : undefined;
|
|
168
|
-
|
|
169
|
-
// 同时记录为 rrweb 自定义事件
|
|
170
145
|
try {
|
|
171
146
|
_rrweb.record.addCustomEvent('custom-error-event', {
|
|
172
147
|
type: 'CUSTOM_ERROR',
|
|
@@ -178,8 +153,6 @@ function reportError(error) {
|
|
|
178
153
|
} catch (e) {
|
|
179
154
|
_logger.default.warn('Failed to add custom error event:', e);
|
|
180
155
|
}
|
|
181
|
-
|
|
182
|
-
// 通知错误触发器
|
|
183
156
|
trigger.onError({
|
|
184
157
|
type: 'custom',
|
|
185
158
|
message: message,
|
|
@@ -189,30 +162,12 @@ function reportError(error) {
|
|
|
189
162
|
}
|
|
190
163
|
});
|
|
191
164
|
}
|
|
192
|
-
|
|
193
|
-
// 调试和测试相关API
|
|
194
165
|
var debug = exports.debug = {
|
|
195
|
-
/**
|
|
196
|
-
* 获取存储适配器类型
|
|
197
|
-
*/
|
|
198
166
|
getStorageAdapterType: function getStorageAdapterType() {
|
|
199
167
|
return _storageManager.storage.getAdapterType();
|
|
200
168
|
},
|
|
201
|
-
// get storage() {
|
|
202
|
-
// return storage;
|
|
203
|
-
// },
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* 获取设备ID
|
|
207
|
-
*/
|
|
208
169
|
getDeviceId: _utils.getDeviceId,
|
|
209
|
-
/**
|
|
210
|
-
* 重置上传状态
|
|
211
|
-
*/
|
|
212
170
|
resetUploadState: _uploader.forceResetUploadState,
|
|
213
|
-
/**
|
|
214
|
-
* 获取存储状态
|
|
215
|
-
*/
|
|
216
171
|
getStorageState: function getStorageState() {
|
|
217
172
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
218
173
|
var deviceId;
|
|
@@ -228,9 +183,6 @@ var debug = exports.debug = {
|
|
|
228
183
|
}, _callee);
|
|
229
184
|
}))();
|
|
230
185
|
},
|
|
231
|
-
/**
|
|
232
|
-
* 清空存储数据
|
|
233
|
-
*/
|
|
234
186
|
clearStorage: function clearStorage() {
|
|
235
187
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
236
188
|
var deviceId;
|
|
@@ -246,9 +198,8 @@ var debug = exports.debug = {
|
|
|
246
198
|
}, _callee2);
|
|
247
199
|
}))();
|
|
248
200
|
},
|
|
249
|
-
/**
|
|
250
|
-
* 检查URL是否应该被记录(白名单且不在黑名单中)
|
|
251
|
-
*/
|
|
252
201
|
shouldRecordUrl: _net.shouldRecordUrl,
|
|
253
202
|
getConfig: _config.getConfig
|
|
254
|
-
};
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// 统一导出所有公共 API
|