123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // KMAnalytics.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/7/12.
- //
- import Cocoa
- // 数据埋点 平台
- @objc enum KMAnalyticsPlatform: Int {
- case AppCenter
- case firebase
- }
- // 数据埋点 Category 参数
- extension KMAnalytics.Parameter.Category {
- public static let tbr = "Tbr"
- public static let subTbr_annotation = "SubTbr_Annotation"
- public static let subTbr_editPDF = "SubTbr_EditPDF"
- public static let subTbr_PageEdit = "SubTbr_PageEdit"
- public static let subTbr_Converter = "SubTbr_Converter"
- public static let subTbr_Tools = "SubTbr_Tools"
- public static let home = "Home"
- public static let leftSideBar = "LeftSideBar"
- public static let puw = "PUW"
- }
- // 数据埋点 Label 参数
- extension KMAnalytics.Parameter.Label {
- public static let tbr_Btn = "Tbr_Btn"
-
- public static let subTbr_Btn = "SubTbr_Btn"
- public static let ai_Btn = "AI_Btn"
- public static let create_Btn = "Create_Btn"
- public static let leftSideBar_Btn = "LeftSideBar_Btn"
- public static let sub_PUW = "Sub_PUW"
- }
- // 数据埋点 参数
- extension KMAnalytics.Parameter {
- public static let categoryKey = "Category"
- public static let labelKey = "Label"
-
- public struct Category {
-
- }
-
- public struct Label {
-
- }
- }
- // 数据埋点 工具类
- @objc class KMAnalytics: NSObject {
- public struct AppTarget: OptionSet, Codable {
- let rawValue: Int
-
- public static var free = AppTarget(rawValue: 1 << 0)
- public static var pro = AppTarget(rawValue: 1 << 1)
- public static var dmg = AppTarget(rawValue: 1 << 2)
- public static var all: AppTarget = [.free, .pro, .dmg]
- }
-
- public struct Parameter {
- }
-
- public static let Category = KMAnalytics.Parameter.Category.self
- public static let Label = KMAnalytics.Parameter.Label.self
-
- // 配置
- static func configure() {
- #if DEBUG
- #if VERSION_FREE
- #if VERSION_DMG
- let appSecret = "fb9d37aa-e3f2-4969-bd06-f65ce529a565"
- #else
- let appSecret = "8c08296d-ca5c-44da-b68a-b4382f119b1f"
- #endif
- #else
- let appSecret = "54212f10-3ac9-42d9-96c0-5387f4b78d30"
- #endif
- #else
-
- #if VERSION_FREE
- #if VERSION_DMG
- let appSecret = "fb9d37aa-e3f2-4969-bd06-f65ce529a565"
- #else
- let appSecret = "8c08296d-ca5c-44da-b68a-b4382f119b1f"
- #endif
- #else
- let appSecret = "54212f10-3ac9-42d9-96c0-5387f4b78d30"
- #endif
- #endif
-
- }
- // 发送事件
- static func trackEvent(eventName: String, parameters: [String : Any]? = nil, platform: KMAnalyticsPlatform = .firebase, appTarget: AppTarget = [.free]) {
- // Swift.debugPrint("trackEvent: \(eventName)")
-
- if (appTarget.contains(.free)) {
- #if VERSION_FREE
- #if VERSION_DMG
- #else
- self._trackEvent(eventName: eventName, parameters: parameters, platform: platform)
- #endif
- #endif
- }
- if (appTarget.contains(.pro)) {
- #if VERSION_FREE
- #else
- self._trackEvent(eventName: eventName, parameters: parameters, platform: platform)
- #endif
- }
- if (appTarget.contains(.dmg)) {
- #if VERSION_DMG
- self._trackEvent(eventName: eventName, parameters: parameters, platform: platform)
- #endif
- }
- }
-
- // MARK: - Private Methods
- // 发送事件
- fileprivate static func _trackEvent(eventName: String, parameters: [String : Any]? = nil, platform: KMAnalyticsPlatform = .firebase) {
- if (platform == .firebase) {
- } else if (platform == .AppCenter) {
- if let data = parameters as? [String : String] {
-
- }
- }
- }
- }
|