fix: iOS BugCollect 修复 warn() 和 freeMemoryMb
修复: - warn() 添加 breadcrumbs 和 device 信息 - freeMemoryMb 改为使用 os_proc_available_memory() 获取可用内存 - 添加 iOS 13+ 版本检查 Co-Authored-By: Claude <noreply@anthropic.com>
这个提交包含在:
父节点
07fcd64b1a
当前提交
5954683efc
@ -153,17 +153,19 @@ public final class BugCollectSDK {
|
|||||||
guard logLevel.rawValue <= LogLevel.warn.rawValue else { return }
|
guard logLevel.rawValue <= LogLevel.warn.rawValue else { return }
|
||||||
guard isReady() else { return }
|
guard isReady() else { return }
|
||||||
|
|
||||||
|
let crumbs = breadcrumbLock.lockAndRun { breadcrumbBuffer }
|
||||||
let issueEvent = IssueEvent(
|
let issueEvent = IssueEvent(
|
||||||
level: "warning",
|
level: "warning",
|
||||||
platform: "ios",
|
platform: "ios",
|
||||||
fingerprint: Fingerprint.compute(type: "Warning", message: message, stacktrace: ""),
|
fingerprint: Fingerprint.compute(type: "Warning", message: message, stacktrace: ""),
|
||||||
appKey: XuqmSDK.shared.requireConfig().appKey,
|
appKey: XuqmSDK.shared.requireConfig().appKey,
|
||||||
exception: IssueEvent.ExceptionInfo(type: "Warning", value: message),
|
exception: IssueEvent.ExceptionInfo(type: "Warning", value: message),
|
||||||
breadcrumbs: [],
|
breadcrumbs: crumbs,
|
||||||
release: appVersion(),
|
release: appVersion(),
|
||||||
environment: environment,
|
environment: environment,
|
||||||
userId: XuqmSDK.shared.userId ?? XuqmSDK.shared.deviceId,
|
userId: XuqmSDK.shared.userId ?? XuqmSDK.shared.deviceId,
|
||||||
user: IssueEvent.UserInfo(id: XuqmSDK.shared.userId ?? XuqmSDK.shared.deviceId),
|
user: IssueEvent.UserInfo(id: XuqmSDK.shared.userId ?? XuqmSDK.shared.deviceId),
|
||||||
|
device: buildDeviceInfo(),
|
||||||
tags: tags
|
tags: tags
|
||||||
)
|
)
|
||||||
queue?.push(issueEvent)
|
queue?.push(issueEvent)
|
||||||
@ -249,6 +251,16 @@ public final class BugCollectSDK {
|
|||||||
let device = UIDevice.current
|
let device = UIDevice.current
|
||||||
let processInfo = ProcessInfo.processInfo
|
let processInfo = ProcessInfo.processInfo
|
||||||
|
|
||||||
|
// 使用 os_proc_available_memory() 获取可用内存(如果可用)
|
||||||
|
let freeMemoryMb: Int
|
||||||
|
if #available(iOS 13.0, *) {
|
||||||
|
let availableMemory = os_proc_available_memory()
|
||||||
|
freeMemoryMb = Int(availableMemory / 1024 / 1024)
|
||||||
|
} else {
|
||||||
|
// Fallback: 使用物理内存(不准确但有值)
|
||||||
|
freeMemoryMb = Int(processInfo.physicalMemory / 1024 / 1024)
|
||||||
|
}
|
||||||
|
|
||||||
return IssueEvent.DeviceInfo(
|
return IssueEvent.DeviceInfo(
|
||||||
model: device.model,
|
model: device.model,
|
||||||
manufacturer: "Apple",
|
manufacturer: "Apple",
|
||||||
@ -257,7 +269,7 @@ public final class BugCollectSDK {
|
|||||||
locale: Locale.current.identifier,
|
locale: Locale.current.identifier,
|
||||||
timezone: TimeZone.current.identifier,
|
timezone: TimeZone.current.identifier,
|
||||||
isEmulator: isSimulator(),
|
isEmulator: isSimulator(),
|
||||||
freeMemoryMb: Int(processInfo.physicalMemory / 1024 / 1024),
|
freeMemoryMb: freeMemoryMb,
|
||||||
buildType: isDebug() ? "debug" : "release"
|
buildType: isDebug() ? "debug" : "release"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户