csmx-watch-sdk
v1.0.0
Published
[](https://www.npmjs.com/package/csmx-watch-sdk) [](LICENSE) [ => event, // 数据发送前处理
});
// 自定义事件上报
monitor.track("userAction", {
type: "click",
target: "button",
});
// 手动采集性能数据
monitor.capturePerformance();
// 手动上报错误
monitor.captureError(new Error("Something went wrong"), {
userId: "user_123",
});React 集成
import { withReactMonitor } from "csmx-watch-sdk";
const ErrorBoundary = withReactMonitor(React, monitor);
function App() {
return (
<ErrorBoundary fallback={ErrorFallback}>
<YourComponents />
</ErrorBoundary>
);
}Vue 集成
import { vueMonitor } from "csmx-watch-sdk";
app.use(vueMonitor, { monitor });插件开发
const customPlugin = {
name: "CustomPlugin",
setup: (monitor) => {
// 插件初始化逻辑
},
};
monitor.addPlugin(customPlugin);⚙️ 配置项
| 参数 | 类型 | 默认值 | 必填 | 说明 | | ------------- | --------------- | ---------------- | ---- | ------------------ | | maxQueueSize | number | 30720 | 否 | 上报队列大小(字节) | | performance | boolean | true | 否 | 是否启用性能监控 | | errorTracking | boolean | true | 否 | 是否启用错误监控 | | sampleRate | number | 1.0 | 否 | 采样率(0-1) | | framework | string | 'vanilla' | 否 | 框架类型 | | plugins | MonitorPlugin[] | [] | 否 | 插件列表 | | beforeSend | Function | (event) => event | 否 | 数据发送前处理函数 |
🔨 本地开发
# 安装依赖
npm install
# 开发模式
npm run dev
# 生产构建
npm run build🌐 浏览器兼容性
|
|
|
|
|
| :-----------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: |
| 50+ | 45+ | 15+ | 10+ |
📄 许可证
MIT License © 2025 AngleNeo
