KMAnalytics.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // KMAnalytics.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/7/12.
  6. //
  7. import Cocoa
  8. import AppCenter
  9. import AppCenterAnalytics
  10. import AppCenterCrashes
  11. import FirebaseCore
  12. import FirebaseAnalytics
  13. // 数据埋点 工具类
  14. @objc class KMAnalytics: NSObject {
  15. public struct AppTarget: OptionSet, Codable {
  16. let rawValue: Int
  17. public static var free = AppTarget(rawValue: 1 << 0)
  18. public static var pro = AppTarget(rawValue: 1 << 1)
  19. public static var dmg = AppTarget(rawValue: 1 << 2)
  20. public static var all: AppTarget = [.free, .pro, .dmg]
  21. }
  22. // 配置
  23. static func configure() {
  24. //#if DEBUG
  25. //#if VERSION_FREE
  26. //#if VERSION_DMG
  27. // let appSecret = "fb9d37aa-e3f2-4969-bd06-f65ce529a565"
  28. //#else
  29. // let appSecret = "8c08296d-ca5c-44da-b68a-b4382f119b1f"
  30. //#endif
  31. //#else
  32. // let appSecret = "54212f10-3ac9-42d9-96c0-5387f4b78d30"
  33. //#endif
  34. // AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
  35. //#else
  36. //// #if VERSION_DMG
  37. //// AppCenter.start(withAppSecret: "416b8e45-69bd-4a16-8fec-b5206e913c4a", services: [Analytics.self, Crashes.self])
  38. //// #else
  39. //// AppCenter.start(withAppSecret: "f0d082d0-9581-458c-9069-7aaf0a2b0a8c", services: [Analytics.self, Crashes.self])
  40. //// #endif
  41. #if VERSION_FREE
  42. #if VERSION_DMG
  43. let appSecret = "f2ea5307-b7be-468b-beda-a17ee458e182"
  44. #else
  45. let appSecret = ""
  46. #endif
  47. #else
  48. let appSecret = ""
  49. #endif
  50. if appSecret.isEmpty == false {
  51. AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
  52. }
  53. // FirebaseApp.configure()
  54. #if DEBUG
  55. // var newArguments = ProcessInfo.processInfo.arguments
  56. // newArguments.append("-FIRDebugEnabled")
  57. // ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
  58. #endif
  59. }
  60. }