@qiu_jun/monitors 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniprogram.d.ts +62 -0
- package/dist/miniprogram.js +252 -0
- package/dist/modules/paint.d.ts +10 -1
- package/dist/modules/paint.js +76 -54
- package/dist/modules/timing.d.ts +10 -1
- package/dist/modules/timing.js +36 -35
- package/dist/monitor.umd.js +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 小程序监控入口(按需引入)
|
|
3
|
+
* 与 H5 入口相互独立:transport 基于 wx.request,错误采集基于 wx.onError / wx.onUnhandledRejection
|
|
4
|
+
*/
|
|
5
|
+
import { SDK_VERSION, createReporter } from './exception/reporter';
|
|
6
|
+
import type { ExcReporter } from './exception/reporter';
|
|
7
|
+
import type { ExcEventPayload, ExcSdkOptions, ExcTransport } from './exception/types';
|
|
8
|
+
export type { ExcEventPayload, ExcSdkOptions, ExcReporter, ExcTransport };
|
|
9
|
+
export { SDK_VERSION, createReporter };
|
|
10
|
+
/** 最小 wx 类型声明(避免强制依赖 miniprogram-api-typings) */
|
|
11
|
+
interface WxLike {
|
|
12
|
+
request(options: {
|
|
13
|
+
url: string;
|
|
14
|
+
method?: string;
|
|
15
|
+
header?: Record<string, string>;
|
|
16
|
+
data?: string;
|
|
17
|
+
success?: (res: {
|
|
18
|
+
statusCode: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
fail?: (err: {
|
|
21
|
+
errMsg?: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
}): void;
|
|
24
|
+
onError(callback: (message: string) => void): void;
|
|
25
|
+
offError?(callback: (message: string) => void): void;
|
|
26
|
+
onUnhandledRejection(callback: (res: {
|
|
27
|
+
reason?: unknown;
|
|
28
|
+
}) => void): void;
|
|
29
|
+
offUnhandledRejection?(callback: (res: {
|
|
30
|
+
reason?: unknown;
|
|
31
|
+
}) => void): void;
|
|
32
|
+
onAppHide?(callback: () => void): void;
|
|
33
|
+
offAppHide?(callback: () => void): void;
|
|
34
|
+
getAccountInfoSync?(): {
|
|
35
|
+
miniProgram?: {
|
|
36
|
+
envVersion?: string;
|
|
37
|
+
version?: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
getSystemInfoSync?(): Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
/** 小程序 transport:wx.request POST JSON */
|
|
43
|
+
export declare function makeMiniProgramTransport(endpoint: string, wxApi?: WxLike): ExcTransport;
|
|
44
|
+
export interface MiniProgramMonitorOptions extends ExcSdkOptions {
|
|
45
|
+
/** 用户标识(对齐 H5 侧 IMonitorOptions.userId) */
|
|
46
|
+
userId?: string;
|
|
47
|
+
/** 默认取全局 wx;支付宝/百度等可显式传入适配后的 API */
|
|
48
|
+
wxApi?: WxLike;
|
|
49
|
+
/** 拦截 App/Page/Component 生命周期(默认 true,须在调用 App()/Page() 之前初始化) */
|
|
50
|
+
interceptLifecycle?: boolean;
|
|
51
|
+
/** 拦截 wx.request 上报失败请求(默认 true,上报自身 URL 除外,防递归) */
|
|
52
|
+
interceptRequest?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface MiniProgramMonitor {
|
|
55
|
+
reporter: ExcReporter;
|
|
56
|
+
/** 上报自定义事件 */
|
|
57
|
+
capture: (event: ExcEventPayload) => void;
|
|
58
|
+
/** 立即上报缓冲中的事件,并还原 App/Page/Component 与 wx.request 的包装 */
|
|
59
|
+
destroy: () => void;
|
|
60
|
+
}
|
|
61
|
+
/** 小程序监控:创建 reporter + 挂载错误采集(wx.onError / wx.onUnhandledRejection)+ 切后台 flush */
|
|
62
|
+
export declare function createMiniProgramMonitor(options: MiniProgramMonitorOptions): MiniProgramMonitor;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReporter = exports.SDK_VERSION = void 0;
|
|
4
|
+
exports.makeMiniProgramTransport = makeMiniProgramTransport;
|
|
5
|
+
exports.createMiniProgramMonitor = createMiniProgramMonitor;
|
|
6
|
+
/**
|
|
7
|
+
* 小程序监控入口(按需引入)
|
|
8
|
+
* 与 H5 入口相互独立:transport 基于 wx.request,错误采集基于 wx.onError / wx.onUnhandledRejection
|
|
9
|
+
*/
|
|
10
|
+
const reporter_1 = require("./exception/reporter");
|
|
11
|
+
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return reporter_1.SDK_VERSION; } });
|
|
12
|
+
Object.defineProperty(exports, "createReporter", { enumerable: true, get: function () { return reporter_1.createReporter; } });
|
|
13
|
+
/** 从全局取 wx(微信 / uni-app 等均已注入),取不到返回 undefined */
|
|
14
|
+
function getWx() {
|
|
15
|
+
return globalThis.wx;
|
|
16
|
+
}
|
|
17
|
+
/** 小程序 transport:wx.request POST JSON */
|
|
18
|
+
function makeMiniProgramTransport(endpoint, wxApi) {
|
|
19
|
+
const api = wxApi !== null && wxApi !== void 0 ? wxApi : getWx();
|
|
20
|
+
if (!api)
|
|
21
|
+
throw new Error('monitor: 未找到 wx 全局对象,请显式传入 wxApi');
|
|
22
|
+
return (payload, projectKey) => new Promise((resolve, reject) => {
|
|
23
|
+
api.request({
|
|
24
|
+
url: endpoint,
|
|
25
|
+
method: 'POST',
|
|
26
|
+
header: { 'content-type': 'application/json', 'X-Project-Key': projectKey },
|
|
27
|
+
data: JSON.stringify(payload),
|
|
28
|
+
success: (res) => {
|
|
29
|
+
if (res.statusCode >= 200 && res.statusCode < 300)
|
|
30
|
+
resolve();
|
|
31
|
+
else
|
|
32
|
+
reject(Object.assign(new Error(`monitor: 上报失败 ${res.statusCode}`), { statusCode: res.statusCode }));
|
|
33
|
+
},
|
|
34
|
+
fail: err => { var _a; return reject(new Error(`monitor: 上报失败 ${(_a = err === null || err === void 0 ? void 0 : err.errMsg) !== null && _a !== void 0 ? _a : 'network error'}`)); },
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/** Page/Component 实例生命周期 */
|
|
39
|
+
const PAGE_LIFECYCLES = ['onLoad', 'onShow', 'onReady', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onError'];
|
|
40
|
+
/** App 生命周期 */
|
|
41
|
+
const APP_LIFECYCLES = ['onLaunch', 'onShow', 'onHide', 'onPageNotFound'];
|
|
42
|
+
/** Component 生命周期 */
|
|
43
|
+
const COMPONENT_LIFECYCLES = ['attached', 'ready', 'detached'];
|
|
44
|
+
/**
|
|
45
|
+
* 包装生命周期:正常执行不打扰;抛错(含 async 生命周期 reject)时上报
|
|
46
|
+
* 带 lifecycle/页面/组件上下文与耗时,然后原样抛出(wx.onError 兜底,内部去重防双报)
|
|
47
|
+
*/
|
|
48
|
+
function wrapLifecycle(fn, name, getContext) {
|
|
49
|
+
return function (...args) {
|
|
50
|
+
const start = Date.now();
|
|
51
|
+
const handleError = (err) => {
|
|
52
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
53
|
+
lifecycleErrorHandler === null || lifecycleErrorHandler === void 0 ? void 0 : lifecycleErrorHandler({
|
|
54
|
+
type: 'error',
|
|
55
|
+
message: e.message,
|
|
56
|
+
stack: e.stack,
|
|
57
|
+
lifecycle: name,
|
|
58
|
+
duration: Date.now() - start,
|
|
59
|
+
page: getContext().page,
|
|
60
|
+
component: getContext().component,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
const result = fn.apply(this, args);
|
|
65
|
+
// async 生命周期(如 async onLoad)的 reject
|
|
66
|
+
if (result instanceof Promise)
|
|
67
|
+
return result.catch((err) => { handleError(err); throw err; });
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
handleError(err);
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** wrapLifecycle 上报出口(由 createMiniProgramMonitor 注入) */
|
|
77
|
+
let lifecycleErrorHandler = null;
|
|
78
|
+
/** 短窗口内同消息去重(生命周期包装抛出 + wx.onError 会收到同一条错误) */
|
|
79
|
+
let lastErrorCache = { message: '', time: 0 };
|
|
80
|
+
function isDuplicate(message) {
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
if (message === lastErrorCache.message && now - lastErrorCache.time < 5000)
|
|
83
|
+
return true;
|
|
84
|
+
lastErrorCache = { message, time: now };
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 拦截全局 App/Page/Component:包装生命周期与组件 methods(抛错时带上下文上报)
|
|
89
|
+
* 必须在业务代码调用 App()/Page()/Component() 之前执行
|
|
90
|
+
*/
|
|
91
|
+
function interceptConstructors() {
|
|
92
|
+
const g = globalThis;
|
|
93
|
+
function wrapDefinition(original, kind) {
|
|
94
|
+
return function (options) {
|
|
95
|
+
const lifecycles = kind === 'App' ? APP_LIFECYCLES : kind === 'Page' ? PAGE_LIFECYCLES : COMPONENT_LIFECYCLES;
|
|
96
|
+
const getContext = () => ({ page: kind === 'App' ? '' : currentPageRoute(), component: kind === 'Component' ? 'Component' : undefined });
|
|
97
|
+
for (const name of lifecycles) {
|
|
98
|
+
const fn = options === null || options === void 0 ? void 0 : options[name];
|
|
99
|
+
if (typeof fn === 'function')
|
|
100
|
+
options[name] = wrapLifecycle(fn, name, getContext);
|
|
101
|
+
}
|
|
102
|
+
// Component 的 methods 也包一层(组件方法抛错常见于这里)
|
|
103
|
+
if (kind === 'Component' && (options === null || options === void 0 ? void 0 : options.methods)) {
|
|
104
|
+
for (const name of Object.keys(options.methods)) {
|
|
105
|
+
const fn = options.methods[name];
|
|
106
|
+
if (typeof fn === 'function')
|
|
107
|
+
options.methods[name] = wrapLifecycle(fn, name, getContext);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return original.call(this, options);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const originals = {};
|
|
114
|
+
for (const key of ['App', 'Page', 'Component']) {
|
|
115
|
+
if (typeof g[key] === 'function') {
|
|
116
|
+
originals[key] = g[key];
|
|
117
|
+
g[key] = Object.assign(wrapDefinition(g[key], key), { __monitor_original__: g[key] });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return () => {
|
|
121
|
+
var _a;
|
|
122
|
+
for (const [key, fn] of Object.entries(originals)) {
|
|
123
|
+
if (((_a = g[key]) === null || _a === void 0 ? void 0 : _a.__monitor_original__) === fn)
|
|
124
|
+
g[key] = fn;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function currentPageRoute() {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
try {
|
|
131
|
+
const pages = (_c = (_b = (_a = globalThis).getCurrentPages) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
|
|
132
|
+
const route = (_d = pages[pages.length - 1]) === null || _d === void 0 ? void 0 : _d.route;
|
|
133
|
+
return route ? `/${route}` : '';
|
|
134
|
+
}
|
|
135
|
+
catch (_e) {
|
|
136
|
+
return '';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** 拦截 wx.request:失败的请求按 H5 侧 request 事件格式上报(上报自身 URL 除外,防递归) */
|
|
140
|
+
function interceptRequest(wxApi, endpoint, capture) {
|
|
141
|
+
const original = wxApi.request.bind(wxApi);
|
|
142
|
+
wxApi.request = (options) => {
|
|
143
|
+
var _a;
|
|
144
|
+
const url = String((_a = options === null || options === void 0 ? void 0 : options.url) !== null && _a !== void 0 ? _a : '');
|
|
145
|
+
if (url === endpoint)
|
|
146
|
+
return original(options);
|
|
147
|
+
const start = Date.now();
|
|
148
|
+
return original({
|
|
149
|
+
...options,
|
|
150
|
+
success: (res) => {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
if (res.statusCode >= 400) {
|
|
153
|
+
capture({
|
|
154
|
+
type: 'request',
|
|
155
|
+
message: `Request failed [${res.statusCode}]: ${String((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET').toUpperCase()} ${url}`,
|
|
156
|
+
device: { durationMs: Date.now() - start },
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
(_b = options === null || options === void 0 ? void 0 : options.success) === null || _b === void 0 ? void 0 : _b.call(options, res);
|
|
160
|
+
},
|
|
161
|
+
fail: (err) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
capture({
|
|
164
|
+
type: 'request',
|
|
165
|
+
message: `Request failed [network]: ${String((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET').toUpperCase()} ${url}`,
|
|
166
|
+
device: { durationMs: Date.now() - start, msg: err === null || err === void 0 ? void 0 : err.errMsg },
|
|
167
|
+
});
|
|
168
|
+
(_b = options === null || options === void 0 ? void 0 : options.fail) === null || _b === void 0 ? void 0 : _b.call(options, err);
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
return () => {
|
|
173
|
+
;
|
|
174
|
+
wxApi.request = original;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** 小程序监控:创建 reporter + 挂载错误采集(wx.onError / wx.onUnhandledRejection)+ 切后台 flush */
|
|
178
|
+
function createMiniProgramMonitor(options) {
|
|
179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
180
|
+
const wxApi = (_a = options.wxApi) !== null && _a !== void 0 ? _a : getWx();
|
|
181
|
+
if (!wxApi)
|
|
182
|
+
throw new Error('monitor: 未找到 wx 全局对象,请显式传入 wxApi');
|
|
183
|
+
const reporter = (0, reporter_1.createReporter)(options, makeMiniProgramTransport(options.endpoint, wxApi));
|
|
184
|
+
const sys = (_b = wxApi.getSystemInfoSync) === null || _b === void 0 ? void 0 : _b.call(wxApi);
|
|
185
|
+
const account = (_c = wxApi.getAccountInfoSync) === null || _c === void 0 ? void 0 : _c.call(wxApi).miniProgram;
|
|
186
|
+
// device 字段与 H5 侧 toExcEvent.baseDeviceFields 对齐:title/url/browser/os/deviceInfo/userAgent
|
|
187
|
+
const baseDevice = {
|
|
188
|
+
browser: `miniProgram ${(_d = account === null || account === void 0 ? void 0 : account.envVersion) !== null && _d !== void 0 ? _d : ''}`.trim(),
|
|
189
|
+
os: String((_e = sys === null || sys === void 0 ? void 0 : sys.system) !== null && _e !== void 0 ? _e : ''),
|
|
190
|
+
deviceInfo: `${(_f = sys === null || sys === void 0 ? void 0 : sys.brand) !== null && _f !== void 0 ? _f : ''} ${(_g = sys === null || sys === void 0 ? void 0 : sys.model) !== null && _g !== void 0 ? _g : ''}`.trim(),
|
|
191
|
+
userAgent: String((_h = sys === null || sys === void 0 ? void 0 : sys.host) !== null && _h !== void 0 ? _h : ''),
|
|
192
|
+
};
|
|
193
|
+
/** 当前页面路由(对齐 H5 侧的 page: location.href) */
|
|
194
|
+
const currentPage = currentPageRoute;
|
|
195
|
+
const withBase = (event) => {
|
|
196
|
+
var _a, _b, _c, _d, _e, _f;
|
|
197
|
+
return ({
|
|
198
|
+
level: 'ERROR',
|
|
199
|
+
...event,
|
|
200
|
+
page: (_a = event.page) !== null && _a !== void 0 ? _a : currentPage(),
|
|
201
|
+
userId: (_b = event.userId) !== null && _b !== void 0 ? _b : options.userId,
|
|
202
|
+
release: (_d = (_c = event.release) !== null && _c !== void 0 ? _c : options.release) !== null && _d !== void 0 ? _d : account === null || account === void 0 ? void 0 : account.version,
|
|
203
|
+
environment: (_f = (_e = event.environment) !== null && _e !== void 0 ? _e : options.environment) !== null && _f !== void 0 ? _f : ((account === null || account === void 0 ? void 0 : account.envVersion) === 'release' ? 'production' : account === null || account === void 0 ? void 0 : account.envVersion),
|
|
204
|
+
device: { ...baseDevice, ...event.device },
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const onError = (message) => {
|
|
208
|
+
// 生命周期包装已上报过的错误(包装后原样抛出会再进这里),5s 内同消息去重
|
|
209
|
+
if (isDuplicate(message))
|
|
210
|
+
return;
|
|
211
|
+
const [msg, ...stackLines] = message.split('\n');
|
|
212
|
+
reporter.capture(withBase({ type: 'error', message: msg, stack: stackLines.join('\n') || undefined }));
|
|
213
|
+
};
|
|
214
|
+
const onUnhandledRejection = (res) => {
|
|
215
|
+
var _a;
|
|
216
|
+
const reason = res.reason;
|
|
217
|
+
const err = reason instanceof Error ? reason : undefined;
|
|
218
|
+
reporter.capture(withBase({
|
|
219
|
+
type: 'unhandledrejection',
|
|
220
|
+
message: (_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : (typeof reason === 'string' ? reason : JSON.stringify(reason)),
|
|
221
|
+
stack: err === null || err === void 0 ? void 0 : err.stack,
|
|
222
|
+
}));
|
|
223
|
+
};
|
|
224
|
+
const onAppHide = () => void reporter.flush();
|
|
225
|
+
wxApi.onError(onError);
|
|
226
|
+
wxApi.onUnhandledRejection(onUnhandledRejection);
|
|
227
|
+
(_j = wxApi.onAppHide) === null || _j === void 0 ? void 0 : _j.call(wxApi, onAppHide);
|
|
228
|
+
const doCapture = (event) => reporter.capture(withBase(event));
|
|
229
|
+
// 生命周期拦截:包装内抛错 → 带上下文上报;随后原样抛出由 wx.onError 兜底(已去重)
|
|
230
|
+
lifecycleErrorHandler = info => doCapture({
|
|
231
|
+
type: 'error',
|
|
232
|
+
message: info.message,
|
|
233
|
+
stack: info.stack,
|
|
234
|
+
device: { lifecycle: info.lifecycle, duration: info.duration, component: info.component },
|
|
235
|
+
});
|
|
236
|
+
const restoreConstructors = options.interceptLifecycle !== false ? interceptConstructors() : null;
|
|
237
|
+
const restoreRequest = options.interceptRequest !== false ? interceptRequest(wxApi, options.endpoint, doCapture) : null;
|
|
238
|
+
return {
|
|
239
|
+
reporter,
|
|
240
|
+
capture: doCapture,
|
|
241
|
+
destroy: () => {
|
|
242
|
+
var _a, _b, _c;
|
|
243
|
+
lifecycleErrorHandler = null;
|
|
244
|
+
restoreConstructors === null || restoreConstructors === void 0 ? void 0 : restoreConstructors();
|
|
245
|
+
restoreRequest === null || restoreRequest === void 0 ? void 0 : restoreRequest();
|
|
246
|
+
(_a = wxApi.offError) === null || _a === void 0 ? void 0 : _a.call(wxApi, onError);
|
|
247
|
+
(_b = wxApi.offUnhandledRejection) === null || _b === void 0 ? void 0 : _b.call(wxApi, onUnhandledRejection);
|
|
248
|
+
(_c = wxApi.offAppHide) === null || _c === void 0 ? void 0 : _c.call(wxApi, onAppHide);
|
|
249
|
+
reporter.destroy();
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
package/dist/modules/paint.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PaintLog } from '../interface';
|
|
2
|
+
type PaintHost = {
|
|
3
|
+
send: (log: PaintLog) => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* 采集绘制指标 FP/FCP/FMP/LCP。
|
|
7
|
+
* 若 SDK 在 window.load 之后初始化,仍会延迟上报(含 buffered 历史指标)。
|
|
8
|
+
*/
|
|
9
|
+
export default function onPaint(this: PaintHost): void;
|
|
10
|
+
export {};
|
package/dist/modules/paint.js
CHANGED
|
@@ -1,61 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = onPaint;
|
|
4
|
+
/** 带历史缓冲的 PerformanceObserver(兼容 SDK 晚于首次绘制才启动) */
|
|
5
|
+
function observeBuffered(type, callback) {
|
|
6
|
+
if (typeof PerformanceObserver === 'undefined')
|
|
7
|
+
return null;
|
|
8
|
+
try {
|
|
9
|
+
const observer = new PerformanceObserver((list) => {
|
|
10
|
+
callback(list.getEntries());
|
|
11
|
+
});
|
|
12
|
+
// type + buffered 可拿到观察前已产生的条目
|
|
13
|
+
observer.observe({ type, buffered: true });
|
|
14
|
+
return observer;
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
console.warn('[monitor] PerformanceObserver 不支持 type=', type, err);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 采集绘制指标 FP/FCP/FMP/LCP。
|
|
23
|
+
* 若 SDK 在 window.load 之后初始化,仍会延迟上报(含 buffered 历史指标)。
|
|
24
|
+
*/
|
|
4
25
|
function onPaint() {
|
|
5
|
-
if (PerformanceObserver) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
else if (perfEntry.name === "first-contentful-paint") {
|
|
19
|
-
FCP = perfEntry;
|
|
20
|
-
console.log("首次内容绘制 时间:", FCP === null || FCP === void 0 ? void 0 : FCP.startTime);
|
|
21
|
-
observerFPAndFCP.disconnect(); // 得到 FCP 后,断开观察,不再观察了
|
|
22
|
-
}
|
|
26
|
+
if (typeof PerformanceObserver === 'undefined') {
|
|
27
|
+
console.warn('[monitor] 当前环境不支持 PerformanceObserver,跳过 paint 采集');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let FP = null;
|
|
31
|
+
let FCP = null;
|
|
32
|
+
let FMP = null;
|
|
33
|
+
let LCP = null;
|
|
34
|
+
const observerFPAndFCP = observeBuffered('paint', (entries) => {
|
|
35
|
+
for (const entry of entries) {
|
|
36
|
+
if (entry.name === 'first-paint') {
|
|
37
|
+
FP = entry;
|
|
38
|
+
console.log('[monitor] FP', FP.startTime);
|
|
23
39
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
40
|
+
else if (entry.name === 'first-contentful-paint') {
|
|
41
|
+
FCP = entry;
|
|
42
|
+
console.log('[monitor] FCP', FCP.startTime);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const observerFMP = observeBuffered('element', (entries) => {
|
|
47
|
+
if (entries.length > 0) {
|
|
48
|
+
FMP = entries[0];
|
|
49
|
+
console.log('[monitor] FMP', FMP.startTime);
|
|
50
|
+
observerFMP === null || observerFMP === void 0 ? void 0 : observerFMP.disconnect();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// LCP 会多次更新,上报前再 disconnect
|
|
54
|
+
const observerLCP = observeBuffered('largest-contentful-paint', (entries) => {
|
|
55
|
+
if (entries.length > 0) {
|
|
56
|
+
LCP = entries[entries.length - 1];
|
|
57
|
+
console.log('[monitor] LCP', LCP.startTime);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
/** load 后再等一段时间,尽量拿到稳定 LCP 再上报 */
|
|
61
|
+
const scheduleReport = () => {
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
observerLCP === null || observerLCP === void 0 ? void 0 : observerLCP.disconnect();
|
|
64
|
+
observerFPAndFCP === null || observerFPAndFCP === void 0 ? void 0 : observerFPAndFCP.disconnect();
|
|
65
|
+
observerFMP === null || observerFMP === void 0 ? void 0 : observerFMP.disconnect();
|
|
66
|
+
const log = {
|
|
67
|
+
type: 'paint',
|
|
68
|
+
FP: FP === null || FP === void 0 ? void 0 : FP.startTime,
|
|
69
|
+
FCP: FCP === null || FCP === void 0 ? void 0 : FCP.startTime,
|
|
70
|
+
FMP: FMP === null || FMP === void 0 ? void 0 : FMP.startTime,
|
|
71
|
+
LCP: LCP === null || LCP === void 0 ? void 0 : LCP.startTime,
|
|
72
|
+
};
|
|
73
|
+
console.log('[monitor] paint 上报', log);
|
|
74
|
+
this.send(log);
|
|
75
|
+
}, 3000);
|
|
76
|
+
};
|
|
77
|
+
if (document.readyState === 'complete') {
|
|
78
|
+
console.log('[monitor] 页面已 load 完成,延迟补报 paint');
|
|
79
|
+
scheduleReport();
|
|
80
|
+
return;
|
|
60
81
|
}
|
|
82
|
+
window.addEventListener('load', scheduleReport);
|
|
61
83
|
}
|
package/dist/modules/timing.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TimingLog } from '../interface';
|
|
2
|
+
type TimingHost = {
|
|
3
|
+
send: (log: TimingLog) => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* 监听页面加载时序。
|
|
7
|
+
* 若 SDK 在 window.load 之后才初始化,直接补报,避免永远收不到 timing。
|
|
8
|
+
*/
|
|
9
|
+
export default function onTiming(this: TimingHost): void;
|
|
10
|
+
export {};
|
package/dist/modules/timing.js
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = onTiming;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
DOMContentLoadedTime = domContentLoadedEventStart - fetchStart;
|
|
15
|
-
// console.log(`DOMContentLoaded 的执行时间:${DOMContentLoadedTime}ms`);
|
|
16
|
-
// 页面完整的加载时间
|
|
17
|
-
loadTime = loadEventStart - fetchStart;
|
|
18
|
-
// console.log(`load 页面完整的加载时间:${loadTime}ms`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// 旧版浏览器降级使用 performance.timing
|
|
22
|
-
else {
|
|
23
|
-
const { fetchStart, domContentLoadedEventStart, loadEventStart } = performance.timing;
|
|
24
|
-
// DOM 树构建完成后触发 DOMContentLoaded 事件
|
|
4
|
+
/** 采集并上报页面加载时序(DOMContentLoaded / load) */
|
|
5
|
+
function reportTiming() {
|
|
6
|
+
let DOMContentLoadedTime = 0;
|
|
7
|
+
let loadTime = 0;
|
|
8
|
+
// 新版:PerformanceNavigationTiming;旧版降级 performance.timing
|
|
9
|
+
if (performance.getEntriesByType) {
|
|
10
|
+
const perfEntries = performance.getEntriesByType('navigation');
|
|
11
|
+
if (perfEntries.length > 0) {
|
|
12
|
+
const navigationEntry = perfEntries[0];
|
|
13
|
+
const { domContentLoadedEventStart, loadEventStart, fetchStart } = navigationEntry;
|
|
25
14
|
DOMContentLoadedTime = domContentLoadedEventStart - fetchStart;
|
|
26
|
-
// console.log(`---DOMContentLoaded 的执行时间:${DOMContentLoadedTime}ms`);
|
|
27
|
-
// 页面完整的加载时间
|
|
28
15
|
loadTime = loadEventStart - fetchStart;
|
|
29
|
-
// console.log(`load 页面完整的加载时间:${loadTime}ms`);
|
|
30
16
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const { fetchStart, domContentLoadedEventStart, loadEventStart } = performance.timing;
|
|
20
|
+
DOMContentLoadedTime = domContentLoadedEventStart - fetchStart;
|
|
21
|
+
loadTime = loadEventStart - fetchStart;
|
|
22
|
+
}
|
|
23
|
+
const log = {
|
|
24
|
+
type: 'timing',
|
|
25
|
+
DOMContentLoadedTime,
|
|
26
|
+
loadTime,
|
|
27
|
+
};
|
|
28
|
+
console.log('[monitor] timing 上报', log);
|
|
29
|
+
this.send(log);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 监听页面加载时序。
|
|
33
|
+
* 若 SDK 在 window.load 之后才初始化,直接补报,避免永远收不到 timing。
|
|
34
|
+
*/
|
|
35
|
+
function onTiming() {
|
|
36
|
+
const run = () => reportTiming.call(this);
|
|
37
|
+
if (document.readyState === 'complete') {
|
|
38
|
+
console.log('[monitor] 页面已 load 完成,立即补报 timing');
|
|
39
|
+
run();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
window.addEventListener('load', run);
|
|
42
43
|
}
|
package/dist/monitor.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).Monitor={})}(this,function(e){"use strict";var i=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(e,t,r)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(e,i)=>{for(var t in i||(i={}))n.call(i,t)&&a(e,t,i[t]);if(o)for(var t of o(i))s.call(i,t)&&a(e,t,i[t]);return e},c=(e,i)=>t(e,r(i)),u=(e,i,t)=>a(e,"symbol"!=typeof i?i+"":i,t),d=(e,i,t)=>new Promise((r,o)=>{var n=e=>{try{a(t.next(e))}catch(i){o(i)}},s=e=>{try{a(t.throw(e))}catch(i){o(i)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,s);a((t=t.apply(e,i)).next())});const h="0.0.1";class w{constructor(e,i){u(this,"buffer",[]),u(this,"timer",null),u(this,"sending",!1),this.options=e,this.transport=i}capture(e){var i,t,r,o,n;const s=null!=(i=this.options.sampleRate)?i:100;s<100&&100*Math.random()>=s||(this.buffer.push(c(l({},e),{level:null!=(t=e.level)?t:"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(i){403!==(null==i?void 0:i.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 p(e,i){return new w(e,i)}function b(e){return(i,t)=>d(null,null,function*(){const r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json","X-Project-Key":t},body:JSON.stringify(i),keepalive:!0});if(!r.ok)throw Object.assign(new Error(`monitor: 上报失败 ${r.status}`),{statusCode:r.status})})}let m,f;function g(){return m}["click","touchstart","mousedown","keydown"].forEach(e=>{document.addEventListener(e,e=>{m=e,f=e.path||e.composedPath()},{capture:!0,passive:!0})});var v,y="user-agent",k="",x="function",T="undefined",S="object",E="string",O="browser",C="cpu",R="device",q="engine",P="os",j="result",H="name",M="type",_="vendor",L="version",I="architecture",$="major",N="model",z="console",A="mobile",F="tablet",D="smarttv",V="wearable",B="xr",Q="embedded",X="inapp",W="brands",U="formFactors",G="fullVersionList",K="platform",Y="platformVersion",J="bitness",Z="sec-ch-ua",ee=Z+"-full-version-list",ie=Z+"-arch",te=Z+"-"+J,re=Z+"-form-factors",oe=Z+"-"+A,ne=Z+"-"+N,se=Z+"-"+K,ae=se+"-version",le=[W,G,A,N,K,Y,I,U,J],ce="Amazon",ue="Apple",de="ASUS",he="BlackBerry",we="Google",pe="Huawei",be="Lenovo",me="Honor",fe="LG",ge="Microsoft",ve="Motorola",ye="Nvidia",ke="OnePlus",xe="OPPO",Te="Samsung",Se="Sharp",Ee="Sony",Oe="Xiaomi",Ce="Zebra",Re="Chrome",qe="Chromium",Pe="Chromecast",je="Edge",He="Firefox",Me="Opera",_e="Facebook",Le="Sogou",Ie="Mobile ",$e=" Browser",Ne="Windows",ze=typeof window!==T&&window.navigator?window.navigator:void 0,Ae=ze&&ze.userAgentData?ze.userAgentData:void 0,Fe=function(e){for(var i={},t=0;t<e.length;t++)i[e[t].toUpperCase()]=e[t];return i},De=function(e,i){if(typeof e===S&&e.length>0){for(var t in e)if(Xe(i)==Xe(e[t]))return!0;return!1}return!!Be(e)&&Xe(i)==Xe(e)},Ve=function(e,i){for(var t in e)return/^(browser|cpu|device|engine|os)$/.test(t)||!!i&&Ve(e[t])},Be=function(e){return typeof e===E},Qe=function(e){if(e){for(var i=[],t=Ge(/\\?\"/g,e).split(","),r=0;r<t.length;r++)if(t[r].indexOf(";")>-1){var o=Ye(t[r]).split(";v=");i[r]={brand:o[0],version:o[1]}}else i[r]=Ye(t[r]);return i}},Xe=function(e){return Be(e)?e.toLowerCase():e},We=function(e){return Be(e)?Ge(/[^\d\.]/g,e).split(".")[0]:void 0},Ue=function(e){for(var i in e){var t=e[i];typeof t==S&&2==t.length?this[t[0]]=t[1]:this[t]=void 0}return this},Ge=function(e,i){return Be(i)?i.replace(e,k):i},Ke=function(e){return Ge(/\\?\"/g,e)},Ye=function(e,i){if(Be(e))return e=Ge(/^\s\s*/,e),typeof i===T?e:e.substring(0,500)},Je=function(e,i){if(e&&i)for(var t,r,o,n,s,a,l=0;l<i.length&&!s;){var c=i[l],u=i[l+1];for(t=r=0;t<c.length&&!s&&c[t];)if(s=c[t++].exec(e))for(o=0;o<u.length;o++)a=s[++r],typeof(n=u[o])===S&&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,i){for(var t in i)if(typeof i[t]===S&&i[t].length>0){for(var r=0;r<i[t].length;r++)if(De(i[t][r],e))return"?"===t?void 0:t}else if(De(i[t],e))return"?"===t?void 0:t;return i.hasOwnProperty("*")?i["*"]:e},ei={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:""},ii={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},ti={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"},ri={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[L,[H,Ie+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[L,[H,je+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[L,[H,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[H,L],[/opios[\/ ]+([\w\.]+)/i],[L,[H,Me+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[L,[H,Me+" GX"]],[/\bopr\/([\w\.]+)/i],[L,[H,Me]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[L,[H,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[L,[H,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:lg |qute)browser)\/([-\w\.]+)/i,/(heytap|ovi|115|surf)browser\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[H,L],[/quark(?:pc)?\/([-\w\.]+)/i],[L,[H,"Quark"]],[/\bddg\/([\w\.]+)/i],[L,[H,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[L,[H,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[L,[H,"WeChat"]],[/konqueror\/([\w\.]+)/i],[L,[H,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[L,[H,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[L,[H,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[L,[H,"Smart "+be+$e]],[/(avast|avg)\/([\w\.]+)/i],[[H,/(.+)/,"$1 Secure"+$e],L],[/\bfocus\/([\w\.]+)/i],[L,[H,He+" Focus"]],[/\bopt\/([\w\.]+)/i],[L,[H,Me+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[L,[H,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[L,[H,"Dolphin"]],[/coast\/([\w\.]+)/i],[L,[H,Me+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[L,[H,"MIUI"+$e]],[/fxios\/([\w\.-]+)/i],[L,[H,Ie+He]],[/\bqihoobrowser\/?([\w\.]*)/i],[L,[H,"360"]],[/\b(qq)\/([\w\.]+)/i],[[H,/(.+)/,"$1Browser"],L],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[H,/(.+)/,"$1"+$e],L],[/samsungbrowser\/([\w\.]+)/i],[L,[H,Te+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[L,[H,Le+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[H,Le+" Mobile"],L],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[H,L],[/(lbbrowser|rekonq)/i],[H],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[L,H],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[H,_e],L,[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,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[H,L,[M,X]],[/\bgsa\/([\w\.]+) .*safari\//i],[L,[H,"GSA"],[M,X]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[L,[H,"TikTok"],[M,X]],[/\[(linkedin)app\]/i],[H,[M,X]],[/(chromium)[\/ ]([-\w\.]+)/i],[H,L],[/headlesschrome(?:\/([\w\.]+)| )/i],[L,[H,Re+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[L,[H,je+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[H,Re+" WebView"],L],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[L,[H,"Android"+$e]],[/chrome\/([\w\.]+) mobile/i],[L,[H,Ie+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[H,L],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[L,[H,Ie+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[H,Ie+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[L,H],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[H,[L,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[H,L],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[H,Ie+He],L],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[H,"Netscape"],L],[/(wolvic|librewolf)\/([\w\.]+)/i],[H,L],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[L,[H,He+" 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|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[H,[L,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[H,[L,/[^\d\.]+./,k]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[I,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[I,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[I,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[I,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[I,"arm"]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[I,/ower/,k,Xe]],[/ sun4\w[;\)]/i],[[I,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[I,Xe]]],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],[N,[_,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],[N,[_,Te],[M,A]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[N,[_,ue],[M,A]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[N,[_,ue],[M,F]],[/(macintosh);/i],[N,[_,ue]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[N,[_,Se],[M,A]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[N,[_,me],[M,F]],[/honor([-\w ]+)[;\)]/i],[N,[_,me],[M,A]],[/\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],[N,[_,pe],[M,F]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[N,[_,pe],[M,A]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[N,/_/g," "],[_,Oe],[M,F]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[N,/_/g," "],[_,Oe],[M,A]],[/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-k]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[N,[_,ke],[M,A]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[N,[_,xe],[M,A]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[N,[_,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],[N,[_,"BLU"],[M,A]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[N,[_,"Vivo"],[M,A]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[N,[_,"Realme"],[M,A]],[/(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],[N,[_,be],[M,F]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[N,[_,be],[M,A]],[/\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],[N,[_,ve],[M,A]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[N,[_,ve],[M,F]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[N,[_,fe],[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],[N,[_,fe],[M,A]],[/(nokia) (t[12][01])/i],[_,N,[M,F]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[N,/_/g," "],[M,A],[_,"Nokia"]],[/(pixel (c|tablet))\b/i],[N,[_,we],[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],[N,[_,we],[M,A]],[/(google) (pixelbook( go)?)/i],[_,N],[/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],[N,[_,Ee],[M,A]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[N,"Xperia Tablet"],[_,Ee],[M,F]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[N,[_,ce],[M,F]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[N,/(.+)/g,"Fire Phone $1"],[_,ce],[M,A]],[/(playbook);[-\w\),; ]+(rim)/i],[N,_,[M,F]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[N,[_,he],[M,A]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[N,[_,de],[M,F]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[N,[_,de],[M,A]],[/(nexus 9)/i],[N,[_,"HTC"],[M,F]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[_,[N,/_/g," "],[M,A]],[/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],[N,[_,"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],[N,[_,"TCL"],[M,A]],[/(itel) ((\w+))/i],[[_,Xe],N,[M,Ze,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[N,[_,"Acer"],[M,F]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[N,[_,"Meizu"],[M,A]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[N,[_,"Ulefone"],[M,A]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[N,[_,"Energizer"],[M,A]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[N,[_,"Cat"],[M,A]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[N,[_,"Smartfren"],[M,A]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[N,[_,"Nothing"],[M,A]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[N,[_,"Archos"],[M,F]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[N,[_,"Archos"],[M,A]],[/; (n159v)/i],[N,[_,"HMD"],[M,A]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[_,N,[M,F]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|infinix|lava|oneplus|tcl)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i],[_,N,[M,A]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[_,N,[M,F]],[/(surface duo)/i],[N,[_,ge],[M,F]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[N,[_,"Fairphone"],[M,A]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[N,[_,ye],[M,F]],[/(sprint) (\w+)/i],[_,N,[M,A]],[/(kin\.[onetw]{3})/i],[[N,/\./g," "],[_,ge],[M,A]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[N,[_,Ce],[M,F]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[N,[_,Ce],[M,A]],[/smart-tv.+(samsung)/i],[_,[M,D]],[/hbbtv.+maple;(\d+)/i],[[N,/^/,"SmartTV"],[_,Te],[M,D]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[_,N,[M,D]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[_,fe],[M,D]],[/(apple) ?tv/i],[_,[N,ue+" TV"],[M,D]],[/crkey.*devicetype\/chromecast/i],[[N,Pe+" Third Generation"],[_,we],[M,D]],[/crkey.*devicetype\/([^/]*)/i],[[N,/^/,"Chromecast "],[_,we],[M,D]],[/fuchsia.*crkey/i],[[N,Pe+" Nest Hub"],[_,we],[M,D]],[/crkey/i],[[N,Pe],[_,we],[M,D]],[/(portaltv)/i],[N,[_,_e],[M,D]],[/droid.+aft(\w+)( bui|\))/i],[N,[_,ce],[M,D]],[/(shield \w+ tv)/i],[N,[_,ye],[M,D]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[N,[_,Se],[M,D]],[/(bravia[\w ]+)( bui|\))/i],[N,[_,Ee],[M,D]],[/(mi(tv|box)-?\w+) bui/i],[N,[_,Oe],[M,D]],[/Hbbtv.*(technisat) (.*);/i],[_,N,[M,D]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[_,/.+\/(\w+)/,"$1",Ze,{LG:"lge"}],[N,Ye],[M,D]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[N,[M,D]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:|large screen[\w ]+safari)\b/i],[[M,D]],[/(playstation \w+)/i],[N,[_,Ee],[M,z]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[N,[_,ge],[M,z]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[_,N,[M,z]],[/droid.+; (shield)( bui|\))/i],[N,[_,ye],[M,z]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[N,[_,Te],[M,V]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[_,N,[M,V]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[N,[_,xe],[M,V]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[N,[_,ue],[M,V]],[/(opwwe\d{3})/i],[N,[_,ke],[M,V]],[/(moto 360)/i],[N,[_,ve],[M,V]],[/(smartwatch 3)/i],[N,[_,Ee],[M,V]],[/(g watch r)/i],[N,[_,fe],[M,V]],[/droid.+; (wt63?0{2,3})\)/i],[N,[_,Ce],[M,V]],[/droid.+; (glass) \d/i],[N,[_,we],[M,B]],[/(pico) (4|neo3(?: link|pro)?)/i],[_,N,[M,B]],[/(quest( \d| pro)?s?).+vr/i],[N,[_,_e],[M,B]],[/mobile vr; rv.+firefox/i],[[M,B]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[_,[M,Q]],[/(aeobc)\b/i],[N,[_,ce],[M,Q]],[/(homepod).+mac os/i],[N,[_,ue],[M,Q]],[/windows iot/i],[[M,Q]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i],[N,[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,A]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[N,[_,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[L,[H,je+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[H,L],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[L,[H,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[H,L],[/ladybird\//i],[[H,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[L,H]],os:[[/(windows nt) (6\.[23]); arm/i],[[H,/N/,"R"],[L,Ze,ei]],[/(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],[H,L],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[L,/(;|\))/g,"",Ze,ei],[H,Ne]],[/(windows ce)\/?([\d\.]*)/i],[H,L],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[L,/_/g,"."],[H,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[H,"macOS"],[L,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[L,[H,Pe+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[L,[H,Pe+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[L,[H,Pe+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[L,[H,Pe+" Linux"]],[/crkey\/([\d\.]+)/i],[L,[H,Pe]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[L,H],[/(ubuntu) ([\w\.]+) like android/i],[[H,/(.+)/,"$1 Touch"],L],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[H,L],[/\(bb(10);/i],[L,[H,he]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[L,[H,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[L,[H,He+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[L,[H,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[L,Ze,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[H,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[L,[H,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[H,"Chrome OS"],L],[/panasonic;(viera)/i,/(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],[H,L],[/(sunos) ?([\d\.]*)/i],[[H,"Solaris"],L],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[H,L]]},oi=(Ue.call((v={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[O,[H,L,$,M]],[C,[I]],[R,[M,N,_]],[q,[H,L]],[P,[H,L]]]),Ue.call(v.isIgnore,[[O,[L,$]],[q,[L]],[P,[L]]]),Ue.call(v.isIgnoreRgx,[[O,/ ?browser$/i],[P,/ ?os$/i]]),Ue.call(v.toString,[[O,[H,L]],[C,[I]],[R,[_,N]],[q,[H,L]],[P,[H,L]]]),v),ni=function(e,i){var t=oi.init[i],r=oi.isIgnore[i]||0,o=oi.isIgnoreRgx[i]||0,n=oi.toString[i]||0;function s(){Ue.call(this,t)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Ae?Ae.getHighEntropyValues(le).then(function(i){return e.setCH(new si(i,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},i!=j&&(s.prototype.is=function(e){var i=!1;for(var t in this)if(this.hasOwnProperty(t)&&!De(r,t)&&Xe(o?Ge(o,this[t]):this[t])==Xe(o?Ge(o,e):e)){if(i=!0,e!=T)break}else if(e==T&&i){i=!i;break}return i},s.prototype.toString=function(){var e=k;for(var i in n)typeof this[n[i]]!==T&&(e+=(e?" ":k)+this[n[i]]);return e||T}),Ae||(s.prototype.then=function(e){var i=this,t=function(){for(var e in i)i.hasOwnProperty(e)&&(this[e]=i[e])};t.prototype={is:s.prototype.is,toString:s.prototype.toString};var r=new t;return e(r),r}),new s};function si(e,i){if(e=e||{},Ue.call(this,le),i)Ue.call(this,[[W,Qe(e[Z])],[G,Qe(e[ee])],[A,/\?1/.test(e[oe])],[N,Ke(e[ne])],[K,Ke(e[se])],[Y,Ke(e[ae])],[I,Ke(e[ie])],[U,Qe(e[re])],[J,Ke(e[te])]]);else for(var t in e)this.hasOwnProperty(t)&&typeof e[t]!==T&&(this[t]=e[t])}function ai(e,i,t,r){return this.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:void 0:this.data},this.set=function(e,i){return this.data[e]=i,this},this.setCH=function(e){return this.uaCH=e,this},this.detectFeature=function(){if(ze&&ze.userAgent==this.ua)switch(this.itemType){case O:ze.brave&&typeof ze.brave.isBrave==x&&this.set(H,"Brave");break;case R:!this.get(M)&&Ae&&Ae[A]&&this.set(M,A),"Macintosh"==this.get(N)&&ze&&typeof ze.standalone!==T&&ze.maxTouchPoints&&ze.maxTouchPoints>2&&this.set(N,"iPad").set(M,F);break;case P:!this.get(H)&&Ae&&Ae[K]&&this.set(H,Ae[K]);break;case j:var e=this.data,i=function(i){return e[i].getItem().detectFeature().get()};this.set(O,i(O)).set(C,i(C)).set(R,i(R)).set(q,i(q)).set(P,i(P))}return this},this.parseUA=function(){return this.itemType!=j&&Je.call(this.data,this.ua,this.rgxMap),this.itemType==O&&this.set($,We(this.get(L))),this},this.parseCH=function(){var e=this.uaCH,i=this.rgxMap;switch(this.itemType){case O:case q:var t,r=e[G]||e[W];if(r)for(var o in r){var n=r[o].brand||r[o],s=r[o].version;this.itemType==O&&!/not.a.brand/i.test(n)&&(!t||/Chrom/.test(t)&&n!=qe||t==je&&/WebView2/.test(n))&&(n=Ze(n,ti),(t=this.get(H))&&!/Chrom/.test(t)&&/Chrom/.test(n)||this.set(H,n).set(L,s).set($,We(s)),t=n),this.itemType==q&&n==qe&&this.set(L,s)}break;case C:var a=e[I];a&&(a&&"64"==e[J]&&(a+="64"),Je.call(this.data,a+";",i));break;case R:if(e[A]&&this.set(M,A),e[N]&&(this.set(N,e[N]),!this.get(M)||!this.get(_))){var l={};Je.call(l,"droid 9; "+e[N]+")",i),!this.get(M)&&l.type&&this.set(M,l.type),!this.get(_)&&l.vendor&&this.set(_,l.vendor)}if(e[U]){var c;if("string"!=typeof e[U])for(var u=0;!c&&u<e[U].length;)c=Ze(e[U][u++],ii);else c=Ze(e[U],ii);this.set(M,c)}break;case P:var d=e[K];if(d){var h=e[Y];d==Ne&&(h=parseInt(We(h),10)>=13?"11":"10"),this.set(H,d).set(L,h)}this.get(H)==Ne&&"Xbox"==e[N]&&this.set(H,"Xbox").set(L,void 0);break;case j:var w=this.data,p=function(i){return w[i].getItem().setCH(e).parseCH().get()};this.set(O,p(O)).set(C,p(C)).set(R,p(R)).set(q,p(q)).set(P,p(P))}return this},Ue.call(this,[["itemType",e],["ua",i],["uaCH",r],["rgxMap",t],["data",ni(this,e)]]),this}function li(e,i,t){if(typeof e===S?(Ve(e,!0)?(typeof i===S&&(t=i),i=e):(t=e,i=void 0),e=void 0):typeof e!==E||Ve(i,!0)||(t=i,i=void 0),t&&typeof t.append===x){var r={};t.forEach(function(e,i){r[i]=e}),t=r}if(!(this instanceof li))return new li(e,i,t).getResult();var o=typeof e===E?e:t&&t[y]?t[y]:ze&&ze.userAgent?ze.userAgent:k,n=new si(t,!0),s=i?function(e,i){var t={},r=i;if(!Ve(i))for(var o in r={},i)for(var n in i[o])r[n]=i[o][n].concat(r[n]?r[n]:[]);for(var s in e)t[s]=r[s]&&r[s].length%2==0?r[s].concat(e[s]):e[s];return t}(ri,i):ri,a=function(e){return e==j?function(){return new ai(e,o,s,n).set("ua",o).set(O,this.getBrowser()).set(C,this.getCPU()).set(R,this.getDevice()).set(q,this.getEngine()).set(P,this.getOS()).get()}:function(){return new ai(e,o,s[e],n).parseUA().get()}};return Ue.call(this,[["getBrowser",a(O)],["getCPU",a(C)],["getDevice",a(R)],["getEngine",a(q)],["getOS",a(P)],["getResult",a(j)],["getUA",function(){return o}],["setUA",function(e){return Be(e)&&(o=e.length>500?Ye(e,500):e),this}]]).setUA(o),this}li.VERSION="2.0.4",li.BROWSER=Fe([H,L,$,M]),li.CPU=Fe([I]),li.DEVICE=Fe([N,_,M,z,A,D,F,V,Q]),li.ENGINE=li.OS=Fe([H,L]);const{browser:ci,device:ui,os:di}=li(navigator.userAgent);function hi(e){return e!==window&&e!==document&&e!==document.documentElement}function wi(e){return e.id?`${e.nodeName.toLowerCase()}#${e.id}`:e.className&&"string"==typeof e.className?`${e.nodeName.toLowerCase()}#${e.className}`:e.nodeName.toLowerCase()}function pi(e){const i=f;return Array.isArray(i)?function(e){return e.reverse().filter(hi).map(wi).join(" ")}(i):e?function(e){let i=e;const t=[];for(;i&&hi(i);)t.unshift(wi(i)),i=i.parentElement;return t.join(" ")}(e):void 0}function bi(e){return e.split("\n").slice(1).map(e=>e.replace(/^\s+at\s+/g,"")).join("\n")}function mi(){try{return location.href}catch(e){return""}}function fi(e){return{title:e.title,url:e.url,browser:e.browser,os:e.os,deviceInfo:e.device,userAgent:e.userAgent}}function gi(e,i){return{page:mi(),userId:i.userId,release:i.release,environment:i.environment,device:fi(e)}}function vi(e,i,t){var r;const o=gi(i,t);if("promiseError"===e.errorType)return c(l({type:"unhandledrejection",level:"ERROR",message:e.message,stack:e.stack},o),{device:c(l({},o.device),{selector:e.selector,filename:e.filename,position:e.position,errorType:e.errorType})});if("loadResourceError"===e.errorType){const i=null!=(r=e.filename)?r:e.message;return c(l({type:"resource",level:"ERROR",message:i?`Resource failed: ${i}`:e.message},o),{device:c(l({},o.device),{tagName:e.tagName,selector:e.selector,errorType:e.errorType})})}return c(l({type:"error",level:"ERROR",message:e.message,stack:e.stack},o),{device:c(l({},o.device),{selector:e.selector,isWhiteScreen:e.isWhiteScreen,filename:e.filename,position:e.position,errorType:e.errorType})})}function yi(e,i,t){const r=gi(i,t);return c(l({type:"paint",level:"INFO",message:"paint metrics"},r),{device:c(l({},r.device),{FP:e.FP,FCP:e.FCP,FMP:e.FMP,LCP:e.LCP})})}function ki(e,i,t){const r=gi(i,t);return c(l({type:"timing",level:"INFO",message:"timing metrics"},r),{device:c(l({},r.device),{DOMContentLoadedTime:e.DOMContentLoadedTime,loadTime:e.loadTime})})}function xi(e,i,t){const r=gi(i,t);return c(l({type:"longTask",level:e.duration>=100?"WARN":"INFO",message:`long task ${e.duration}ms`},r),{device:c(l({},r.device),{startTime:e.startTime,duration:e.duration,selector:e.selector,eventType:e.eventType})})}function Ti(e,i,t){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(),u=null!=(n=e.status)?n:0,d=0===u?"network":String(u),h=gi(i,t);return c(l({type:"request",level:"ERROR",message:`Request failed [${d}]: ${a} ${s}`},h),{device:c(l({},h.device),{durationMs:e.duration,msg:e.msg})})}function Si(e,i,t){if("error"===e.type)return[vi(e,i,t)];if("paint"===e.type)return[yi(e,i,t)];if("timing"===e.type)return[ki(e,i,t)];if("longTask"===e.type)return[xi(e,i,t)];if("batchXHR"===e.type)return function(e,i,t){return e.requests.map(e=>Ti(e,i,t)).filter(e=>null!=e)}(e,i,t);if("xhr"===e.type||"fetch"===e.type){const r=Ti(e,i,t);return r?[r]:[]}return[]}function Ei(){window.addEventListener("error",e=>{const i=e.target;let t;if(i&&(t=i.src||i.href)){const r={type:"error",errorType:"loadResourceError",message:`${t} resource loading fail.`,filename:t,tagName:i.tagName,selector:pi(e.target)};this.send(r)}else{const i=g(),t=function(){const e=["html","body","#root"];let i=0;function t(t){const r=function(e){let i;return i=e.id?`#${e.id}`:e.className&&"string"==typeof e.className?"."+e.className.split(" ").filter(e=>!!e).join("."):e.nodeName.toLowerCase(),i}(t);e.indexOf(r)>-1&&i++}for(let r=1;r<=9;r++){const e=document.elementFromPoint(window.innerWidth/10*r,window.innerHeight/2),i=document.elementFromPoint(window.innerWidth/2,window.innerHeight/10*r);t(e),t(i)}return 18===i}(),r={type:"error",errorType:"jsError",message:e.message,filename:e.filename,position:`${e.lineno}:${e.colno}`,stack:bi(e.error.stack),selector:i?pi():"",isWhiteScreen:t};this.send(r)}},!0),window.addEventListener("unhandledrejection",e=>{const i=g();let t;const r=e.reason;let o,n=0,s=0,a="";if("string"==typeof e.reason)t=r;else if("object"==typeof r&&(t=r.message,r.stack)){const e=r.stack.match(/at\s+(.+):(\d+):(\d+)/);o=e[1],n=e[2],s=e[3],a=bi(r.stack)}const l={type:"error",errorType:"promiseError",message:t,filename:o,position:`${n}:${s}`,stack:a,selector:i?pi():""};this.send(l)},!0)}function Oi(){if(PerformanceObserver){new PerformanceObserver(e=>{e.getEntries().forEach(e=>{if(e.duration>100){const i=g(),t={type:"longTask",startTime:e.startTime,duration:e.duration,selector:i?pi():"",eventType:null==i?void 0:i.type};this.send(t)}})}).observe({entryTypes:["longtask"]})}}function Ci(){if(PerformanceObserver){let e=null,i=null,t=null,r=null;const o=new PerformanceObserver(function(t){const r=t.getEntries();for(const n of r)"first-paint"===n.name?e=n:"first-contentful-paint"===n.name&&(i=n,o.disconnect())});o.observe({entryTypes:["paint"]});const n=new PerformanceObserver(e=>{const i=e.getEntries();t=i[0],n.disconnect()});n.observe({entryTypes:["element"]});const s=new PerformanceObserver(e=>{const i=e.getEntries();r=i[0]});s.observe({entryTypes:["largest-contentful-paint"]}),window.addEventListener("load",()=>{setTimeout(()=>{s.disconnect();const o={type:"paint",FP:null==e?void 0:e.startTime,FCP:null==i?void 0:i.startTime,FMP:null==t?void 0:t.startTime,LCP:null==r?void 0:r.startTime};this.send(o)},3e3)})}}function Ri(){window.addEventListener("load",()=>{let e=0,i=0;if(performance.getEntriesByType){const t=performance.getEntriesByType("navigation");if(t.length>0){const r=t[0],{domContentLoadedEventStart:o,loadEventStart:n,fetchStart:s}=r;e=o-s,i=n-s}}else{const{fetchStart:t,domContentLoadedEventStart:r,loadEventStart:o}=performance.timing;e=r-t,i=o-t}const t={type:"timing",DOMContentLoadedTime:e,loadTime:i};this.send(t)})}function qi(){const e=window.XMLHttpRequest,i=this;window.XMLHttpRequest=function(){const t=new e,r=t.open,o=t.send;let n,s,a;return t.open=function(e,i,...t){return s=i,a=e,r.apply(this,[e,i,...t])},t.send=function(){return n=(new Date).getTime(),t.addEventListener("error",function(){const e=(new Date).getTime()-n,r=t.status,o=String(null!=s?s:"");i.endpoint&&o===i.endpoint||i.captureRequest({type:"xhr",url:s,method:a||"GET",duration:e,status:r||0,success:!1,msg:`XHR请求错误: ${s}`,startTime:(new Date).getTime()})}),t.addEventListener("timeout",function(){const e=(new Date).getTime()-n,r=t.status,o=String(null!=s?s:"");i.endpoint&&o===i.endpoint||i.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)},t}}e.ExcReporter=w,e.Monitor=class{constructor(e){var i,t;u(this,"endpoint"),u(this,"projectKey"),u(this,"timeoutDuration"),u(this,"errorQueue"),u(this,"requestQueue"),u(this,"maxQueueSize"),u(this,"sendTimer"),u(this,"reporter"),u(this,"options"),u(this,"originalXHR"),u(this,"originalFetch"),u(this,"originalOnerror"),this.options=e,this.endpoint=e.endpoint,this.projectKey=e.projectKey,this.timeoutDuration=null!=(i=e.timeoutDuration)?i:6e4,this.errorQueue=[],this.requestQueue=[],this.maxQueueSize=null!=(t=e.maxQueueSize)?t:10,this.sendTimer=null,this.reporter=p({endpoint:e.endpoint,projectKey:e.projectKey,release:e.release,environment:e.environment,maxBatch:e.maxBatch,flushInterval:e.flushInterval},b(e.endpoint)),this.init(),this.originalXHR=window.XMLHttpRequest,this.originalFetch=window.fetch,this.originalOnerror=window.onerror}init(){Ei.call(this),Oi.call(this),Ci.call(this),Ri.call(this),qi.call(this)}send(e){const i=Si(e,{title:document.title,url:location.href,userAgent:navigator.userAgent,browser:`${ci.name} ${ci.version}`,device:`${ui.model} ${ui.vendor}`,os:`${di.name} ${di.version}`},this.options);for(const t of i)this.reporter.capture(t)}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 i;if(!e.type||!["xhr","fetch"].includes(e.type))return;if(t=String(null!=(i=e.url)?i:""),(r=this.endpoint)&&String(t)===r)return;var t,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(){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=[]}},e.SDK_VERSION=h,e.createReporter=p,e.makeH5Transport=b,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).Monitor={})}(this,function(e){"use strict";var i=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(e,t,r)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,l=(e,i)=>{for(var t in i||(i={}))n.call(i,t)&&a(e,t,i[t]);if(o)for(var t of o(i))s.call(i,t)&&a(e,t,i[t]);return e},u=(e,i)=>t(e,r(i)),c=(e,i,t)=>a(e,"symbol"!=typeof i?i+"":i,t),d=(e,i,t)=>new Promise((r,o)=>{var n=e=>{try{a(t.next(e))}catch(i){o(i)}},s=e=>{try{a(t.throw(e))}catch(i){o(i)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,s);a((t=t.apply(e,i)).next())});const h="0.0.1";class w{constructor(e,i){c(this,"buffer",[]),c(this,"timer",null),c(this,"sending",!1),this.options=e,this.transport=i}capture(e){var i,t,r,o,n;const s=null!=(i=this.options.sampleRate)?i:100;s<100&&100*Math.random()>=s||(this.buffer.push(u(l({},e),{level:null!=(t=e.level)?t:"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(i){403!==(null==i?void 0:i.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 p(e,i){return new w(e,i)}function b(e){return(i,t)=>d(null,null,function*(){const r=yield fetch(e,{method:"POST",headers:{"content-type":"application/json","X-Project-Key":t},body:JSON.stringify(i),keepalive:!0});if(!r.ok)throw Object.assign(new Error(`monitor: 上报失败 ${r.status}`),{statusCode:r.status})})}let m,f;function g(){return m}["click","touchstart","mousedown","keydown"].forEach(e=>{document.addEventListener(e,e=>{m=e,f=e.path||e.composedPath()},{capture:!0,passive:!0})});var v,y="user-agent",k="",x="function",T="undefined",S="object",C="string",O="browser",E="cpu",R="device",q="engine",P="os",j="result",H="name",M="type",_="vendor",L="version",I="architecture",$="major",N="model",z="console",A="mobile",F="tablet",D="smarttv",V="wearable",B="xr",Q="embedded",X="inapp",W="brands",U="formFactors",G="fullVersionList",K="platform",Y="platformVersion",J="bitness",Z="sec-ch-ua",ee=Z+"-full-version-list",ie=Z+"-arch",te=Z+"-"+J,re=Z+"-form-factors",oe=Z+"-"+A,ne=Z+"-"+N,se=Z+"-"+K,ae=se+"-version",le=[W,G,A,N,K,Y,I,U,J],ue="Amazon",ce="Apple",de="ASUS",he="BlackBerry",we="Google",pe="Huawei",be="Lenovo",me="Honor",fe="LG",ge="Microsoft",ve="Motorola",ye="Nvidia",ke="OnePlus",xe="OPPO",Te="Samsung",Se="Sharp",Ce="Sony",Oe="Xiaomi",Ee="Zebra",Re="Chrome",qe="Chromium",Pe="Chromecast",je="Edge",He="Firefox",Me="Opera",_e="Facebook",Le="Sogou",Ie="Mobile ",$e=" Browser",Ne="Windows",ze=typeof window!==T&&window.navigator?window.navigator:void 0,Ae=ze&&ze.userAgentData?ze.userAgentData:void 0,Fe=function(e){for(var i={},t=0;t<e.length;t++)i[e[t].toUpperCase()]=e[t];return i},De=function(e,i){if(typeof e===S&&e.length>0){for(var t in e)if(Xe(i)==Xe(e[t]))return!0;return!1}return!!Be(e)&&Xe(i)==Xe(e)},Ve=function(e,i){for(var t in e)return/^(browser|cpu|device|engine|os)$/.test(t)||!!i&&Ve(e[t])},Be=function(e){return typeof e===C},Qe=function(e){if(e){for(var i=[],t=Ge(/\\?\"/g,e).split(","),r=0;r<t.length;r++)if(t[r].indexOf(";")>-1){var o=Ye(t[r]).split(";v=");i[r]={brand:o[0],version:o[1]}}else i[r]=Ye(t[r]);return i}},Xe=function(e){return Be(e)?e.toLowerCase():e},We=function(e){return Be(e)?Ge(/[^\d\.]/g,e).split(".")[0]:void 0},Ue=function(e){for(var i in e){var t=e[i];typeof t==S&&2==t.length?this[t[0]]=t[1]:this[t]=void 0}return this},Ge=function(e,i){return Be(i)?i.replace(e,k):i},Ke=function(e){return Ge(/\\?\"/g,e)},Ye=function(e,i){if(Be(e))return e=Ge(/^\s\s*/,e),typeof i===T?e:e.substring(0,500)},Je=function(e,i){if(e&&i)for(var t,r,o,n,s,a,l=0;l<i.length&&!s;){var u=i[l],c=i[l+1];for(t=r=0;t<u.length&&!s&&u[t];)if(s=u[t++].exec(e))for(o=0;o<c.length;o++)a=s[++r],typeof(n=c[o])===S&&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,i){for(var t in i)if(typeof i[t]===S&&i[t].length>0){for(var r=0;r<i[t].length;r++)if(De(i[t][r],e))return"?"===t?void 0:t}else if(De(i[t],e))return"?"===t?void 0:t;return i.hasOwnProperty("*")?i["*"]:e},ei={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:""},ii={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},ti={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"},ri={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[L,[H,Ie+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[L,[H,je+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[L,[H,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[H,L],[/opios[\/ ]+([\w\.]+)/i],[L,[H,Me+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[L,[H,Me+" GX"]],[/\bopr\/([\w\.]+)/i],[L,[H,Me]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[L,[H,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[L,[H,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:lg |qute)browser)\/([-\w\.]+)/i,/(heytap|ovi|115|surf)browser\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[H,L],[/quark(?:pc)?\/([-\w\.]+)/i],[L,[H,"Quark"]],[/\bddg\/([\w\.]+)/i],[L,[H,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[L,[H,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[L,[H,"WeChat"]],[/konqueror\/([\w\.]+)/i],[L,[H,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[L,[H,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[L,[H,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[L,[H,"Smart "+be+$e]],[/(avast|avg)\/([\w\.]+)/i],[[H,/(.+)/,"$1 Secure"+$e],L],[/\bfocus\/([\w\.]+)/i],[L,[H,He+" Focus"]],[/\bopt\/([\w\.]+)/i],[L,[H,Me+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[L,[H,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[L,[H,"Dolphin"]],[/coast\/([\w\.]+)/i],[L,[H,Me+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[L,[H,"MIUI"+$e]],[/fxios\/([\w\.-]+)/i],[L,[H,Ie+He]],[/\bqihoobrowser\/?([\w\.]*)/i],[L,[H,"360"]],[/\b(qq)\/([\w\.]+)/i],[[H,/(.+)/,"$1Browser"],L],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[H,/(.+)/,"$1"+$e],L],[/samsungbrowser\/([\w\.]+)/i],[L,[H,Te+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[L,[H,Le+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[H,Le+" Mobile"],L],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[H,L],[/(lbbrowser|rekonq)/i],[H],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[L,H],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[H,_e],L,[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,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[H,L,[M,X]],[/\bgsa\/([\w\.]+) .*safari\//i],[L,[H,"GSA"],[M,X]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[L,[H,"TikTok"],[M,X]],[/\[(linkedin)app\]/i],[H,[M,X]],[/(chromium)[\/ ]([-\w\.]+)/i],[H,L],[/headlesschrome(?:\/([\w\.]+)| )/i],[L,[H,Re+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[L,[H,je+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[H,Re+" WebView"],L],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[L,[H,"Android"+$e]],[/chrome\/([\w\.]+) mobile/i],[L,[H,Ie+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[H,L],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[L,[H,Ie+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[H,Ie+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[L,H],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[H,[L,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[H,L],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[H,Ie+He],L],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[H,"Netscape"],L],[/(wolvic|librewolf)\/([\w\.]+)/i],[H,L],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[L,[H,He+" 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|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[H,[L,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[H,[L,/[^\d\.]+./,k]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[I,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[I,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[I,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[I,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[I,"arm"]],[/((ppc|powerpc)(64)?)( mac|;|\))/i],[[I,/ower/,k,Xe]],[/ sun4\w[;\)]/i],[[I,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i],[[I,Xe]]],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],[N,[_,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],[N,[_,Te],[M,A]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[N,[_,ce],[M,A]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[N,[_,ce],[M,F]],[/(macintosh);/i],[N,[_,ce]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[N,[_,Se],[M,A]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[N,[_,me],[M,F]],[/honor([-\w ]+)[;\)]/i],[N,[_,me],[M,A]],[/\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],[N,[_,pe],[M,F]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[N,[_,pe],[M,A]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[N,/_/g," "],[_,Oe],[M,F]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[N,/_/g," "],[_,Oe],[M,A]],[/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-k]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[N,[_,ke],[M,A]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[N,[_,xe],[M,A]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[N,[_,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],[N,[_,"BLU"],[M,A]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[N,[_,"Vivo"],[M,A]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[N,[_,"Realme"],[M,A]],[/(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],[N,[_,be],[M,F]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[N,[_,be],[M,A]],[/\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],[N,[_,ve],[M,A]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[N,[_,ve],[M,F]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[N,[_,fe],[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],[N,[_,fe],[M,A]],[/(nokia) (t[12][01])/i],[_,N,[M,F]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[N,/_/g," "],[M,A],[_,"Nokia"]],[/(pixel (c|tablet))\b/i],[N,[_,we],[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],[N,[_,we],[M,A]],[/(google) (pixelbook( go)?)/i],[_,N],[/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],[N,[_,Ce],[M,A]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[N,"Xperia Tablet"],[_,Ce],[M,F]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[N,[_,ue],[M,F]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[N,/(.+)/g,"Fire Phone $1"],[_,ue],[M,A]],[/(playbook);[-\w\),; ]+(rim)/i],[N,_,[M,F]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[N,[_,he],[M,A]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[N,[_,de],[M,F]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[N,[_,de],[M,A]],[/(nexus 9)/i],[N,[_,"HTC"],[M,F]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[_,[N,/_/g," "],[M,A]],[/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],[N,[_,"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],[N,[_,"TCL"],[M,A]],[/(itel) ((\w+))/i],[[_,Xe],N,[M,Ze,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[N,[_,"Acer"],[M,F]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[N,[_,"Meizu"],[M,A]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[N,[_,"Ulefone"],[M,A]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[N,[_,"Energizer"],[M,A]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[N,[_,"Cat"],[M,A]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[N,[_,"Smartfren"],[M,A]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[N,[_,"Nothing"],[M,A]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[N,[_,"Archos"],[M,F]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[N,[_,"Archos"],[M,A]],[/; (n159v)/i],[N,[_,"HMD"],[M,A]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[_,N,[M,F]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|infinix|lava|oneplus|tcl)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i],[_,N,[M,A]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[_,N,[M,F]],[/(surface duo)/i],[N,[_,ge],[M,F]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[N,[_,"Fairphone"],[M,A]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[N,[_,ye],[M,F]],[/(sprint) (\w+)/i],[_,N,[M,A]],[/(kin\.[onetw]{3})/i],[[N,/\./g," "],[_,ge],[M,A]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[N,[_,Ee],[M,F]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[N,[_,Ee],[M,A]],[/smart-tv.+(samsung)/i],[_,[M,D]],[/hbbtv.+maple;(\d+)/i],[[N,/^/,"SmartTV"],[_,Te],[M,D]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[_,N,[M,D]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[_,fe],[M,D]],[/(apple) ?tv/i],[_,[N,ce+" TV"],[M,D]],[/crkey.*devicetype\/chromecast/i],[[N,Pe+" Third Generation"],[_,we],[M,D]],[/crkey.*devicetype\/([^/]*)/i],[[N,/^/,"Chromecast "],[_,we],[M,D]],[/fuchsia.*crkey/i],[[N,Pe+" Nest Hub"],[_,we],[M,D]],[/crkey/i],[[N,Pe],[_,we],[M,D]],[/(portaltv)/i],[N,[_,_e],[M,D]],[/droid.+aft(\w+)( bui|\))/i],[N,[_,ue],[M,D]],[/(shield \w+ tv)/i],[N,[_,ye],[M,D]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[N,[_,Se],[M,D]],[/(bravia[\w ]+)( bui|\))/i],[N,[_,Ce],[M,D]],[/(mi(tv|box)-?\w+) bui/i],[N,[_,Oe],[M,D]],[/Hbbtv.*(technisat) (.*);/i],[_,N,[M,D]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[_,/.+\/(\w+)/,"$1",Ze,{LG:"lge"}],[N,Ye],[M,D]],[/droid.+; ([\w- ]+) (?:android tv|smart[- ]?tv)/i],[N,[M,D]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:|large screen[\w ]+safari)\b/i],[[M,D]],[/(playstation \w+)/i],[N,[_,Ce],[M,z]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[N,[_,ge],[M,z]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[_,N,[M,z]],[/droid.+; (shield)( bui|\))/i],[N,[_,ye],[M,z]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[N,[_,Te],[M,V]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[_,N,[M,V]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[N,[_,xe],[M,V]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[N,[_,ce],[M,V]],[/(opwwe\d{3})/i],[N,[_,ke],[M,V]],[/(moto 360)/i],[N,[_,ve],[M,V]],[/(smartwatch 3)/i],[N,[_,Ce],[M,V]],[/(g watch r)/i],[N,[_,fe],[M,V]],[/droid.+; (wt63?0{2,3})\)/i],[N,[_,Ee],[M,V]],[/droid.+; (glass) \d/i],[N,[_,we],[M,B]],[/(pico) (4|neo3(?: link|pro)?)/i],[_,N,[M,B]],[/(quest( \d| pro)?s?).+vr/i],[N,[_,_e],[M,B]],[/mobile vr; rv.+firefox/i],[[M,B]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[_,[M,Q]],[/(aeobc)\b/i],[N,[_,ue],[M,Q]],[/(homepod).+mac os/i],[N,[_,ce],[M,Q]],[/windows iot/i],[[M,Q]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i],[N,[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,A]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[N,[_,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[L,[H,je+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[H,L],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[L,[H,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[H,L],[/ladybird\//i],[[H,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[L,H]],os:[[/(windows nt) (6\.[23]); arm/i],[[H,/N/,"R"],[L,Ze,ei]],[/(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],[H,L],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[L,/(;|\))/g,"",Ze,ei],[H,Ne]],[/(windows ce)\/?([\d\.]*)/i],[H,L],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[L,/_/g,"."],[H,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[H,"macOS"],[L,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[L,[H,Pe+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[L,[H,Pe+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[L,[H,Pe+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[L,[H,Pe+" Linux"]],[/crkey\/([\d\.]+)/i],[L,[H,Pe]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[L,H],[/(ubuntu) ([\w\.]+) like android/i],[[H,/(.+)/,"$1 Touch"],L],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[H,L],[/\(bb(10);/i],[L,[H,he]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[L,[H,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[L,[H,He+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[L,[H,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[L,Ze,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[H,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[L,[H,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[H,"Chrome OS"],L],[/panasonic;(viera)/i,/(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],[H,L],[/(sunos) ?([\d\.]*)/i],[[H,"Solaris"],L],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[H,L]]},oi=(Ue.call((v={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[O,[H,L,$,M]],[E,[I]],[R,[M,N,_]],[q,[H,L]],[P,[H,L]]]),Ue.call(v.isIgnore,[[O,[L,$]],[q,[L]],[P,[L]]]),Ue.call(v.isIgnoreRgx,[[O,/ ?browser$/i],[P,/ ?os$/i]]),Ue.call(v.toString,[[O,[H,L]],[E,[I]],[R,[_,N]],[q,[H,L]],[P,[H,L]]]),v),ni=function(e,i){var t=oi.init[i],r=oi.isIgnore[i]||0,o=oi.isIgnoreRgx[i]||0,n=oi.toString[i]||0;function s(){Ue.call(this,t)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Ae?Ae.getHighEntropyValues(le).then(function(i){return e.setCH(new si(i,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},i!=j&&(s.prototype.is=function(e){var i=!1;for(var t in this)if(this.hasOwnProperty(t)&&!De(r,t)&&Xe(o?Ge(o,this[t]):this[t])==Xe(o?Ge(o,e):e)){if(i=!0,e!=T)break}else if(e==T&&i){i=!i;break}return i},s.prototype.toString=function(){var e=k;for(var i in n)typeof this[n[i]]!==T&&(e+=(e?" ":k)+this[n[i]]);return e||T}),Ae||(s.prototype.then=function(e){var i=this,t=function(){for(var e in i)i.hasOwnProperty(e)&&(this[e]=i[e])};t.prototype={is:s.prototype.is,toString:s.prototype.toString};var r=new t;return e(r),r}),new s};function si(e,i){if(e=e||{},Ue.call(this,le),i)Ue.call(this,[[W,Qe(e[Z])],[G,Qe(e[ee])],[A,/\?1/.test(e[oe])],[N,Ke(e[ne])],[K,Ke(e[se])],[Y,Ke(e[ae])],[I,Ke(e[ie])],[U,Qe(e[re])],[J,Ke(e[te])]]);else for(var t in e)this.hasOwnProperty(t)&&typeof e[t]!==T&&(this[t]=e[t])}function ai(e,i,t,r){return this.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:void 0:this.data},this.set=function(e,i){return this.data[e]=i,this},this.setCH=function(e){return this.uaCH=e,this},this.detectFeature=function(){if(ze&&ze.userAgent==this.ua)switch(this.itemType){case O:ze.brave&&typeof ze.brave.isBrave==x&&this.set(H,"Brave");break;case R:!this.get(M)&&Ae&&Ae[A]&&this.set(M,A),"Macintosh"==this.get(N)&&ze&&typeof ze.standalone!==T&&ze.maxTouchPoints&&ze.maxTouchPoints>2&&this.set(N,"iPad").set(M,F);break;case P:!this.get(H)&&Ae&&Ae[K]&&this.set(H,Ae[K]);break;case j:var e=this.data,i=function(i){return e[i].getItem().detectFeature().get()};this.set(O,i(O)).set(E,i(E)).set(R,i(R)).set(q,i(q)).set(P,i(P))}return this},this.parseUA=function(){return this.itemType!=j&&Je.call(this.data,this.ua,this.rgxMap),this.itemType==O&&this.set($,We(this.get(L))),this},this.parseCH=function(){var e=this.uaCH,i=this.rgxMap;switch(this.itemType){case O:case q:var t,r=e[G]||e[W];if(r)for(var o in r){var n=r[o].brand||r[o],s=r[o].version;this.itemType==O&&!/not.a.brand/i.test(n)&&(!t||/Chrom/.test(t)&&n!=qe||t==je&&/WebView2/.test(n))&&(n=Ze(n,ti),(t=this.get(H))&&!/Chrom/.test(t)&&/Chrom/.test(n)||this.set(H,n).set(L,s).set($,We(s)),t=n),this.itemType==q&&n==qe&&this.set(L,s)}break;case E:var a=e[I];a&&(a&&"64"==e[J]&&(a+="64"),Je.call(this.data,a+";",i));break;case R:if(e[A]&&this.set(M,A),e[N]&&(this.set(N,e[N]),!this.get(M)||!this.get(_))){var l={};Je.call(l,"droid 9; "+e[N]+")",i),!this.get(M)&&l.type&&this.set(M,l.type),!this.get(_)&&l.vendor&&this.set(_,l.vendor)}if(e[U]){var u;if("string"!=typeof e[U])for(var c=0;!u&&c<e[U].length;)u=Ze(e[U][c++],ii);else u=Ze(e[U],ii);this.set(M,u)}break;case P:var d=e[K];if(d){var h=e[Y];d==Ne&&(h=parseInt(We(h),10)>=13?"11":"10"),this.set(H,d).set(L,h)}this.get(H)==Ne&&"Xbox"==e[N]&&this.set(H,"Xbox").set(L,void 0);break;case j:var w=this.data,p=function(i){return w[i].getItem().setCH(e).parseCH().get()};this.set(O,p(O)).set(E,p(E)).set(R,p(R)).set(q,p(q)).set(P,p(P))}return this},Ue.call(this,[["itemType",e],["ua",i],["uaCH",r],["rgxMap",t],["data",ni(this,e)]]),this}function li(e,i,t){if(typeof e===S?(Ve(e,!0)?(typeof i===S&&(t=i),i=e):(t=e,i=void 0),e=void 0):typeof e!==C||Ve(i,!0)||(t=i,i=void 0),t&&typeof t.append===x){var r={};t.forEach(function(e,i){r[i]=e}),t=r}if(!(this instanceof li))return new li(e,i,t).getResult();var o=typeof e===C?e:t&&t[y]?t[y]:ze&&ze.userAgent?ze.userAgent:k,n=new si(t,!0),s=i?function(e,i){var t={},r=i;if(!Ve(i))for(var o in r={},i)for(var n in i[o])r[n]=i[o][n].concat(r[n]?r[n]:[]);for(var s in e)t[s]=r[s]&&r[s].length%2==0?r[s].concat(e[s]):e[s];return t}(ri,i):ri,a=function(e){return e==j?function(){return new ai(e,o,s,n).set("ua",o).set(O,this.getBrowser()).set(E,this.getCPU()).set(R,this.getDevice()).set(q,this.getEngine()).set(P,this.getOS()).get()}:function(){return new ai(e,o,s[e],n).parseUA().get()}};return Ue.call(this,[["getBrowser",a(O)],["getCPU",a(E)],["getDevice",a(R)],["getEngine",a(q)],["getOS",a(P)],["getResult",a(j)],["getUA",function(){return o}],["setUA",function(e){return Be(e)&&(o=e.length>500?Ye(e,500):e),this}]]).setUA(o),this}li.VERSION="2.0.4",li.BROWSER=Fe([H,L,$,M]),li.CPU=Fe([I]),li.DEVICE=Fe([N,_,M,z,A,D,F,V,Q]),li.ENGINE=li.OS=Fe([H,L]);const{browser:ui,device:ci,os:di}=li(navigator.userAgent);function hi(e){return e!==window&&e!==document&&e!==document.documentElement}function wi(e){return e.id?`${e.nodeName.toLowerCase()}#${e.id}`:e.className&&"string"==typeof e.className?`${e.nodeName.toLowerCase()}#${e.className}`:e.nodeName.toLowerCase()}function pi(e){const i=f;return Array.isArray(i)?function(e){return e.reverse().filter(hi).map(wi).join(" ")}(i):e?function(e){let i=e;const t=[];for(;i&&hi(i);)t.unshift(wi(i)),i=i.parentElement;return t.join(" ")}(e):void 0}function bi(e){return e.split("\n").slice(1).map(e=>e.replace(/^\s+at\s+/g,"")).join("\n")}function mi(){try{return location.href}catch(e){return""}}function fi(e){return{title:e.title,url:e.url,browser:e.browser,os:e.os,deviceInfo:e.device,userAgent:e.userAgent}}function gi(e,i){return{page:mi(),userId:i.userId,release:i.release,environment:i.environment,device:fi(e)}}function vi(e,i,t){var r;const o=gi(i,t);if("promiseError"===e.errorType)return u(l({type:"unhandledrejection",level:"ERROR",message:e.message,stack:e.stack},o),{device:u(l({},o.device),{selector:e.selector,filename:e.filename,position:e.position,errorType:e.errorType})});if("loadResourceError"===e.errorType){const i=null!=(r=e.filename)?r:e.message;return u(l({type:"resource",level:"ERROR",message:i?`Resource failed: ${i}`:e.message},o),{device:u(l({},o.device),{tagName:e.tagName,selector:e.selector,errorType:e.errorType})})}return u(l({type:"error",level:"ERROR",message:e.message,stack:e.stack},o),{device:u(l({},o.device),{selector:e.selector,isWhiteScreen:e.isWhiteScreen,filename:e.filename,position:e.position,errorType:e.errorType})})}function yi(e,i,t){const r=gi(i,t);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 ki(e,i,t){const r=gi(i,t);return u(l({type:"timing",level:"INFO",message:"timing metrics"},r),{device:u(l({},r.device),{DOMContentLoadedTime:e.DOMContentLoadedTime,loadTime:e.loadTime})})}function xi(e,i,t){const r=gi(i,t);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 Ti(e,i,t){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=gi(i,t);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 Si(e,i,t){if("error"===e.type)return[vi(e,i,t)];if("paint"===e.type)return[yi(e,i,t)];if("timing"===e.type)return[ki(e,i,t)];if("longTask"===e.type)return[xi(e,i,t)];if("batchXHR"===e.type)return function(e,i,t){return e.requests.map(e=>Ti(e,i,t)).filter(e=>null!=e)}(e,i,t);if("xhr"===e.type||"fetch"===e.type){const r=Ti(e,i,t);return r?[r]:[]}return[]}function Ci(){window.addEventListener("error",e=>{const i=e.target;let t;if(i&&(t=i.src||i.href)){const r={type:"error",errorType:"loadResourceError",message:`${t} resource loading fail.`,filename:t,tagName:i.tagName,selector:pi(e.target)};this.send(r)}else{const i=g(),t=function(){const e=["html","body","#root"];let i=0;function t(t){const r=function(e){let i;return i=e.id?`#${e.id}`:e.className&&"string"==typeof e.className?"."+e.className.split(" ").filter(e=>!!e).join("."):e.nodeName.toLowerCase(),i}(t);e.indexOf(r)>-1&&i++}for(let r=1;r<=9;r++){const e=document.elementFromPoint(window.innerWidth/10*r,window.innerHeight/2),i=document.elementFromPoint(window.innerWidth/2,window.innerHeight/10*r);t(e),t(i)}return 18===i}(),r={type:"error",errorType:"jsError",message:e.message,filename:e.filename,position:`${e.lineno}:${e.colno}`,stack:bi(e.error.stack),selector:i?pi():"",isWhiteScreen:t};this.send(r)}},!0),window.addEventListener("unhandledrejection",e=>{const i=g();let t;const r=e.reason;let o,n=0,s=0,a="";if("string"==typeof e.reason)t=r;else if("object"==typeof r&&(t=r.message,r.stack)){const e=r.stack.match(/at\s+(.+):(\d+):(\d+)/);o=e[1],n=e[2],s=e[3],a=bi(r.stack)}const l={type:"error",errorType:"promiseError",message:t,filename:o,position:`${n}:${s}`,stack:a,selector:i?pi():""};this.send(l)},!0)}function Oi(){if(PerformanceObserver){new PerformanceObserver(e=>{e.getEntries().forEach(e=>{if(e.duration>100){const i=g(),t={type:"longTask",startTime:e.startTime,duration:e.duration,selector:i?pi():"",eventType:null==i?void 0:i.type};this.send(t)}})}).observe({entryTypes:["longtask"]})}}function Ei(e,i){if("undefined"==typeof PerformanceObserver)return null;try{const t=new PerformanceObserver(e=>{i(e.getEntries())});return t.observe({type:e,buffered:!0}),t}catch(t){return null}}function Ri(){if("undefined"==typeof PerformanceObserver)return;let e=null,i=null,t=null,r=null;const o=Ei("paint",t=>{for(const r of t)"first-paint"===r.name?e=r:"first-contentful-paint"===r.name&&(i=r)}),n=Ei("element",e=>{e.length>0&&(t=e[0],null==n||n.disconnect())}),s=Ei("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==i?void 0:i.startTime,FMP:null==t?void 0:t.startTime,LCP:null==r?void 0:r.startTime};this.send(a)},3e3)};"complete"!==document.readyState?window.addEventListener("load",a):a()}function qi(){let e=0,i=0;if(performance.getEntriesByType){const t=performance.getEntriesByType("navigation");if(t.length>0){const r=t[0],{domContentLoadedEventStart:o,loadEventStart:n,fetchStart:s}=r;e=o-s,i=n-s}}else{const{fetchStart:t,domContentLoadedEventStart:r,loadEventStart:o}=performance.timing;e=r-t,i=o-t}const t={type:"timing",DOMContentLoadedTime:e,loadTime:i};this.send(t)}function Pi(){const e=()=>qi.call(this);"complete"!==document.readyState?window.addEventListener("load",e):e()}function ji(){const e=window.XMLHttpRequest,i=this;window.XMLHttpRequest=function(){const t=new e,r=t.open,o=t.send;let n,s,a;return t.open=function(e,i,...t){return s=i,a=e,r.apply(this,[e,i,...t])},t.send=function(){return n=(new Date).getTime(),t.addEventListener("error",function(){const e=(new Date).getTime()-n,r=t.status,o=String(null!=s?s:"");i.endpoint&&o===i.endpoint||i.captureRequest({type:"xhr",url:s,method:a||"GET",duration:e,status:r||0,success:!1,msg:`XHR请求错误: ${s}`,startTime:(new Date).getTime()})}),t.addEventListener("timeout",function(){const e=(new Date).getTime()-n,r=t.status,o=String(null!=s?s:"");i.endpoint&&o===i.endpoint||i.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)},t}}e.ExcReporter=w,e.Monitor=class{constructor(e){var i,t;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,"options"),c(this,"originalXHR"),c(this,"originalFetch"),c(this,"originalOnerror"),this.options=e,this.endpoint=e.endpoint,this.projectKey=e.projectKey,this.timeoutDuration=null!=(i=e.timeoutDuration)?i:6e4,this.errorQueue=[],this.requestQueue=[],this.maxQueueSize=null!=(t=e.maxQueueSize)?t:10,this.sendTimer=null,this.reporter=p({endpoint:e.endpoint,projectKey:e.projectKey,release:e.release,environment:e.environment,maxBatch:e.maxBatch,flushInterval:e.flushInterval},b(e.endpoint)),this.init(),this.originalXHR=window.XMLHttpRequest,this.originalFetch=window.fetch,this.originalOnerror=window.onerror}init(){Ci.call(this),Oi.call(this),Ri.call(this),Pi.call(this),ji.call(this)}send(e){const i=Si(e,{title:document.title,url:location.href,userAgent:navigator.userAgent,browser:`${ui.name} ${ui.version}`,device:`${ci.model} ${ci.vendor}`,os:`${di.name} ${di.version}`},this.options);for(const t of i)this.reporter.capture(t)}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 i;if(!e.type||!["xhr","fetch"].includes(e.type))return;if(t=String(null!=(i=e.url)?i:""),(r=this.endpoint)&&String(t)===r)return;var t,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(){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=[]}},e.SDK_VERSION=h,e.createReporter=p,e.makeH5Transport=b,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qiu_jun/monitors",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "前端监控,用于捕获,分析,和报告网站或应用程序中的异常,错误和性能问题的方法",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./dist/h5.d.ts",
|
|
17
17
|
"default": "./dist/h5.js"
|
|
18
18
|
},
|
|
19
|
+
"./miniprogram": {
|
|
20
|
+
"types": "./dist/miniprogram.d.ts",
|
|
21
|
+
"default": "./dist/miniprogram.js"
|
|
22
|
+
},
|
|
19
23
|
"./reporter": {
|
|
20
24
|
"types": "./dist/reporter.d.ts",
|
|
21
25
|
"default": "./dist/reporter.js"
|
|
@@ -27,6 +31,7 @@
|
|
|
27
31
|
"scripts": {
|
|
28
32
|
"preinstall": "npx only-allow pnpm",
|
|
29
33
|
"build": "pnpm run clean && pnpm run compile && pnpm run bundle",
|
|
34
|
+
"prepublishOnly": "pnpm run build",
|
|
30
35
|
"clean": "rimraf dist",
|
|
31
36
|
"compile": "tsc -p tsconfig.build.json",
|
|
32
37
|
"bundle": "vite build"
|