Electron 集成 Sentry

2021-09-30  本文已影响0人  依然还是或者其他

Electron 集成 Sentry

sentry分为支持本地部署。目前只涉及在线版本。

Sentry

yarn add @sentry/electron


根据进程不同选择不同的Sentry
import * as Sentry from "@sentry/electron/dist/main";  // 主进程

import * as Sentry from "@sentry/electron/dist/renderer";  //渲染进程


Sentry.init({ dsn: "https://92f427b4b5f6474a958e88d985b3f57c@o1011820.ingest.sentry.io/5976771" });



crashReporter.start({
  productName,   //产品名称
  companyName,   //公司名称
  submitURL,    // sentrt的minidump提交地址
  extra:{      //额外信息,如版本号等
    "release":pjson.version
  }
});


minidump 及 符号表

crashReporter 为 Electron 提供的收集机制,它可以收集应用程序无法捕获的崩溃错误,收集后,可以把信息保存到本地或者上传到指定服务器。
上传的文件是二进制的minidump类型文件,一个minidump只包括了最必要的信息,用于恢复故障进程的所有线程的调用堆栈,以及查看故障时刻局部变量的值。

由于sentrt解析出的minidump内容多为内容地址,不容易根据内容排查问题。
调试符号允许您有更好的调试会话。他们拥有关于可执行文件和动态库中包含的函数的信息,并为您提供获取干净的调用堆栈的信息。为此,Electron官方提供了相关版本的符号表

上传符号表到Sentry


// ...省略
zipPath = await downloadSymbols({
    version,
    platform: 'win32',
    arch: 'ia32',
    symbols: true,
  });
  await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);

  zipPath = await downloadSymbols({
    version,
    platform: 'win32',
    arch: 'x64',
    symbols: true,
  });
  await sentryCli.execute(['upload-dif', '-t', 'breakpad', zipPath], true);
  
  //...省略

然后下载到本地后自行进行上传,命令行可根据sentryCli.execute执行的内容自行拼接组织


sentry-cli upload-dif -t breakpad -o 组织名 -p 项目名  路径

参考

Sentrty官网Electron配置文档说明

Sentry-cli: 监控 electron crash 的最后一步

sentry 工作流和集成之调试信息文件

electron上传符号表到sentry

Electron10.3.0版本的资源包括符号表

minidump详细介绍

上一篇 下一篇

猜你喜欢

热点阅读