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:
@ -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
|
||||||
|
@ -40,7 +40,8 @@ const pushUseConnect = ({
|
|||||||
url: 'v1/connect',
|
url: 'v1/connect',
|
||||||
body: {
|
body: {
|
||||||
expoToken
|
expoToken
|
||||||
}
|
},
|
||||||
|
sentry: true
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
displayMessage({
|
displayMessage({
|
||||||
mode,
|
mode,
|
||||||
|
@ -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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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') {
|
||||||
|
@ -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') {
|
||||||
|
Reference in New Issue
Block a user