FMTrackEventManager.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // FMTrackEventManager.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by liujiajie on 2024/2/7.
  6. //
  7. import Foundation
  8. let kTrackEventManager = FMTrackEventManager.defaultManager
  9. @objcMembers class FMTrackEventManager: NSObject{
  10. static let defaultManager: FMTrackEventManager = {
  11. let manager = FMTrackEventManager()
  12. return manager
  13. }()
  14. override init() {
  15. super.init()
  16. }
  17. func trackEvent(event: String, withProperties properties: [String: String]?) {
  18. if event.count < 1 { return }
  19. #if DEBUG
  20. let keyStr: String = properties?.keys.first ?? ""
  21. let vStr: String = properties?.values.first ?? ""
  22. NSLog("###-FireBaseEvent-(%@)-properties(%@):(%@)",event,keyStr,vStr)
  23. #endif
  24. }
  25. func trackOnceEvent(event: String, withProperties properties: [String: String]?) {
  26. if event.count < 1 { return }
  27. var eventString = event
  28. if properties?.keys.count ?? 0 > 0 && properties?.values.count ?? 0 > 0 {
  29. var keyString = ""
  30. for key in properties!.keys {
  31. keyString += key
  32. }
  33. for value in properties!.values {
  34. keyString += value
  35. }
  36. eventString += keyString
  37. }
  38. }
  39. }