瀏覽代碼

feat:埋点

“wangdongchao” 1 年之前
父節點
當前提交
610624d47d

+ 8 - 0
Asteria.xcodeproj/project.pbxproj

@@ -234,6 +234,7 @@
 		88484D292C4606DD007C3293 /* AppDelegate+PushNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 88484D282C4606DD007C3293 /* AppDelegate+PushNotification.m */; };
 		88484D2B2C48C8E5007C3293 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 88484D2A2C48C8E5007C3293 /* GoogleService-Info.plist */; };
 		88484D2E2C4A4857007C3293 /* ASMessageViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 88484D2D2C4A4857007C3293 /* ASMessageViewModel.m */; };
+		88484D312C4E3C68007C3293 /* ASFireBaseEventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 88484D302C4E3C68007C3293 /* ASFireBaseEventManager.m */; };
 		88516B6E2C12E51600F2E396 /* ASLoginBindingC.m in Sources */ = {isa = PBXBuildFile; fileRef = 88516B6D2C12E51600F2E396 /* ASLoginBindingC.m */; };
 		88C9F9202C3FC64400B47ADA /* ASPushOneSignalManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 88C9F91F2C3FC64400B47ADA /* ASPushOneSignalManager.m */; };
 		8C24ECE114420CDEE7B9B22B /* Pods_Asteria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54DCE8001991D89B696E7D44 /* Pods_Asteria.framework */; };
