Authored by 孙凯

add UIGestureRecognizer time review by hongmo

@@ -46,6 +46,7 @@ @@ -46,6 +46,7 @@
46 B17F61DB1F6678CD009D1606 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B17F61DA1F6678CD009D1606 /* UserNotifications.framework */; }; 46 B17F61DB1F6678CD009D1606 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B17F61DA1F6678CD009D1606 /* UserNotifications.framework */; };
47 B188D2051F692DB600FFBEDF /* SDWebImageDownloaderOperation+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B188D2041F692DB600FFBEDF /* SDWebImageDownloaderOperation+AutoTrack.m */; }; 47 B188D2051F692DB600FFBEDF /* SDWebImageDownloaderOperation+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B188D2041F692DB600FFBEDF /* SDWebImageDownloaderOperation+AutoTrack.m */; };
48 B1A393141F7B4E04009700D9 /* UIControl+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */; }; 48 B1A393141F7B4E04009700D9 /* UIControl+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */; };
  49 + B1A393171F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A393161F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m */; };
49 B1A9387C1F6A8AF600D6582C /* NSString+ER_URL.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */; }; 50 B1A9387C1F6A8AF600D6582C /* NSString+ER_URL.m in Sources */ = {isa = PBXBuildFile; fileRef = B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */; };
50 B1B6C3A01F74AD3100627DF3 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3951F74AD3100627DF3 /* README.md */; }; 51 B1B6C3A01F74AD3100627DF3 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3951F74AD3100627DF3 /* README.md */; };
51 B1B6C3A11F74AD3100627DF3 /* UIScrollView+YHExposure.m in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3991F74AD3100627DF3 /* UIScrollView+YHExposure.m */; }; 52 B1B6C3A11F74AD3100627DF3 /* UIScrollView+YHExposure.m in Sources */ = {isa = PBXBuildFile; fileRef = B1B6C3991F74AD3100627DF3 /* UIScrollView+YHExposure.m */; };
@@ -163,6 +164,8 @@ @@ -163,6 +164,8 @@
163 B188D2041F692DB600FFBEDF /* SDWebImageDownloaderOperation+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SDWebImageDownloaderOperation+AutoTrack.m"; sourceTree = "<group>"; }; 164 B188D2041F692DB600FFBEDF /* SDWebImageDownloaderOperation+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SDWebImageDownloaderOperation+AutoTrack.m"; sourceTree = "<group>"; };
164 B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIControl+AutoTrack.h"; sourceTree = "<group>"; }; 165 B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIControl+AutoTrack.h"; sourceTree = "<group>"; };
165 B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIControl+AutoTrack.m"; sourceTree = "<group>"; }; 166 B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIControl+AutoTrack.m"; sourceTree = "<group>"; };
  167 + B1A393151F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIGestureRecognizer+AutoTrack.h"; sourceTree = "<group>"; };
  168 + B1A393161F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIGestureRecognizer+AutoTrack.m"; sourceTree = "<group>"; };
166 B1A9387A1F6A8AF600D6582C /* NSString+ER_URL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+ER_URL.h"; sourceTree = "<group>"; }; 169 B1A9387A1F6A8AF600D6582C /* NSString+ER_URL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+ER_URL.h"; sourceTree = "<group>"; };
167 B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+ER_URL.m"; sourceTree = "<group>"; }; 170 B1A9387B1F6A8AF600D6582C /* NSString+ER_URL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+ER_URL.m"; sourceTree = "<group>"; };
168 B1B6C3951F74AD3100627DF3 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; }; 171 B1B6C3951F74AD3100627DF3 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@@ -308,6 +311,8 @@ @@ -308,6 +311,8 @@
308 29CDB4B01F6FA5A500AAD350 /* PowerfulBannerView+AutoTrack.m */, 311 29CDB4B01F6FA5A500AAD350 /* PowerfulBannerView+AutoTrack.m */,
309 B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */, 312 B1A393121F7B4E04009700D9 /* UIControl+AutoTrack.h */,
310 B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */, 313 B1A393131F7B4E04009700D9 /* UIControl+AutoTrack.m */,
  314 + B1A393151F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.h */,
  315 + B1A393161F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m */,
311 ); 316 );
312 path = YH_AOP; 317 path = YH_AOP;
313 sourceTree = "<group>"; 318 sourceTree = "<group>";
@@ -719,6 +724,7 @@ @@ -719,6 +724,7 @@
719 5255C2C11F5D25F400A8FC5F /* YHEventReport.m in Sources */, 724 5255C2C11F5D25F400A8FC5F /* YHEventReport.m in Sources */,
720 529A004B1F564E8500A83F63 /* main.m in Sources */, 725 529A004B1F564E8500A83F63 /* main.m in Sources */,
721 B1C419021F616187005E0729 /* OpenUDID.m in Sources */, 726 B1C419021F616187005E0729 /* OpenUDID.m in Sources */,
  727 + B1A393171F7C918C009700D9 /* UIGestureRecognizer+AutoTrack.m in Sources */,
722 B1D774A51F62A37E00BA89C3 /* SDWebImageDownloader.m in Sources */, 728 B1D774A51F62A37E00BA89C3 /* SDWebImageDownloader.m in Sources */,
723 52878C0D1F5FEE4C000A1597 /* YH_EventDataFactory.m in Sources */, 729 52878C0D1F5FEE4C000A1597 /* YH_EventDataFactory.m in Sources */,
724 B1D774AC1F62A37E00BA89C3 /* UIImage+MultiFormat.m in Sources */, 730 B1D774AC1F62A37E00BA89C3 /* UIImage+MultiFormat.m in Sources */,
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 #import "UIViewController+AutoTrack.h" 20 #import "UIViewController+AutoTrack.h"
21 #import "UITabBar+AutoTrack.h" 21 #import "UITabBar+AutoTrack.h"
22 #import "UIControl+AutoTrack.h" 22 #import "UIControl+AutoTrack.h"
  23 +#import "UIGestureRecognizer+AutoTrack.h"
23 24
24 #define kYHEventReportIgnoredViewController @"YHEventReportQueue" 25 #define kYHEventReportIgnoredViewController @"YHEventReportQueue"
25 26
@@ -147,6 +148,8 @@ static NSArray *kYHEventReportIgnoredViewControllerArray; @@ -147,6 +148,8 @@ static NSArray *kYHEventReportIgnoredViewControllerArray;
147 [UIViewController startTrack]; 148 [UIViewController startTrack];
148 [UITabBar startTrack]; 149 [UITabBar startTrack];
149 [UIControl startTrack]; 150 [UIControl startTrack];
  151 + [UIGestureRecognizer startTrack];
  152 +
150 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 153 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
151 [UIWebView startTrack]; 154 [UIWebView startTrack];
152 [SDWebImageDownloaderOperation startTrack]; 155 [SDWebImageDownloaderOperation startTrack];
  1 +//
  2 +// UIGestureRecognizer+AutoTrack.h
  3 +// YHEventReport
  4 +//
  5 +// Created by 孙凯 on 2017/9/28.
  6 +// Copyright © 2017年 YOHO. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface UIGestureRecognizer (AutoTrack)
  12 +
  13 +@property(nonatomic,copy)NSString *yh_viewId;//唯一ID
  14 +
  15 ++(void)startTrack;
  16 +
  17 +@end
  1 +//
  2 +// UIGestureRecognizer+AutoTrack.m
  3 +// YHEventReport
  4 +//
  5 +// Created by 孙凯 on 2017/9/28.
  6 +// Copyright © 2017年 YOHO. All rights reserved.
  7 +//
  8 +
  9 +#import "UIGestureRecognizer+AutoTrack.h"
  10 +#import "YHSwizzle.h"
  11 +#import <objc/runtime.h>
  12 +#import <objc/message.h>
  13 +#import "YHLog.h"
  14 +#import "YHEventReport.h"
  15 +#import "YH_EventCollector.h"
  16 +
  17 +@interface UIGestureRecognizer ()<UIGestureRecognizerDelegate>
  18 +
  19 +@property(nullable,nonatomic,weak) id <UIGestureRecognizerDelegate> my_delegate;
  20 +
  21 +@end
  22 +
  23 +@implementation UIGestureRecognizer (AutoTrack)
  24 +
  25 +#pragma mark - 属性
  26 +- (void)setYh_viewId:(NSString *)yh_viewId{
  27 + objc_setAssociatedObject(self,@selector(yh_viewId),yh_viewId,OBJC_ASSOCIATION_RETAIN);
  28 +}
  29 +
  30 +- (NSString *)yh_viewId{
  31 + return objc_getAssociatedObject(self, @selector(yh_viewId));
  32 +}
  33 +
  34 +- (id)my_delegate
  35 +{
  36 + return objc_getAssociatedObject(self, _cmd);
  37 +}
  38 +
  39 +- (void)setMy_delegate:(id)my_delegate
  40 +{
  41 + objc_setAssociatedObject(self, @selector(my_delegate), my_delegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  42 +}
  43 +
  44 +#pragma mark - load
  45 ++ (void)startTrack{
  46 + static dispatch_once_t onceToken;
  47 + dispatch_once(&onceToken, ^{
  48 + @try {
  49 + SEL selectors[] = {
  50 + @selector(initWithTarget:action:),
  51 + @selector(addTarget:action:),
  52 + @selector(setDelegate:),
  53 + };
  54 +
  55 + for (NSUInteger index = 0; index < sizeof(selectors) / sizeof(SEL); ++index) {
  56 + SEL originalSelector = selectors[index];
  57 + SEL swizzledSelector = NSSelectorFromString([@"yher_" stringByAppendingString:NSStringFromSelector(originalSelector)]);
  58 + NSError *error = NULL;
  59 + [[self class] yh_swizzleMethod:originalSelector
  60 + withMethod:swizzledSelector
  61 + error:&error];
  62 + if (error) {
  63 + YHLog(@"Failed to swizzle: on UIControl. Details: %@", error);
  64 + error = NULL;
  65 + }
  66 + }
  67 + } @catch (NSException *exception) {
  68 + YHLog(@"%@ error: %@", self, exception);
  69 + }
  70 + });
  71 +}
  72 +
  73 +#pragma mark - hook API
  74 +-(void)yher_setDelegate:(id<UIGestureRecognizerDelegate>)delegate
  75 +{
  76 + [self yher_setDelegate:self];
  77 + if (![delegate isKindOfClass:[self class]]) {
  78 + [self setMy_delegate:delegate];
  79 + }
  80 +}
  81 +
  82 +- (instancetype)yher_initWithTarget:(nullable id)target action:(nullable SEL)action
  83 +{
  84 + [UIGestureRecognizer yher_exchangeSelector:action target:target toSelector:@selector(yher_gestureRecognizerDidTouch_cmd:)];
  85 + [self setDelegate:target];
  86 + return [self yher_initWithTarget:target action:action];
  87 +}
  88 +
  89 +- (void)yher_addTarget:(id)target action:(SEL)action
  90 +{
  91 + [UIGestureRecognizer yher_exchangeSelector:action target:target toSelector:@selector(yher_gestureRecognizerDidTouch_cmd:)];
  92 + [self setDelegate:target];
  93 + [self yher_addTarget:target action:action];
  94 +}
  95 +
  96 +#pragma mark - action
  97 +- (void)yher_gestureRecognizerDidTouch_cmd:(UIGestureRecognizer*)sender
  98 +{
  99 + if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable) {
  100 + [[YH_EventCollector sharedInstance] timeEventEndWithUIGestureRecognizer:sender];
  101 + }
  102 +
  103 + [self yher_gestureRecognizerDidTouch_cmd:sender];
  104 +}
  105 +
  106 +#pragma mark - hook func
  107 ++ (void)yher_exchangeSelector:(SEL)originSel target:(nullable id)target toSelector:(SEL)replazSel
  108 +{
  109 + Class originalClass = object_getClass(target);
  110 + Class swizzledClass = [self class];
  111 + SEL originalSelector = originSel;
  112 + SEL swizzledSelector = replazSel;
  113 + Method originalMethod = class_getInstanceMethod(originalClass, originalSelector);
  114 + Method swizzledMethod = class_getInstanceMethod(swizzledClass, swizzledSelector);
  115 +
  116 + IMP originalIMP = method_getImplementation(originalMethod);
  117 + IMP swizzledIMP = method_getImplementation(swizzledMethod);
  118 + const char *originalType = method_getTypeEncoding(originalMethod);
  119 + const char *swizzledType = method_getTypeEncoding(swizzledMethod);
  120 +
  121 + class_replaceMethod(originalClass,swizzledSelector,originalIMP,originalType);
  122 + class_replaceMethod(originalClass,originalSelector,swizzledIMP,swizzledType);
  123 +}
  124 +
  125 +#pragma mark - UIGestureRecognizerDelegate
  126 +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
  127 +{
  128 + if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].buttonPerformanceTrackEnable) {
  129 + [[YH_EventCollector sharedInstance] timeEventStartWithUIGestureRecognizer:self];
  130 + }
  131 +
  132 + if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizerShouldBegin:)]) {
  133 + return [self.my_delegate gestureRecognizerShouldBegin:gestureRecognizer];
  134 + }
  135 + return YES;
  136 +}
  137 +
  138 +
  139 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  140 +{
  141 + if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]) {
  142 + return [self.my_delegate gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer];
  143 + }
  144 +
  145 + return YES;
  146 +}
  147 +
  148 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  149 +{
  150 + if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:)]) {
  151 + return [self.my_delegate gestureRecognizer:gestureRecognizer shouldRequireFailureOfGestureRecognizer:otherGestureRecognizer];
  152 + }
  153 + return YES;
  154 +}
  155 +
  156 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  157 +{
  158 + if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:)]) {
  159 + return [self.my_delegate gestureRecognizer:gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer];
  160 + }
  161 + return YES;
  162 +}
  163 +
  164 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
  165 +{
  166 + if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldReceiveTouch:)]) {
  167 + return [self.my_delegate gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch];
  168 + }
  169 + return YES;
  170 +}
  171 +
  172 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press
  173 +{
  174 + if (self.my_delegate && [self.my_delegate respondsToSelector:@selector(gestureRecognizer:shouldReceivePress:)]) {
  175 + return [self.my_delegate gestureRecognizer:gestureRecognizer shouldReceivePress:press];
  176 + }
  177 + return YES;
  178 +}
  179 +
  180 +
  181 +@end
@@ -238,7 +238,9 @@ @@ -238,7 +238,9 @@
238 case YHPN_BUTTON: 238 case YHPN_BUTTON:
239 str = @"BUTTON"; 239 str = @"BUTTON";
240 break; 240 break;
241 - 241 + case YHPN_GESTURERECOGNIZER:
  242 + str = @"GESTURERECOGNIZER";
  243 + break;
242 default: 244 default:
243 break; 245 break;
244 } 246 }
@@ -27,6 +27,8 @@ @@ -27,6 +27,8 @@
27 - (void)timeEventStartWithUIControl:(UIControl *)control; 27 - (void)timeEventStartWithUIControl:(UIControl *)control;
28 - (void)timeEventEndWithUIControl:(UIControl *)control; 28 - (void)timeEventEndWithUIControl:(UIControl *)control;
29 29
  30 +- (void)timeEventStartWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
  31 +- (void)timeEventEndWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
30 32
31 + (void)trackAppClickWithView:(id)targetView UITableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; 33 + (void)trackAppClickWithView:(id)targetView UITableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
32 34
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 #import "UIWebView+AutoTrack.h" 18 #import "UIWebView+AutoTrack.h"
19 #import "UITabBarItem+Yoho.h" 19 #import "UITabBarItem+Yoho.h"
20 #import "UIControl+AutoTrack.h" 20 #import "UIControl+AutoTrack.h"
  21 +#import "UIGestureRecognizer+AutoTrack.h"
21 22
22 #define kYHEventReportQueue @"YHEventReportQueue" 23 #define kYHEventReportQueue @"YHEventReportQueue"
23 #define kYHEventReporrH5StartKey @"YHEventReporrH5StartKey" 24 #define kYHEventReporrH5StartKey @"YHEventReporrH5StartKey"
@@ -343,10 +344,55 @@ @@ -343,10 +344,55 @@
343 NSDictionary *param = [YH_EventDataFactory factoryTimeEventDataWithUIControl:control ElapsedTime:elapsedTime]; 344 NSDictionary *param = [YH_EventDataFactory factoryTimeEventDataWithUIControl:control ElapsedTime:elapsedTime];
344 345
345 if (param) { 346 if (param) {
346 - //[[YH_EventCacheManager sharedInstance] pushPerformanceData:param pointName:YHPN_BUTTON]; 347 + [[YH_EventCacheManager sharedInstance] pushPerformanceData:param pointName:YHPN_BUTTON];
347 } 348 }
348 } 349 }
349 350
  351 +
  352 +#pragma mark - UIGestureRecognizer performance
  353 +- (void)timeEventStartWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
  354 +{
  355 + NSNumber *startTime = @([[NSDate date] timeIntervalSince1970]);
  356 + NSString *viewId = [NSString stringWithFormat:@"%@%@",NSStringFromClass([gestureRecognizer class]),startTime];
  357 + NSLog(@"startTime = %f",[[NSDate date] timeIntervalSince1970]);
  358 +
  359 + if (startTime==0||IsStrEmpty(viewId)) {
  360 + return;
  361 + }
  362 +
  363 + if (!gestureRecognizer) {
  364 + return;
  365 + }
  366 +
  367 + gestureRecognizer.yh_viewId=viewId;
  368 + dispatch_async(self.serialQueue, ^{
  369 + self.timedEvents[viewId] = startTime;
  370 + });
  371 +}
  372 +
  373 +- (void)timeEventEndWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
  374 +{
  375 + NSTimeInterval elapsedTime = [self eventElapsedTime:gestureRecognizer.yh_viewId];
  376 +
  377 + //NSLog(@"end = %f",[[NSDate date] timeIntervalSince1970]);
  378 + if (elapsedTime==0) {
  379 + return;
  380 + }
  381 + if (!IsStrEmpty(gestureRecognizer.yh_viewId)) {
  382 + dispatch_async(self.serialQueue, ^{
  383 + [self.timedEvents removeObjectForKey:gestureRecognizer.yh_viewId];
  384 + });
  385 + }
  386 +
  387 + NSDictionary *param = [YH_EventDataFactory factoryTimeEventDataWithUIGestureRecognizer:gestureRecognizer ElapsedTime:elapsedTime];
  388 +
  389 + //NSLog(@"%@",param);
  390 + if (param) {
  391 + [[YH_EventCacheManager sharedInstance] pushPerformanceData:param pointName:YHPN_GESTURERECOGNIZER];
  392 + }
  393 +}
  394 +
  395 +
350 @end 396 @end
351 397
352 398
@@ -91,6 +91,7 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) { @@ -91,6 +91,7 @@ typedef NS_ENUM(NSInteger, YHEventReportPointName) {
91 YHPN_WEBVIEW,//UIWebView 加载时间 // @"WEBVIEW" 91 YHPN_WEBVIEW,//UIWebView 加载时间 // @"WEBVIEW"
92 YHPN_IMAGEVIEW,//Image (SDWebImage) 加载时间 // @"IMAGE" 92 YHPN_IMAGEVIEW,//Image (SDWebImage) 加载时间 // @"IMAGE"
93 YHPN_BUTTON,//Button 响应时间 // @"BUTTON" 93 YHPN_BUTTON,//Button 响应时间 // @"BUTTON"
  94 + YHPN_GESTURERECOGNIZER //UIGestureRecognizer响应时间// @"GESTURERECOGNIZER"
94 }; 95 };
95 96
96 typedef NS_ENUM(NSInteger, YHEventReportType) { 97 typedef NS_ENUM(NSInteger, YHEventReportType) {
@@ -21,6 +21,8 @@ @@ -21,6 +21,8 @@
21 21
22 +(NSDictionary *)factoryTimeEventDataWithUIControl:(UIControl *)control ElapsedTime:(NSTimeInterval)elapsedTime; 22 +(NSDictionary *)factoryTimeEventDataWithUIControl:(UIControl *)control ElapsedTime:(NSTimeInterval)elapsedTime;
23 23
  24 ++(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime;
  25 +
24 + (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo; 26 + (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo;
25 27
26 @end 28 @end
@@ -66,6 +66,19 @@ @@ -66,6 +66,19 @@
66 return dict; 66 return dict;
67 } 67 }
68 68
  69 ++(NSDictionary *)factoryTimeEventDataWithUIGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer ElapsedTime:(NSTimeInterval)elapsedTime {
  70 +
  71 + NSString *className = NSStringFromClass([gestureRecognizer class]);
  72 +
  73 + if (IsStrEmpty(className)) {
  74 + return nil;
  75 + }
  76 +
  77 + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[className er_encodedString],kYHEventReportTimeURL,[NSString stringWithFormat:@"%.0f",elapsedTime*1000],kYHEventReportTimeElapsed,@"",kYHEventReportTimeTitle,nil];
  78 +
  79 + return dict;
  80 +}
  81 +
69 + (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo 82 + (NSDictionary *)factoryEventAppInfo:(YH_PerformanceAppInfo*)appInfo
70 { 83 {
71 NSDictionary *commonInfo = [NSDictionary dictionaryWithObjectsAndKeys: 84 NSDictionary *commonInfo = [NSDictionary dictionaryWithObjectsAndKeys: