Authored by 孙凯

Merge branch 'develop' of http://git.yoho.cn/mobile/YH_EventReport into develop

... ... @@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = "YHEventReport"
s.version = "0.1.18"
s.version = "0.1.20"
s.summary = "YHEventReport."
s.description = "无埋点SDK"
s.homepage = "http://git.yoho.cn/mobile/YH_EventReport"
... ...
... ... @@ -41,7 +41,7 @@ NSArray* cityList;
tableView.delegate = self;
tableView.dataSource = self;
[self.view addSubview:tableView];
// [self.view addSubview:tableView];
... ... @@ -53,7 +53,7 @@ NSArray* cityList;
// [self.view addSubview:webView];
[self.view addSubview:webView];
... ...
... ... @@ -38,6 +38,51 @@
/**
* @property
*
* @abstract
* 是否开启按钮性能上报
*
* @discussion
* 默认值为 关.
*/
@property (atomic,getter=isButtonPerformanceTrackEnable) BOOL buttonPerformanceTrackEnable;
/**
* @property
*
* @abstract
* 是否开启图片加载性能上报
*
* @discussion
* 默认值为 关.
*/
@property (atomic,getter=isImagePerformanceTrackEnable) BOOL imagePerformanceTrackEnable;
/**
* @property
*
* @abstract
* 是否开启控制器(包括webview)加载性能上报
*
* @discussion
* 默认值为 关.
*/
@property (atomic,getter=isControllerPerformanceTrackEnable) BOOL controllerPerformanceTrackEnable;
/**
* @property
*
* @abstract
* 是否开启Http加载性能上报
*
* @discussion
* 默认值为 关.
*/
@property (atomic,getter=isHttpPerformanceTrackEnable) BOOL httpPerformanceTrackEnable;
/**
* @abstract
* 设置本地缓存最大空间
*
... ...
... ... @@ -62,7 +62,7 @@
- (void) yher_operationStart
{
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled){
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventStartWithWebImageDownload:self];
}
... ... @@ -71,7 +71,7 @@
- (void) yher_operationDidFinish
{
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled){
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownload:self status:YHEventLoadStatusSuc];
}
[self yher_operationDidFinish];
... ... @@ -79,7 +79,7 @@
- (void) yher_operationCancel
{
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled){
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownload:self status:YHEventLoadStatusFailed];
}
[self yher_operationCancel];
... ... @@ -87,7 +87,7 @@
- (void) yher_operationError :(NSError*)error
{
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled){
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownload:self status:YHEventLoadStatusFailed];
}
[self yher_operationError:error];
... ...
... ... @@ -195,8 +195,6 @@
[[YH_EventCacheManager sharedInstance] pushUIControlEvent:viewPath title:title content:content];
}
}
}
}
... ...
... ... @@ -20,43 +20,41 @@
+(void)startTrack{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@try {
NSError *viewdidloadError = NULL;
[[self class] yh_swizzleMethod:@selector(viewDidLoad)
withMethod:@selector(yher_viewDidLoad)
error:&viewdidloadError];
if (viewdidloadError) {
YHLog(@"Failed to swizzle viewDidLoad: on UIViewController. Details: %@", viewdidloadError);
viewdidloadError = NULL;
}
NSError *viewdidappearError = NULL;
[[self class] yh_swizzleMethod:@selector(viewDidAppear:)
withMethod:@selector(yher_viewDidAppear:)
error:&viewdidappearError];
if (viewdidappearError) {
YHLog(@"Failed to swizzle viewDidAppear: on UIViewController. Details: %@", viewdidappearError);
viewdidappearError = NULL;
}
} @catch (NSException *exception) {
YHLog(@"%@ error: %@", self, exception);
@try {
NSError *viewdidloadError = NULL;
[[self class] yh_swizzleMethod:@selector(viewDidLoad)
withMethod:@selector(yher_viewDidLoad)
error:&viewdidloadError];
if (viewdidloadError) {
YHLog(@"Failed to swizzle viewDidLoad: on UIViewController. Details: %@", viewdidloadError);
viewdidloadError = NULL;
}
});
NSError *viewdidappearError = NULL;
[[self class] yh_swizzleMethod:@selector(viewDidAppear:)
withMethod:@selector(yher_viewDidAppear:)
error:&viewdidappearError];
if (viewdidappearError) {
YHLog(@"Failed to swizzle viewDidAppear: on UIViewController. Details: %@", viewdidappearError);
viewdidappearError = NULL;
}
} @catch (NSException *exception) {
YHLog(@"%@ error: %@", self, exception);
}
});
}
- (void)yher_viewDidLoad{
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && ![[YHEventReport sharedInstance] isPerformanceViewControllerStringIgnored:NSStringFromClass([self class])]) {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isControllerPerformanceTrackEnable && ![[YHEventReport sharedInstance] isPerformanceViewControllerStringIgnored:NSStringFromClass([self class])]) {
[[YH_EventCollector sharedInstance] timeEventStartWithViewController:self];
}
[self yher_viewDidLoad];
}
-(void)yher_viewDidAppear:(BOOL)animated {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && ![[YHEventReport sharedInstance] isPerformanceViewControllerStringIgnored:NSStringFromClass([self class])]) {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isControllerPerformanceTrackEnable && ![[YHEventReport sharedInstance] isPerformanceViewControllerStringIgnored:NSStringFromClass([self class])]) {
[[YH_EventCollector sharedInstance] timeEventEndWithViewController:self];
}
[self yher_viewDidAppear:animated];
... ...
... ... @@ -15,9 +15,7 @@
#import "YHEventReport.h"
@implementation UIWebView (AutoTrack)
/*
todo 还需要处理setDelegate 没有调用的情况
**/
+(void)startTrack{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
... ... @@ -41,7 +39,7 @@ void yher_webViewDidStartLoad(id self, SEL _cmd,id webView)
SEL selector = NSSelectorFromString(@"yher_webViewDidStartLoad");
((void(*)(id, SEL, id))objc_msgSend)(self, selector, webView);
if (![YHEventReport sharedInstance].isPerformanceTrackEnabled) {
if (![YHEventReport sharedInstance].isPerformanceTrackEnabled || ![YHEventReport sharedInstance].isControllerPerformanceTrackEnable) {
return;
}
... ... @@ -53,7 +51,7 @@ void yher_webViewDidFinishLoad(id self, SEL _cmd,id webView)
SEL selector = NSSelectorFromString(@"yher_webViewDidFinishLoad");
((void(*)(id, SEL, id))objc_msgSend)(self, selector, webView);
if (![YHEventReport sharedInstance].isPerformanceTrackEnabled) {
if (![YHEventReport sharedInstance].isPerformanceTrackEnabled ||![YHEventReport sharedInstance].isControllerPerformanceTrackEnable) {
return;
}
[[YH_EventCollector sharedInstance] timeEventEndWithWebView:webView status:YHEventLoadStatusSuc];
... ... @@ -64,7 +62,7 @@ void yher_webViewDidFailLoadWithError(id self, SEL _cmd,id webView,NSError* erro
SEL selector = NSSelectorFromString(@"yher_webViewDidFailLoadWithError");
((void(*)(id, SEL, id,id))objc_msgSend)(self, selector, webView,error);
if (![YHEventReport sharedInstance].isPerformanceTrackEnabled) {
if (![YHEventReport sharedInstance].isPerformanceTrackEnabled||![YHEventReport sharedInstance].isControllerPerformanceTrackEnable) {
return;
}
[[YH_EventCollector sharedInstance] timeEventEndWithWebView:webView status:YHEventLoadStatusFailed];
... ...