// // FMTrackEventManager.swift // PDF Reader Pro // // Created by liujiajie on 2024/2/7. // import Foundation import FirebaseAnalytics let kTrackEventManager = FMTrackEventManager.defaultManager @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() var theParams: [String : String] = [:] for (key, value) in properties ?? [:] { theParams["itemname"] = key theParams["action"] = value } Analytics.logEvent(event, parameters: theParams) } 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 } var theParams: [String : String] = [:] for (key, value) in properties ?? [:] { theParams["itemname"] = key theParams["action"] = value } Analytics.logEvent(event, parameters: theParams) } }