fix: 修复 Sentry 启用条件,确保在生产环境中正确启用;优化设备过滤逻辑,避免潜在的空值错误
This commit is contained in:
parent
3d60954547
commit
ddb7fda36f
|
|
@ -22,7 +22,7 @@ Sentry.init({
|
|||
sendDefaultPii: true,
|
||||
enableLogs: true,
|
||||
// debug: true,
|
||||
// enabled: !__DEV__, // 仅在生产环境启用 Sentry
|
||||
enabled: !__DEV__, // 仅在生产环境启用 Sentry
|
||||
})
|
||||
|
||||
// 目前无需求,先注释掉
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ export const useBleExplorer = () => {
|
|||
logToSentry('device_discovered_batch')
|
||||
|
||||
setState((prev) => {
|
||||
const newDevices = devicesToAdd.filter((nd) => !prev.discoveredDevices.some((ed) => ed.id === nd.id))
|
||||
const newDevices = devicesToAdd.filter((nd) => !prev.discoveredDevices?.some((ed) => ed?.id === nd?.id))
|
||||
if (newDevices.length === 0) return prev
|
||||
console.debug(`Batch adding ${newDevices.length} devices`)
|
||||
return { ...prev, discoveredDevices: [...prev.discoveredDevices, ...newDevices] }
|
||||
|
|
@ -154,7 +154,7 @@ export const useBleExplorer = () => {
|
|||
const queueDevice = useCallback(
|
||||
(device: BleDevice) => {
|
||||
// 检查是否已在队列中
|
||||
if (pendingDevicesRef.current.some((d) => d?.id === device?.id)) return
|
||||
if (pendingDevicesRef.current?.some((d) => d?.id === device?.id)) return
|
||||
|
||||
pendingDevicesRef.current.push(device)
|
||||
|
||||
|
|
@ -348,12 +348,14 @@ export const useBleExplorer = () => {
|
|||
|
||||
// console.log('startScan--------', device)
|
||||
|
||||
if (!hasTargetService || !device.id) {
|
||||
if (!hasTargetService || !device?.id) {
|
||||
return
|
||||
}
|
||||
|
||||
device.connected = false
|
||||
console.debug(`Device found: ${device.name} (${device.id}), serviceUUIDs: ${device.serviceUUIDs}`)
|
||||
console.debug(
|
||||
`Device found: ${device.name} (${device.id}), serviceUUIDs: ${JSON.stringify(device.serviceUUIDs)}`,
|
||||
)
|
||||
|
||||
// 使用队列批量更新,避免频繁触发 setState
|
||||
queueDevice(device)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as Sentry from '@sentry/react-native'
|
||||
import * as Updates from 'expo-updates'
|
||||
import { useEffect, useState } from 'react'
|
||||
import * as Sentry from '@sentry/react-native'
|
||||
|
||||
interface UseUpdateCheckerOptions {
|
||||
/** 检查更新的间隔时间(毫秒),默认1分钟 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue