统一手动错误报告打开流程
复用异步错误采集 helper 并在打开面板前完成事件登记
This commit is contained in:
@@ -130,6 +130,12 @@ export function AuthenticatedClient({
|
||||
const [customServerUrl, setCustomServerUrl] = useState(
|
||||
initialServerSelection.customBaseUrl,
|
||||
);
|
||||
const openManualErrorReport = useCallback(async () => {
|
||||
await captureClientError(new Error('用户主动报告问题'), {
|
||||
source: 'manual',
|
||||
});
|
||||
setErrorReportOpen(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const uninstallWebviewLogBridge = installWebviewLogBridge();
|
||||
@@ -151,16 +157,13 @@ export function AuthenticatedClient({
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const openReport = () => {
|
||||
void captureClientError(new Error('用户主动报告问题'), {
|
||||
source: 'manual',
|
||||
});
|
||||
setErrorReportOpen(true);
|
||||
};
|
||||
window.addEventListener(OPEN_ERROR_REPORT_EVENT, openReport);
|
||||
window.addEventListener(OPEN_ERROR_REPORT_EVENT, openManualErrorReport);
|
||||
return () =>
|
||||
window.removeEventListener(OPEN_ERROR_REPORT_EVENT, openReport);
|
||||
}, []);
|
||||
window.removeEventListener(
|
||||
OPEN_ERROR_REPORT_EVENT,
|
||||
openManualErrorReport,
|
||||
);
|
||||
}, [openManualErrorReport]);
|
||||
|
||||
function persistServerSelection() {
|
||||
try {
|
||||
@@ -587,12 +590,7 @@ export function AuthenticatedClient({
|
||||
<>
|
||||
<ClientRuntimeErrorBoundary
|
||||
onLogout={logout}
|
||||
onReport={() => {
|
||||
void captureClientError(new Error('用户主动报告问题'), {
|
||||
source: 'manual',
|
||||
});
|
||||
setErrorReportOpen(true);
|
||||
}}
|
||||
onReport={() => void openManualErrorReport()}
|
||||
>
|
||||
{children({ user: authUser, logout })}
|
||||
</ClientRuntimeErrorBoundary>
|
||||
|
||||
Reference in New Issue
Block a user