sobey-monitor-sdk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +58 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Sobey Monitor SDK
2
+
3
+ 前端全方位监控 SDK,支持错误监控、性能监控、用户行为回溯。适合单页面应用及多端环境。
4
+
5
+ ## 特性
6
+
7
+ - **错误监控**:JS 运行时错误、Promise 异常、资源加载失败、HTTP 请求错误、白屏检测。
8
+ - **性能监控**:核心 Web Vitals 指标 (FP, FCP, LCP, FID, CLS, TTFB) 及页面加载流程。
9
+ - **行为回溯**:通过面包屑 (Breadcrumbs) 自动记录用户点击、路由变化、控制台日志等行为轨迹。
10
+ - **多应用隔离**:支持多 appId 隔离上报,配合管理后台实现多项目监控。
11
+
12
+ ## 安装
13
+
14
+ ```bash
15
+ npm install sobey-monitor-sdk --save
16
+ ```
17
+
18
+ ## 快速开始
19
+
20
+ ```javascript
21
+ import { monitor } from 'sobey-monitor-sdk';
22
+
23
+ monitor.init({
24
+ appId: 'your-app-id', // 在管理后台申请
25
+ dsn: 'http://localhost:3000/api/report', // 后端接收地址
26
+ debug: true, // 开启调试模式
27
+ });
28
+ ```
29
+
30
+ ## API
31
+
32
+ ### `monitor.init(config)`
33
+ 初始化 SDK。
34
+
35
+ ### `monitor.setUser(userInfo)`
36
+ 设置当前用户信息,方便追踪。
37
+
38
+ ### `monitor.captureError(error, extra)`
39
+ 手动上报异常或错误。
40
+
41
+ ### `monitor.addBreadcrumb(breadcrumb)`
42
+ 手动添加一条用户行为轨迹。
43
+
44
+ ### `monitor.flush()`
45
+ 立即上报缓冲区中的数据。
46
+
47
+ ## 构建
48
+
49
+ ```bash
50
+ npm install
51
+ npm run build
52
+ ```
53
+
54
+ 构建产物将生成在 `dist` 目录中:
55
+ - `index.cjs.js`: CommonJS 格式
56
+ - `index.esm.js`: ES Module 格式
57
+ - `index.umd.js`: UMD 格式 (支持 CDN 引入)
58
+ - `index.d.ts`: TypeScript 类型定义
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sobey-monitor-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "前端全方位监控 SDK,支持错误监控、性能监控、用户行为回溯。适合单页面应用及多端环境。",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",