|
@@ -12,11 +12,13 @@ import AppCenterCrashes
|
|
|
import FirebaseCore
|
|
|
import FirebaseAnalytics
|
|
|
|
|
|
+// 数据埋点 平台
|
|
|
@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"
|
|
@@ -29,6 +31,7 @@ extension KMAnalytics.Parameter.Category {
|
|
|
public static let puw = "PUW"
|
|
|
}
|
|
|
|
|
|
+// 数据埋点 Label 参数
|
|
|
extension KMAnalytics.Parameter.Label {
|
|
|
public static let tbr_Btn = "Tbr_Btn"
|
|
|
|
|
@@ -39,6 +42,7 @@ extension KMAnalytics.Parameter.Label {
|
|
|
public static let sub_PUW = "Sub_PUW"
|
|
|
}
|
|
|
|
|
|
+// 数据埋点 参数
|
|
|
extension KMAnalytics.Parameter {
|
|
|
public static let categoryKey = "Category"
|
|
|
public static let labelKey = "Label"
|
|
@@ -52,6 +56,7 @@ extension KMAnalytics.Parameter {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 数据埋点 工具类
|
|
|
@objc class KMAnalytics: NSObject {
|
|
|
public struct AppTarget: OptionSet, Codable {
|
|
|
let rawValue: Int
|
|
@@ -73,19 +78,19 @@ extension KMAnalytics.Parameter {
|
|
|
static func configure() {
|
|
|
var appSecret = "416b8e45-69bd-4a16-8fec-b5206e913c4a"
|
|
|
AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
|
|
|
-// FirebaseApp.configure()
|
|
|
+ FirebaseApp.configure()
|
|
|
// Analytics.logEvent(AnalyticsEventSignUp, parameters: [
|
|
|
// AnalyticsParameterMethod: "method"
|
|
|
// ])
|
|
|
|
|
|
#if DEBUG
|
|
|
-// var newArguments = ProcessInfo.processInfo.arguments
|
|
|
-// newArguments.append("-FIRDebugEnabled")
|
|
|
-// ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
|
|
|
+ var newArguments = ProcessInfo.processInfo.arguments
|
|
|
+ newArguments.append("-FIRDebugEnabled")
|
|
|
+ ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
- // plat
|
|
|
+ // 发送事件
|
|
|
static func trackEvent(eventName: String, parameters: [String : Any]? = nil, platform: KMAnalyticsPlatform = .firebase, appTarget: AppTarget = [.free]) {
|
|
|
if (appTarget.contains(.free)) {
|
|
|
#if VERSION_FREE
|