1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Capture push control error

This commit is contained in:
Zhiyuan Zheng
2021-03-12 00:19:45 +01:00
parent edcd86cba7
commit cca0ca7032
5 changed files with 18 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import axios from 'axios' import axios from 'axios'
import chalk from 'chalk' import chalk from 'chalk'
import * as Sentry from 'sentry-expo'
const ctx = new chalk.Instance({ level: 3 }) const ctx = new chalk.Instance({ level: 3 })
@ -12,6 +13,7 @@ export type Params = {
} }
headers?: { [key: string]: string } headers?: { [key: string]: string }
body?: FormData | Object body?: FormData | Object
sentry?: boolean
} }
const apiGeneral = async <T = unknown>({ const apiGeneral = async <T = unknown>({
@ -20,7 +22,8 @@ const apiGeneral = async <T = unknown>({
url, url,
params, params,
headers, headers,
body body,
sentry = false
}: Params): Promise<{ body: T }> => { }: Params): Promise<{ body: T }> => {
if (!domain) { if (!domain) {
return Promise.reject() return Promise.reject()
@ -56,6 +59,10 @@ const apiGeneral = async <T = unknown>({
}) })
}) })
.catch(error => { .catch(error => {
if (sentry) {
Sentry.Native.captureException(error, error)
}
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code // The request was made and the server responded with a status code
// that falls out of the range of 2xx // that falls out of the range of 2xx

View File

@ -40,7 +40,8 @@ const pushUseConnect = ({
url: 'v1/connect', url: 'v1/connect',
body: { body: {
expoToken expoToken
} },
sentry: true
}).catch(() => { }).catch(() => {
displayMessage({ displayMessage({
mode, mode,

View File

@ -29,7 +29,8 @@ const register1 = async ({
method: 'post', method: 'post',
domain: PUSH_SERVER, domain: PUSH_SERVER,
url: 'v1/register1', url: 'v1/register1',
body: { expoToken, instanceUrl, accountId, accountFull } body: { expoToken, instanceUrl, accountId, accountFull },
sentry: true
}) })
} }
@ -50,7 +51,8 @@ const register2 = async ({
method: 'post', method: 'post',
domain: PUSH_SERVER, domain: PUSH_SERVER,
url: 'v1/register2', url: 'v1/register2',
body: { expoToken, instanceUrl, accountId, serverKey, removeKeys } body: { expoToken, instanceUrl, accountId, serverKey, removeKeys },
sentry: true
}) })
} }

View File

@ -27,7 +27,8 @@ const pushUnregister = async (state: RootState, expoToken: string) => {
expoToken, expoToken,
instanceUrl: instance.url, instanceUrl: instance.url,
accountId: instance.account.id accountId: instance.account.id
} },
sentry: true
}) })
if (Platform.OS === 'android') { if (Platform.OS === 'android') {

View File

@ -34,7 +34,8 @@ export const updateInstancePushDecode = createAsyncThunk(
instanceUrl: instance.url, instanceUrl: instance.url,
accountId: instance.account.id, accountId: instance.account.id,
...(disable && { keys: instance.push.keys }) ...(disable && { keys: instance.push.keys })
} },
sentry: true
}) })
if (Platform.OS === 'android') { if (Platform.OS === 'android') {