error track
This commit is contained in:
@@ -12,6 +12,7 @@ import { clientInitData, feConfigs } from '@/store/static';
|
||||
import { appWithTranslation, useTranslation } from 'next-i18next';
|
||||
import { getLangStore, setLangStore } from '@/utils/i18n';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
|
||||
import 'nprogress/nprogress.css';
|
||||
import '@/styles/reset.scss';
|
||||
@@ -37,6 +38,7 @@ function App({ Component, pageProps }: AppProps) {
|
||||
const router = useRouter();
|
||||
const { hiId } = router.query as { hiId?: string };
|
||||
const { i18n } = useTranslation();
|
||||
const { setLastRoute } = useGlobalStore();
|
||||
|
||||
const [scripts, setScripts] = useState<FeConfigsType['scripts']>([]);
|
||||
const [googleClientVerKey, setGoogleVerKey] = useState<string>();
|
||||
@@ -75,6 +77,10 @@ function App({ Component, pageProps }: AppProps) {
|
||||
const lang = getLangStore() || 'zh';
|
||||
i18n?.changeLanguage?.(lang);
|
||||
setLangStore(lang);
|
||||
|
||||
return () => {
|
||||
setLastRoute(router.asPath);
|
||||
};
|
||||
}, [router.asPath]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { serviceSideProps } from '@/utils/i18n';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import { addLog } from '@/service/utils/tools';
|
||||
import { getErrText } from '@/utils/tools';
|
||||
|
||||
function Error() {
|
||||
const router = useRouter();
|
||||
const { lastRoute } = useGlobalStore();
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
window.umami?.track('pageError', {
|
||||
userAgent: navigator.userAgent,
|
||||
platform: navigator.platform,
|
||||
appName: navigator.appName
|
||||
appName: navigator.appName,
|
||||
lastRoute,
|
||||
route: router.asPath
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
@@ -26,7 +34,9 @@ function Error() {
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context: any) {
|
||||
console.log(context);
|
||||
console.log('[render error]: ', context);
|
||||
|
||||
addLog.error(getErrText(context?.res));
|
||||
|
||||
return {
|
||||
props: { ...(await serviceSideProps(context)) }
|
||||
|
||||
Reference in New Issue
Block a user