1
0
mirror of https://github.com/tooot-app/app synced 2025-02-18 04:40:57 +01:00

Capture push control error

This commit is contained in:
Zhiyuan Zheng 2021-03-12 00:19:45 +01:00
parent edcd86cba7
commit cca0ca7032
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
5 changed files with 18 additions and 6 deletions

View File

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

View File

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

View File

@ -29,7 +29,8 @@ const register1 = async ({
method: 'post',
domain: PUSH_SERVER,
url: 'v1/register1',
body: { expoToken, instanceUrl, accountId, accountFull }
body: { expoToken, instanceUrl, accountId, accountFull },
sentry: true
})
}
@ -50,7 +51,8 @@ const register2 = async ({
method: 'post',
domain: PUSH_SERVER,
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,
instanceUrl: instance.url,
accountId: instance.account.id
}
},
sentry: true
})
if (Platform.OS === 'android') {

View File

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