为什么我的哨兵不允许报错?区别于页面报错提供更有效的自定义标签,帮助快速定位和分享我的踩坑之路:sourceMap已上传,但只能看到错误,看不到源码。constsentryConfig={url:'https://sentry.xxx.com/',authToken:'***',org:'frontend',project:'cms',release:version,sourceMaps:{包括:['./build/static/js'],ignore:['node_modules'],urlPrefix:'~/sub-wechat/static/js',},};例如在线访问地址为https://www.**.com/sub-wechat/indexurlPrefix必须在域名根目录访问,所以必须设置为~/sub-wechat/static/js(子wechat/static/js文件夹下全是.js)坑2:终于可以看到源码了,但是看到的源码错行,位置不对。为什么?!一开始我怀疑是哨兵的问题,但是弄完之后我也没做错,怪怪的哈哈哈哈。后来吃过晚饭,静下心来仔细查看,发现浏览器的报错也不对,最后发现罪魁祸首是css的懒加载。我还是不明白为什么这会影响sourcemap错误定位??请问https://github.com/vitejs/vit...为什么要统一打包Sentry项目?报错信息不统一。主动上报错误(如log、warn、debug、fatal、error)TAG上报的信息层级统一为什么监控接口错误错误监控和日志排查提供更有效的信息;接口异常状态,根据异常状态查找代码漏洞;有一个统一的请求SDK,处理起来非常简单,sentry.jsimport*asSentryfrom'@sentry/browser';import{Integrations}from'@sentry/tracing';/***fatal:非常严重的系统异常,系统无法继续运行,必须处理,严重程度类似于uncaughterror*error(默认值):系统异常,无法正常运行。如果类型未被捕获,则错误必须由开发人员修复。如果被捕获,则意味着可预见的错误,这要视情况而定。*debug:协助解决线上问题*warn:系统可以继续运行,用户可以继续操作,用于上报一些警告行的错误信息*log:简单的日志管理*//***@descriptionsentry初始化配置,仅适用于在线和测试版环境*@param{string}env环境*@param{string}dsn哨兵生成的dsn值。*@param{string}发布项目版本*@param{array}tags哨兵对应的标签*@examplenpmr**Capture.init({env:'production',dsn:'1231afaf1',release:'1.0.0',标签:{TIME:newDate()})**/constSeverity={Fatal:'fatal',Error:'error',Warning:'warning',Log:'log',Info:'info',Debug:'debug',};classCapture{constructor(options){const{env,dsn,release,tags,}=options;if(env==='production'){Sentry.init({dsn,release,integrations:[newIntegrations.BrowserTracing()],tracesSampleRate:1.0,beforeSend(event){const{exception}=event;//该主动报接口请求错误,constrequestErr=exception.values.find((item)=>item.value.startsWith('Requestfailedwithstatuscode'));if(requestErr)returnnull;constsendUser=event;//这里可以根据业务情况发送用户信息constuserData=localStorage.getItem('userData');letuser={cellphone:null,真实姓名:空,};如果(userData){constuserObj=JSON.parse(userData);user={手机:userObj.cellphone,realName:userObj.realName,公司:userObj.manageDepartmentNames,companyId:userObj.companyId,};}sendUser.user=用户;返回事件;},ignoreErrors:['获取失败','尝试获取资源时出现网络错误','超出ResizeObserver循环限制','ResizeObserver循环完成但未传递通知','正在加载块','无法为CSS预加载','请求中止',],});Sentry.configureScope((scope)=>{constdate=newDate();constymdDate=`${date.getFullYear()}/${date.getMonth()+1}/${date.getDate()}`;consthour=date.getHours().toString();scope.setTag('ERRORTYPE','uncaught');scope.setTag('环境',环境);scope.setTag('DATE',ymdDate);scope.setTag('HOUR',小时);scope.setLevel(Severity.Error);if(tags&&typeoftags==='object'){Object.keys(tags).forEach((key)=>{scope.setTag(key,tags[key]);});}});}}//eslint-disable-next-lineclass-methods-use-thissentryCapture({error='',extra,level,tags,}){Sentry.withScope((scope)=>{scope.setTag('ERRORTYPE','caught');scope.setLevel(level);让reportError=error;if(errorinstanceofError){reportError=error.toString();}elseif(typeoferror==='object'){reportError=JSON.stringify(error);}if(extra&&typeofextra==='object'){Object.keys(extra).forEach((key)=>{scope.setExtra(key,extra[key]);});}if(tags&&typeoftags==='object'){Object.keys(tags).forEach((key)=>{scope.setTag(key,tags[k哎]);});}如果(reportError==='CANCEL')返回;Sentry.captureException(新错误(reportError));});}fatal(param){this.sentryCapture({...param,level:Severity.Fatal});}error(param){this.sentryCapture({...param,level:Severity.Error});}warn(param){this.sentryCapture({...param,level:Severity.Warning});}debug(param){this.sentryCapture({...param,level:Severity.Debug});}log(param){this.sentryCapture({...param,level:Severity.Log});}}exportdefaultCapture;使用importCapturefrom'sentry.js';constcapture=newCapture({dsn:'*****',release:version,env:import.meta.env.MODE,});请教下大神为什么延迟加载会影响sourceMap位置?
