// // FMTrackEventManager.swift // PDF Reader Pro // // Created by liujiajie on 2024/2/7. // import Foundation import AppCenterAnalytics @objcMembers class FMTrackEventManager: NSObject{ static let defaultManager: FMTrackEventManager = { let manager = FMTrackEventManager() return manager }() override init() { super.init() } func trackEvent(event: String, withProperties properties: [String: String]?) { if event.count < 1 { return } #if DEBUG let keyStr: String = properties?.keys.first ?? "" let vStr: String = properties?.values.first ?? "" NSLog("###-FireBaseEvent-(%@)-properties(%@):(%@)",event,keyStr,vStr) #endif // if RIAnalytics.isNewUserForCurrentVersion() if let props = properties { Analytics.trackEvent(event, withProperties: props) } else { Analytics.trackEvent(event) } } func trackOnceEvent(event: String, withProperties properties: [String: String]?) { if event.count < 1 { return } var eventString = event if properties?.keys.count ?? 0 > 0 && properties?.values.count ?? 0 > 0 { var keyString = "" for key in properties!.keys { keyString += key } for value in properties!.values { keyString += value } eventString += keyString } if let props = properties { Analytics.trackEvent(event, withProperties: props) } else { Analytics.trackEvent(event) } } }