Commit 06ac613e authored by 汪洋's avatar 汪洋

将埋点属性拆出扩展

parent b01766cd
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
} }
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
NSLog(@"%@", self.referer);
self.navigationBar.title = @"列表"; self.navigationBar.title = @"列表";
self.navigationBar.rightTitle = @"没什么用"; self.navigationBar.rightTitle = @"没什么用";
_table.separatorStyle = UITableViewCellSeparatorStyleSingleLine; _table.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
[super viewDidLoad]; [super viewDidLoad];
self.pageName = @"yw"; self.pageName = @"yw";
self.title = @"你好"; self.title = @"你好";
NSLog(@"%@", self.referer);
} }
- (void)didReceiveMemoryWarning - (void)didReceiveMemoryWarning
......
...@@ -14,7 +14,7 @@ PODS: ...@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0) - AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0): - AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession - AFNetworking/NSURLSession
- GMBase (0.0.1): - GMBase (0.0.2):
- GMNetService (= 0.1.3) - GMNetService (= 0.1.3)
- GMPhobos (= 0.2.8) - GMPhobos (= 0.2.8)
- GMRefresh (= 0.1.3) - GMRefresh (= 0.1.3)
...@@ -46,7 +46,7 @@ EXTERNAL SOURCES: ...@@ -46,7 +46,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
GMBase: 831023e2846dde63903f80bffbed12d1607b16d4 GMBase: 241736988ce4b6f5677c917d973aedd3d6403daf
GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc
GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32 GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32
GMPhobos: 9f046f82fa806bc21cde83732fb411edac0b3d20 GMPhobos: 9f046f82fa806bc21cde83732fb411edac0b3d20
......
{ {
"name": "GMBase", "name": "GMBase",
"version": "0.0.1", "version": "0.0.2",
"summary": "更美iOS APP 的 Objective-C 基础Pod库", "summary": "更美iOS APP 的 Objective-C 基础Pod库",
"homepage": "http://git.gengmei.cc/gengmeiios/GMBase", "homepage": "http://git.gengmei.cc/gengmeiios/GMBase",
"license": "仅限北京更美互动信息科技有限公司内部使用", "license": "仅限北京更美互动信息科技有限公司内部使用",
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
"source": { "source": {
"git": "http://git.gengmei.cc/gengmeiios/GMBase.git", "git": "http://git.gengmei.cc/gengmeiios/GMBase.git",
"tag": "0.0.1" "tag": "0.0.2"
}, },
"platforms": { "platforms": {
"ios": "8.0" "ios": "8.0"
......
...@@ -14,7 +14,7 @@ PODS: ...@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0) - AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0): - AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession - AFNetworking/NSURLSession
- GMBase (0.0.1): - GMBase (0.0.2):
- GMNetService (= 0.1.3) - GMNetService (= 0.1.3)
- GMPhobos (= 0.2.8) - GMPhobos (= 0.2.8)
- GMRefresh (= 0.1.3) - GMRefresh (= 0.1.3)
...@@ -46,7 +46,7 @@ EXTERNAL SOURCES: ...@@ -46,7 +46,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
GMBase: 831023e2846dde63903f80bffbed12d1607b16d4 GMBase: 241736988ce4b6f5677c917d973aedd3d6403daf
GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc
GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32 GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32
GMPhobos: 9f046f82fa806bc21cde83732fb411edac0b3d20 GMPhobos: 9f046f82fa806bc21cde83732fb411edac0b3d20
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "OCEmptyView.h" #import "OCEmptyView.h"
#import "OCNavigatioinBar.h" #import "OCNavigatioinBar.h"
#import "UIViewController+HUD.h" #import "UIViewController+HUD.h"
#import "UIViewController+Phobos.h"
#import "WMBaseListViewController.h" #import "WMBaseListViewController.h"
#import "WMBaseViewController.h" #import "WMBaseViewController.h"
#import "WMFetchDataViewModel.h" #import "WMFetchDataViewModel.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.0.1</string> <string>0.0.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
//
// UIViewController+Phobos.h
// Pods
//
// Created by wangyang on 16/7/12.
//
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIViewController (Phobos)
/**
* @author 翟国钧, 16-02-24 17:02:22
*
* @brief 埋点的时候,有些埋点都需要业务id,比如DoctorId,针对那些只能在父类中埋点的业务,要在子类中设置当前id,然后在父类中取到
* 在一些详情页的分享和收藏的时候,由于分享、收藏的方法在basewebview里,所以,统一在里面做处理,但是需要在子类中把想要的参数传过去。包括:type(类型)、from(来自哪)、businessId(对应业务id)
* @since 5.9.1
*/
@property (nonatomic, copy, nonnull) NSString *businessId;
/**
* @author 翟国钧 in 16-02-25 19:02:32
*
* @brief 获取前一个页面的pageName
*
* @since 5.9.1
*/
@property (nonatomic, strong, readonly, nonnull) NSString *referer;
/**
* @author 翟国钧 in 16-02-25 19:02:32
*
* 埋点pv事件中当前页面的别名
* @since 5.9.1
*/
@property (nonatomic, copy, nonnull) NSString *pageName;
@end
NS_ASSUME_NONNULL_END
\ No newline at end of file
//
// UIViewController+Phobos.m
// Pods
//
// Created by wangyang on 16/7/12.
//
//
#import "UIViewController+Phobos.h"
#import <objc/runtime.h>
@implementation UIViewController (Phobos)
/**
* @author 翟国钧, 16-03-01 15:03:24
*
* @brief 取当前导航栈中当前VC的上级VC,如果该VC存在,就获取他的pageName
*
* @return 前一页的pageName
*
* @since 5.9.1
*/
- (NSString *)referer
{
NSArray *navigationPool = self.navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
if (refererIndex < 0 ) {
return @"";
}
UIViewController *controller = navigationPool[refererIndex];
return controller.pageName == nil ? @"" : controller.pageName;
}
- (NSString *)pageName {
NSString *name = objc_getAssociatedObject(self, @selector(pageName));
return name == nil ? @"" : name;
}
- (void)setPageName:(NSString *)pageName {
objc_setAssociatedObject(self, @selector(pageName), pageName, OBJC_ASSOCIATION_COPY);
}
- (NSString *)businessId {
NSString *businessId = objc_getAssociatedObject(self, @selector(businessId));
return businessId == nil ? @"" : businessId;
}
- (void)setBusinessId:(NSString *)businessId {
objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY);
}
@end
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "OCNavigatioinBar.h" #import "OCNavigatioinBar.h"
#import "UIViewController+HUD.h" #import "UIViewController+HUD.h"
#import "UIViewController+Phobos.h"
@interface WMBaseViewController : UIViewController <OCNavigatioinBarDelegate> @interface WMBaseViewController : UIViewController <OCNavigatioinBarDelegate>
@property (nonatomic, strong) OCNavigatioinBar *navigationBar; @property (nonatomic, strong) OCNavigatioinBar *navigationBar;
...@@ -18,33 +19,3 @@ ...@@ -18,33 +19,3 @@
- (void)initController __attribute__((objc_requires_super)); - (void)initController __attribute__((objc_requires_super));
- (void)pushViewController:(UIViewController *)controller; - (void)pushViewController:(UIViewController *)controller;
@end @end
#pragma mark - 埋点
@interface UIViewController (Phobos)
/**
* @author 翟国钧, 16-02-24 17:02:22
*
* @brief 埋点的时候,有些埋点都需要业务id,比如DoctorId,针对那些只能在父类中埋点的业务,要在子类中设置当前id,然后在父类中取到
* 在一些详情页的分享和收藏的时候,由于分享、收藏的方法在basewebview里,所以,统一在里面做处理,但是需要在子类中把想要的参数传过去。包括:type(类型)、from(来自哪)、businessId(对应业务id)
* @since 5.9.1
*/
@property (nonatomic , copy) NSString *businessId;
/**
* @author 翟国钧 in 16-02-25 19:02:32
*
* @brief 获取前一个页面的pageName
*
* @since 5.9.1
*/
@property (nonatomic, strong, readonly) NSString *referer;
/**
* @author 翟国钧 in 16-02-25 19:02:32
*
* 埋点pv事件中当前页面的别名
* @since 5.9.1
*/
@property (nonatomic, copy) NSString *pageName;
@end
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#import "WMBaseViewController.h" #import "WMBaseViewController.h"
#import "GMBaseUtil.h" #import "GMBaseUtil.h"
#import <GMPhobos/Phobos.h> #import <GMPhobos/Phobos.h>
#import <objc/runtime.h>
@interface WMBaseViewController () { @interface WMBaseViewController () {
} }
...@@ -45,9 +44,6 @@ ...@@ -45,9 +44,6 @@
} }
- (void)initController{ - (void)initController{
self.pageName = @"";
self.businessId = @"";
// 在 initController 中初始化自定义导航栏有很大好处。至少可以保证视图被push之前就可以访问navigationBar,以配置title等属性 // 在 initController 中初始化自定义导航栏有很大好处。至少可以保证视图被push之前就可以访问navigationBar,以配置title等属性
[self customNavigationBar]; [self customNavigationBar];
} }
...@@ -159,44 +155,3 @@ ...@@ -159,44 +155,3 @@
} }
} }
@end @end
#pragma mark - 埋点
@implementation UIViewController (Phobos)
/**
* @author 翟国钧, 16-03-01 15:03:24
*
* @brief 取当前导航栈中当前VC的上级VC,如果该VC存在,就获取他的pageName
*
* @return 前一页的pageName
*
* @since 5.9.1
*/
- (NSString *)referer
{
NSArray *navigationPool = self.navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
if (refererIndex < 0 ) {
return @"";
}
UIViewController *controller = navigationPool[refererIndex];
return controller.pageName == nil ? @"" : controller.pageName;
}
- (NSString *)pageName {
NSString *name = objc_getAssociatedObject(self, @selector(pageName));
return name == nil ? @"" : name;
}
- (void)setPageName:(NSString *)pageName {
objc_setAssociatedObject(self, @selector(pageName), pageName, OBJC_ASSOCIATION_COPY);
}
- (NSString *)businessId {
return objc_getAssociatedObject(self, @selector(businessId));
}
- (void)setBusinessId:(NSString *)businessId {
objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY);
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment