422c8931d6
实现: 在rust内存里维护错误事件队列, webview调用tauri command传入, 后台任务agent工具等直接插入 把rust , webview console的日志统一写到AppData文件夹下的(滚动保存的)日志文件. rust对传入的错误进行筛选,脱敏, 防抖,后通知前端提醒用户. 用户提醒是一个不阻塞的小UI, 展开后可以选择错误上报, 可以附加文字描述 上传时附带最近日志, 错误堆栈等信息 元数据存在数据库, 考虑到字符串信息很难查询, 所以在api server打包成zip存在OSS. 管理页面新增错误报告的查看页面     --------- Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/240 Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
89 lines
2.5 KiB
Rust
89 lines
2.5 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Event {
|
|
pub event_id: String,
|
|
pub fingerprint: String,
|
|
pub source: String,
|
|
pub message: String,
|
|
pub stack: Option<String>,
|
|
pub occurred_at: String,
|
|
pub count: u32,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ErrorReportLogInput {
|
|
pub name: String,
|
|
pub content: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct CreateErrorReportBatchRequest {
|
|
pub schema_version: u32,
|
|
pub submission_id: String,
|
|
pub events: Vec<Event>,
|
|
pub user_description: Option<String>,
|
|
pub logs: Vec<ErrorReportLogInput>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct CreateErrorReportBatchResponse {
|
|
pub batch_id: String,
|
|
pub submission_id: String,
|
|
pub status: String,
|
|
pub accepted_event_ids: Vec<String>,
|
|
pub created_at: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct AdminErrorReportListQuery {
|
|
pub status: Option<String>,
|
|
pub fingerprint: Option<String>,
|
|
pub source: Option<String>,
|
|
pub limit: Option<u32>,
|
|
pub offset: Option<u32>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct AdminErrorReportEntry {
|
|
pub batch_id: String,
|
|
pub event_count: u32,
|
|
pub log_count: u32,
|
|
pub fingerprint: Option<String>,
|
|
pub source: Option<String>,
|
|
pub status: String,
|
|
pub user_id: String,
|
|
pub created_at: String,
|
|
pub updated_at: String,
|
|
pub user_description: Option<String>,
|
|
pub attachment_size_bytes: u64,
|
|
pub submission_id: Option<String>,
|
|
pub oss_object_key: Option<String>,
|
|
pub archive_sha256: Option<String>,
|
|
pub upload_status: Option<String>,
|
|
pub review_status: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct AdminErrorReportListResponse {
|
|
pub reports: Vec<AdminErrorReportEntry>,
|
|
pub total: u64,
|
|
pub offset: u32,
|
|
pub limit: u32,
|
|
pub has_more: bool,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct AdminUpdateErrorReportRequest {
|
|
pub status: String,
|
|
pub note: Option<String>,
|
|
}
|