Ver código fonte

【内嵌支付】付费埋点调整为AppCenter

tangchao 6 meses atrás
pai
commit
5449688005

+ 10 - 0
PDF Office/PDF Master/Class/Analytics/KMAnalytics.swift

@@ -77,6 +77,16 @@ extension KMAnalytics.Parameter {
     // 配置
     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
+        AppCenter.start(withAppSecret: appSecret, services: [Analytics.self, Crashes.self])
 #else
 // #if VERSION_DMG
 //        AppCenter.start(withAppSecret: "416b8e45-69bd-4a16-8fec-b5206e913c4a", services: [Analytics.self, Crashes.self])

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -1217,6 +1217,7 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
         if IAPProductsManager.default().isAvailableAllFunction() == false {
             let winC = KMPurchaseCompareWindowController.sharedInstance()
             winC?.kEventName = "Reading_Rotate_BuyNow"
+            winC?.kEventTag = 1
             winC?.showWindow(nil)
             return
         }
@@ -1235,6 +1236,7 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
         if IAPProductsManager.default().isAvailableAllFunction() == false {
             let winC = KMPurchaseCompareWindowController.sharedInstance()
             winC?.kEventName = "Reading_Rotate_BuyNow"
+            winC?.kEventTag = 1
             winC?.showWindow(nil)
             return
         }

+ 25 - 7
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseCompareDMGWindowController.m

@@ -659,6 +659,12 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     NSString *paidEventName = [self _buyNowEventToPaidEventName];
     NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
     
+    NSString *thePaidEventName = paidEventParams.allValues.firstObject;
+    NSDictionary *thePaidEventParams = nil;
+    if (paidEventName != nil && paidEventParams.allKeys.firstObject != nil) {
+        thePaidEventParams = @{paidEventParams.allKeys.firstObject : paidEventName};
+    }
+    
     [self close];
     
     NSString *productID = @"";
@@ -672,8 +678,8 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 //    [embeddedWC beginSheetModalFor:NSApp.mainWindow completionHandler:^(NSInteger result) {
 //            
 //    }];
-    embeddedWC.kEventName = paidEventName;
-    embeddedWC.kEventParams = paidEventParams;
+    embeddedWC.kEventName = thePaidEventName;
+    embeddedWC.kEventParams = thePaidEventParams;
     [embeddedWC showWindow:nil];
     [[embeddedWC window] center];
 #endif
@@ -736,12 +742,17 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     [self trackEvent_buyNow];
     NSString *paidEventName = [self _buyNowEventToPaidEventName];
     NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
+    NSString *thePaidEventName = paidEventParams.allValues.firstObject;
+    NSDictionary *thePaidEventParams = nil;
+    if (paidEventName != nil && paidEventParams.allKeys.firstObject != nil) {
+        thePaidEventParams = @{paidEventParams.allKeys.firstObject : paidEventName};
+    }
     
     [self close];
 #if VERSION_DMG
     KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.ai.product_1"];
-    embeddedWC.kEventName = paidEventName;
-    embeddedWC.kEventParams = paidEventParams;
+    embeddedWC.kEventName = thePaidEventName;
+    embeddedWC.kEventParams = thePaidEventParams;
     [embeddedWC showWindow:nil];
     [[embeddedWC window] center];
 #endif
@@ -769,7 +780,14 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 @implementation KMPurchaseCompareDMGWindowController (KMAnalytic)
 
 - (void)trackEvent_buyNow {
-    [self trackEvent_dmgWithEventName:self.kEventName params:[self _getBuyNowEventParams] platform:KMAnalyticsPlatformFirebase];
+    NSDictionary *params = [self _getBuyNowEventParams];
+    NSString *theEventName = params.allValues.firstObject;
+    NSDictionary *theParams = nil;
+    if (self.kEventName != nil && params.allKeys.firstObject != nil) {
+        theParams = @{params.allKeys.firstObject : self.kEventName};
+    }
+    
+    [self trackEvent_dmgWithEventName:theEventName params:theParams platform:KMAnalyticsPlatformAppCenter];
 }
 
 - (NSDictionary *)_getBuyNowEventParams {
@@ -793,7 +811,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
                [eveN isEqual:@"Reading_Replace_BuyNow"] ||
                [eveN isEqual:@"Reading_Extract_BuyNow"] ||
                [eveN isEqual:@"Reading_Split_BuyNow"] ||
-               [eveN isEqual:@"Reading_Rotate_BuyNow"] ||
+               ([eveN isEqual:@"Reading_Rotate_BuyNow"] && self.kEventTag == 0) ||
                [eveN isEqual:@"Reading_Reverse_BuyNow"] ||
                [eveN isEqual:@"Reading_Copy_BuyNow"] ||
                [eveN isEqual:@"Reading_Delete_BuyNow"] ||
@@ -860,7 +878,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
                [eveN isEqual:@"Reading_Rotate_BuyNow"] ||
                [eveN isEqual:@"Reading_Theme_BuyNow"] ||
                [eveN isEqual:@"Reading_MultiTab_BuyNow"]) {
-        return @{@"Purchase_PageDisplay" : @"SubTbr_Page Display"};
+        return @{@"Purchase_PageDisplay" : @"SubTbr_PageDisplay"};
     } else if ([eveN isEqual:@"Onbrd_PrintPoster_BuyNow"] ||
                [eveN isEqual:@"Onbrd_PrintMultiple_BuyNow"] ||
                [eveN isEqual:@"Onbrd_PrintBooklet_BuyNow"]) {

+ 1 - 1
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -1265,7 +1265,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     }
     
     private func _trackEvent_paid() {
-        self.trackEvent_dmg(eventName: self.kEventName, params: self.kEventParams, platform: .firebase)
+        self.trackEvent_dmg(eventName: self.kEventName, params: self.kEventParams, platform: .AppCenter)
     }
     
     private let tabDict: [ProductType: String] = [