Browse Source

【埋点】- 埋点管理类

liujiajie 1 year ago
parent
commit
b5271845f4

+ 57 - 0
PDF Office/PDF Master/Class/PDFWindowController/Tools/FMTrackEventManager.swift

@@ -0,0 +1,57 @@
+//
+//  FMTrackEventManager.swift
+//  PDF Reader Pro
+//
+//  Created by liujiajie on 2024/2/7.
+//
+
+import Foundation
+import AppCenterAnalytics
+
+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
+        NSLog("###-FireBaseEvent-(event)-(properties?.first?.key)-(properties?.first?.value)")
+#endif
+        // if RIAnalytics.isNewUserForCurrentVersion()
+        if let props = properties {
+            Analytics.trackEvent(event, withProperties: props)
+        } else {
+            Analytics.trackEvent(event)
+        }
+    }
+    
+    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
+        } 
+        
+        if let props = properties {
+            Analytics.trackEvent(event, withProperties: props)
+        } else {
+            Analytics.trackEvent(event)
+        }
+    }
+    
+}
+

+ 8 - 0
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -2575,6 +2575,9 @@
 		BB0B2CDC2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0B2CDB2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift */; };
 		BB0B2CDD2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0B2CDB2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift */; };
 		BB0B2CDE2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0B2CDB2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift */; };
+		BB10F1E42B736F11008EAF7E /* FMTrackEventManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB10F1E32B736F11008EAF7E /* FMTrackEventManager.swift */; };
+		BB10F1E52B736F11008EAF7E /* FMTrackEventManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB10F1E32B736F11008EAF7E /* FMTrackEventManager.swift */; };
+		BB10F1E62B736F11008EAF7E /* FMTrackEventManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB10F1E32B736F11008EAF7E /* FMTrackEventManager.swift */; };
 		BB10FAE52AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB10FAE42AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift */; };
 		BB10FAE62AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB10FAE42AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift */; };
 		BB10FAE72AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB10FAE42AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift */; };
@@ -5950,6 +5953,7 @@
 		BB0A823129C00400002C5C1B /* KMCommonEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCommonEnum.swift; sourceTree = "<group>"; };
 		BB0B2CD72B04AE560088FFD8 /* LeftSideView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LeftSideView.xib; sourceTree = "<group>"; };
 		BB0B2CDB2B04B9510088FFD8 /* KMLeftSideViewSearchField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLeftSideViewSearchField.swift; sourceTree = "<group>"; };
+		BB10F1E32B736F11008EAF7E /* FMTrackEventManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FMTrackEventManager.swift; sourceTree = "<group>"; };
 		BB10FAE42AFE039E00F18D65 /* KMPDFEditPageRangeWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPDFEditPageRangeWindowController.swift; sourceTree = "<group>"; };
 		BB10FAE82AFE03CC00F18D65 /* KMPDFEditPageRangeWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMPDFEditPageRangeWindowController.xib; sourceTree = "<group>"; };
 		BB10FAED2AFE233C00F18D65 /* KMLineInspector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLineInspector.swift; sourceTree = "<group>"; };
@@ -8829,6 +8833,7 @@
 				ADA08A8929F21A53009B2A7B /* KMPDFViewAnnotationOnceModeStore.swift */,
 				BBBAECFB2B57713F00266BD3 /* KMTransitionInfo.swift */,
 				BBBAED132B57E97000266BD3 /* SKTypeSelectHelper.swift */,
+				BB10F1E32B736F11008EAF7E /* FMTrackEventManager.swift */,
 			);
 			path = Tools;
 			sourceTree = "<group>";
@@ -14960,6 +14965,7 @@
 				BB31DA622AFA3088006D63CB /* KMPreferenceController.swift in Sources */,
 				9FD0D2AF2AD51BCC00DA3FF8 /* CPDFListEditAnnotationViewController.swift in Sources */,
 				ADAFDA422AE8F3C400F084BC /* KMAdvertisementTimeStampConversion.swift in Sources */,
+				BB10F1E42B736F11008EAF7E /* FMTrackEventManager.swift in Sources */,
 				9F0CB4E92986559400007028 /* KMDesignToken+PaddingBottom.swift in Sources */,
 				ADDDCE272B43A32A005B4AB5 /* AppSandboxFileAccessOpenSavePanelDelegate.m in Sources */,
 				BB570ADB2B512C90005E7E4A /* KMLeftSideViewController+Thumbnail.swift in Sources */,
@@ -16583,6 +16589,7 @@
 				BB146FD0299DC0D100784A6A /* GTMMIMEDocument.m in Sources */,
 				AD055E262B70B3C10035F824 /* KMBookmarkController.swift in Sources */,
 				AD3AAD142B0B5B2700DE5FE7 /* KMCompareContentWindowController.swift in Sources */,
+				BB10F1E52B736F11008EAF7E /* FMTrackEventManager.swift in Sources */,
 				9F705F8E291E579F005199AD /* KMHistoryFileTableView.swift in Sources */,
 				9F0CB49029683DEE00007028 /* KMPropertiesPanelLineSubVC.swift in Sources */,
 				AD53B6FF29AC5FCD00D61E81 /* KMLightMemberToken.swift in Sources */,
@@ -17544,6 +17551,7 @@
 				9FF94F1329A7476000B1EF69 /* KMDesignPropertySelector.swift in Sources */,
 				9F39B9462A661ED500930ACA /* KMHomeScrollView.swift in Sources */,
 				BBB9B315299A5D6D004F3235 /* DropboxModel.m in Sources */,
+				BB10F1E62B736F11008EAF7E /* FMTrackEventManager.swift in Sources */,
 				9F0CB51B2986568000007028 /* KMDesignToken+BorderRadiusTopRight.swift in Sources */,
 				BB1B0ACD2B4FC6E900889528 /* KMFunctionGuideWindowController.swift in Sources */,
 				8942F7BD29222C7E00389627 /* KMBookCellView.swift in Sources */,