@guomain/monitor-web 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @gm Monitor SDK
2
+
3
+ 前端错误监控:运行时错误、Promise、资源加载、接口异常、Vue/React、手动上报、catch 自动采集(需 Vite 插件)。
4
+
5
+ ## 安装
6
+
7
+ ```sh
8
+ pnpm add @guomain/monitor-web
9
+ pnpm add -D @guomain/monitor-plugins @guomain/monitor-types
10
+ ```
11
+
12
+ ## 快速开始
13
+
14
+ ```ts
15
+ import { createWebMonitor } from '@guomain/monitor-web'
16
+
17
+ const monitor = createWebMonitor({
18
+ appId: 'your-app',
19
+ dsn: '/api/monitor',
20
+ vue: { app }
21
+ })
22
+
23
+ globalThis.__GM_MONITOR__ = monitor
24
+ monitor.start()
25
+ ```
26
+
27
+ 完整说明见仓库内 `SDK.md` 与 `PUBLISH.md`。
@@ -0,0 +1,8 @@
1
+ import type { MonitorInstance } from '@guomain/monitor-types';
2
+ import type { Teardown } from '../shared/browser';
3
+ /**
4
+ * 安装 Web 错误监控能力。
5
+ * @param monitor 当前监控实例。
6
+ */
7
+ export declare function setupWebError(monitor: MonitorInstance): Teardown;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAMjD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CA+BhE"}
@@ -0,0 +1,7 @@
1
+ import type { MonitorInstance } from '@guomain/monitor-types';
2
+ /**
3
+ * 监听未处理的 Promise rejection。
4
+ * @param monitor 当前监控实例。
5
+ */
6
+ export declare function setupPromiseError(monitor: MonitorInstance): import("../shared/browser").Teardown;
7
+ //# sourceMappingURL=promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../src/error/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,wCAIzD"}
@@ -0,0 +1,15 @@
1
+ import type { MonitorInstance } from '@guomain/monitor-types';
2
+ /**
3
+ * 标记一次 transport 调用开始,由 monitor-web 在执行用户 transport 前调用。
4
+ */
5
+ export declare function beginTransportScope(): void;
6
+ /**
7
+ * 标记一次 transport 调用结束。
8
+ */
9
+ export declare function endTransportScope(): void;
10
+ /**
11
+ * 安装请求错误监控。
12
+ * @param monitor 当前监控实例。
13
+ */
14
+ export declare function setupRequestError(monitor: MonitorInstance): () => void;
15
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/error/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAoB7D;;GAEG;AACH,wBAAgB,mBAAmB,SAElC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,SAIhC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,cASzD"}
@@ -0,0 +1,7 @@
1
+ import type { MonitorInstance } from '@guomain/monitor-types';
2
+ /**
3
+ * 监听资源加载错误。
4
+ * @param monitor 当前监控实例。
5
+ */
6
+ export declare function setupResourceError(monitor: MonitorInstance): import("../shared/browser").Teardown;
7
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/error/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7D;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,wCAuB1D"}
@@ -0,0 +1,7 @@
1
+ import type { MonitorInstance } from '@guomain/monitor-types';
2
+ /**
3
+ * 监听 JS 运行时错误。
4
+ * @param monitor 当前监控实例。
5
+ */
6
+ export declare function setupRuntimeError(monitor: MonitorInstance): import("../shared/browser").Teardown;
7
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/error/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,wCAqBzD"}
package/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { MonitorConfig, MonitorInstance } from '@guomain/monitor-types';
2
+ /**
3
+ * 创建 Web 端监控实例。
4
+ * @param config SDK 初始化配置,包含应用标识、Web 错误开关、Vue app、transport 等。
5
+ */
6
+ export declare function createWebMonitor(config: MonitorConfig): MonitorInstance;
7
+ export type { MonitorConfig, MonitorEvent, MonitorEventMeta, MonitorInstance, MonitorPayload, MonitorTransport } from '@guomain/monitor-types';
8
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAoB,MAAM,wBAAwB,CAAA;AAK9F;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAsDvE;AA2HD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,gBAAgB,EACjB,MAAM,wBAAwB,CAAA"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "version": "0.1.0",
3
+ "license": "MIT",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+http://192.168.200.220/GomainFE/stamp.git",
7
+ "directory": "monitor/packages/monitor-web"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "name": "@guomain/monitor-web",
14
+ "description": "Web error monitoring SDK (Vue/React, fetch/XHR, global errors)",
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "main": "./web.cjs.js",
18
+ "module": "./web.es.js",
19
+ "unpkg": "./web.umd.js",
20
+ "types": "./index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./index.d.ts",
24
+ "import": "./web.es.js",
25
+ "require": "./web.cjs.js",
26
+ "default": "./web.es.js"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@guomain/monitor-types": "^0.1.0"
31
+ },
32
+ "files": [
33
+ "**/*"
34
+ ]
35
+ }
@@ -0,0 +1,15 @@
1
+ export type Teardown = () => void;
2
+ /**
3
+ * 注册浏览器事件并返回清理函数。
4
+ * @param target 事件目标,目前只处理 window。
5
+ * @param type 事件类型。
6
+ * @param listener 事件监听函数。
7
+ * @param options addEventListener 配置。
8
+ */
9
+ export declare function on<K extends keyof WindowEventMap>(target: Window, type: K, listener: (event: WindowEventMap[K]) => void, options?: boolean | AddEventListenerOptions): Teardown;
10
+ /**
11
+ * 从资源节点读取加载地址。
12
+ * @param target 触发 error 事件的资源节点。
13
+ */
14
+ export declare function getResourceUrl(target: EventTarget | null): string | undefined;
15
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/shared/browser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAA;AAEjC;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,cAAc,EAC/C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,QAAQ,CAGV;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,sBAWxD"}