|
@@ -128,15 +128,32 @@ _$http.interceptors.request.use(
|
|
|
}
|
|
|
);
|
|
|
|
|
|
-// Add a response interceptor
|
|
|
-_$httpWith500Msg.interceptors.response.use(
|
|
|
- response => {
|
|
|
+const recordRequest = response => {
|
|
|
+ let matchedRoutePath;
|
|
|
+ try {
|
|
|
+ const matched = router.resolve(location).route.matched;
|
|
|
+ const exactMatched = matched[matched.length - 1];
|
|
|
+ matchedRoutePath = exactMatched.path;
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
window._hmt.push([
|
|
|
"_trackEvent",
|
|
|
`页面-${location.pathname}`,
|
|
|
"网络请求-响应",
|
|
|
- new URL(response.config.url, "http://www.qmth.com.cn").pathname
|
|
|
+ "解析出错"
|
|
|
]);
|
|
|
+ }
|
|
|
+ window._hmt.push([
|
|
|
+ "_trackEvent",
|
|
|
+ `页面-${matchedRoutePath || location.pathname}`,
|
|
|
+ "网络请求-响应",
|
|
|
+ new URL(response.config.url, "http://www.qmth.com.cn").pathname
|
|
|
+ ]);
|
|
|
+};
|
|
|
+// Add a response interceptor
|
|
|
+_$httpWith500Msg.interceptors.response.use(
|
|
|
+ response => {
|
|
|
+ recordRequest(response);
|
|
|
return response;
|
|
|
},
|
|
|
error => {
|
|
@@ -213,12 +230,7 @@ _$httpWith500Msg.interceptors.response.use(
|
|
|
_$http.interceptors.response.use(
|
|
|
// no auto 500 error UI
|
|
|
response => {
|
|
|
- window._hmt.push([
|
|
|
- "_trackEvent",
|
|
|
- `页面-${location.pathname}`,
|
|
|
- "网络请求-响应",
|
|
|
- new URL(response.config.url, "http://www.qmth.com.cn").pathname
|
|
|
- ]);
|
|
|
+ recordRequest(response);
|
|
|
return response;
|
|
|
},
|
|
|
error => {
|