@@ -824,6 +825,8 @@
 		88484D2A2C48C8E5007C3293 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
 		88484D2C2C4A4857007C3293 /* ASMessageViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASMessageViewModel.h; sourceTree = "<group>"; };
 		88484D2D2C4A4857007C3293 /* ASMessageViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASMessageViewModel.m; sourceTree = "<group>"; };
+		88484D2F2C4E3C68007C3293 /* ASFireBaseEventManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASFireBaseEventManager.h; sourceTree = "<group>"; };
+		88484D302C4E3C68007C3293 /* ASFireBaseEventManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASFireBaseEventManager.m; sourceTree = "<group>"; };
 		88516B6C2C12E51600F2E396 /* ASLoginBindingC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLoginBindingC.h; sourceTree = "<group>"; };
 		88516B6D2C12E51600F2E396 /* ASLoginBindingC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLoginBindingC.m; sourceTree = "<group>"; };
 		88C9F91E2C3FC64400B47ADA /* ASPushOneSignalManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASPushOneSignalManager.h; sourceTree = "<group>"; };
@@ -2043,6 +2046,8 @@
 		9A1247912A1B07F400126226 /* Tool */ = {
 			isa = PBXGroup;
 			children = (
+				88484D2F2C4E3C68007C3293 /* ASFireBaseEventManager.h */,
+				88484D302C4E3C68007C3293 /* ASFireBaseEventManager.m */,
 				9A1247922A1B082300126226 /* Fuction_Tool.h */,
 				9A1247932A1B082300126226 /* Fuction_Tool.m */,
 			);
@@ -3058,6 +3063,7 @@
 				8134C1BD2A1372D5006EB0EC /* ASUserCenterTableHeadView.m in Sources */,
 				88484D262C4132AB007C3293 /* ASJumpHandler.m in Sources */,
 				9AD346002A08D60F005CA070 /* ZFPresentTransition.m in Sources */,
+				88484D312C4E3C68007C3293 /* ASFireBaseEventManager.m in Sources */,
 				81717D112A3C4AE000648139 /* KWSearchViewModel.m in Sources */,
 				9A337E3B2A04EE1A00D058A5 /* BViewController.m in Sources */,
 				8810F56A2BF5F86D00346FD4 /* ASPayFailedViewController.m in Sources */,
@@ -3406,6 +3412,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				DEVELOPMENT_TEAM = 6749KGSMFB;
 				GCC_PREFIX_HEADER = "$(SRCROOT)/Asteria/PreFixHeader.h";
 				GENERATE_INFOPLIST_FILE = YES;
@@ -3486,6 +3493,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1;
+				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 6749KGSMFB;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = NotificationServiceExtension/Info.plist;

+ 19 - 0
Asteria/Fuction/Cart/Cart_CheckoutC.m

@@ -55,6 +55,8 @@
 @property (nonatomic, assign) int index;
 @property (nonatomic, assign) int giftShowCount;
 
+@property (nonatomic, assign) int eventCount;
+
 
 @end
 
@@ -64,6 +66,7 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     self.title = @"Checkout";
+    self.eventCount = 0;
     
     //获取支付方式
     [self requestPaymentMode];
@@ -300,6 +303,19 @@
 
 - (void)updateData{
     
+    //进到结算中心页面 埋点统计  每次进入只统计一次
+    
+    if (self.eventCount == 0) {
+        if (self.totalsM) {
+            NSMutableArray *itemArray = [[NSMutableArray alloc] initWithCapacity:1];
+            for (CartTotalsItemsM *m in self.totalsM.items) {
+                [itemArray addObject:@{@"item_id":m.product_id,@"item_name":m.name}];
+            }
+            [[ASFireBaseEventManager shareInstance] checkOutEventWithCur:[ASCurrencyManager shared].currentCur value:self.totalsM.subtotal.doubleValue items:itemArray];
+            self.eventCount = 1;
+        }
+    }
+    
     [self.topView setTopViewData:AS_String_NotNull(self.totalsM.items_qty) price:[NSString stringWithFormat:@"%@%.2f",AS_String_NotNull(self.totalsM.currency_symbol),[AS_String_NotNull(self.totalsM.subtotal) floatValue]]];
     
     [self.TableV.infodata removeAllObjects];
@@ -577,6 +593,9 @@
                 
                 NSString *orderidStr = [NSString stringWithFormat:@"%@", [payDic objectForKey:@"orderid"]];
                 
+                //支付成功埋点
+                [[ASFireBaseEventManager shareInstance] purchaseEventWithCur:[ASCurrencyManager shared].currentCur value:[self.totalsM.grand_total doubleValue] transaction_id:orderidStr item:self.totalsM];
+                
                 [self paymentResultStatus:orderidStr];
                 
 //                if ([payMethod isEqualToString:@"paypal_express"]) {

+ 3 - 0
Asteria/Fuction/Cart/M/CartTotalsM.h

@@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN
 ///Grand total 相关内容
 @property (nonatomic, strong) NSArray *total_segments;
 
+@property (nonatomic, copy) NSString *tax_amount;
+@property (nonatomic, copy) NSString *shipping_amount;
+
 
 @end
 @interface CartTotalsItemsM : NSObject

+ 11 - 1
Asteria/Fuction/Goods/VC/ASGoodsDetailsViewController.m

@@ -88,6 +88,10 @@
         @strongify(self)
         self.bottomClickType = num;
         [self reqNet_Size_rewriteCartAddProducts];
+        
+        if (num != 1) {
+            [[ASFireBaseEventManager shareInstance] addcartEventWithCur:[ASCurrencyManager shared].currentCur value:self.model.final_prices.doubleValue items:@[@{@"item_name":self.model.name, @"item_id":self.model.Id}]];
+        }
     };
     
     IPhoneXHeigh
@@ -271,6 +275,12 @@
             self.model = model;
             self.title = model.name;
             
+           
+            
+            [[ASFireBaseEventManager shareInstance] viewItemEventWithCur:[ASCurrencyManager shared].currentCur value:model.final_prices.doubleValue items:@[@{@"item_id":model.Id,@"item_name":model.name}]];
+            
+//            NSLog(@"=======%@", [arry objectAtIndex:9]);
+            
             [self updateGoodsDetailsData];
             
             [self loadWebString];
@@ -310,7 +320,7 @@
 }
 
 - (void)updateGoodsDetailsData {
-        
+    
     [self.TableV.infodata removeAllObjects];
     //商品图
     NSDictionary *banner = @{@"type":@"banner", @"data":self.model};

+ 1 - 0
Asteria/Fuction/Goods/VC/AS_GoodsSizeC.m

@@ -207,6 +207,7 @@
         self.xxx_isCart = NO;
     }else{
         self.xxx_isCart = YES;
+        [[ASFireBaseEventManager shareInstance] addcartEventWithCur:[ASCurrencyManager shared].currentCur value:self.model.final_prices.doubleValue items:@[@{@"item_name":self.model.name, @"item_id":self.model.Id}]];
     }
     [self reqNet_Size_rewriteCartAddProducts:type];
 }

+ 7 - 0
Asteria/Fuction/UserCenter/Orders/Controller/ASOrderListSubController.m

@@ -165,6 +165,7 @@
     
     NSMutableArray *itemOptionArr = [[NSMutableArray alloc] initWithCapacity:1];
     
+    NSMutableArray *fireItemArr = [[NSMutableArray alloc] initWithCapacity:1];
     for (KWMineOrderProInfoModel *proModel in orderModel.items) {
         
         if (![proModel.name hasPrefix:@"FREE"]) {
@@ -179,9 +180,15 @@
                 
                 [itemOptionArr addObject:optionParam];
             }
+            
+            NSDictionary *fireDic = @{@"item_name":proModel.name, @"item_id":proModel.product_id};
+            [fireItemArr addObject:fireDic];
         }
     }
     
