接入 AGC 错误报告后端接口

新增登录态错误报告批量提交与管理员查询接口。

生成 JSONL 诊断归档并支持私有 OSS 上传及状态记录。

接入 AppState、路由和后台 Tab 权限审计。
This commit is contained in:
2026-09-01 10:10:32 +08:00
parent 0a9f24d8c6
commit 1f252ef86d
6 changed files with 935 additions and 1 deletions
+3
View File
@@ -1792,6 +1792,8 @@ fn admin_permission_requirement(_method: &Method, path: &str) -> AdminPermission
"/admin/api/debug/http" => AnyTab(&["debug"]),
"/admin/api/tracking/events" => AnyTab(&["tracking"]),
"/admin/api/tracking/event-keys" => AnyTab(&["tracking", "tasks"]),
"/admin/api/error-reports" => AnyTab(&["error-reports"]),
path if path.starts_with("/admin/api/error-reports/") => AnyTab(&["error-reports"]),
"/admin/api/feature-gates" => AnyTab(&["gray-release"]),
"/admin/api/editor-generation-pricing" => AnyTab(&["editor-generation-pricing"]),
"/admin/api/editor-assets" => AnyTab(&["editor-assets"]),
@@ -5646,6 +5648,7 @@ mod tests {
("tables", Method::GET, "/admin/api/database/tables"),
("debug", Method::POST, "/admin/api/debug/http"),
("tracking", Method::GET, "/admin/api/tracking/events"),
("error-reports", Method::GET, "/admin/api/error-reports"),
("gray-release", Method::GET, "/admin/api/feature-gates"),
("redeem", Method::GET, "/admin/api/profile/redeem-codes"),
("invite", Method::GET, "/admin/api/profile/invite-codes"),
+1
View File
@@ -46,6 +46,7 @@ pub fn build_router(state: AppState) -> Router {
.merge(modules::platform::router(state.clone()))
.merge(modules::external_generation::router(state.clone()))
.merge(modules::platform_support::router(state.clone()))
.merge(crate::error_reports::router(state.clone()))
.route(
"/api/profile/recharge/wechat/notify",
post(handle_wechat_pay_notify),
File diff suppressed because it is too large Load Diff
+1
View File
@@ -32,6 +32,7 @@ mod editor_screen_background_decision;
mod editor_screen_background_filter;
mod editor_sound_effect_prompt_assist;
mod error_middleware;
mod error_reports;
mod external_api_audit;
mod external_api_auth;
mod external_api_keys;
+13
View File
@@ -44,6 +44,7 @@ use crate::editor_generation_config::{
EditorGenerationPricingConfig, EditorGenerationPricingError, EditorGenerationPricingStore,
EditorGenerationPricingUnit,
};
use crate::error_reports::ErrorReportStore;
use crate::tracking_outbox::TrackingOutbox;
use crate::wallet_refund_outbox::{ProfileWalletRefundOutboxWorker, WalletRefundOutbox};
use crate::wechat::pay::{build_wechat_pay_config, map_wechat_pay_init_error};
@@ -296,6 +297,7 @@ pub struct AppStateInner {
#[cfg(any())]
puzzle_gallery_cache: PuzzleGalleryCache,
tracking_outbox: Option<Arc<TrackingOutbox>>,
error_report_store: Arc<ErrorReportStore>,
wallet_refund_outbox: Option<Arc<WalletRefundOutbox>>,
profile_wallet_refund_outbox_worker: Arc<ProfileWalletRefundOutboxWorker>,
editor_generation_pricing_store: EditorGenerationPricingStore,
@@ -589,6 +591,12 @@ impl AppState {
let ai_task_service = AiTaskService::new(InMemoryAiTaskStore::default());
let spacetime_client = SpacetimeClient::new(spacetime_client_config_for_process(&config));
let tracking_outbox = TrackingOutbox::from_config(&config, spacetime_client.clone());
let error_report_store = ErrorReportStore::new(
config
.tracking_outbox_dir
.parent()
.unwrap_or_else(|| std::path::Path::new("server-rs/.data")),
);
let wallet_refund_outbox =
WalletRefundOutbox::from_config(&config, spacetime_client.clone());
let profile_wallet_refund_outbox_worker =
@@ -666,6 +674,7 @@ impl AppState {
#[cfg(any())]
puzzle_gallery_cache: PuzzleGalleryCache::new(),
tracking_outbox,
error_report_store,
wallet_refund_outbox,
profile_wallet_refund_outbox_worker,
editor_generation_pricing_store,
@@ -1303,6 +1312,10 @@ impl AppState {
self.oss_client.as_ref()
}
pub fn error_report_store(&self) -> &Arc<ErrorReportStore> {
&self.error_report_store
}
pub fn password_entry_service(&self) -> &PasswordEntryService {
&self.password_entry_service
}
@@ -10,7 +10,7 @@ use crate::creation_entry_config::{
};
/// 后台 member 可被授予的一级 Tab 权限;账号管理仅 owner 可见,不进入该集合。
pub const ADMIN_TAB_PERMISSIONS: [&str; 15] = [
pub const ADMIN_TAB_PERMISSIONS: [&str; 16] = [
"dashboard",
"overview",
"tables",
@@ -26,6 +26,7 @@ pub const ADMIN_TAB_PERMISSIONS: [&str; 15] = [
"editor-generation-pricing",
"editor-showcase",
"editor-assets",
"error-reports",
];
/// 不随一级 Tab 自动授予的后台高风险操作权限。