# fe-monitor-sdk **Repository Path**: fe-hl/fe-monitor-sdk ## Basic Information - **Project Name**: fe-monitor-sdk - **Description**: 前端监控SDK,轻量级 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2019-08-28 - **Last Updated**: 2024-03-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: SDK, monitor, TypeScript ## README # 前端监控 SDK ## 安装 ```npm npm i @fe-hl/monitor-sdk -S ``` ## 使用 - 除了`perfLog`页面渲染性能监控,其他都是实时上报 ### 参数说明 | 参数 | 是否必传 | 默认值 |说明 | | :-----| :----: | :----: | :----: | | pid | true | - | 产品ID | | reportUrl | true | - | 上报接口地址 | | debug | false | false | debug模式打印控制台,不上报接口 | | jsErrorLog | false | false | js异常 | | promiseErrorLog | false | false | promise异常 | | resourcesErrorLog | false | false | 资源加载异常 | | exposureLog | false | false | 曝光埋点 | | automaticBurialPointLog | false | false | 自动埋点 | | pageDwellTimeLog | false | false | 页面停留时间 | | pvLog | false | false | pv | | xhrLog | false | false | 接口监控 | | resourcesPerfLog | false | false | 资源加载性能 | | perfLog | false | false | 页面渲染性能 | ```js import MonitorSdk from '@fe-hl/monitor-sdk'; const monitorSdk = MonitorSdk({ pid: '1000', // 产品ID reportUrl: 'http://127.0.0.1:9001/report', // 上报的地址 debug: false, // 是否开启debug,开启后打印控制台不上报 jsErrorLog: true, // js异常 promiseErrorLog: true, // promise异常 resourcesErrorLog: true, // 资源加载异常 exposureLog: true, // // 曝光 automaticBurialPointLog: true, // 自动埋点 pageDwellTimeLog: true, // 页面停留时间 pvLog: true, // PV xhrLog: true, // 接口监控 resourcesPerfLog: true, // 资源加载性能 perfLog: true, // 页面渲染性能 }); // 自定义上报 monitorSdk.report({ type: 'click', message:"下单成功" }); ``` ## 爆光埋点 - 给需要`爆光`的元素加上`appear`属性,当元素在可视区域内,上报接口 ```html