# wrong-report **Repository Path**: king_atlantis/wrong-report ## Basic Information - **Project Name**: wrong-report - **Description**: 前端监控js报错、静态资源加载报错、promise和ajax请求报错并通过图片上报的插件 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-03-07 - **Last Updated**: 2023-10-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wrong-report 监控前端js报错、静态资源加载、promise的错误信息以及FP、FCP、LCP数据,并通过图片上报错误信息(目前还在测试优化阶段)。 ``` JS报错, 静态资源加载报错, FP、FCP、LCP, ``` # 安装//Install ```npm npm install wrong-report --save ``` # ES6 ```JavaScript import {initReporting} from 'wrong-report' //使用示例: initReporting("http://localhost:8080/error")//报错信息提交后台的接口(自己测试的) //或者 initReporting({ url:"http://localhost:8080/error", isSupportObserve:true,//是否开启FP、FCP、LCP监控(默认开启) isSupportJS:true,//是否开启js报错监控(默认开启) })//报错信息提交后台的接口(自己测试的) ``` # 上报示例 ```JavaScript //js上报 new Image().src = `${this.url}?errorMsg=${encodeURIComponent(errorMsg)}&errorURL=${encodeURIComponent(errorURL)}&errorType=${encodeURIComponent(errorType)}&message=${encodeURIComponent(message)}&locationHref=${encodeURIComponent(location.href)}`; //FP、FCP、LCP上报 new Image().src = `${this.url}?entryType=${entryType}&name=${name}&time=${startTime}&locationHref=${encodeURIComponent(location.href)}` ```