feat: 接入自建 Sentry 错误上报
- DSN 指向 rustrak 自建 Sentry(项目 8),release 标记 mqttx@版本 - panic 路径:sentry-panic 链式钩子捕获 + 外层钩子 flush 5s, 确保 panic=abort 终止进程前事件送出 - 存储层 elog! 持久化错误同步 capture_message 上报 - 传输用 reqwest+rustls,避免 openssl 依赖
This commit is contained in:
@@ -4,6 +4,19 @@ use gpui_kit::*;
|
||||
use mqttx_desktop::ui;
|
||||
use mqttx_desktop::update;
|
||||
|
||||
/// 自建 Sentry(rustrak):panic 与关键错误上报。
|
||||
const SENTRY_DSN: &str =
|
||||
"https://9853b05c2a3a4fce921c650587168f49@api.rustrak.sentry.heavenlybook.cn/8";
|
||||
|
||||
/// 返回的 guard 必须在程序整个生命周期内存活,drop 即停用上报。
|
||||
fn init_sentry() -> sentry::ClientInitGuard {
|
||||
sentry::init(
|
||||
sentry::ClientOptions::new()
|
||||
.dsn(SENTRY_DSN)
|
||||
.release(format!("mqttx@{}", env!("CARGO_PKG_VERSION"))),
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// OTA 收尾:清理遗留文件;若暂存区有待安装的新版本(用户上次同意安装),
|
||||
// 在进入 UI 前完成自替换并重启。
|
||||
@@ -15,6 +28,17 @@ fn main() {
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
let _sentry_guard = init_sentry();
|
||||
// sentry 的 panic 钩子只捕获不等待传输;再包一层在钩子末尾 flush,
|
||||
// 保证 panic=abort 立即终止进程前事件已送出。
|
||||
let chained_panic_hook = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |info| {
|
||||
chained_panic_hook(info);
|
||||
if let Some(client) = sentry::Hub::current().client() {
|
||||
client.flush(Some(std::time::Duration::from_secs(5)));
|
||||
}
|
||||
}));
|
||||
|
||||
application()
|
||||
// AllAssets 嵌入全量 Lucide 图标;Assets 只含 default-icons.txt 的 101 个,
|
||||
// 其余 IconName(MailOpen/SlidersHorizontal 等)运行时会渲染空白
|
||||
|
||||
Reference in New Issue
Block a user