新增模块:XuqmBugCollectSDK - BugCollectSDK: 主入口,错误捕获 API - CrashCapture: 崩溃捕获(NSException + POSIX 信号) - IssueEvent/LogEvent: 数据模型 - Fingerprint: 错误指纹计算(SHA-256) - LogQueue: 内存队列 + 定时上传 - LogStorage: 崩溃文件持久化 - LogUploader: HTTP 上传到服务端 - FunnelTracker: 漏斗追踪 功能: - captureError/captureCrash 捕获错误 - addBreadcrumb 添加面包屑 - event 记录自定义事件 - warn/info 日志级别记录 - 自动初始化(onInitialize hook) Co-Authored-By: Claude <noreply@anthropic.com>
72 行
1.8 KiB
Swift
72 行
1.8 KiB
Swift
import Foundation
|
|
|
|
public struct SDKConfig: Sendable {
|
|
public let appKey: String
|
|
public let debug: Bool
|
|
public let autoRegisterPush: Bool
|
|
|
|
public init(
|
|
appKey: String,
|
|
debug: Bool = false,
|
|
autoRegisterPush: Bool = true
|
|
) {
|
|
self.appKey = appKey
|
|
self.debug = debug
|
|
self.autoRegisterPush = autoRegisterPush
|
|
}
|
|
}
|
|
|
|
public extension SDKConfig {
|
|
static func development(
|
|
appKey: String,
|
|
debug: Bool = false,
|
|
autoRegisterPush: Bool = true
|
|
) -> SDKConfig {
|
|
SDKConfig(
|
|
appKey: appKey,
|
|
debug: debug,
|
|
autoRegisterPush: autoRegisterPush
|
|
)
|
|
}
|
|
}
|
|
|
|
public enum SDKEndpoints {
|
|
private static var _apiBaseURL: URL?
|
|
private static var _imWebSocketURL: URL?
|
|
private static var _bugCollectApiURL: URL?
|
|
|
|
public static var apiBaseURL: URL {
|
|
_apiBaseURL ?? URL(string: "https://dev.xuqinmin.com")!
|
|
}
|
|
|
|
public static var imWebSocketURL: URL {
|
|
_imWebSocketURL ?? URL(string: "wss://dev.xuqinmin.com/ws/im")!
|
|
}
|
|
|
|
public static var bugCollectApiURL: URL? {
|
|
_bugCollectApiURL ?? _apiBaseURL
|
|
}
|
|
|
|
public static func configure(
|
|
apiBaseURL: String? = nil,
|
|
imWebSocketURL: String? = nil,
|
|
bugCollectApiURL: String? = nil
|
|
) {
|
|
if let api = apiBaseURL, let url = URL(string: api) {
|
|
_apiBaseURL = url
|
|
}
|
|
if let ws = imWebSocketURL, let url = URL(string: ws) {
|
|
_imWebSocketURL = url
|
|
}
|
|
if let bc = bugCollectApiURL, let url = URL(string: bc) {
|
|
_bugCollectApiURL = url
|
|
}
|
|
}
|
|
|
|
public static func reset() {
|
|
_apiBaseURL = nil
|
|
_imWebSocketURL = nil
|
|
_bugCollectApiURL = nil
|
|
}
|
|
}
|