+    //订单列表加车 埋点统计
+    [[ASFireBaseEventManager shareInstance] addcartEventWithCur:[ASCurrencyManager shared].currentCur value:orderModel.grand_total.doubleValue items:fireItemArr];
+    
     self.addCartCount = itemOptionArr.count;
     if (self.addCartCount == 0) {
         return;

+ 1 - 1
Asteria/Fuction/UserCenter/Orders/View/ASPayFinishHeadView.m

@@ -161,7 +161,7 @@
             
             _iconImage.image = [UIImage imageNamed:@"pay_failed_icon"];
             _payStatusLab.text = @"Payment Failed.";
-            _descLab.text = @"Please try another card or refresh browser. Paypal gateway has rejected request. The buyer cannot pay with PayPal for this transaction(#13113: buyer cannot pay).";
+            _descLab.text = @"Please Try Another Card Or Refresh Browser. Paypal Gateway Has Rejected Request. The Buyer Cannot Pay With Paypal For This Transaction.";
             [_topBtn setTitle:@"Edit the payment information" forState:UIControlStateNormal];
             
             [_topBtn mas_updateConstraints:^(MASConstraintMaker *make) {

+ 2 - 0
Asteria/PreFixHeader.h

@@ -34,6 +34,8 @@
 #import "ASCommonUtils.h"
 //推送管理类
 #import "ASPushOneSignalManager.h"
+//埋点统计
+#import "ASFireBaseEventManager.h"
 
 
 //所有功能模块需要依赖的 项目(需变化)特定内容,相关内容和不变化的Base无关

+ 49 - 0
Asteria/Product/Tool/ASFireBaseEventManager.h

@@ -0,0 +1,49 @@
+//
+//  ASFireBaseEventManager.h
+//  westkissMob
+//
+//  Created by iOS on 2024/2/22.
+//
+
+#import <Foundation/Foundation.h>
+#import "CartTotalsM.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+
+@interface ASFireBaseEventManager : NSObject
+
++ (instancetype)shareInstance;
+
+/// 加购事件  点击加购按钮触发
+/// - Parameter:
+///  - cur:  货币(USD)
+///  - value: 金额
+///  - items: @[@{"item_id":@"",@"item_name":@""}]
+- (void)addcartEventWithCur:(NSString *)cur value:(double)value items:(NSArray<NSDictionary<NSString *, NSString*> *>*)items;
+
+/// 支付事件  在订单确认页面触发
+/// - Parameter:
+///  - cur:  货币(USD)
+///  - value: 金额
+///  - transaction_id: 单号
+///  - items: @[@{"item_id":@"",@"item_name":@""}]
+- (void)purchaseEventWithCur:(NSString *)cur value:(double)value transaction_id:(NSString *)transaction_id item:(CartTotalsM *)carListM;
+
+/// 去下单事件   在进入结账页面触发
+/// - Parameter:
+///  - cur:  货币(USD)
+///  - value: 金额
+///  - items: @[@{"item_id":@"",@"item_name":@""}]
+- (void)checkOutEventWithCur:(NSString *)cur value:(double)value items:(NSArray<NSDictionary<NSString *, NSString*> *>*)items;
+
+/// 查看商品详情
+/// - Parameter:
+///  - cur:  货币(USD)
+///  - value: 金额
+///  - items: @[@{"item_id":@"",@"item_name":@""}]
+- (void)viewItemEventWithCur:(NSString *)cur value:(double)value items:(NSArray<NSDictionary<NSString *, NSString*> *>*)items;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 117 - 0
Asteria/Product/Tool/ASFireBaseEventManager.m

@@ -0,0 +1,117 @@
+//
+//  ASFireBaseEventManager.m
+//  westkissMob
+//
+//  Created by iOS on 2024/2/22.
+//
+
+#import "ASFireBaseEventManager.h"
+#import <FirebaseAnalytics/FirebaseAnalytics.h>
+
+@interface ASFireBaseEventManager()
+
+
+@end
+
+@implementation ASFireBaseEventManager
+
+static  ASFireBaseEventManager *singleClass = nil;
++ (instancetype)shareInstance{
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        singleClass = [[ASFireBaseEventManager alloc]init];
+    });
+    return singleClass;
+}
+
+- (void)addcartEventWithCur:(NSString *)cur value:(double)value items:(NSArray<NSDictionary<NSString *, NSString*> *>*)items {
+    NSMutableArray *arr = [NSMutableArray array];
+    for (NSDictionary<NSString *, NSString*> *dic in items) {
+        NSMutableDictionary<NSString *, NSString*> *tempDic = [NSMutableDictionary dictionary];
+        tempDic[kFIRParameterItemID] = dic[@"item_id"];
+        tempDic[kFIRParameterItemName] = dic[@"item_name"];
+        [arr addObject:tempDic];
+    }
+    if (cur.isEmpty || arr.count == 0 || value == 0) {
+        return;
+    }
+    [FIRAnalytics logEventWithName:kFIREventAddToCart parameters:@{
+        kFIRParameterCurrency:cur,
+        kFIRParameterValue:[NSNumber numberWithDouble:value],
+        kFIRParameterItems:arr,
+    }];
+}
+
+- (void)purchaseEventWithCur:(NSString *)cur value:(double)value transaction_id:(NSString *)transaction_id item:(CartTotalsM *)carListM {
+    NSString *affiliate = @"APP Store";
+#if (DEBUG)
+    affiliate = @"Debug Store";
+#endif
+    NSMutableArray *arr = [NSMutableArray array];
+    for (CartTotalsItemsM *cartItem in carListM.items) {
+        NSMutableDictionary<NSString *, NSString*> *tempDic = [NSMutableDictionary dictionary];
+        tempDic[kFIRParameterItemID] = cartItem.product_id;
+        tempDic[kFIRParameterItemName] = cartItem.name;
+        
+        [arr addObject:tempDic];
+    }
+    NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
+    tempDic[kFIRParameterTransactionID] = transaction_id;//@"T12345";
+    tempDic[kFIRParameterAffiliation] = affiliate;
+    tempDic[kFIRParameterCurrency] = cur;
+    double totalPay = carListM.grand_total.doubleValue;
+    tempDic[kFIRParameterValue] = [NSNumber numberWithDouble:totalPay];
+    
+    double taxPay = carListM.tax_amount.doubleValue;
+    tempDic[kFIRParameterTax] = [NSNumber numberWithDouble:taxPay];
+    
+    double shipPay = carListM.shipping_amount.doubleValue;
+    tempDic[kFIRParameterShipping] = [NSNumber numberWithDouble:shipPay];
+    tempDic[kFIRParameterCoupon] = carListM.coupon_code;
+    tempDic[kFIRParameterItems] = arr;
+    if (cur.isEmpty || arr.count == 0) {
+        return;
+    }
+    [FIRAnalytics logEventWithName:kFIREventPurchase parameters:tempDic];
+}
+
+- (void)checkOutEventWithCur:(NSString *)cur value:(double)value items:(NSArray<NSDictionary<NSString *, NSString*> *>*)items {
+    NSMutableArray *arr = [NSMutableArray array];
+    for (NSDictionary<NSString *, NSString*> *dic in items) {
+        NSMutableDictionary<NSString *, NSString*> *tempDic = [NSMutableDictionary dictionary];
+        tempDic[kFIRParameterItemID] = dic[@"item_id"];
+        tempDic[kFIRParameterItemName] = dic[@"item_name"];
+        [arr addObject:tempDic];
+    }
+    if (cur.isEmpty || items.count == 0 || value == 0) {
+        return;
+    }
+    [FIRAnalytics logEventWithName:kFIREventBeginCheckout parameters:@{
+        kFIRParameterCurrency:cur,
+        kFIRParameterValue:[NSNumber numberWithDouble:value],
+        kFIRParameterItems:arr,
+    }];
+}
+
+- (void)viewItemEventWithCur:(NSString *)cur value:(double)value items:(NSArray<NSDictionary<NSString *, NSString*> *>*)items {
+    NSMutableArray *arr = [NSMutableArray array];
+    for (NSDictionary<NSString *, NSString*> *dic in items) {
+        NSMutableDictionary<NSString *, NSString*> *tempDic = [NSMutableDictionary dictionary];
+        tempDic[kFIRParameterItemID] = dic[@"item_id"];
+        tempDic[kFIRParameterItemName] = dic[@"item_name"];
+        [arr addObject:tempDic];
+    }
+    if (cur.isEmpty || arr.count == 0 || value == 0) {
+        return;
+    }
+    
+    [FIRAnalytics logEventWithName:kFIREventViewItem parameters:@{
+        kFIRParameterCurrency:cur,
+        kFIRParameterValue:[NSNumber numberWithDouble:value],
+        kFIRParameterItems:arr,
+    }];
+}
+
+
+
+@end