Repository navigation
Expand file tree
/
Copy pathshared.tsx
More file actions
51 lines (48 loc) · 1.54 KB
/
Copy pathshared.tsx
File metadata and controls
51 lines (48 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as T from '@/constants/types'
import * as C from '@/constants'
import * as Constants from '@/constants/settings'
import * as React from 'react'
import logger from '@/logger'
import {RPCError} from '@/util/errors'
import {androidIsTestDevice, version} from '@/constants/platform'
export const getExtraChatLogsForLogSend = () => {
return {}
}
export const useSendFeedback = () => {
const [error, setError] = React.useState('')
const sendFeedback = React.useCallback((feedback: string, sendLogs: boolean, sendMaxBytes: boolean) => {
const f = async () => {
// We don't want test devices (pre-launch reports) to send us log sends.
if (androidIsTestDevice) {
return
}
try {
setError('')
if (sendLogs) {
await logger.dump()
}
const status = {version}
logger.info(`Sending ${sendLogs ? 'log' : 'feedback'} to daemon`)
const extra = sendLogs ? {...status, ...getExtraChatLogsForLogSend()} : status
const logSendId = await T.RPCGen.configLogSendRpcPromise(
{
feedback: feedback || '',
sendLogs,
sendMaxBytes,
statusJSON: JSON.stringify(extra),
},
Constants.sendFeedbackWaitingKey
)
logger.info('logSendId is', logSendId)
} catch (error) {
if (!(error instanceof RPCError)) {
return
}
logger.warn('err in sending logs', error)
setError(error.desc)
}
}
C.ignorePromise(f())
}, [])
return {error, sendFeedback}
}