Skip to content

Commit 342612f

Browse files
committed
feat:请求失败上传至sentry
1 parent 2670a03 commit 342612f

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "MeshTalk",
44
"slug": "MeshTalk",
5-
"version": "1.1.0",
5+
"version": "1.1.3",
66
"orientation": "portrait",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "light",

src/store/useLoginStore.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const useLoginStore = create<LoginStoreState>((set, get) => ({
2323
},
2424
onPressLogin: async () => {
2525
if (get().path.length > 0) {
26-
const { data } = await getAppConfig("https://" + get().path);
27-
if (data) {
26+
const { data, ok } = await getAppConfig("https://" + get().path);
27+
if (data && ok) {
2828
set({ loginData: data });
2929

3030
const url = `https://${get().path}/oauth/authorize?scope=read%20write%20follow%20push&response_type=code&redirect_uri=${get().loginData?.redirect_uri}&client_id=${get().loginData?.client_id}`;
@@ -39,6 +39,8 @@ const useLoginStore = create<LoginStoreState>((set, get) => ({
3939
},
4040
});
4141
}
42+
} else {
43+
Toast.show("请检查网络设置");
4244
}
4345
} else {
4446
Toast.show("请输入应用实例地址");

src/utils/request.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as Sentry from "@sentry/react-native";
12
import { create, ApiResponse } from "apisauce";
23
import { AxiosRequestConfig } from "axios";
34

@@ -43,6 +44,15 @@ const get = <T>(
4344
status: response.status,
4445
problem: response.problem,
4546
}); // 假设response有这些属性
47+
if (!response.ok) {
48+
Sentry.captureEvent({
49+
request: {
50+
url,
51+
data: params,
52+
},
53+
message: "request fail" + response.originalError,
54+
});
55+
}
4656
return response;
4757
})
4858
.catch((error: any) => {
@@ -64,6 +74,15 @@ const post = <T>(
6474
status: response.status,
6575
problem: response.problem,
6676
}); // 假设response有这些属性
77+
if (!response.ok) {
78+
Sentry.captureEvent({
79+
request: {
80+
url,
81+
data,
82+
},
83+
message: "request fail" + response.originalError,
84+
});
85+
}
6786
return response;
6887
})
6988
.catch((error: any) => {
@@ -87,6 +106,15 @@ const patch = <T>(
87106
status: response.status,
88107
problem: response.problem,
89108
}); // 假设response有这些属性
109+
if (!response.ok) {
110+
Sentry.captureEvent({
111+
request: {
112+
url,
113+
data,
114+
},
115+
message: "request fail" + response.originalError,
116+
});
117+
}
90118
return response;
91119
})
92120
.catch((error: any) => {

0 commit comments

Comments
 (0)