fix(mini-user): use Taro.request for analytics and prod API origin

Replace fetch with wx/Taro.request in client-logging for WeChat mini program; point production build to api.dukanghaoke.com.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 22:53:35 +08:00
parent 89fd333702
commit c8ea5a3119
7 changed files with 157 additions and 39 deletions
+12 -10
View File
@@ -1,3 +1,5 @@
import { postJson } from './http';
export type ClientErrorLevel = 'fatal' | 'error' | 'warn' | 'info';
export type ClientErrorCategory =
| 'js_error'
@@ -31,10 +33,10 @@ export function installClientErrorReporting(opts: ClientErrorReporterOptions) {
};
if (token) headers.Authorization = `Bearer ${token}`;
void fetch(`${opts.apiBase}/common/client-errors`, {
method: 'POST',
postJson({
url: `${opts.apiBase}/common/client-errors`,
headers,
body: JSON.stringify({
body: {
level: payload.level,
category: payload.category,
message: payload.message,
@@ -42,8 +44,8 @@ export function installClientErrorReporting(opts: ClientErrorReporterOptions) {
pagePath: window.location.pathname,
clientApp: opts.clientApp,
extra: payload.extra,
}),
}).catch(() => {});
},
});
};
window.addEventListener('error', (ev) => {
@@ -78,16 +80,16 @@ export function reportApiError(
};
if (token) headers.Authorization = `Bearer ${token}`;
void fetch(`${opts.apiBase}/common/client-errors`, {
method: 'POST',
postJson({
url: `${opts.apiBase}/common/client-errors`,
headers,
body: JSON.stringify({
body: {
level: 'warn',
category: input.category ?? 'api_error',
message: input.message.slice(0, 1000),
pagePath: window.location.pathname,
clientApp: opts.clientApp,
extra: { status: input.status, url: input.url },
}),
}).catch(() => {});
},
});
}