@qiu_jun/monitors 0.0.8 → 0.0.9
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 +10 -1
- package/dist/exception/reporter.d.ts +1 -1
- package/dist/exception/reporter.js +5 -3
- package/dist/exception/types.d.ts +3 -0
- package/dist/interface/index.d.ts +7 -0
- package/dist/miniprogram.d.ts +2 -0
- package/dist/miniprogram.js +16 -4
- package/dist/modules/fetch.d.ts +1 -0
- package/dist/modules/fetch.js +85 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +3 -1
- package/dist/modules/xhr.js +53 -18
- package/dist/monitor.d.ts +4 -0
- package/dist/monitor.js +39 -29
- package/dist/monitor.umd.js +1 -1
- package/dist/utils/businessError.d.ts +10 -0
- package/dist/utils/businessError.js +31 -0
- package/dist/utils/toExcEvent.js +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,11 +47,20 @@ const monitor = new Monitor({
|
|
|
47
47
|
|---|---|---|
|
|
48
48
|
| JS 错误 | `error` | 含选择器、白屏检测 |
|
|
49
49
|
| Promise 未捕获 | `unhandledrejection` | |
|
|
50
|
-
| XHR 失败/超时 | `request` |
|
|
50
|
+
| XHR/fetch 失败/超时 | `request` | 网络失败 `[network]`、HTTP `[500]`;业务错误 `[business 1102]`(需配 `isBusinessError`,见下) |
|
|
51
51
|
| FP/FCP/FMP/LCP | `paint` | 指标在 `device` |
|
|
52
52
|
| DOMContentLoaded/load | `timing` | |
|
|
53
53
|
| 长任务 | `longTask` | duration ≥ 100ms 时 level=WARN |
|
|
54
54
|
|
|
55
|
+
**业务错误拦截**:后端 HTTP 200 但响应体 `code` 非成功(如 `{ code: 1102, message: '无权限访问' }`)默认不会上报,配置判定函数后按 `request` 事件上报(`message` 形如 `Request failed [business 1102]: POST /api/xxx`,`device.msg` 带后端 message、`device.code` 带错误码):
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
new Monitor({
|
|
59
|
+
// ...
|
|
60
|
+
isBusinessError: body => (body as { code?: number })?.code !== 0, // 项目内约定 code !== 0 即业务错误
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
55
64
|
## 错误回放(可选,Web/H5)
|
|
56
65
|
|
|
57
66
|
基于 rrweb 环形录制用户操作,**出错时**上传最近 15~30 秒回放(独立接口),错误事件通过 `device.replayId` 关联,异常平台用 rrweb-player 播放。小程序无 DOM 不支持。
|
|
@@ -8,7 +8,7 @@ export declare class ExcReporter {
|
|
|
8
8
|
private timer;
|
|
9
9
|
private sending;
|
|
10
10
|
constructor(options: ExcSdkOptions, transport: ExcTransport);
|
|
11
|
-
/** 采样 +
|
|
11
|
+
/** 采样 + 入缓冲:ERROR/FATAL 走 errorSampleRate(默认全量),WARN 及以下走 sampleRate */
|
|
12
12
|
capture(event: ExcEventPayload): void;
|
|
13
13
|
flush(): Promise<void>;
|
|
14
14
|
destroy(): void;
|
|
@@ -40,15 +40,17 @@ class ExcReporter {
|
|
|
40
40
|
value: false
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
/** 采样 +
|
|
43
|
+
/** 采样 + 入缓冲:ERROR/FATAL 走 errorSampleRate(默认全量),WARN 及以下走 sampleRate */
|
|
44
44
|
capture(event) {
|
|
45
45
|
var _a, _b, _c, _d, _e;
|
|
46
|
-
const
|
|
46
|
+
const level = (_a = event.level) !== null && _a !== void 0 ? _a : 'ERROR';
|
|
47
|
+
const isErrorLevel = level === 'ERROR' || level === 'FATAL';
|
|
48
|
+
const sampleRate = (_b = (isErrorLevel ? this.options.errorSampleRate : this.options.sampleRate)) !== null && _b !== void 0 ? _b : 100;
|
|
47
49
|
if (sampleRate < 100 && Math.random() * 100 >= sampleRate)
|
|
48
50
|
return;
|
|
49
51
|
this.buffer.push({
|
|
50
52
|
...event,
|
|
51
|
-
level
|
|
53
|
+
level,
|
|
52
54
|
occurredAt: (_c = event.occurredAt) !== null && _c !== void 0 ? _c : new Date().toISOString(),
|
|
53
55
|
sdkVersion: (_d = event.sdkVersion) !== null && _d !== void 0 ? _d : exports.SDK_VERSION,
|
|
54
56
|
});
|
|
@@ -8,7 +8,10 @@ export interface ExcSdkOptions {
|
|
|
8
8
|
projectKey: string;
|
|
9
9
|
release?: string;
|
|
10
10
|
environment?: string;
|
|
11
|
+
/** 低级别事件(WARN/INFO,性能类等)采样率(%),0-100,默认 100 全量 */
|
|
11
12
|
sampleRate?: number;
|
|
13
|
+
/** 错误事件(ERROR/FATAL)采样率(%),0-100,默认 100 全量;不随 sampleRate 联动,需压错误量时显式调低 */
|
|
14
|
+
errorSampleRate?: number;
|
|
12
15
|
maxBatch?: number;
|
|
13
16
|
flushInterval?: number;
|
|
14
17
|
}
|
|
@@ -17,6 +17,8 @@ export interface IMonitorOptions {
|
|
|
17
17
|
maxQueueSize?: number;
|
|
18
18
|
/** 同类错误采集去重窗口(ms),默认 0 不启用;窗口内 errorType+message+filename 相同的错误只上报一条。建议与 replay.minUploadIntervalMs 同值(如 30000),错误事件与回放 1:1 */
|
|
19
19
|
errorDedupeMs?: number;
|
|
20
|
+
/** 业务错误判定:HTTP 2xx 但响应体 code 非成功的接口(如 { code: 1102, message: '无权限访问' })返回 true 则上报为 request 事件。入参为解析后的响应体(非 JSON / 解析失败跳过);XHR responseType 为 blob/arraybuffer 时读不到响应体同样跳过。示例:body => (body as any)?.code !== 0 */
|
|
21
|
+
isBusinessError?: (body: unknown) => boolean;
|
|
20
22
|
/** 错误回放(仅 Web/H5,小程序无 DOM 不支持),默认关闭 */
|
|
21
23
|
replay?: ReplayOptions;
|
|
22
24
|
}
|
|
@@ -97,6 +99,11 @@ export interface RequestLog {
|
|
|
97
99
|
status?: number;
|
|
98
100
|
url?: string;
|
|
99
101
|
method?: string;
|
|
102
|
+
/** 业务错误详情(isBusinessError 判定命中时填充,如 { code: 1102, message: '无权限访问' }) */
|
|
103
|
+
business?: {
|
|
104
|
+
code?: number | string;
|
|
105
|
+
message?: string;
|
|
106
|
+
};
|
|
100
107
|
/** 请求发生时页面地址(captureRequest 自动填充) */
|
|
101
108
|
page?: string;
|
|
102
109
|
}
|
package/dist/miniprogram.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface MiniProgramMonitorOptions extends ExcSdkOptions {
|
|
|
50
50
|
interceptLifecycle?: boolean;
|
|
51
51
|
/** 拦截 wx.request 上报失败请求(默认 true,上报自身 URL 除外,防递归) */
|
|
52
52
|
interceptRequest?: boolean;
|
|
53
|
+
/** 业务错误判定:statusCode 2xx 但响应体 code 非成功时上报,判定方式同 H5 侧 IMonitorOptions.isBusinessError */
|
|
54
|
+
isBusinessError?: (body: unknown) => boolean;
|
|
53
55
|
}
|
|
54
56
|
export interface MiniProgramMonitor {
|
|
55
57
|
reporter: ExcReporter;
|
package/dist/miniprogram.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.createMiniProgramMonitor = createMiniProgramMonitor;
|
|
|
10
10
|
const reporter_1 = require("./exception/reporter");
|
|
11
11
|
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return reporter_1.SDK_VERSION; } });
|
|
12
12
|
Object.defineProperty(exports, "createReporter", { enumerable: true, get: function () { return reporter_1.createReporter; } });
|
|
13
|
+
const businessError_1 = require("./utils/businessError");
|
|
13
14
|
/** 从全局取 wx(微信 / uni-app 等均已注入),取不到返回 undefined */
|
|
14
15
|
function getWx() {
|
|
15
16
|
return globalThis.wx;
|
|
@@ -143,7 +144,7 @@ function currentPageRoute() {
|
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
/** 拦截 wx.request:失败的请求按 H5 侧 request 事件格式上报(上报自身 URL 除外,防递归) */
|
|
146
|
-
function interceptRequest(wxApi, endpoint, capture) {
|
|
147
|
+
function interceptRequest(wxApi, endpoint, isBusinessError, capture) {
|
|
147
148
|
const original = wxApi.request.bind(wxApi);
|
|
148
149
|
wxApi.request = (options) => {
|
|
149
150
|
var _a;
|
|
@@ -154,7 +155,7 @@ function interceptRequest(wxApi, endpoint, capture) {
|
|
|
154
155
|
return original({
|
|
155
156
|
...options,
|
|
156
157
|
success: (res) => {
|
|
157
|
-
var _a, _b;
|
|
158
|
+
var _a, _b, _c;
|
|
158
159
|
if (res.statusCode >= 400) {
|
|
159
160
|
capture({
|
|
160
161
|
type: 'request',
|
|
@@ -162,7 +163,18 @@ function interceptRequest(wxApi, endpoint, capture) {
|
|
|
162
163
|
device: { durationMs: Date.now() - start },
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
|
-
|
|
166
|
+
else if (isBusinessError) {
|
|
167
|
+
// 业务错误:statusCode 2xx 但响应体 code 非成功(res.data 默认已被 wx 按 JSON 解析)
|
|
168
|
+
const business = (0, businessError_1.detectBusinessError)(res.data, isBusinessError);
|
|
169
|
+
if (business) {
|
|
170
|
+
capture({
|
|
171
|
+
type: 'request',
|
|
172
|
+
message: `Request failed [business${business.code !== undefined ? ` ${business.code}` : ''}]: ${String((_b = options === null || options === void 0 ? void 0 : options.method) !== null && _b !== void 0 ? _b : 'GET').toUpperCase()} ${url}`,
|
|
173
|
+
device: { durationMs: Date.now() - start, msg: business.message, code: business.code },
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
(_c = options === null || options === void 0 ? void 0 : options.success) === null || _c === void 0 ? void 0 : _c.call(options, res);
|
|
166
178
|
},
|
|
167
179
|
fail: (err) => {
|
|
168
180
|
var _a, _b;
|
|
@@ -247,7 +259,7 @@ function createMiniProgramMonitor(options) {
|
|
|
247
259
|
device: { lifecycle: info.lifecycle, duration: info.duration, component: info.component },
|
|
248
260
|
});
|
|
249
261
|
const restoreConstructors = options.interceptLifecycle !== false ? interceptConstructors() : null;
|
|
250
|
-
const restoreRequest = options.interceptRequest !== false ? interceptRequest(wxApi, options.endpoint, doCapture) : null;
|
|
262
|
+
const restoreRequest = options.interceptRequest !== false ? interceptRequest(wxApi, options.endpoint, options.isBusinessError, doCapture) : null;
|
|
251
263
|
return {
|
|
252
264
|
reporter,
|
|
253
265
|
capture: doCapture,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function onFetch(): void;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = onFetch;
|
|
4
|
+
const businessError_1 = require("../utils/businessError");
|
|
5
|
+
/** 主动取消/超时产生的异常名,不算请求失败 */
|
|
6
|
+
const SKIPPED_ERROR_NAMES = ['AbortError', 'TimeoutError'];
|
|
7
|
+
function onFetch() {
|
|
8
|
+
const originalFetch = typeof window.fetch === 'function' ? window.fetch.bind(window) : undefined;
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const _this = this;
|
|
11
|
+
if (!originalFetch)
|
|
12
|
+
return;
|
|
13
|
+
/** 监控自身的异常不能影响业务请求 */
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
const safeCapture = (info) => {
|
|
16
|
+
try {
|
|
17
|
+
_this.captureRequest(info);
|
|
18
|
+
}
|
|
19
|
+
catch ( /* 静默 */_a) { /* 静默 */ }
|
|
20
|
+
};
|
|
21
|
+
window.fetch = function (input, init) {
|
|
22
|
+
var _a;
|
|
23
|
+
const reqUrl = typeof input === 'string' ? input : (input instanceof URL ? input.href : input.url);
|
|
24
|
+
const reqMethod = String((_a = init === null || init === void 0 ? void 0 : init.method) !== null && _a !== void 0 ? _a : (input instanceof Request ? input.method : 'GET')).toUpperCase();
|
|
25
|
+
// 上报/回放自身 URL 不拦截:防递归,且 clone 读 body 会干扰 keepalive 上报
|
|
26
|
+
if ((_this.endpoint && reqUrl === _this.endpoint) || (_this.replayEndpoint && reqUrl === _this.replayEndpoint))
|
|
27
|
+
return originalFetch(input, init);
|
|
28
|
+
const startTime = new Date().getTime();
|
|
29
|
+
return originalFetch(input, init).then((res) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const duration = new Date().getTime() - startTime;
|
|
32
|
+
if (res.status >= 400) {
|
|
33
|
+
safeCapture({
|
|
34
|
+
type: 'fetch',
|
|
35
|
+
url: reqUrl,
|
|
36
|
+
method: reqMethod,
|
|
37
|
+
msg: `fetch请求失败: 状态码 ${res.status}`,
|
|
38
|
+
duration,
|
|
39
|
+
status: res.status,
|
|
40
|
+
success: false,
|
|
41
|
+
startTime,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (res.status >= 200 && res.status < 300 && _this.isBusinessError) {
|
|
45
|
+
// 仅对 JSON/文本类响应 clone 读文本判定业务错误,避免缓冲大体积二进制;clone 不消费业务侧响应体
|
|
46
|
+
const contentType = (_a = res.headers.get('content-type')) !== null && _a !== void 0 ? _a : '';
|
|
47
|
+
if (contentType.includes('json') || contentType.startsWith('text/')) {
|
|
48
|
+
res.clone().text().then((text) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const business = (0, businessError_1.detectBusinessError)(text, _this.isBusinessError);
|
|
51
|
+
if (!business)
|
|
52
|
+
return;
|
|
53
|
+
safeCapture({
|
|
54
|
+
type: 'fetch',
|
|
55
|
+
url: reqUrl,
|
|
56
|
+
method: reqMethod,
|
|
57
|
+
msg: `fetch业务错误: ${(_a = business.message) !== null && _a !== void 0 ? _a : reqUrl}`,
|
|
58
|
+
duration: new Date().getTime() - startTime,
|
|
59
|
+
status: res.status,
|
|
60
|
+
success: false,
|
|
61
|
+
business,
|
|
62
|
+
startTime,
|
|
63
|
+
});
|
|
64
|
+
}).catch(() => { });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return res;
|
|
68
|
+
}, (err) => {
|
|
69
|
+
var _a;
|
|
70
|
+
if (SKIPPED_ERROR_NAMES.includes((_a = err === null || err === void 0 ? void 0 : err.name) !== null && _a !== void 0 ? _a : ''))
|
|
71
|
+
throw err;
|
|
72
|
+
safeCapture({
|
|
73
|
+
type: 'fetch',
|
|
74
|
+
url: reqUrl,
|
|
75
|
+
method: reqMethod,
|
|
76
|
+
msg: `fetch请求错误: ${reqUrl}`,
|
|
77
|
+
duration: new Date().getTime() - startTime,
|
|
78
|
+
status: 0,
|
|
79
|
+
success: false,
|
|
80
|
+
startTime,
|
|
81
|
+
});
|
|
82
|
+
throw err;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.onXHR = exports.onTiming = exports.onPaint = exports.onLongTask = exports.onWindowErr = void 0;
|
|
6
|
+
exports.onFetch = exports.onXHR = exports.onTiming = exports.onPaint = exports.onLongTask = exports.onWindowErr = void 0;
|
|
7
7
|
var err_1 = require("./err");
|
|
8
8
|
Object.defineProperty(exports, "onWindowErr", { enumerable: true, get: function () { return __importDefault(err_1).default; } });
|
|
9
9
|
var longTask_1 = require("./longTask");
|
|
@@ -14,3 +14,5 @@ var timing_1 = require("./timing");
|
|
|
14
14
|
Object.defineProperty(exports, "onTiming", { enumerable: true, get: function () { return __importDefault(timing_1).default; } });
|
|
15
15
|
var xhr_1 = require("./xhr");
|
|
16
16
|
Object.defineProperty(exports, "onXHR", { enumerable: true, get: function () { return __importDefault(xhr_1).default; } });
|
|
17
|
+
var fetch_1 = require("./fetch");
|
|
18
|
+
Object.defineProperty(exports, "onFetch", { enumerable: true, get: function () { return __importDefault(fetch_1).default; } });
|
package/dist/modules/xhr.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = onXHR;
|
|
4
|
+
const businessError_1 = require("../utils/businessError");
|
|
5
|
+
/** 读取 XHR 响应体:responseType 非 text/json 时访问 responseText 会抛 InvalidStateError,读不到返回 undefined */
|
|
6
|
+
function readXhrBody(xhr) {
|
|
7
|
+
try {
|
|
8
|
+
if (xhr.responseType === '' || xhr.responseType === 'text')
|
|
9
|
+
return xhr.responseText;
|
|
10
|
+
return xhr.responseType === 'json' ? xhr.response : undefined;
|
|
11
|
+
}
|
|
12
|
+
catch (_a) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
4
16
|
function onXHR() {
|
|
5
17
|
const originalXHR = window.XMLHttpRequest;
|
|
6
18
|
// @ts-ignore
|
|
@@ -56,24 +68,47 @@ function onXHR() {
|
|
|
56
68
|
startTime: new Date().getTime()
|
|
57
69
|
});
|
|
58
70
|
});
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
// 请求完成:HTTP >= 400 与业务错误(HTTP 2xx 但响应体 code 非成功)。
|
|
72
|
+
// error/timeout 后 loadend 也会触发,但那时 status 为 0,走不进下面任一分支,不会重复上报
|
|
73
|
+
xhr.addEventListener('loadend', function () {
|
|
74
|
+
var _a;
|
|
75
|
+
const duration = new Date().getTime() - startTime;
|
|
76
|
+
const status = xhr.status;
|
|
77
|
+
const urlStr = String(reqUrl !== null && reqUrl !== void 0 ? reqUrl : '');
|
|
78
|
+
if (_this.endpoint && urlStr === _this.endpoint)
|
|
79
|
+
return;
|
|
80
|
+
// HTTP 层失败(4xx/5xx)
|
|
81
|
+
if (status >= 400) {
|
|
82
|
+
_this.captureRequest({
|
|
83
|
+
type: 'xhr',
|
|
84
|
+
url: reqUrl,
|
|
85
|
+
method: reqMethod || 'GET',
|
|
86
|
+
msg: `XHR请求失败: 状态码 ${status}`,
|
|
87
|
+
duration,
|
|
88
|
+
status,
|
|
89
|
+
success: false,
|
|
90
|
+
startTime
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// 业务错误:需配置 isBusinessError 才会读响应体判定
|
|
95
|
+
if (status >= 200 && status < 300 && _this.isBusinessError) {
|
|
96
|
+
const business = (0, businessError_1.detectBusinessError)(readXhrBody(xhr), _this.isBusinessError);
|
|
97
|
+
if (business) {
|
|
98
|
+
_this.captureRequest({
|
|
99
|
+
type: 'xhr',
|
|
100
|
+
url: reqUrl,
|
|
101
|
+
method: reqMethod || 'GET',
|
|
102
|
+
msg: `XHR业务错误: ${(_a = business.message) !== null && _a !== void 0 ? _a : urlStr}`,
|
|
103
|
+
duration,
|
|
104
|
+
status,
|
|
105
|
+
success: false,
|
|
106
|
+
business,
|
|
107
|
+
startTime
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
77
112
|
return originalSend.apply(this, arguments);
|
|
78
113
|
};
|
|
79
114
|
return xhr;
|
package/dist/monitor.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export default class Monitor {
|
|
|
6
6
|
endpoint: string;
|
|
7
7
|
/** 接入项目 projectKey */
|
|
8
8
|
projectKey: string;
|
|
9
|
+
/** 回放上传地址(fetch 拦截排除用,未开启回放为空) */
|
|
10
|
+
replayEndpoint: string;
|
|
11
|
+
/** 业务错误判定:HTTP 2xx 但响应体 code 非成功时上报(XHR/fetch/wx.request) */
|
|
12
|
+
isBusinessError?: (body: unknown) => boolean;
|
|
9
13
|
timeoutDuration: number;
|
|
10
14
|
errorQueue: RequestLog[];
|
|
11
15
|
requestQueue: RequestLog[];
|
package/dist/monitor.js
CHANGED
|
@@ -8,7 +8,7 @@ const exception_1 = require("./exception"), modules_1 = require("./modules"), in
|
|
|
8
8
|
|
|
9
9
|
class Monitor {
|
|
10
10
|
constructor(e) {
|
|
11
|
-
var
|
|
11
|
+
var r, t;
|
|
12
12
|
Object.defineProperty(this, "endpoint", {
|
|
13
13
|
enumerable: !0,
|
|
14
14
|
configurable: !0,
|
|
@@ -19,6 +19,16 @@ class Monitor {
|
|
|
19
19
|
configurable: !0,
|
|
20
20
|
writable: !0,
|
|
21
21
|
value: void 0
|
|
22
|
+
}), Object.defineProperty(this, "replayEndpoint", {
|
|
23
|
+
enumerable: !0,
|
|
24
|
+
configurable: !0,
|
|
25
|
+
writable: !0,
|
|
26
|
+
value: ""
|
|
27
|
+
}), Object.defineProperty(this, "isBusinessError", {
|
|
28
|
+
enumerable: !0,
|
|
29
|
+
configurable: !0,
|
|
30
|
+
writable: !0,
|
|
31
|
+
value: void 0
|
|
22
32
|
}), Object.defineProperty(this, "timeoutDuration", {
|
|
23
33
|
enumerable: !0,
|
|
24
34
|
configurable: !0,
|
|
@@ -80,53 +90,53 @@ class Monitor {
|
|
|
80
90
|
writable: !0,
|
|
81
91
|
value: void 0
|
|
82
92
|
}), this.options = e, this.endpoint = e.endpoint, this.projectKey = e.projectKey,
|
|
83
|
-
this.timeoutDuration = null !== (
|
|
84
|
-
this.errorQueue = [], this.requestQueue = [], this.maxQueueSize = null !== (
|
|
85
|
-
this.sendTimer = null, this.
|
|
93
|
+
this.isBusinessError = e.isBusinessError, this.timeoutDuration = null !== (r = e.timeoutDuration) && void 0 !== r ? r : 6e4,
|
|
94
|
+
this.errorQueue = [], this.requestQueue = [], this.maxQueueSize = null !== (t = e.maxQueueSize) && void 0 !== t ? t : 10,
|
|
95
|
+
this.sendTimer = null, this.originalXHR = window.XMLHttpRequest, this.originalFetch = window.fetch,
|
|
96
|
+
this.originalOnerror = window.onerror, this.reporter = (0, exception_1.createReporter)({
|
|
86
97
|
endpoint: e.endpoint,
|
|
87
98
|
projectKey: e.projectKey,
|
|
88
99
|
release: e.release,
|
|
89
100
|
environment: e.environment,
|
|
90
101
|
maxBatch: e.maxBatch,
|
|
91
102
|
flushInterval: e.flushInterval
|
|
92
|
-
}, (0, exception_1.makeH5Transport)(e.endpoint)), this.init(), this.initReplay()
|
|
93
|
-
this.originalXHR = window.XMLHttpRequest, this.originalFetch = window.fetch, this.originalOnerror = window.onerror;
|
|
103
|
+
}, (0, exception_1.makeH5Transport)(e.endpoint)), this.init(), this.initReplay();
|
|
94
104
|
}
|
|
95
105
|
init() {
|
|
96
106
|
modules_1.onWindowErr.call(this), modules_1.onLongTask.call(this), modules_1.onPaint.call(this),
|
|
97
|
-
modules_1.onTiming.call(this), modules_1.onXHR.call(this);
|
|
107
|
+
modules_1.onTiming.call(this), modules_1.onXHR.call(this), modules_1.onFetch.call(this);
|
|
98
108
|
}
|
|
99
109
|
initReplay() {
|
|
100
|
-
var e,
|
|
101
|
-
const
|
|
102
|
-
if (!(null ==
|
|
103
|
-
const i = null !== (e =
|
|
110
|
+
var e, r;
|
|
111
|
+
const t = this.options.replay;
|
|
112
|
+
if (!(null == t ? void 0 : t.enabled)) return;
|
|
113
|
+
const i = null !== (e = t.sampleRate) && void 0 !== e ? e : 1;
|
|
104
114
|
if (Math.random() >= i) return;
|
|
105
|
-
const o = null !== (
|
|
106
|
-
o && (this.replay = new replay_1.ReplayController({
|
|
115
|
+
const o = null !== (r = t.replayEndpoint) && void 0 !== r ? r : (0, replay_1.deriveReplayEndpoint)(this.endpoint);
|
|
116
|
+
o && (this.replayEndpoint = o, this.replay = new replay_1.ReplayController({
|
|
107
117
|
replayEndpoint: o,
|
|
108
118
|
projectKey: this.projectKey,
|
|
109
|
-
bufferSeconds:
|
|
110
|
-
maxUploadsPerSession:
|
|
111
|
-
minUploadIntervalMs:
|
|
112
|
-
maxReplayBytes:
|
|
113
|
-
captureRequest:
|
|
114
|
-
maskTextClass:
|
|
119
|
+
bufferSeconds: t.bufferSeconds,
|
|
120
|
+
maxUploadsPerSession: t.maxUploadsPerSession,
|
|
121
|
+
minUploadIntervalMs: t.minUploadIntervalMs,
|
|
122
|
+
maxReplayBytes: t.maxReplayBytes,
|
|
123
|
+
captureRequest: t.captureRequest,
|
|
124
|
+
maskTextClass: t.maskTextClass
|
|
115
125
|
}), this.replay.start());
|
|
116
126
|
}
|
|
117
127
|
isDuplicateError(e) {
|
|
118
|
-
var
|
|
119
|
-
const i = null !== (
|
|
128
|
+
var r, t;
|
|
129
|
+
const i = null !== (r = this.options.errorDedupeMs) && void 0 !== r ? r : 0;
|
|
120
130
|
if (i <= 0 || "error" !== e.type) return !1;
|
|
121
|
-
const o = `${e.errorType}|${e.message}|${null !== (
|
|
131
|
+
const o = `${e.errorType}|${e.message}|${null !== (t = e.filename) && void 0 !== t ? t : ""}`, n = Date.now(), s = this.errorSentAt.get(o);
|
|
122
132
|
if (void 0 !== s && n - s < i) return !0;
|
|
123
|
-
if (this.errorSentAt.size >= 100) for (const [e,
|
|
133
|
+
if (this.errorSentAt.size >= 100) for (const [e, r] of this.errorSentAt) n - r >= i && this.errorSentAt.delete(e);
|
|
124
134
|
return this.errorSentAt.set(o, n), !1;
|
|
125
135
|
}
|
|
126
136
|
send(e) {
|
|
127
|
-
var
|
|
137
|
+
var r;
|
|
128
138
|
if (this.isDuplicateError(e)) return;
|
|
129
|
-
const
|
|
139
|
+
const t = (0, index_1.getLogBaseData)(), i = (0, toExcEvent_1.toExcEvents)(e, t, this.options), o = null === (r = this.replay) || void 0 === r ? void 0 : r.captureIfTriggered(e);
|
|
130
140
|
if (o) for (const e of i) e.device = {
|
|
131
141
|
...e.device,
|
|
132
142
|
replayId: o
|
|
@@ -149,11 +159,11 @@ class Monitor {
|
|
|
149
159
|
}), this.errorQueue = []);
|
|
150
160
|
}
|
|
151
161
|
captureRequest(e) {
|
|
152
|
-
var
|
|
162
|
+
var r;
|
|
153
163
|
if (!e.type || ![ "xhr", "fetch" ].includes(e.type)) return;
|
|
154
|
-
if ((0, toExcEvent_1.isExceptionReportUrl)(String(null !== (
|
|
155
|
-
const
|
|
156
|
-
for (const
|
|
164
|
+
if ((0, toExcEvent_1.isExceptionReportUrl)(String(null !== (r = e.url) && void 0 !== r ? r : ""), this.endpoint)) return;
|
|
165
|
+
const t = [ "url", "method", "duration", "status", "success", "startTime" ];
|
|
166
|
+
for (const r of t) if (void 0 === e[r]) return;
|
|
157
167
|
e.page = window.location.href, this.requestQueue.push(e), this.requestQueue.length >= this.maxQueueSize && this.reportRequest();
|
|
158
168
|
}
|
|
159
169
|
sendQueuedData() {
|
package/dist/monitor.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Monitor={})}(this,function(e){"use strict";var t=Object.defineProperty,i=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(e,i,r)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,l=(e,t)=>{for(var i in t||(t={}))n.call(t,i)&&a(e,i,t[i]);if(o)for(var i of o(t))s.call(t,i)&&a(e,i,t[i]);return e},u=(e,t)=>i(e,r(t)),c=(e,t,i)=>a(e,"symbol"!=typeof t?t+"":t,i),d=(e,t,i)=>new Promise((r,o)=>{var n=e=>{try{a(i.next(e))}catch(t){o(t)}},s=e=>{try{a(i.throw(e))}catch(t){o(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,s);a((i=i.apply(e,t)).next())});const h="0.0.1";class p{constructor(e,t){c(this,"buffer",[]),c(this,"timer",null),c(this,"sending",!1),this.options=e,this.transport=t}capture(e){var t,i,r,o,n;const s=null!=(t=this.options.sampleRate)?t:100;s<100&&100*Math.random()>=s||(this.buffer.push(u(l({},e),{level:null!=(i=e.level)?i:"ERROR",occurredAt:null!=(r=e.occurredAt)?r:(new Date).toISOString(),sdkVersion:null!=(o=e.sdkVersion)?o:h})),this.buffer.length>100&&(this.buffer=this.buffer.slice(-100)),this.buffer.length>=(null!=(n=this.options.maxBatch)?n:20)?this.flush():this.ensureTimer())}flush(){return d(this,null,function*(){if(this.sending||0===this.buffer.length)return;this.clearTimer(),this.sending=!0;const e=this.buffer;this.buffer=[];try{yield this.transport({events:e},this.options.projectKey)}catch(t){403!==(null==t?void 0:t.statusCode)&&(this.buffer=[...e,...this.buffer].slice(-100),this.ensureTimer())}finally{this.sending=!1}})}destroy(){this.clearTimer(),this.flush()}ensureTimer(){var e;this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},null!=(e=this.options.flushInterval)?e:3e4))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}}function w(e,t){return new p(e,t)}function m(e){return(t,i)=>d(null,null,function*(){const r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json","X-Project-Key":i},body:JSON.stringify(t),keepalive:!0});if(!r.ok)throw Object.assign(new Error(`monitor: 上报失败 ${r.status}`),{statusCode:r.status})})}let b,f;function g(){return b}["click","touchstart","mousedown","keydown"].forEach(e=>{document.addEventListener(e,e=>{b=e,f=e.path||e.composedPath()},{capture:!0,passive:!0})});var v,y="user-agent",k="",x="function",T="object",S="string",C="undefined",O="browser",R="cpu",E="device",q="engine",P="os",j="result",M="name",A="type",I="vendor",H="version",$="architecture",U="major",_="model",F="console",L="mobile",z="tablet",N="smarttv",D="wearable",B="xr",V="embedded",Q="inapp",X="brands",W="formFactors",G="fullVersionList",K="platform",J="platformVersion",Y="bitness",Z="sec-ch-ua",ee=Z+"-full-version-list",te=Z+"-arch",ie=Z+"-"+Y,re=Z+"-form-factors",oe=Z+"-"+L,ne=Z+"-"+_,se=Z+"-"+K,ae=se+"-version",le=[X,G,L,_,K,J,$,W,Y],ue="Amazon",ce="Apple",de="ASUS",he="BlackBerry",pe="Google",we="Huawei",me="Lenovo",be="Honor",fe="LG",ge="Microsoft",ve="Motorola",ye="Nvidia",ke="OnePlus",xe="OPPO",Te="Samsung",Se="Sharp",Ce="Sony",Oe="Xiaomi",Re="Zebra",Ee="Chrome",qe="Chromium",Pe="Chromecast",je="Edge",Me="Firefox",Ae="Opera",Ie="Facebook",He="Sogou",$e="Mobile ",Ue=" Browser",_e="Windows",Fe=typeof window!==C&&window.navigator?window.navigator:void 0,Le=Fe&&Fe.userAgentData?Fe.userAgentData:void 0,ze=function(e){for(var t={},i=0;i<e.length;i++)t[e[i].toUpperCase()]=e[i];return t},Ne=function(e,t){if(typeof e===T&&e.length>0){for(var i in e)if(Qe(t)==Qe(e[i]))return!0;return!1}return!!Be(e)&&Qe(t)==Qe(e)},De=function(e,t){for(var i in e)return/^(browser|cpu|device|engine|os)$/.test(i)||!!t&&De(e[i])},Be=function(e){return typeof e===S},Ve=function(e){if(e){for(var t=[],i=We(e).split(","),r=0;r<i.length;r++)if(i[r].indexOf(";")>-1){var o=Je(i[r]).split(";v=");t[r]={brand:o[0],version:o[1]}}else t[r]=Je(i[r]);return t}},Qe=function(e){return Be(e)?e.toLowerCase():e},Xe=function(e){return Be(e)?Ke(/[^\d\.]/g,e).split(".")[0]:void 0},We=function(e){return Be(e)?Je(Ke(/\\?\"/g,e),500):void 0},Ge=function(e){for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];typeof i==T&&2==i.length?this[i[0]]=i[1]:this[i]=void 0}return this},Ke=function(e,t){return Be(t)?t.replace(e,k):t},Je=function(e,t){return e=Ke(/^\s\s*/,String(e)),typeof t===C?e:e.substring(0,t)},Ye=function(e,t){if(e&&t)for(var i,r,o,n,s,a,l=0;l<t.length&&!s;){var u=t[l],c=t[l+1];for(i=r=0;i<u.length&&!s&&u[i];)if(s=u[i++].exec(e))for(o=0;o<c.length;o++)a=s[++r],typeof(n=c[o])===T&&n.length>0?2===n.length?typeof n[1]==x?this[n[0]]=n[1].call(this,a):this[n[0]]=n[1]:n.length>=3&&(typeof n[1]!==x||n[1].exec&&n[1].test?3==n.length?this[n[0]]=a?a.replace(n[1],n[2]):void 0:4==n.length?this[n[0]]=a?n[3].call(this,a.replace(n[1],n[2])):void 0:n.length>4&&(this[n[0]]=a?n[3].apply(this,[a.replace(n[1],n[2])].concat(n.slice(4))):void 0):n.length>3?this[n[0]]=a?n[1].apply(this,n.slice(2)):void 0:this[n[0]]=a?n[1].call(this,a,n[2]):void 0):this[n]=a||void 0;l+=2}},Ze=function(e,t){for(var i in t)if(typeof t[i]===T&&t[i].length>0){for(var r=0;r<t[i].length;r++)if(Ne(t[i][r],e))return"?"===i?void 0:i}else if(Ne(t[i],e))return"?"===i?void 0:i;return t.hasOwnProperty("*")?t["*"]:e},et={ME:"4.90","NT 3.51":"3.51","NT 4.0":"4.0",2e3:["5.0","5.01"],XP:["5.1","5.2"],Vista:"6.0",7:"6.1",8:"6.2",8.1:"6.3",10:["6.4","10.0"],NT:""},tt={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},it={Chrome:"Google Chrome",Edge:"Microsoft Edge","Edge WebView2":"Microsoft Edge WebView2","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome","Huawei Browser":"HuaweiBrowser","MIUI Browser":"Miui Browser","Opera Mobi":"OperaMobile",Yandex:"YaBrowser"},rt={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[H,[M,$e+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[H,[M,je+" WebView"],[A,Q]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[H,[M,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[M,H],[/opios[\/ ]+([\w\.]+)/i],[H,[M,Ae+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[H,[M,Ae+" GX"]],[/\bopr\/([\w\.]+)/i],[H,[M,Ae]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[H,[M,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[H,[M,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(atlas|flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:hi|lg |ovi|qute)browser|palemoon)\/v?([-\w\.]+)/i,/(brave)(?: chrome)?\/([\d\.]+)/i,/(aloha|heytap|ovi|115|surf|qwant)browser\/([\d\.]+)/i,/(qwant)(?:ios|mobile)\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[M,H],[/quark(?:pc)?\/([-\w\.]+)/i],[H,[M,"Quark"]],[/\bddg\/([\w\.]+)/i],[H,[M,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb| ucpc)[\/ ]?([\w\.]+)/i],[H,[M,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[H,[M,"WeChat"]],[/konqueror\/([\w\.]+)/i],[H,[M,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[H,[M,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[H,[M,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[H,[M,"Smart "+me+Ue]],[/(av(?:ast|g|ira))\/([\w\.]+)/i],[[M,/(.+)/,"$1 Secure"+Ue],H],[/norton\/([\w\.]+)/i],[H,[M,"Norton Private"+Ue]],[/\bfocus\/([\w\.]+)/i],[H,[M,Me+" Focus"]],[/ mms\/([\w\.]+)$/i],[H,[M,Ae+" Neon"]],[/ opt\/([\w\.]+)$/i],[H,[M,Ae+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[H,[M,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[H,[M,"Dolphin"]],[/coast\/([\w\.]+)/i],[H,[M,Ae+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[H,[M,"MIUI"+Ue]],[/fxios\/([\w\.-]+)/i],[H,[M,$e+Me]],[/\bqihoobrowser\/?([\w\.]*)/i],[H,[M,"360"]],[/\b(qq)\/([\w\.]+)/i],[[M,/(.+)/,"$1Browser"],H],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[M,/(.+)/,"$1"+Ue],H],[/ HBPC\/([\w\.]+)/],[H,[M,we+Ue]],[/samsungbrowser\/([\w\.]+)/i],[H,[M,Te+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[H,[M,He+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[M,He+" Mobile"],H],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[M,H],[/(lbbrowser|luakit|rekonq|steam(?= (clie|tenf|gameo)))/i],[M],[/ome\/([\w\.]+).+(iron(?= saf)|360(?=[es]e$))/i],[H,M],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[M,Ie],H,[A,Q]],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(bing)(?:web|sapphire)\/([\w\.]+)/i,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[M,H,[A,Q]],[/\bgsa\/([\w\.]+) .*safari\//i],[H,[M,"GSA"],[A,Q]],[/(?:musical_ly|trill)(?:.+app_?version\/|_)([\w\.]+)/i],[H,[M,"TikTok"],[A,Q]],[/\[(linkedin)app\]/i],[M,[A,Q]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[M,/(.+)/,"Zalo"],H,[A,Q]],[/(chromium)[\/ ]([-\w\.]+)/i],[M,H],[/ome-(lighthouse)$/i],[M,[A,"fetcher"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[H,[M,Ee+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[H,[M,je+" WebView2"],[A,Q]],[/; wv\).+(chrome)\/([\w\.]+)/i],[[M,Ee+" WebView"],H,[A,Q]],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[H,[M,"Android"+Ue]],[/chrome\/([\w\.]+) mobile/i],[H,[M,$e+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[M,H],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[H,[M,$e+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[M,$e+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[H,M],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[M,[H,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[M,H],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[M,$e+Me],H],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[M,"Netscape"],H],[/(wolvic|librewolf)\/([\w\.]+)/i],[M,H],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[H,[M,Me+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+(?= .+rv\:.+gecko\/\d+)|[0-4][\w\.]+(?!.+compatible))/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[M,[H,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[M,[H,/[^\d\.]+./,k]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[$,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[$,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[$,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[$,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[$,"arm"]],[/ sun4\w[;\)]/i],[[$,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i,/((ppc|powerpc)(64)?)( mac|;|\))/i,/(?:osf1|[freopnt]{3,4}bsd) (alpha)/i],[[$,/ower/,k,Qe]],[/mc680.0/i],[[$,"68k"]],[/winnt.+\[axp/i],[[$,"alpha"]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[_,[I,Te],[A,z]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,/sec-(sgh\w+)/i],[_,[I,Te],[A,L]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[_,[I,ce],[A,L]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[_,[I,ce],[A,z]],[/(macintosh);/i],[_,[I,ce]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[_,[I,Se],[A,L]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[_,[I,be],[A,z]],[/honor([-\w ]+)[;\)]/i],[_,[I,be],[A,L]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[_,[I,we],[A,z]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[_,[I,we],[A,L]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b(?:xiao)?((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[_,/_/g," "],[I,Oe],[A,z]],[/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/oid[^\)]+; (redmi[\-_ ]?(?:note|k)?[\w_ ]+|m?[12]\d[01]\d\w{3,6}|poco[\w ]+|(shark )?\w{3}-[ah]0|qin ?[1-3](s\+|ultra| pro)?)( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note|max|cc)?[_ ]?(?:\d{0,2}\w?)[_ ]?(?:plus|se|lite|pro)?( 5g|lte)?)(?: bui|\))/i,/; ([\w ]+) miui\/v?\d/i],[[_,/_/g," "],[I,Oe],[A,L]],[/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-l]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[_,[I,ke],[A,L]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[_,[I,xe],[A,L]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[_,[I,Ze,{OnePlus:["203","304","403","404","413","415"],"*":xe}],[A,z]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[_,[I,"BLU"],[A,L]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[_,[I,"Vivo"],[A,L]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[_,[I,"Realme"],[A,L]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[_,[I,me],[A,z]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[_,[I,me],[A,L]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,/((?:moto(?! 360)[-\w\(\) ]+|xt\d{3,4}[cgkosw\+]?[-\d]*|nexus 6)(?= bui|\)))/i],[_,[I,ve],[A,L]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[_,[I,ve],[A,z]],[/\b(?:lg)?([vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[_,[I,fe],[A,z]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[_,[I,fe],[A,L]],[/(nokia) (t[12][01])/i],[I,_,[A,z]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[_,/_/g," "],[A,L],[I,"Nokia"]],[/(pixel (c|tablet))\b/i],[_,[I,pe],[A,z]],[/droid.+;(?: google)? (g(01[13]a|020[aem]|025[jn]|1b60|1f8f|2ybb|4s1m|576d|5nz6|8hhn|8vou|a02099|c15s|d1yq|e2ae|ec77|gh2x|kv4x|p4bc|pj41|r83y|tt9q|ur25|wvk6)|pixel[\d ]*a?( pro)?( xl)?( fold)?( \(5g\))?)( bui|\))/i],[_,[I,pe],[A,L]],[/(google) (pixelbook( go)?)/i],[I,_],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-\w\w\d\d)(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[_,[I,Ce],[A,L]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[_,"Xperia Tablet"],[I,Ce],[A,z]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[_,[I,ue],[A,z]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[_,/(.+)/g,"Fire Phone $1"],[I,ue],[A,L]],[/(playbook);[-\w\),; ]+(rim)/i],[_,I,[A,z]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[_,[I,he],[A,L]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[_,[I,de],[A,z]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[_,[I,de],[A,L]],[/(nexus 9)/i],[_,[I,"HTC"],[A,z]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[I,[_,/_/g," "],[A,L]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[_,[I,"TCL"],[A,z]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[_,[I,"TCL"],[A,L]],[/(itel) ((\w+))/i],[[I,Qe],_,[A,Ze,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[_,[I,"Acer"],[A,z]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[_,[I,"Meizu"],[A,L]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[_,[I,"Ulefone"],[A,L]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[_,[I,"Energizer"],[A,L]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[_,[I,"Cat"],[A,L]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[_,[I,"Smartfren"],[A,L]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[_,[I,"Nothing"],[A,L]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[_,[I,"Archos"],[A,z]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[_,[I,"Archos"],[A,L]],[/blackview ([-\w ]+)( b|\))/i,/; (bv\d{4}[-\w ]*)( b|\))/i],[_,[I,"Blackview"],[A,L]],[/; (n159v)/i],[_,[I,"HMD"],[A,L]],[/((revvl[ \w\+]+|tm(?:rv|af)\w*[45]g(?:tb)?))( b|\))/i],[_,[A,function(e,t){return t.test.test(e)?t.ifTrue:t.ifFalse},{test:/ta?b/i,ifTrue:z,ifFalse:L}],[I,"T-Mobile"]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[I,_,[A,z]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|coolpad|cubot|hmd|imo|infinix|lava|oneplus|tcl|wiko)[_ ]([-\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i,/(hisense) ([ehv][\w ]+)\)/i,/droid[^;]+; (philips)[_ ]([sv-x][\d]{3,4}[xz]?)/i],[I,_,[A,L]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[I,_,[A,z]],[/(surface duo)/i],[_,[I,ge],[A,z]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[_,[I,"Fairphone"],[A,L]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[_,[I,ye],[A,z]],[/(sprint) (\w+)/i],[I,_,[A,L]],[/(kin\.[onetw]{3})/i],[[_,/\./g," "],[I,ge],[A,L]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[_,[I,Re],[A,z]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[_,[I,Re],[A,L]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[I,[A,N]],[/hbbtv.+maple;(\d+)/i],[[_,/^/,"SmartTV"],[I,Te],[A,N]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[I,_,[A,N]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[I,fe],[A,N]],[/(apple) ?tv/i],[I,[_,ce+" TV"],[A,N]],[/crkey.*devicetype\/chromecast/i],[[_,Pe+" Third Generation"],[I,pe],[A,N]],[/crkey.*devicetype\/([^/]*)/i],[[_,/^/,"Chromecast "],[I,pe],[A,N]],[/fuchsia.*crkey/i],[[_,Pe+" Nest Hub"],[I,pe],[A,N]],[/crkey/i],[[_,Pe],[I,pe],[A,N]],[/(portaltv)/i],[_,[I,Ie],[A,N]],[/droid.+aft(\w+)( bui|\))/i],[_,[I,ue],[A,N]],[/(shield \w+ tv)/i],[_,[I,ye],[A,N]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[_,[I,Se],[A,N]],[/(bravia[\w ]+)( bui|\))/i],[_,[I,Ce],[A,N]],[/(mi(tv|box)-?\w+) bui/i],[_,[I,Oe],[A,N]],[/Hbbtv.*(technisat) (.*);/i],[I,_,[A,N]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[I,/.+\/(\w+)/,"$1",Ze,{LG:"lge"}],[_,Je],[A,N]],[/(playstation \w+)/i],[_,[I,Ce],[A,F]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[_,[I,ge],[A,F]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i,/(valve).+(steam deck)/i,/droid.+; ((shield|rgcube|gr0006))( bui|\))/i],[[I,Ze,{Nvidia:"Shield",Anbernic:"RGCUBE",Logitech:"GR0006"}],_,[A,F]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[_,[I,Te],[A,D]],[/((pebble))app/i,/(asus|google|lg|oppo|xiaomi) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[I,_,[A,D]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[_,[I,xe],[A,D]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[_,[I,ce],[A,D]],[/(opwwe\d{3})/i],[_,[I,ke],[A,D]],[/(moto 360)/i],[_,[I,ve],[A,D]],[/(smartwatch 3)/i],[_,[I,Ce],[A,D]],[/(g watch r)/i],[_,[I,fe],[A,D]],[/droid.+; (wt63?0{2,3})\)/i],[_,[I,Re],[A,D]],[/droid.+; (glass) \d/i],[_,[I,pe],[A,B]],[/(pico) ([\w ]+) os\d/i],[I,_,[A,B]],[/(quest( \d| pro)?s?).+vr/i],[_,[I,Ie],[A,B]],[/mobile vr; rv.+firefox/i],[[A,B]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[I,[A,V]],[/(aeobc)\b/i],[_,[I,ue],[A,V]],[/(homepod).+mac os/i],[_,[I,ce],[A,V]],[/windows iot/i],[[A,V]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[_,[A,N]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[A,N]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[_,[A,Ze,{mobile:"Mobile",xr:"VR","*":z}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[A,z]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[A,L]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[_,[I,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[H,[M,je+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[M,H],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[H,[M,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links|dillo)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[M,H],[/ladybird\//i],[[M,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[H,M]],os:[[/(windows nt) (6\.[23]); arm/i],[[M,/N/,"R"],[H,Ze,et]],[/(windows (?:phone|mobile|iot))(?: os)?[\/ ]?([\d\.]*( se)?)/i,/(windows)[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i],[M,H],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[H,/(;|\))/g,"",Ze,et],[M,_e]],[/(windows ce)\/?([\d\.]*)/i],[M,H],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv|ios(?=.+ip(?:ad|hone)|.+apple ?tv)|ip(?:ad|hone)(?: |.+i(?:pad)?)os|apple ?tv.+ios)[\/ ]([\w\.]+)/i,/\btvos ?([\w\.]+)/i,/cfnetwork\/.+darwin/i],[[H,/_/g,"."],[M,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[M,"macOS"],[H,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[H,[M,Pe+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[H,[M,Pe+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[H,[M,Pe+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[H,[M,Pe+" Linux"]],[/crkey\/([\d\.]+)/i],[H,[M,Pe]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[H,M],[/(ubuntu) ([\w\.]+) like android/i],[[M,/(.+)/,"$1 Touch"],H],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[M,H],[/\(bb(10);/i],[H,[M,he]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[H,[M,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile[;\w ]*|tablet|tv|[^\)]*(?:viera|lg(?:l25|-d300)|alcatel ?o.+|y300-f1)); rv:([\w\.]+)\).+gecko\//i],[H,[M,Me+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[H,[M,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[H,Ze,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[M,"webOS"]],[/watch(?: ?os[,\/ ]|\d,\d\/)([\d\.]+)/i],[H,[M,"watchOS"]],[/cros [\w]+(?:\)| ([\w\.]+)\b)/i],[H,[M,"Chrome OS"]],[/kepler ([\w\.]+); (aft|aeo)/i],[H,[M,"Vega OS"]],[/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/linux.+(mint)[\/\(\) ]?([\w\.]*)/i,/(mageia|vectorlinux|fuchsia|arcaos|arch(?= ?linux))[;l ]([\d\.]*)/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire|knoppix)(?: gnu[\/ ]linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/\b(aix)[; ]([1-9\.]{0,4})/i,/(hurd|linux|morphos)(?: (?:arm|x86|ppc)\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) ?(r\d)?/i],[M,H],[/(sunos) ?([\d\.]*)/i],[[M,"Solaris"],H],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[M,H]]},ot=(Ge.call((v={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[O,[M,H,U,A]],[R,[$]],[E,[A,_,I]],[q,[M,H]],[P,[M,H]]]),Ge.call(v.isIgnore,[[O,[H,U]],[q,[H]],[P,[H]]]),Ge.call(v.isIgnoreRgx,[[O,/ ?browser$/i],[P,/ ?os$/i]]),Ge.call(v.toString,[[O,[M,H]],[R,[$]],[E,[I,_]],[q,[M,H]],[P,[M,H]]]),v),nt=function(e,t){var i=ot.init[t],r=ot.isIgnore[t]||0,o=ot.isIgnoreRgx[t]||0,n=ot.toString[t]||0;function s(){Ge.call(this,i)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Le?Le.getHighEntropyValues(le).then(function(t){return e.setCH(new st(t,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=j&&(s.prototype.is=function(e){var t=!1;for(var i in this)if(this.hasOwnProperty(i)&&!Ne(r,i)&&Qe(o?Ke(o,this[i]):this[i])==Qe(o?Ke(o,e):e)){if(t=!0,e!=C)break}else if(e==C&&t){t=!t;break}return t},s.prototype.toString=function(){var e=k;for(var t in n)typeof this[n[t]]!==C&&(e+=(e?" ":k)+this[n[t]]);return e||C}),s.prototype.then=function(e){var t=this,i=function(){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])};i.prototype={is:s.prototype.is,toString:s.prototype.toString,withClientHints:s.prototype.withClientHints,withFeatureCheck:s.prototype.withFeatureCheck};var r=new i;return e(r),r},new s};function st(e,t){if(e=e||{},Ge.call(this,le),t)Ge.call(this,[[X,Ve(e[Z])],[G,Ve(e[ee])],[L,/\?1/.test(e[oe])],[_,We(e[ne])],[K,We(e[se])],[J,We(e[ae])],[$,We(e[te])],[W,Ve(e[re])],[Y,We(e[ie])]]);else for(var i in e)this.hasOwnProperty(i)&&typeof e[i]!==C&&(this[i]=e[i])}function at(e,t,i,r){return Ge.call(this,[["itemType",e],["ua",t],["uaCH",r],["rgxMap",i],["data",nt(this,e)]]),this}function lt(e,t,i){if(typeof e===T?(De(e,!0)?(typeof t===T&&(i=t),t=e):(i=e,t=void 0),e=void 0):typeof e!==S||De(t,!0)||(i=t,t=void 0),i)if(typeof i.append===x){var r={};i.forEach(function(e,t){r[String(t).toLowerCase()]=e}),i=r}else{var o={};for(var n in i)i.hasOwnProperty(n)&&(o[String(n).toLowerCase()]=i[n]);i=o}if(!(this instanceof lt))return new lt(e,t,i).getResult();var s=typeof e===S?e:i&&i[y]?i[y]:Fe&&Fe.userAgent?Fe.userAgent:k,a=new st(i,!0),l=rt,u=function(e){return e==j?function(){return new at(e,s,l,a).set("ua",s).set(O,this.getBrowser()).set(R,this.getCPU()).set(E,this.getDevice()).set(q,this.getEngine()).set(P,this.getOS()).get()}:function(){return new at(e,s,l[e],a).parseUA().get()}};return Ge.call(this,[["getBrowser",u(O)],["getCPU",u(R)],["getDevice",u(E)],["getEngine",u(q)],["getOS",u(P)],["getResult",u(j)],["getUA",function(){return s}],["setUA",function(e){return Be(e)&&(s=Je(e,500)),this}],["useExtension",function(e){return e&&(l=function(e,t){var i={},r=t;if(!De(t))for(var o in r={},t)for(var n in t[o])r[n]=t[o][n].concat(r[n]?r[n]:[]);for(var s in e)i[s]=r[s]&&r[s].length%2==0?r[s].concat(e[s]):e[s];return i}(l,e)),this}]]).setUA(s).useExtension(t),this}at.prototype.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:void 0:this.data},at.prototype.set=function(e,t){return this.data[e]=t,this},at.prototype.setCH=function(e){return this.uaCH=e,this},at.prototype.detectFeature=function(){if(Fe&&Fe.userAgent==this.ua)switch(this.itemType){case O:Fe.brave&&typeof Fe.brave.isBrave==x&&this.set(M,"Brave");break;case E:!this.get(A)&&Le&&Le[L]&&this.set(A,L),"Macintosh"==this.get(_)&&Fe&&typeof Fe.standalone!==C&&Fe.maxTouchPoints&&Fe.maxTouchPoints>2&&this.set(_,"iPad").set(A,z);break;case P:!this.get(M)&&Le&&Le[K]&&this.set(M,Le[K]);break;case j:var e=this.data,t=function(t){return e[t].getItem().detectFeature().get()};this.set(O,t(O)).set(R,t(R)).set(E,t(E)).set(q,t(q)).set(P,t(P))}return this},at.prototype.parseUA=function(){switch(this.itemType!=j&&Ye.call(this.data,this.ua,this.rgxMap),this.itemType){case O:this.set(U,Xe(this.get(H)));break;case P:if("iOS"==this.get(M)&&this.get(H)&&/^1[89][^\d]/.exec(this.get(H))){var e=/\) Version\/((\d+)[\d\.]*)/.exec(this.ua);e&&parseInt(e[2],10)>=26&&this.set(H,e[1])}}return this},at.prototype.parseCH=function(){var e=this.uaCH,t=this.rgxMap;switch(this.itemType){case O:case q:var i,r=e[G]||e[X];if(r)for(var o=0;o<r.length;o++){var n=r[o].brand||r[o],s=r[o].version;this.itemType==O&&!/not.a.brand/i.test(n)&&(!i||/Chrom/.test(i)&&n!=qe||i==je&&/WebView2/.test(n))&&(n=Ze(n,it),(i=this.get(M))&&!/Chrom/.test(i)&&/Chrom/.test(n)||this.set(M,n).set(H,s).set(U,Xe(s)),i=n),this.itemType==q&&n==qe&&this.set(H,s)}break;case R:var a=e[$];a&&(a&&"64"==e[Y]&&(a+="64"),Ye.call(this.data,a+";",t));break;case E:if(e[L]&&this.set(A,L),e[_]&&(this.set(_,e[_]),!this.get(A)||!this.get(I))){var l={};Ye.call(l,"droid 9; "+e[_]+")",t),!this.get(A)&&l.type&&this.set(A,l.type),!this.get(I)&&l.vendor&&this.set(I,l.vendor)}if(e[W]){var u;if("string"!=typeof e[W])for(var c=0;!u&&c<e[W].length;)u=Ze(e[W][c++],tt);else u=Ze(e[W],tt);this.set(A,u)}break;case P:var d=e[K];if(d){var h=e[J];d==_e&&(h=parseInt(Xe(h),10)>=13?"11":"10"),this.set(M,d).set(H,h)}this.get(M)==_e&&"Xbox"==e[_]&&this.set(M,"Xbox").set(H,void 0);break;case j:var p=this.data,w=function(t){return p[t].getItem().setCH(e).parseCH().get()};this.set(O,w(O)).set(R,w(R)).set(E,w(E)).set(q,w(q)).set(P,w(P))}return this},lt.VERSION="2.0.10",lt.BROWSER=ze([M,H,U,A]),lt.CPU=ze([$]),lt.DEVICE=ze([_,I,A,F,L,N,z,D,V]),lt.ENGINE=lt.OS=ze([M,H]);const{browser:ut,device:ct,os:dt}=lt(navigator.userAgent);function ht(e){return e!==window&&e!==document&&e!==document.documentElement}function pt(e){return e.id?`${e.nodeName.toLowerCase()}#${e.id}`:e.className&&"string"==typeof e.className?`${e.nodeName.toLowerCase()}#${e.className}`:e.nodeName.toLowerCase()}function wt(e){const t=f;if(Array.isArray(t))return function(e){return e.reverse().filter(ht).map(pt).join(" ")}(t)}function mt(e){return e.split("\n").slice(1).map(e=>e.replace(/^\s+at\s+/g,"")).join("\n")}function bt(){try{return location.href}catch(e){return""}}function ft(e){return{title:e.title,url:e.url,browser:e.browser,os:e.os,deviceInfo:e.device,userAgent:e.userAgent}}function gt(e,t){return{page:bt(),userId:t.userId,release:t.release,environment:t.environment,device:ft(e)}}function vt(e,t,i){const r=gt(t,i);return"promiseError"===e.errorType?u(l({type:"unhandledrejection",level:"ERROR",message:e.message,stack:e.stack},r),{device:u(l({},r.device),{selector:e.selector,filename:e.filename,position:e.position,errorType:e.errorType})}):u(l({type:"error",level:"ERROR",message:e.message,stack:e.stack},r),{device:u(l({},r.device),{selector:e.selector,isWhiteScreen:e.isWhiteScreen,filename:e.filename,position:e.position,errorType:e.errorType})})}function yt(e,t,i){const r=gt(t,i);return u(l({type:"paint",level:"INFO",message:"paint metrics"},r),{device:u(l({},r.device),{FP:e.FP,FCP:e.FCP,FMP:e.FMP,LCP:e.LCP})})}function kt(e,t,i){const r=gt(t,i);return u(l({type:"timing",level:"INFO",message:"timing metrics"},r),{device:u(l({},r.device),{DOMContentLoadedTime:e.DOMContentLoadedTime,loadTime:e.loadTime})})}function xt(e,t,i){const r=gt(t,i);return u(l({type:"longTask",level:e.duration>=100?"WARN":"INFO",message:`long task ${e.duration}ms`},r),{device:u(l({},r.device),{startTime:e.startTime,duration:e.duration,selector:e.selector,eventType:e.eventType})})}function Tt(e,t,i){var r,o,n;if(!1!==e.success)return null;const s=String(null!=(r=e.url)?r:""),a=String(null!=(o=e.method)?o:"GET").toUpperCase(),c=null!=(n=e.status)?n:0,d=0===c?"network":String(c),h=gt(t,i);return u(l({type:"request",level:"ERROR",message:`Request failed [${d}]: ${a} ${s}`},h),{device:u(l({},h.device),{durationMs:e.duration,msg:e.msg})})}function St(e,t,i){if("error"===e.type)return[vt(e,t,i)];if("paint"===e.type)return[yt(e,t,i)];if("timing"===e.type)return[kt(e,t,i)];if("longTask"===e.type)return[xt(e,t,i)];if("batchXHR"===e.type)return function(e,t,i){return e.requests.map(e=>Tt(e,t,i)).filter(e=>null!=e)}(e,t,i);if("xhr"===e.type||"fetch"===e.type){const r=Tt(e,t,i);return r?[r]:[]}return[]}function Ct(){window.addEventListener("error",e=>{const t=e.target;if(t&&(t.src||t.href))return;const i=g(),r=function(){const e=["html","body","#root"];let t=0;function i(i){const r=function(e){let t;return t=e.id?`#${e.id}`:e.className&&"string"==typeof e.className?"."+e.className.split(" ").filter(e=>!!e).join("."):e.nodeName.toLowerCase(),t}(i);e.indexOf(r)>-1&&t++}for(let r=1;r<=9;r++){const e=document.elementFromPoint(window.innerWidth/10*r,window.innerHeight/2),t=document.elementFromPoint(window.innerWidth/2,window.innerHeight/10*r);i(e),i(t)}return 18===t}(),o={type:"error",errorType:"jsError",message:e.message,filename:e.filename,position:`${e.lineno}:${e.colno}`,stack:mt(e.error.stack),selector:i?wt():"",isWhiteScreen:r};this.send(o)},!0),window.addEventListener("unhandledrejection",e=>{const t=g();let i;const r=e.reason;let o,n=0,s=0,a="";if("string"==typeof e.reason)i=r;else if("object"==typeof r&&(i=r.message,r.stack)){const e=r.stack.match(/at\s+(.+):(\d+):(\d+)/);o=e[1],n=e[2],s=e[3],a=mt(r.stack)}const l={type:"error",errorType:"promiseError",message:i,filename:o,position:`${n}:${s}`,stack:a,selector:t?wt():""};this.send(l)},!0)}function Ot(){if(PerformanceObserver){new PerformanceObserver(e=>{e.getEntries().forEach(e=>{if(e.duration>100){const t=g(),i={type:"longTask",startTime:e.startTime,duration:e.duration,selector:t?wt():"",eventType:null==t?void 0:t.type};this.send(i)}})}).observe({entryTypes:["longtask"]})}}function Rt(e,t){if("undefined"==typeof PerformanceObserver)return null;try{const i=new PerformanceObserver(e=>{t(e.getEntries())});return i.observe({type:e,buffered:!0}),i}catch(i){return null}}function Et(){if("undefined"==typeof PerformanceObserver)return;let e=null,t=null,i=null,r=null;const o=Rt("paint",i=>{for(const r of i)"first-paint"===r.name?e=r:"first-contentful-paint"===r.name&&(t=r)}),n=Rt("element",e=>{e.length>0&&(i=e[0],null==n||n.disconnect())}),s=Rt("largest-contentful-paint",e=>{e.length>0&&(r=e[e.length-1])}),a=()=>{setTimeout(()=>{null==s||s.disconnect(),null==o||o.disconnect(),null==n||n.disconnect();const a={type:"paint",FP:null==e?void 0:e.startTime,FCP:null==t?void 0:t.startTime,FMP:null==i?void 0:i.startTime,LCP:null==r?void 0:r.startTime};this.send(a)},3e3)};"complete"!==document.readyState?window.addEventListener("load",a):a()}function qt(){let e=0,t=0;if(performance.getEntriesByType){const i=performance.getEntriesByType("navigation");if(i.length>0){const r=i[0],{domContentLoadedEventStart:o,loadEventStart:n,fetchStart:s}=r;e=o-s,t=n-s}}else{const{fetchStart:i,domContentLoadedEventStart:r,loadEventStart:o}=performance.timing;e=r-i,t=o-i}const i={type:"timing",DOMContentLoadedTime:e,loadTime:t};this.send(i)}function Pt(){const e=()=>qt.call(this);"complete"!==document.readyState?window.addEventListener("load",e):e()}function jt(){const e=window.XMLHttpRequest,t=this;window.XMLHttpRequest=function(){const i=new e,r=i.open,o=i.send;let n,s,a;return i.open=function(e,t,...i){return s=t,a=e,r.apply(this,[e,t,...i])},i.send=function(){return n=(new Date).getTime(),i.addEventListener("error",function(){const e=(new Date).getTime()-n,r=i.status,o=String(null!=s?s:"");t.endpoint&&o===t.endpoint||t.captureRequest({type:"xhr",url:s,method:a||"GET",duration:e,status:r||0,success:!1,msg:`XHR请求错误: ${s}`,startTime:(new Date).getTime()})}),i.addEventListener("timeout",function(){const e=(new Date).getTime()-n,r=i.status,o=String(null!=s?s:"");t.endpoint&&o===t.endpoint||t.captureRequest({type:"xhr",url:s,method:a||"GET",msg:"XHR请求超时",duration:e,status:r||0,success:!1,startTime:(new Date).getTime()})}),o.apply(this,arguments)},i}}const Mt={bufferSeconds:30,maxUploadsPerSession:10,minUploadIntervalMs:3e4,maxReplayBytes:2097152};class At{constructor(e){c(this,"segments",[]),c(this,"stopFn",null),c(this,"starting",!1),c(this,"lastUploadAt",0),c(this,"uploadCount",0),this.opts=e}start(){return d(this,null,function*(){var e,t,i;if(!this.stopFn&&!this.starting){this.starting=!0;try{const{record:r}=yield import("rrweb");this.stopFn=null!=(i=r({emit:(e,t)=>{for((t||0===this.segments.length)&&this.segments.push([]),this.segments[this.segments.length-1].push(e);this.segments.length>2;)this.segments.shift()},checkoutEveryNms:Math.max(500*(null!=(e=this.opts.bufferSeconds)?e:Mt.bufferSeconds),1e4),maskAllInputs:!0,maskTextClass:null!=(t=this.opts.maskTextClass)?t:"rr-mask",blockClass:"rr-block",sampling:{mousemove:50,scroll:150,input:"last"}}))?i:null}catch(r){}}})}captureIfTriggered(e){var t,i,r;if(!this.isTrigger(e))return;const o=Date.now();if(o-this.lastUploadAt<(null!=(t=this.opts.minUploadIntervalMs)?t:Mt.minUploadIntervalMs))return;if(this.uploadCount>=(null!=(i=this.opts.maxUploadsPerSession)?i:Mt.maxUploadsPerSession))return;const n=[].concat(...this.segments);if(0===n.length)return;const s=function(){const e=globalThis.crypto;if("function"==typeof(null==e?void 0:e.randomUUID))return e.randomUUID();if("function"==typeof(null==e?void 0:e.getRandomValues)){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}return Array.from({length:32},()=>Math.floor(16*Math.random()).toString(16)).join("")}();this.lastUploadAt=o,this.uploadCount++;const a=null!=(r=this.opts.maxReplayBytes)?r:Mt.maxReplayBytes,l=this.segments.length>1&&JSON.stringify(n).length>a?[...this.segments[this.segments.length-1]]:n;return this.compressAndUpload(s,l),s}stop(){var e;null==(e=this.stopFn)||e.call(this),this.stopFn=null}isTrigger(e){return"error"===e.type||!!this.opts.captureRequest&&("xhr"===e.type||"fetch"===e.type||"batchXHR"===e.type)}compressAndUpload(e,t){return d(this,null,function*(){try{const i=JSON.stringify(t),{deflate:r}=yield import("pako");yield function(e,t,i){return d(this,null,function*(){const r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json","X-Project-Key":t},body:JSON.stringify(i)});if(!r.ok)throw Object.assign(new Error(`monitor: 回放上传失败 ${r.status}`),{statusCode:r.status})})}(this.opts.replayEndpoint,this.opts.projectKey,{replayId:e,format:"rrweb@2",codec:"deflate-base64",size:i.length,durationMs:t.length>1?t[t.length-1].timestamp-t[0].timestamp:0,occurredAt:(new Date).toISOString(),data:It(r(i))})}catch(i){}})}}function It(e){let t="";for(let i=0;i<e.length;i+=32768)t+=String.fromCharCode(...e.subarray(i,i+32768));return btoa(t)}e.ExcReporter=p,e.Monitor=class{constructor(e){var t,i;c(this,"endpoint"),c(this,"projectKey"),c(this,"timeoutDuration"),c(this,"errorQueue"),c(this,"requestQueue"),c(this,"maxQueueSize"),c(this,"sendTimer"),c(this,"reporter"),c(this,"replay",null),c(this,"options"),c(this,"errorSentAt",new Map),c(this,"originalXHR"),c(this,"originalFetch"),c(this,"originalOnerror"),this.options=e,this.endpoint=e.endpoint,this.projectKey=e.projectKey,this.timeoutDuration=null!=(t=e.timeoutDuration)?t:6e4,this.errorQueue=[],this.requestQueue=[],this.maxQueueSize=null!=(i=e.maxQueueSize)?i:10,this.sendTimer=null,this.reporter=w({endpoint:e.endpoint,projectKey:e.projectKey,release:e.release,environment:e.environment,maxBatch:e.maxBatch,flushInterval:e.flushInterval},m(e.endpoint)),this.init(),this.initReplay(),this.originalXHR=window.XMLHttpRequest,this.originalFetch=window.fetch,this.originalOnerror=window.onerror}init(){Ct.call(this),Ot.call(this),Et.call(this),Pt.call(this),jt.call(this)}initReplay(){var e,t;const i=this.options.replay;if(!(null==i?void 0:i.enabled))return;const r=null!=(e=i.sampleRate)?e:1;if(Math.random()>=r)return;const o=null!=(t=i.replayEndpoint)?t:function(e){const t=e.replace(/\/+$/,"");return t.endsWith("/report")?`${t.slice(0,-7)}/replay`:void 0}(this.endpoint);o&&(this.replay=new At({replayEndpoint:o,projectKey:this.projectKey,bufferSeconds:i.bufferSeconds,maxUploadsPerSession:i.maxUploadsPerSession,minUploadIntervalMs:i.minUploadIntervalMs,maxReplayBytes:i.maxReplayBytes,captureRequest:i.captureRequest,maskTextClass:i.maskTextClass}),this.replay.start())}isDuplicateError(e){var t,i;const r=null!=(t=this.options.errorDedupeMs)?t:0;if(r<=0||"error"!==e.type)return!1;const o=`${e.errorType}|${e.message}|${null!=(i=e.filename)?i:""}`,n=Date.now(),s=this.errorSentAt.get(o);if(void 0!==s&&n-s<r)return!0;if(this.errorSentAt.size>=100)for(const[a,l]of this.errorSentAt)n-l>=r&&this.errorSentAt.delete(a);return this.errorSentAt.set(o,n),!1}send(e){var t;if(this.isDuplicateError(e))return;const i=St(e,{title:document.title,url:location.href,userAgent:navigator.userAgent,browser:`${ut.name} ${ut.version}`,device:`${ct.model} ${ct.vendor}`,os:`${dt.name} ${dt.version}`},this.options),r=null==(t=this.replay)?void 0:t.captureIfTriggered(e);if(r)for(const o of i)o.device=u(l({},o.device),{replayId:r});for(const o of i)this.reporter.capture(o)}capture(e){this.reporter.capture(e)}reportRequest(){0!==this.requestQueue.length&&(this.send({type:"batchXHR",requests:[...this.requestQueue]}),this.requestQueue=[])}reportError(){0!==this.errorQueue.length&&(this.send({type:"batchXHR",requests:[...this.errorQueue]}),this.errorQueue=[])}captureRequest(e){var t;if(!e.type||!["xhr","fetch"].includes(e.type))return;if(i=String(null!=(t=e.url)?t:""),(r=this.endpoint)&&String(i)===r)return;var i,r;const o=["url","method","duration","status","success","startTime"];for(const n of o)if(void 0===e[n])return;e.page=window.location.href,this.requestQueue.push(e),this.requestQueue.length>=this.maxQueueSize&&this.reportRequest()}sendQueuedData(){this.errorQueue.length>0&&this.reportError(),this.requestQueue.length>0&&this.reportRequest()}destroy(){var e;null==(e=this.replay)||e.stop(),this.sendQueuedData(),this.reporter.destroy(),window.XMLHttpRequest=this.originalXHR,window.fetch=this.originalFetch,window.onerror=this.originalOnerror,this.sendTimer&&(clearInterval(this.sendTimer),this.sendTimer=null),this.errorQueue=[],this.requestQueue=[],this.errorSentAt.clear()}},e.SDK_VERSION=h,e.createReporter=w,e.makeH5Transport=m,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Monitor={})}(this,function(e){"use strict";var t=Object.defineProperty,i=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,a=(e,i,r)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[i]=r,l=(e,t)=>{for(var i in t||(t={}))s.call(t,i)&&a(e,i,t[i]);if(o)for(var i of o(t))n.call(t,i)&&a(e,i,t[i]);return e},u=(e,t)=>i(e,r(t)),c=(e,t,i)=>a(e,"symbol"!=typeof t?t+"":t,i),d=(e,t,i)=>new Promise((r,o)=>{var s=e=>{try{a(i.next(e))}catch(t){o(t)}},n=e=>{try{a(i.throw(e))}catch(t){o(t)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(s,n);a((i=i.apply(e,t)).next())});const h="0.0.1";class p{constructor(e,t){c(this,"buffer",[]),c(this,"timer",null),c(this,"sending",!1),this.options=e,this.transport=t}capture(e){var t,i,r,o,s;const n=null!=(t=e.level)?t:"ERROR",a=null!=(i="ERROR"===n||"FATAL"===n?this.options.errorSampleRate:this.options.sampleRate)?i:100;a<100&&100*Math.random()>=a||(this.buffer.push(u(l({},e),{level:n,occurredAt:null!=(r=e.occurredAt)?r:(new Date).toISOString(),sdkVersion:null!=(o=e.sdkVersion)?o:h})),this.buffer.length>100&&(this.buffer=this.buffer.slice(-100)),this.buffer.length>=(null!=(s=this.options.maxBatch)?s:20)?this.flush():this.ensureTimer())}flush(){return d(this,null,function*(){if(this.sending||0===this.buffer.length)return;this.clearTimer(),this.sending=!0;const e=this.buffer;this.buffer=[];try{yield this.transport({events:e},this.options.projectKey)}catch(t){403!==(null==t?void 0:t.statusCode)&&(this.buffer=[...e,...this.buffer].slice(-100),this.ensureTimer())}finally{this.sending=!1}})}destroy(){this.clearTimer(),this.flush()}ensureTimer(){var e;this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},null!=(e=this.options.flushInterval)?e:3e4))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}}function m(e,t){return new p(e,t)}function w(e){return(t,i)=>d(null,null,function*(){const r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json","X-Project-Key":i},body:JSON.stringify(t),keepalive:!0});if(!r.ok)throw Object.assign(new Error(`monitor: 上报失败 ${r.status}`),{statusCode:r.status})})}let f,b;function g(){return f}["click","touchstart","mousedown","keydown"].forEach(e=>{document.addEventListener(e,e=>{f=e,b=e.path||e.composedPath()},{capture:!0,passive:!0})});var v,y="user-agent",k="",x="function",T="object",S="string",E="undefined",C="browser",R="cpu",O="device",q="engine",P="os",j="result",A="name",M="type",I="vendor",$="version",H="architecture",L="major",U="model",D="console",B="mobile",F="tablet",_="smarttv",N="wearable",z="xr",V="embedded",X="inapp",Q="brands",W="formFactors",G="fullVersionList",K="platform",J="platformVersion",Y="bitness",Z="sec-ch-ua",ee=Z+"-full-version-list",te=Z+"-arch",ie=Z+"-"+Y,re=Z+"-form-factors",oe=Z+"-"+B,se=Z+"-"+U,ne=Z+"-"+K,ae=ne+"-version",le=[Q,G,B,U,K,J,H,W,Y],ue="Amazon",ce="Apple",de="ASUS",he="BlackBerry",pe="Google",me="Huawei",we="Lenovo",fe="Honor",be="LG",ge="Microsoft",ve="Motorola",ye="Nvidia",ke="OnePlus",xe="OPPO",Te="Samsung",Se="Sharp",Ee="Sony",Ce="Xiaomi",Re="Zebra",Oe="Chrome",qe="Chromium",Pe="Chromecast",je="Edge",Ae="Firefox",Me="Opera",Ie="Facebook",$e="Sogou",He="Mobile ",Le=" Browser",Ue="Windows",De=typeof window!==E&&window.navigator?window.navigator:void 0,Be=De&&De.userAgentData?De.userAgentData:void 0,Fe=function(e){for(var t={},i=0;i<e.length;i++)t[e[i].toUpperCase()]=e[i];return t},_e=function(e,t){if(typeof e===T&&e.length>0){for(var i in e)if(Xe(t)==Xe(e[i]))return!0;return!1}return!!ze(e)&&Xe(t)==Xe(e)},Ne=function(e,t){for(var i in e)return/^(browser|cpu|device|engine|os)$/.test(i)||!!t&&Ne(e[i])},ze=function(e){return typeof e===S},Ve=function(e){if(e){for(var t=[],i=We(e).split(","),r=0;r<i.length;r++)if(i[r].indexOf(";")>-1){var o=Je(i[r]).split(";v=");t[r]={brand:o[0],version:o[1]}}else t[r]=Je(i[r]);return t}},Xe=function(e){return ze(e)?e.toLowerCase():e},Qe=function(e){return ze(e)?Ke(/[^\d\.]/g,e).split(".")[0]:void 0},We=function(e){return ze(e)?Je(Ke(/\\?\"/g,e),500):void 0},Ge=function(e){for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];typeof i==T&&2==i.length?this[i[0]]=i[1]:this[i]=void 0}return this},Ke=function(e,t){return ze(t)?t.replace(e,k):t},Je=function(e,t){return e=Ke(/^\s\s*/,String(e)),typeof t===E?e:e.substring(0,t)},Ye=function(e,t){if(e&&t)for(var i,r,o,s,n,a,l=0;l<t.length&&!n;){var u=t[l],c=t[l+1];for(i=r=0;i<u.length&&!n&&u[i];)if(n=u[i++].exec(e))for(o=0;o<c.length;o++)a=n[++r],typeof(s=c[o])===T&&s.length>0?2===s.length?typeof s[1]==x?this[s[0]]=s[1].call(this,a):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]!==x||s[1].exec&&s[1].test?3==s.length?this[s[0]]=a?a.replace(s[1],s[2]):void 0:4==s.length?this[s[0]]=a?s[3].call(this,a.replace(s[1],s[2])):void 0:s.length>4&&(this[s[0]]=a?s[3].apply(this,[a.replace(s[1],s[2])].concat(s.slice(4))):void 0):s.length>3?this[s[0]]=a?s[1].apply(this,s.slice(2)):void 0:this[s[0]]=a?s[1].call(this,a,s[2]):void 0):this[s]=a||void 0;l+=2}},Ze=function(e,t){for(var i in t)if(typeof t[i]===T&&t[i].length>0){for(var r=0;r<t[i].length;r++)if(_e(t[i][r],e))return"?"===i?void 0:i}else if(_e(t[i],e))return"?"===i?void 0:i;return t.hasOwnProperty("*")?t["*"]:e},et={ME:"4.90","NT 3.51":"3.51","NT 4.0":"4.0",2e3:["5.0","5.01"],XP:["5.1","5.2"],Vista:"6.0",7:"6.1",8:"6.2",8.1:"6.3",10:["6.4","10.0"],NT:""},tt={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},it={Chrome:"Google Chrome",Edge:"Microsoft Edge","Edge WebView2":"Microsoft Edge WebView2","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome","Huawei Browser":"HuaweiBrowser","MIUI Browser":"Miui Browser","Opera Mobi":"OperaMobile",Yandex:"YaBrowser"},rt={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[$,[A,He+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[$,[A,je+" WebView"],[M,X]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[$,[A,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[A,$],[/opios[\/ ]+([\w\.]+)/i],[$,[A,Me+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[$,[A,Me+" GX"]],[/\bopr\/([\w\.]+)/i],[$,[A,Me]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[$,[A,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[$,[A,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(atlas|flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:hi|lg |ovi|qute)browser|palemoon)\/v?([-\w\.]+)/i,/(brave)(?: chrome)?\/([\d\.]+)/i,/(aloha|heytap|ovi|115|surf|qwant)browser\/([\d\.]+)/i,/(qwant)(?:ios|mobile)\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[A,$],[/quark(?:pc)?\/([-\w\.]+)/i],[$,[A,"Quark"]],[/\bddg\/([\w\.]+)/i],[$,[A,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb| ucpc)[\/ ]?([\w\.]+)/i],[$,[A,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[$,[A,"WeChat"]],[/konqueror\/([\w\.]+)/i],[$,[A,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[$,[A,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[$,[A,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[$,[A,"Smart "+we+Le]],[/(av(?:ast|g|ira))\/([\w\.]+)/i],[[A,/(.+)/,"$1 Secure"+Le],$],[/norton\/([\w\.]+)/i],[$,[A,"Norton Private"+Le]],[/\bfocus\/([\w\.]+)/i],[$,[A,Ae+" Focus"]],[/ mms\/([\w\.]+)$/i],[$,[A,Me+" Neon"]],[/ opt\/([\w\.]+)$/i],[$,[A,Me+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[$,[A,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[$,[A,"Dolphin"]],[/coast\/([\w\.]+)/i],[$,[A,Me+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[$,[A,"MIUI"+Le]],[/fxios\/([\w\.-]+)/i],[$,[A,He+Ae]],[/\bqihoobrowser\/?([\w\.]*)/i],[$,[A,"360"]],[/\b(qq)\/([\w\.]+)/i],[[A,/(.+)/,"$1Browser"],$],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[A,/(.+)/,"$1"+Le],$],[/ HBPC\/([\w\.]+)/],[$,[A,me+Le]],[/samsungbrowser\/([\w\.]+)/i],[$,[A,Te+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[$,[A,$e+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[A,$e+" Mobile"],$],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[A,$],[/(lbbrowser|luakit|rekonq|steam(?= (clie|tenf|gameo)))/i],[A],[/ome\/([\w\.]+).+(iron(?= saf)|360(?=[es]e$))/i],[$,A],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[A,Ie],$,[M,X]],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(bing)(?:web|sapphire)\/([\w\.]+)/i,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[A,$,[M,X]],[/\bgsa\/([\w\.]+) .*safari\//i],[$,[A,"GSA"],[M,X]],[/(?:musical_ly|trill)(?:.+app_?version\/|_)([\w\.]+)/i],[$,[A,"TikTok"],[M,X]],[/\[(linkedin)app\]/i],[A,[M,X]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[A,/(.+)/,"Zalo"],$,[M,X]],[/(chromium)[\/ ]([-\w\.]+)/i],[A,$],[/ome-(lighthouse)$/i],[A,[M,"fetcher"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[$,[A,Oe+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[$,[A,je+" WebView2"],[M,X]],[/; wv\).+(chrome)\/([\w\.]+)/i],[[A,Oe+" WebView"],$,[M,X]],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[$,[A,"Android"+Le]],[/chrome\/([\w\.]+) mobile/i],[$,[A,He+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[A,$],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[$,[A,He+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[A,He+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[$,A],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[A,[$,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[A,$],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[A,He+Ae],$],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[A,"Netscape"],$],[/(wolvic|librewolf)\/([\w\.]+)/i],[A,$],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[$,[A,Ae+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+(?= .+rv\:.+gecko\/\d+)|[0-4][\w\.]+(?!.+compatible))/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[A,[$,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[A,[$,/[^\d\.]+./,k]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[H,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[H,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[H,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[H,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[H,"arm"]],[/ sun4\w[;\)]/i],[[H,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i,/((ppc|powerpc)(64)?)( mac|;|\))/i,/(?:osf1|[freopnt]{3,4}bsd) (alpha)/i],[[H,/ower/,k,Xe]],[/mc680.0/i],[[H,"68k"]],[/winnt.+\[axp/i],[[H,"alpha"]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[U,[I,Te],[M,F]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,/sec-(sgh\w+)/i],[U,[I,Te],[M,B]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[U,[I,ce],[M,B]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[U,[I,ce],[M,F]],[/(macintosh);/i],[U,[I,ce]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[U,[I,Se],[M,B]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[U,[I,fe],[M,F]],[/honor([-\w ]+)[;\)]/i],[U,[I,fe],[M,B]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[U,[I,me],[M,F]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[U,[I,me],[M,B]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b(?:xiao)?((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[U,/_/g," "],[I,Ce],[M,F]],[/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/oid[^\)]+; (redmi[\-_ ]?(?:note|k)?[\w_ ]+|m?[12]\d[01]\d\w{3,6}|poco[\w ]+|(shark )?\w{3}-[ah]0|qin ?[1-3](s\+|ultra| pro)?)( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note|max|cc)?[_ ]?(?:\d{0,2}\w?)[_ ]?(?:plus|se|lite|pro)?( 5g|lte)?)(?: bui|\))/i,/; ([\w ]+) miui\/v?\d/i],[[U,/_/g," "],[I,Ce],[M,B]],[/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-l]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[U,[I,ke],[M,B]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[U,[I,xe],[M,B]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[U,[I,Ze,{OnePlus:["203","304","403","404","413","415"],"*":xe}],[M,F]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[U,[I,"BLU"],[M,B]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[U,[I,"Vivo"],[M,B]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[U,[I,"Realme"],[M,B]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[U,[I,we],[M,F]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[U,[I,we],[M,B]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,/((?:moto(?! 360)[-\w\(\) ]+|xt\d{3,4}[cgkosw\+]?[-\d]*|nexus 6)(?= bui|\)))/i],[U,[I,ve],[M,B]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[U,[I,ve],[M,F]],[/\b(?:lg)?([vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[U,[I,be],[M,F]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[U,[I,be],[M,B]],[/(nokia) (t[12][01])/i],[I,U,[M,F]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[U,/_/g," "],[M,B],[I,"Nokia"]],[/(pixel (c|tablet))\b/i],[U,[I,pe],[M,F]],[/droid.+;(?: google)? (g(01[13]a|020[aem]|025[jn]|1b60|1f8f|2ybb|4s1m|576d|5nz6|8hhn|8vou|a02099|c15s|d1yq|e2ae|ec77|gh2x|kv4x|p4bc|pj41|r83y|tt9q|ur25|wvk6)|pixel[\d ]*a?( pro)?( xl)?( fold)?( \(5g\))?)( bui|\))/i],[U,[I,pe],[M,B]],[/(google) (pixelbook( go)?)/i],[I,U],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-\w\w\d\d)(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[U,[I,Ee],[M,B]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[U,"Xperia Tablet"],[I,Ee],[M,F]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[U,[I,ue],[M,F]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[U,/(.+)/g,"Fire Phone $1"],[I,ue],[M,B]],[/(playbook);[-\w\),; ]+(rim)/i],[U,I,[M,F]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[U,[I,he],[M,B]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[U,[I,de],[M,F]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[U,[I,de],[M,B]],[/(nexus 9)/i],[U,[I,"HTC"],[M,F]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[I,[U,/_/g," "],[M,B]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[U,[I,"TCL"],[M,F]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[U,[I,"TCL"],[M,B]],[/(itel) ((\w+))/i],[[I,Xe],U,[M,Ze,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[U,[I,"Acer"],[M,F]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[U,[I,"Meizu"],[M,B]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[U,[I,"Ulefone"],[M,B]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[U,[I,"Energizer"],[M,B]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[U,[I,"Cat"],[M,B]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[U,[I,"Smartfren"],[M,B]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[U,[I,"Nothing"],[M,B]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[U,[I,"Archos"],[M,F]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[U,[I,"Archos"],[M,B]],[/blackview ([-\w ]+)( b|\))/i,/; (bv\d{4}[-\w ]*)( b|\))/i],[U,[I,"Blackview"],[M,B]],[/; (n159v)/i],[U,[I,"HMD"],[M,B]],[/((revvl[ \w\+]+|tm(?:rv|af)\w*[45]g(?:tb)?))( b|\))/i],[U,[M,function(e,t){return t.test.test(e)?t.ifTrue:t.ifFalse},{test:/ta?b/i,ifTrue:F,ifFalse:B}],[I,"T-Mobile"]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[I,U,[M,F]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|coolpad|cubot|hmd|imo|infinix|lava|oneplus|tcl|wiko)[_ ]([-\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i,/(hisense) ([ehv][\w ]+)\)/i,/droid[^;]+; (philips)[_ ]([sv-x][\d]{3,4}[xz]?)/i],[I,U,[M,B]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[I,U,[M,F]],[/(surface duo)/i],[U,[I,ge],[M,F]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[U,[I,"Fairphone"],[M,B]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[U,[I,ye],[M,F]],[/(sprint) (\w+)/i],[I,U,[M,B]],[/(kin\.[onetw]{3})/i],[[U,/\./g," "],[I,ge],[M,B]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[U,[I,Re],[M,F]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[U,[I,Re],[M,B]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[I,[M,_]],[/hbbtv.+maple;(\d+)/i],[[U,/^/,"SmartTV"],[I,Te],[M,_]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[I,U,[M,_]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[I,be],[M,_]],[/(apple) ?tv/i],[I,[U,ce+" TV"],[M,_]],[/crkey.*devicetype\/chromecast/i],[[U,Pe+" Third Generation"],[I,pe],[M,_]],[/crkey.*devicetype\/([^/]*)/i],[[U,/^/,"Chromecast "],[I,pe],[M,_]],[/fuchsia.*crkey/i],[[U,Pe+" Nest Hub"],[I,pe],[M,_]],[/crkey/i],[[U,Pe],[I,pe],[M,_]],[/(portaltv)/i],[U,[I,Ie],[M,_]],[/droid.+aft(\w+)( bui|\))/i],[U,[I,ue],[M,_]],[/(shield \w+ tv)/i],[U,[I,ye],[M,_]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[U,[I,Se],[M,_]],[/(bravia[\w ]+)( bui|\))/i],[U,[I,Ee],[M,_]],[/(mi(tv|box)-?\w+) bui/i],[U,[I,Ce],[M,_]],[/Hbbtv.*(technisat) (.*);/i],[I,U,[M,_]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[I,/.+\/(\w+)/,"$1",Ze,{LG:"lge"}],[U,Je],[M,_]],[/(playstation \w+)/i],[U,[I,Ee],[M,D]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[U,[I,ge],[M,D]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i,/(valve).+(steam deck)/i,/droid.+; ((shield|rgcube|gr0006))( bui|\))/i],[[I,Ze,{Nvidia:"Shield",Anbernic:"RGCUBE",Logitech:"GR0006"}],U,[M,D]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[U,[I,Te],[M,N]],[/((pebble))app/i,/(asus|google|lg|oppo|xiaomi) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[I,U,[M,N]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[U,[I,xe],[M,N]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[U,[I,ce],[M,N]],[/(opwwe\d{3})/i],[U,[I,ke],[M,N]],[/(moto 360)/i],[U,[I,ve],[M,N]],[/(smartwatch 3)/i],[U,[I,Ee],[M,N]],[/(g watch r)/i],[U,[I,be],[M,N]],[/droid.+; (wt63?0{2,3})\)/i],[U,[I,Re],[M,N]],[/droid.+; (glass) \d/i],[U,[I,pe],[M,z]],[/(pico) ([\w ]+) os\d/i],[I,U,[M,z]],[/(quest( \d| pro)?s?).+vr/i],[U,[I,Ie],[M,z]],[/mobile vr; rv.+firefox/i],[[M,z]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[I,[M,V]],[/(aeobc)\b/i],[U,[I,ue],[M,V]],[/(homepod).+mac os/i],[U,[I,ce],[M,V]],[/windows iot/i],[[M,V]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[U,[M,_]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[M,_]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[U,[M,Ze,{mobile:"Mobile",xr:"VR","*":F}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[M,F]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[M,B]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[U,[I,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[$,[A,je+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[A,$],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[$,[A,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links|dillo)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[A,$],[/ladybird\//i],[[A,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[$,A]],os:[[/(windows nt) (6\.[23]); arm/i],[[A,/N/,"R"],[$,Ze,et]],[/(windows (?:phone|mobile|iot))(?: os)?[\/ ]?([\d\.]*( se)?)/i,/(windows)[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i],[A,$],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[$,/(;|\))/g,"",Ze,et],[A,Ue]],[/(windows ce)\/?([\d\.]*)/i],[A,$],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv|ios(?=.+ip(?:ad|hone)|.+apple ?tv)|ip(?:ad|hone)(?: |.+i(?:pad)?)os|apple ?tv.+ios)[\/ ]([\w\.]+)/i,/\btvos ?([\w\.]+)/i,/cfnetwork\/.+darwin/i],[[$,/_/g,"."],[A,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[A,"macOS"],[$,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[$,[A,Pe+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[$,[A,Pe+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[$,[A,Pe+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[$,[A,Pe+" Linux"]],[/crkey\/([\d\.]+)/i],[$,[A,Pe]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[$,A],[/(ubuntu) ([\w\.]+) like android/i],[[A,/(.+)/,"$1 Touch"],$],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[A,$],[/\(bb(10);/i],[$,[A,he]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[$,[A,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile[;\w ]*|tablet|tv|[^\)]*(?:viera|lg(?:l25|-d300)|alcatel ?o.+|y300-f1)); rv:([\w\.]+)\).+gecko\//i],[$,[A,Ae+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[$,[A,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[$,Ze,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[A,"webOS"]],[/watch(?: ?os[,\/ ]|\d,\d\/)([\d\.]+)/i],[$,[A,"watchOS"]],[/cros [\w]+(?:\)| ([\w\.]+)\b)/i],[$,[A,"Chrome OS"]],[/kepler ([\w\.]+); (aft|aeo)/i],[$,[A,"Vega OS"]],[/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/linux.+(mint)[\/\(\) ]?([\w\.]*)/i,/(mageia|vectorlinux|fuchsia|arcaos|arch(?= ?linux))[;l ]([\d\.]*)/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire|knoppix)(?: gnu[\/ ]linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/\b(aix)[; ]([1-9\.]{0,4})/i,/(hurd|linux|morphos)(?: (?:arm|x86|ppc)\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) ?(r\d)?/i],[A,$],[/(sunos) ?([\d\.]*)/i],[[A,"Solaris"],$],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[A,$]]},ot=(Ge.call((v={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[C,[A,$,L,M]],[R,[H]],[O,[M,U,I]],[q,[A,$]],[P,[A,$]]]),Ge.call(v.isIgnore,[[C,[$,L]],[q,[$]],[P,[$]]]),Ge.call(v.isIgnoreRgx,[[C,/ ?browser$/i],[P,/ ?os$/i]]),Ge.call(v.toString,[[C,[A,$]],[R,[H]],[O,[I,U]],[q,[A,$]],[P,[A,$]]]),v),st=function(e,t){var i=ot.init[t],r=ot.isIgnore[t]||0,o=ot.isIgnoreRgx[t]||0,s=ot.toString[t]||0;function n(){Ge.call(this,i)}return n.prototype.getItem=function(){return e},n.prototype.withClientHints=function(){return Be?Be.getHighEntropyValues(le).then(function(t){return e.setCH(new nt(t,!1)).parseCH().get()}):e.parseCH().get()},n.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=j&&(n.prototype.is=function(e){var t=!1;for(var i in this)if(this.hasOwnProperty(i)&&!_e(r,i)&&Xe(o?Ke(o,this[i]):this[i])==Xe(o?Ke(o,e):e)){if(t=!0,e!=E)break}else if(e==E&&t){t=!t;break}return t},n.prototype.toString=function(){var e=k;for(var t in s)typeof this[s[t]]!==E&&(e+=(e?" ":k)+this[s[t]]);return e||E}),n.prototype.then=function(e){var t=this,i=function(){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])};i.prototype={is:n.prototype.is,toString:n.prototype.toString,withClientHints:n.prototype.withClientHints,withFeatureCheck:n.prototype.withFeatureCheck};var r=new i;return e(r),r},new n};function nt(e,t){if(e=e||{},Ge.call(this,le),t)Ge.call(this,[[Q,Ve(e[Z])],[G,Ve(e[ee])],[B,/\?1/.test(e[oe])],[U,We(e[se])],[K,We(e[ne])],[J,We(e[ae])],[H,We(e[te])],[W,Ve(e[re])],[Y,We(e[ie])]]);else for(var i in e)this.hasOwnProperty(i)&&typeof e[i]!==E&&(this[i]=e[i])}function at(e,t,i,r){return Ge.call(this,[["itemType",e],["ua",t],["uaCH",r],["rgxMap",i],["data",st(this,e)]]),this}function lt(e,t,i){if(typeof e===T?(Ne(e,!0)?(typeof t===T&&(i=t),t=e):(i=e,t=void 0),e=void 0):typeof e!==S||Ne(t,!0)||(i=t,t=void 0),i)if(typeof i.append===x){var r={};i.forEach(function(e,t){r[String(t).toLowerCase()]=e}),i=r}else{var o={};for(var s in i)i.hasOwnProperty(s)&&(o[String(s).toLowerCase()]=i[s]);i=o}if(!(this instanceof lt))return new lt(e,t,i).getResult();var n=typeof e===S?e:i&&i[y]?i[y]:De&&De.userAgent?De.userAgent:k,a=new nt(i,!0),l=rt,u=function(e){return e==j?function(){return new at(e,n,l,a).set("ua",n).set(C,this.getBrowser()).set(R,this.getCPU()).set(O,this.getDevice()).set(q,this.getEngine()).set(P,this.getOS()).get()}:function(){return new at(e,n,l[e],a).parseUA().get()}};return Ge.call(this,[["getBrowser",u(C)],["getCPU",u(R)],["getDevice",u(O)],["getEngine",u(q)],["getOS",u(P)],["getResult",u(j)],["getUA",function(){return n}],["setUA",function(e){return ze(e)&&(n=Je(e,500)),this}],["useExtension",function(e){return e&&(l=function(e,t){var i={},r=t;if(!Ne(t))for(var o in r={},t)for(var s in t[o])r[s]=t[o][s].concat(r[s]?r[s]:[]);for(var n in e)i[n]=r[n]&&r[n].length%2==0?r[n].concat(e[n]):e[n];return i}(l,e)),this}]]).setUA(n).useExtension(t),this}at.prototype.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:void 0:this.data},at.prototype.set=function(e,t){return this.data[e]=t,this},at.prototype.setCH=function(e){return this.uaCH=e,this},at.prototype.detectFeature=function(){if(De&&De.userAgent==this.ua)switch(this.itemType){case C:De.brave&&typeof De.brave.isBrave==x&&this.set(A,"Brave");break;case O:!this.get(M)&&Be&&Be[B]&&this.set(M,B),"Macintosh"==this.get(U)&&De&&typeof De.standalone!==E&&De.maxTouchPoints&&De.maxTouchPoints>2&&this.set(U,"iPad").set(M,F);break;case P:!this.get(A)&&Be&&Be[K]&&this.set(A,Be[K]);break;case j:var e=this.data,t=function(t){return e[t].getItem().detectFeature().get()};this.set(C,t(C)).set(R,t(R)).set(O,t(O)).set(q,t(q)).set(P,t(P))}return this},at.prototype.parseUA=function(){switch(this.itemType!=j&&Ye.call(this.data,this.ua,this.rgxMap),this.itemType){case C:this.set(L,Qe(this.get($)));break;case P:if("iOS"==this.get(A)&&this.get($)&&/^1[89][^\d]/.exec(this.get($))){var e=/\) Version\/((\d+)[\d\.]*)/.exec(this.ua);e&&parseInt(e[2],10)>=26&&this.set($,e[1])}}return this},at.prototype.parseCH=function(){var e=this.uaCH,t=this.rgxMap;switch(this.itemType){case C:case q:var i,r=e[G]||e[Q];if(r)for(var o=0;o<r.length;o++){var s=r[o].brand||r[o],n=r[o].version;this.itemType==C&&!/not.a.brand/i.test(s)&&(!i||/Chrom/.test(i)&&s!=qe||i==je&&/WebView2/.test(s))&&(s=Ze(s,it),(i=this.get(A))&&!/Chrom/.test(i)&&/Chrom/.test(s)||this.set(A,s).set($,n).set(L,Qe(n)),i=s),this.itemType==q&&s==qe&&this.set($,n)}break;case R:var a=e[H];a&&(a&&"64"==e[Y]&&(a+="64"),Ye.call(this.data,a+";",t));break;case O:if(e[B]&&this.set(M,B),e[U]&&(this.set(U,e[U]),!this.get(M)||!this.get(I))){var l={};Ye.call(l,"droid 9; "+e[U]+")",t),!this.get(M)&&l.type&&this.set(M,l.type),!this.get(I)&&l.vendor&&this.set(I,l.vendor)}if(e[W]){var u;if("string"!=typeof e[W])for(var c=0;!u&&c<e[W].length;)u=Ze(e[W][c++],tt);else u=Ze(e[W],tt);this.set(M,u)}break;case P:var d=e[K];if(d){var h=e[J];d==Ue&&(h=parseInt(Qe(h),10)>=13?"11":"10"),this.set(A,d).set($,h)}this.get(A)==Ue&&"Xbox"==e[U]&&this.set(A,"Xbox").set($,void 0);break;case j:var p=this.data,m=function(t){return p[t].getItem().setCH(e).parseCH().get()};this.set(C,m(C)).set(R,m(R)).set(O,m(O)).set(q,m(q)).set(P,m(P))}return this},lt.VERSION="2.0.10",lt.BROWSER=Fe([A,$,L,M]),lt.CPU=Fe([H]),lt.DEVICE=Fe([U,I,M,D,B,_,F,N,V]),lt.ENGINE=lt.OS=Fe([A,$]);const{browser:ut,device:ct,os:dt}=lt(navigator.userAgent);function ht(e){return e!==window&&e!==document&&e!==document.documentElement}function pt(e){return e.id?`${e.nodeName.toLowerCase()}#${e.id}`:e.className&&"string"==typeof e.className?`${e.nodeName.toLowerCase()}#${e.className}`:e.nodeName.toLowerCase()}function mt(e){const t=b;if(Array.isArray(t))return function(e){return e.reverse().filter(ht).map(pt).join(" ")}(t)}function wt(e){return e.split("\n").slice(1).map(e=>e.replace(/^\s+at\s+/g,"")).join("\n")}function ft(){try{return location.href}catch(e){return""}}function bt(e){return{title:e.title,url:e.url,browser:e.browser,os:e.os,deviceInfo:e.device,userAgent:e.userAgent}}function gt(e,t){return{page:ft(),userId:t.userId,release:t.release,environment:t.environment,device:bt(e)}}function vt(e,t,i){const r=gt(t,i);return"promiseError"===e.errorType?u(l({type:"unhandledrejection",level:"ERROR",message:e.message,stack:e.stack},r),{device:u(l({},r.device),{selector:e.selector,filename:e.filename,position:e.position,errorType:e.errorType})}):u(l({type:"error",level:"ERROR",message:e.message,stack:e.stack},r),{device:u(l({},r.device),{selector:e.selector,isWhiteScreen:e.isWhiteScreen,filename:e.filename,position:e.position,errorType:e.errorType})})}function yt(e,t,i){const r=gt(t,i);return u(l({type:"paint",level:"INFO",message:"paint metrics"},r),{device:u(l({},r.device),{FP:e.FP,FCP:e.FCP,FMP:e.FMP,LCP:e.LCP})})}function kt(e,t,i){const r=gt(t,i);return u(l({type:"timing",level:"INFO",message:"timing metrics"},r),{device:u(l({},r.device),{DOMContentLoadedTime:e.DOMContentLoadedTime,loadTime:e.loadTime})})}function xt(e,t,i){const r=gt(t,i);return u(l({type:"longTask",level:e.duration>=100?"WARN":"INFO",message:`long task ${e.duration}ms`},r),{device:u(l({},r.device),{startTime:e.startTime,duration:e.duration,selector:e.selector,eventType:e.eventType})})}function Tt(e,t,i){var r,o,s,n;if(!1!==e.success)return null;const a=String(null!=(r=e.url)?r:""),c=String(null!=(o=e.method)?o:"GET").toUpperCase(),d=null!=(s=e.status)?s:0,h=e.business?"business"+(void 0!==e.business.code?` ${e.business.code}`:""):0===d?"network":String(d),p=gt(t,i);return u(l({type:"request",level:"ERROR",message:`Request failed [${h}]: ${c} ${a}`},p),{device:u(l({},p.device),{durationMs:e.duration,msg:e.msg,code:null==(n=e.business)?void 0:n.code})})}function St(e,t,i){if("error"===e.type)return[vt(e,t,i)];if("paint"===e.type)return[yt(e,t,i)];if("timing"===e.type)return[kt(e,t,i)];if("longTask"===e.type)return[xt(e,t,i)];if("batchXHR"===e.type)return function(e,t,i){return e.requests.map(e=>Tt(e,t,i)).filter(e=>null!=e)}(e,t,i);if("xhr"===e.type||"fetch"===e.type){const r=Tt(e,t,i);return r?[r]:[]}return[]}function Et(){window.addEventListener("error",e=>{const t=e.target;if(t&&(t.src||t.href))return;const i=g(),r=function(){const e=["html","body","#root"];let t=0;function i(i){const r=function(e){let t;return t=e.id?`#${e.id}`:e.className&&"string"==typeof e.className?"."+e.className.split(" ").filter(e=>!!e).join("."):e.nodeName.toLowerCase(),t}(i);e.indexOf(r)>-1&&t++}for(let r=1;r<=9;r++){const e=document.elementFromPoint(window.innerWidth/10*r,window.innerHeight/2),t=document.elementFromPoint(window.innerWidth/2,window.innerHeight/10*r);i(e),i(t)}return 18===t}(),o={type:"error",errorType:"jsError",message:e.message,filename:e.filename,position:`${e.lineno}:${e.colno}`,stack:wt(e.error.stack),selector:i?mt():"",isWhiteScreen:r};this.send(o)},!0),window.addEventListener("unhandledrejection",e=>{const t=g();let i;const r=e.reason;let o,s=0,n=0,a="";if("string"==typeof e.reason)i=r;else if("object"==typeof r&&(i=r.message,r.stack)){const e=r.stack.match(/at\s+(.+):(\d+):(\d+)/);o=e[1],s=e[2],n=e[3],a=wt(r.stack)}const l={type:"error",errorType:"promiseError",message:i,filename:o,position:`${s}:${n}`,stack:a,selector:t?mt():""};this.send(l)},!0)}function Ct(){if(PerformanceObserver){new PerformanceObserver(e=>{e.getEntries().forEach(e=>{if(e.duration>100){const t=g(),i={type:"longTask",startTime:e.startTime,duration:e.duration,selector:t?mt():"",eventType:null==t?void 0:t.type};this.send(i)}})}).observe({entryTypes:["longtask"]})}}function Rt(e,t){if("undefined"==typeof PerformanceObserver)return null;try{const i=new PerformanceObserver(e=>{t(e.getEntries())});return i.observe({type:e,buffered:!0}),i}catch(i){return null}}function Ot(){if("undefined"==typeof PerformanceObserver)return;let e=null,t=null,i=null,r=null;const o=Rt("paint",i=>{for(const r of i)"first-paint"===r.name?e=r:"first-contentful-paint"===r.name&&(t=r)}),s=Rt("element",e=>{e.length>0&&(i=e[0],null==s||s.disconnect())}),n=Rt("largest-contentful-paint",e=>{e.length>0&&(r=e[e.length-1])}),a=()=>{setTimeout(()=>{null==n||n.disconnect(),null==o||o.disconnect(),null==s||s.disconnect();const a={type:"paint",FP:null==e?void 0:e.startTime,FCP:null==t?void 0:t.startTime,FMP:null==i?void 0:i.startTime,LCP:null==r?void 0:r.startTime};this.send(a)},3e3)};"complete"!==document.readyState?window.addEventListener("load",a):a()}function qt(){let e=0,t=0;if(performance.getEntriesByType){const i=performance.getEntriesByType("navigation");if(i.length>0){const r=i[0],{domContentLoadedEventStart:o,loadEventStart:s,fetchStart:n}=r;e=o-n,t=s-n}}else{const{fetchStart:i,domContentLoadedEventStart:r,loadEventStart:o}=performance.timing;e=r-i,t=o-i}const i={type:"timing",DOMContentLoadedTime:e,loadTime:t};this.send(i)}function Pt(){const e=()=>qt.call(this);"complete"!==document.readyState?window.addEventListener("load",e):e()}function jt(e,t){if("function"!=typeof t)return null;let i=e;if("string"==typeof i){const e=i.trim();if(!e.startsWith("{")&&!e.startsWith("["))return null;try{i=JSON.parse(e)}catch(o){return null}}if(!t(i))return null;const r=null!==i&&"object"==typeof i?i:{};return{code:"number"==typeof r.code||"string"==typeof r.code?r.code:void 0,message:"string"==typeof r.message?r.message:void 0}}function At(){const e=window.XMLHttpRequest,t=this;window.XMLHttpRequest=function(){const i=new e,r=i.open,o=i.send;let s,n,a;return i.open=function(e,t,...i){return n=t,a=e,r.apply(this,[e,t,...i])},i.send=function(){return s=(new Date).getTime(),i.addEventListener("error",function(){const e=(new Date).getTime()-s,r=i.status,o=String(null!=n?n:"");t.endpoint&&o===t.endpoint||t.captureRequest({type:"xhr",url:n,method:a||"GET",duration:e,status:r||0,success:!1,msg:`XHR请求错误: ${n}`,startTime:(new Date).getTime()})}),i.addEventListener("timeout",function(){const e=(new Date).getTime()-s,r=i.status,o=String(null!=n?n:"");t.endpoint&&o===t.endpoint||t.captureRequest({type:"xhr",url:n,method:a||"GET",msg:"XHR请求超时",duration:e,status:r||0,success:!1,startTime:(new Date).getTime()})}),i.addEventListener("loadend",function(){var e;const r=(new Date).getTime()-s,o=i.status,l=String(null!=n?n:"");if(!t.endpoint||l!==t.endpoint)if(o>=400)t.captureRequest({type:"xhr",url:n,method:a||"GET",msg:`XHR请求失败: 状态码 ${o}`,duration:r,status:o,success:!1,startTime:s});else if(o>=200&&o<300&&t.isBusinessError){const u=jt(function(e){try{return""===e.responseType||"text"===e.responseType?e.responseText:"json"===e.responseType?e.response:void 0}catch(t){return}}(i),t.isBusinessError);u&&t.captureRequest({type:"xhr",url:n,method:a||"GET",msg:`XHR业务错误: ${null!=(e=u.message)?e:l}`,duration:r,status:o,success:!1,business:u,startTime:s})}}),o.apply(this,arguments)},i}}const Mt=["AbortError","TimeoutError"];function It(){const e="function"==typeof window.fetch?window.fetch.bind(window):void 0,t=this;if(!e)return;const i=e=>{try{t.captureRequest(e)}catch(i){}};window.fetch=function(r,o){var s;const n="string"==typeof r?r:r instanceof URL?r.href:r.url,a=String(null!=(s=null==o?void 0:o.method)?s:r instanceof Request?r.method:"GET").toUpperCase();if(t.endpoint&&n===t.endpoint||t.replayEndpoint&&n===t.replayEndpoint)return e(r,o);const l=(new Date).getTime();return e(r,o).then(e=>{var r;const o=(new Date).getTime()-l;if(e.status>=400)i({type:"fetch",url:n,method:a,msg:`fetch请求失败: 状态码 ${e.status}`,duration:o,status:e.status,success:!1,startTime:l});else if(e.status>=200&&e.status<300&&t.isBusinessError){const o=null!=(r=e.headers.get("content-type"))?r:"";(o.includes("json")||o.startsWith("text/"))&&e.clone().text().then(r=>{var o;const s=jt(r,t.isBusinessError);s&&i({type:"fetch",url:n,method:a,msg:`fetch业务错误: ${null!=(o=s.message)?o:n}`,duration:(new Date).getTime()-l,status:e.status,success:!1,business:s,startTime:l})}).catch(()=>{})}return e},e=>{var t;if(Mt.includes(null!=(t=null==e?void 0:e.name)?t:""))throw e;throw i({type:"fetch",url:n,method:a,msg:`fetch请求错误: ${n}`,duration:(new Date).getTime()-l,status:0,success:!1,startTime:l}),e})}}const $t={bufferSeconds:30,maxUploadsPerSession:10,minUploadIntervalMs:3e4,maxReplayBytes:2097152};class Ht{constructor(e){c(this,"segments",[]),c(this,"stopFn",null),c(this,"starting",!1),c(this,"lastUploadAt",0),c(this,"uploadCount",0),this.opts=e}start(){return d(this,null,function*(){var e,t,i;if(!this.stopFn&&!this.starting){this.starting=!0;try{const{record:r}=yield import("rrweb");this.stopFn=null!=(i=r({emit:(e,t)=>{for((t||0===this.segments.length)&&this.segments.push([]),this.segments[this.segments.length-1].push(e);this.segments.length>2;)this.segments.shift()},checkoutEveryNms:Math.max(500*(null!=(e=this.opts.bufferSeconds)?e:$t.bufferSeconds),1e4),maskAllInputs:!0,maskTextClass:null!=(t=this.opts.maskTextClass)?t:"rr-mask",blockClass:"rr-block",sampling:{mousemove:50,scroll:150,input:"last"}}))?i:null}catch(r){}}})}captureIfTriggered(e){var t,i,r;if(!this.isTrigger(e))return;const o=Date.now();if(o-this.lastUploadAt<(null!=(t=this.opts.minUploadIntervalMs)?t:$t.minUploadIntervalMs))return;if(this.uploadCount>=(null!=(i=this.opts.maxUploadsPerSession)?i:$t.maxUploadsPerSession))return;const s=[].concat(...this.segments);if(0===s.length)return;const n=function(){const e=globalThis.crypto;if("function"==typeof(null==e?void 0:e.randomUUID))return e.randomUUID();if("function"==typeof(null==e?void 0:e.getRandomValues)){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}return Array.from({length:32},()=>Math.floor(16*Math.random()).toString(16)).join("")}();this.lastUploadAt=o,this.uploadCount++;const a=null!=(r=this.opts.maxReplayBytes)?r:$t.maxReplayBytes,l=this.segments.length>1&&JSON.stringify(s).length>a?[...this.segments[this.segments.length-1]]:s;return this.compressAndUpload(n,l),n}stop(){var e;null==(e=this.stopFn)||e.call(this),this.stopFn=null}isTrigger(e){return"error"===e.type||!!this.opts.captureRequest&&("xhr"===e.type||"fetch"===e.type||"batchXHR"===e.type)}compressAndUpload(e,t){return d(this,null,function*(){try{const i=JSON.stringify(t),{deflate:r}=yield import("pako");yield function(e,t,i){return d(this,null,function*(){const r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json","X-Project-Key":t},body:JSON.stringify(i)});if(!r.ok)throw Object.assign(new Error(`monitor: 回放上传失败 ${r.status}`),{statusCode:r.status})})}(this.opts.replayEndpoint,this.opts.projectKey,{replayId:e,format:"rrweb@2",codec:"deflate-base64",size:i.length,durationMs:t.length>1?t[t.length-1].timestamp-t[0].timestamp:0,occurredAt:(new Date).toISOString(),data:Lt(r(i))})}catch(i){}})}}function Lt(e){let t="";for(let i=0;i<e.length;i+=32768)t+=String.fromCharCode(...e.subarray(i,i+32768));return btoa(t)}e.ExcReporter=p,e.Monitor=class{constructor(e){var t,i;c(this,"endpoint"),c(this,"projectKey"),c(this,"replayEndpoint",""),c(this,"isBusinessError"),c(this,"timeoutDuration"),c(this,"errorQueue"),c(this,"requestQueue"),c(this,"maxQueueSize"),c(this,"sendTimer"),c(this,"reporter"),c(this,"replay",null),c(this,"options"),c(this,"errorSentAt",new Map),c(this,"originalXHR"),c(this,"originalFetch"),c(this,"originalOnerror"),this.options=e,this.endpoint=e.endpoint,this.projectKey=e.projectKey,this.isBusinessError=e.isBusinessError,this.timeoutDuration=null!=(t=e.timeoutDuration)?t:6e4,this.errorQueue=[],this.requestQueue=[],this.maxQueueSize=null!=(i=e.maxQueueSize)?i:10,this.sendTimer=null,this.originalXHR=window.XMLHttpRequest,this.originalFetch=window.fetch,this.originalOnerror=window.onerror,this.reporter=m({endpoint:e.endpoint,projectKey:e.projectKey,release:e.release,environment:e.environment,maxBatch:e.maxBatch,flushInterval:e.flushInterval},w(e.endpoint)),this.init(),this.initReplay()}init(){Et.call(this),Ct.call(this),Ot.call(this),Pt.call(this),At.call(this),It.call(this)}initReplay(){var e,t;const i=this.options.replay;if(!(null==i?void 0:i.enabled))return;const r=null!=(e=i.sampleRate)?e:1;if(Math.random()>=r)return;const o=null!=(t=i.replayEndpoint)?t:function(e){const t=e.replace(/\/+$/,"");return t.endsWith("/report")?`${t.slice(0,-7)}/replay`:void 0}(this.endpoint);o&&(this.replayEndpoint=o,this.replay=new Ht({replayEndpoint:o,projectKey:this.projectKey,bufferSeconds:i.bufferSeconds,maxUploadsPerSession:i.maxUploadsPerSession,minUploadIntervalMs:i.minUploadIntervalMs,maxReplayBytes:i.maxReplayBytes,captureRequest:i.captureRequest,maskTextClass:i.maskTextClass}),this.replay.start())}isDuplicateError(e){var t,i;const r=null!=(t=this.options.errorDedupeMs)?t:0;if(r<=0||"error"!==e.type)return!1;const o=`${e.errorType}|${e.message}|${null!=(i=e.filename)?i:""}`,s=Date.now(),n=this.errorSentAt.get(o);if(void 0!==n&&s-n<r)return!0;if(this.errorSentAt.size>=100)for(const[a,l]of this.errorSentAt)s-l>=r&&this.errorSentAt.delete(a);return this.errorSentAt.set(o,s),!1}send(e){var t;if(this.isDuplicateError(e))return;const i=St(e,{title:document.title,url:location.href,userAgent:navigator.userAgent,browser:`${ut.name} ${ut.version}`,device:`${ct.model} ${ct.vendor}`,os:`${dt.name} ${dt.version}`},this.options),r=null==(t=this.replay)?void 0:t.captureIfTriggered(e);if(r)for(const o of i)o.device=u(l({},o.device),{replayId:r});for(const o of i)this.reporter.capture(o)}capture(e){this.reporter.capture(e)}reportRequest(){0!==this.requestQueue.length&&(this.send({type:"batchXHR",requests:[...this.requestQueue]}),this.requestQueue=[])}reportError(){0!==this.errorQueue.length&&(this.send({type:"batchXHR",requests:[...this.errorQueue]}),this.errorQueue=[])}captureRequest(e){var t;if(!e.type||!["xhr","fetch"].includes(e.type))return;if(i=String(null!=(t=e.url)?t:""),(r=this.endpoint)&&String(i)===r)return;var i,r;const o=["url","method","duration","status","success","startTime"];for(const s of o)if(void 0===e[s])return;e.page=window.location.href,this.requestQueue.push(e),this.requestQueue.length>=this.maxQueueSize&&this.reportRequest()}sendQueuedData(){this.errorQueue.length>0&&this.reportError(),this.requestQueue.length>0&&this.reportRequest()}destroy(){var e;null==(e=this.replay)||e.stop(),this.sendQueuedData(),this.reporter.destroy(),window.XMLHttpRequest=this.originalXHR,window.fetch=this.originalFetch,window.onerror=this.originalOnerror,this.sendTimer&&(clearInterval(this.sendTimer),this.sendTimer=null),this.errorQueue=[],this.requestQueue=[],this.errorSentAt.clear()}},e.SDK_VERSION=h,e.createReporter=m,e.makeH5Transport=w,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 业务错误详情(isBusinessError 判定命中时提取) */
|
|
2
|
+
export interface BusinessErrorInfo {
|
|
3
|
+
code?: number | string;
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 解析响应体并按 isBusinessError 判定业务错误
|
|
8
|
+
* body 支持已解析对象或 JSON 字符串;非 JSON 文本 / 解析失败 / 未配置判定函数返回 null(不拦截)
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectBusinessError(body: unknown, isBusinessError?: (body: unknown) => boolean): BusinessErrorInfo | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectBusinessError = detectBusinessError;
|
|
4
|
+
/**
|
|
5
|
+
* 解析响应体并按 isBusinessError 判定业务错误
|
|
6
|
+
* body 支持已解析对象或 JSON 字符串;非 JSON 文本 / 解析失败 / 未配置判定函数返回 null(不拦截)
|
|
7
|
+
*/
|
|
8
|
+
function detectBusinessError(body, isBusinessError) {
|
|
9
|
+
if (typeof isBusinessError !== 'function')
|
|
10
|
+
return null;
|
|
11
|
+
let parsed = body;
|
|
12
|
+
if (typeof parsed === 'string') {
|
|
13
|
+
const text = parsed.trim();
|
|
14
|
+
// 非 { 或 [ 开头直接跳过,避免对 HTML/文本整体 JSON.parse
|
|
15
|
+
if (!text.startsWith('{') && !text.startsWith('['))
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
parsed = JSON.parse(text);
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!isBusinessError(parsed))
|
|
25
|
+
return null;
|
|
26
|
+
const record = parsed !== null && typeof parsed === 'object' ? parsed : {};
|
|
27
|
+
return {
|
|
28
|
+
code: typeof record.code === 'number' || typeof record.code === 'string' ? record.code : undefined,
|
|
29
|
+
message: typeof record.message === 'string' ? record.message : undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
package/dist/utils/toExcEvent.js
CHANGED
|
@@ -91,20 +91,23 @@ function mapLongTaskLog(log, base, opts) {
|
|
|
91
91
|
}
|
|
92
92
|
/** RequestLog(失败)→ request */
|
|
93
93
|
function mapRequestLog(req, base, opts) {
|
|
94
|
-
var _a, _b, _c;
|
|
94
|
+
var _a, _b, _c, _d;
|
|
95
95
|
if (req.success !== false)
|
|
96
96
|
return null;
|
|
97
97
|
const url = String((_a = req.url) !== null && _a !== void 0 ? _a : '');
|
|
98
98
|
const method = String((_b = req.method) !== null && _b !== void 0 ? _b : 'GET').toUpperCase();
|
|
99
99
|
const status = (_c = req.status) !== null && _c !== void 0 ? _c : 0;
|
|
100
|
-
|
|
100
|
+
// 业务错误用 business + code 作 reason(HTTP 200,靠状态码区分不了具体错误)
|
|
101
|
+
const reason = req.business
|
|
102
|
+
? `business${req.business.code !== undefined ? ` ${req.business.code}` : ''}`
|
|
103
|
+
: (status === 0 ? 'network' : String(status));
|
|
101
104
|
const ctx = contextFields(base, opts);
|
|
102
105
|
return {
|
|
103
106
|
type: 'request',
|
|
104
107
|
level: 'ERROR',
|
|
105
108
|
message: `Request failed [${reason}]: ${method} ${url}`,
|
|
106
109
|
...ctx,
|
|
107
|
-
device: { ...ctx.device, durationMs: req.duration, msg: req.msg },
|
|
110
|
+
device: { ...ctx.device, durationMs: req.duration, msg: req.msg, code: (_d = req.business) === null || _d === void 0 ? void 0 : _d.code },
|
|
108
111
|
};
|
|
109
112
|
}
|
|
110
113
|
function mapBatchRequestLog(log, base, opts) {
|