集成友盟统计分析和应用性能监控

This commit is contained in:
2026-07-07 14:20:04 +08:00
parent 90ba28e61f
commit 741e701750
9 changed files with 155 additions and 2 deletions

View File

@ -0,0 +1,51 @@
//
// UmengBootstrap.swift
// suixinkan
//
import Foundation
/// SDK
enum UmengBootstrap {
/// SDK
private(set) static var isConfigured = false
private static let lock = NSLock()
private static var configureHandler: (_ appKey: String, _ channel: String) -> Void = { appKey, channel in
UMConfigure.setLogEnabled(false)
UMConfigure.initWithAppkey(appKey, channel: channel)
}
/// App SDK
@discardableResult
static func configureIfNeeded(appStore: AppStore = .shared) -> Bool {
guard appStore.privacyAgreementAccepted else { return false }
lock.lock()
defer { lock.unlock() }
guard !isConfigured else { return true }
configureHandler(UmengConfig.appKey, UmengConfig.channel)
isConfigured = true
return true
}
/// SDK
static func setConfigureHandlerForTesting(_ handler: @escaping (_ appKey: String, _ channel: String) -> Void) {
lock.lock()
defer { lock.unlock() }
configureHandler = handler
}
///
static func resetForTesting() {
lock.lock()
defer { lock.unlock() }
isConfigured = false
configureHandler = { appKey, channel in
UMConfigure.setLogEnabled(false)
UMConfigure.initWithAppkey(appKey, channel: channel)
}
}
}

View File

@ -0,0 +1,15 @@
//
// UmengConfig.swift
// suixinkan
//
import Foundation
/// SDK
enum UmengConfig {
/// iOS AppKey
nonisolated static let appKey = "6a470b81cbfa6959516c34d0"
/// 使 App Store
nonisolated static let channel = "App Store"
}