Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sentry-cli: electron crash 监控的最后一步 #4

Open
Zaynex opened this issue Mar 7, 2020 · 0 comments
Open

sentry-cli: electron crash 监控的最后一步 #4

Zaynex opened this issue Mar 7, 2020 · 0 comments

Comments

@Zaynex
Copy link
Owner

Zaynex commented Mar 7, 2020

Sentry 是非常优秀的异常监控平台,支持多种语言和平台(比如 ReactNative,Electron)。并且是开源的,开发人员可以将 Sentry 部署在自己的云服务器上。

文本的重点不是如何接入 Sentry 到 Electron,而是如何将 Sentry 捕获到的 Electron crash 解析出来。
请参考 Sentry 接入 Electron

当 Sentry 捕获到 Electron 的崩溃时,会将 Electron 的 minidump 文件上传到指定的 Sentry 服务器,
其配置参考如下:

import * as Sentry from '@sentry/electron';
const { crashReporter } = require('electron');
crashReporter.start({
    companyName: 'xxx',
    productName: 'xxx',
    ignoreSystemCrashHandler: true,
    submitURL: 'https://sentry.io/api/9/minidump/?sentry_key=xxxx',
  });

如果是自己搭建的服务器,那么 submitURL 就是自己的服务域名。

当我们制造 Electron 崩溃时,我们在 sentry 平台上会看到类似的监控崩溃信息。

image

虽然能在平台上收到崩溃的监控,上传的 minidump 文件是汇编级别的代码,我们还需要对应的 symbol 文件来解析这些调用栈,使其还原至我们在项目中写的具体函数名。

上传 Debug Information Files

Debug information files are used to convert addresses and minified function names from native crash reports into function names and locations.

调试信息文件用于将地址和简化的函数名从本机崩溃报告转换为函数名和位置。

sentry-cli

我们需要 sentry-cli 来帮助我们查找对应的 symbol 文件。

image

我们根据 uuid 在本地中查找所需的文件

npm install -g @sentry/cli

sentry-cli 有非常完善的文档,这里只介绍如何在本地上传 symbol 文件

首先利用 sentry-cli 登录,url 默认是 sentry.io,如果是自己的服务,那么你需要按照如下操作进行登录。

sentry-cli --url xxxxx login

按照指示登录后,我们需要获取相应的 auth-token。

校验完毕后,我们可以通过 uuid 查找本地的 symbol 文件

sentry-cli difutil find uuid

找到本地的 symbol 文件后,我们需要上传到服务器

sentry-cli --auth-token xxxx upload-dif -o org -p project xxxx(localpath)

如果是 sentry 自己搭建的服务,在上传可能会遇到 413 实体过大的问题,需要将 nginx 配置设置为
client_max_body_size 20M

上传之后,我们就能解析具体的异常信息了。
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant