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
+15
View File
@@ -1,10 +1,25 @@
import Taro from '@tarojs/taro';
import { createUserTracker, getSessionId } from '@dukang/client-logging';
import { API_BASE, CLIENT_APP, getToken } from './api';
function currentPagePath(): string | undefined {
try {
const pages = Taro.getCurrentPages();
const cur = pages[pages.length - 1] as { route?: string; $taroPath?: string } | undefined;
return cur?.$taroPath || cur?.route || undefined;
} catch {
return undefined;
}
}
const tracker = createUserTracker({
apiBase: API_BASE,
clientApp: CLIENT_APP,
getToken,
getPagePath: currentPagePath,
postJson: ({ url, headers, body }) => {
void Taro.request({ url, method: 'POST', header: headers, data: body }).catch(() => {});
},
});
export { getSessionId };