...
|
...
|
@@ -46,6 +46,7 @@ NS_INLINE NSString *YH_Objectkey(id anyObject) { |
|
|
@property (nonatomic, strong) NSMutableArray *tabViewControllerArray;
|
|
|
/**页面调用链*/
|
|
|
@property (nonatomic, strong) NSMutableArray *pageChains;
|
|
|
@property (nonatomic, strong) NSMutableSet *ignoredViewControllers;
|
|
|
//@property (nonatomic, strong) NSLock *lock;
|
|
|
@end
|
|
|
|
...
|
...
|
@@ -68,6 +69,7 @@ NS_INLINE NSString *YH_Objectkey(id anyObject) { |
|
|
self.serialQueue = dispatch_queue_create([kYHEventReportQueue UTF8String], DISPATCH_QUEUE_SERIAL);
|
|
|
self.timedEvents = [NSMutableDictionary dictionary];
|
|
|
self.pageChains = [NSMutableArray array];
|
|
|
self.ignoredViewControllers = [NSMutableSet set];
|
|
|
// self.lock = [[NSLock alloc] init];
|
|
|
// self.lock.name = @"com.yoho.buy.EventCollector";
|
|
|
NSArray *tabAry= @[];
|
...
|
...
|
@@ -191,7 +193,52 @@ NS_INLINE NSString *YH_Objectkey(id anyObject) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
- (double)eventElapsedTime:(NSString *)viewId accurateEndTime:(NSTimeInterval)endtime {
|
|
|
if (IsStrEmpty(viewId)) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
__block double startTime = 0;
|
|
|
dispatch_sync(self.serialQueue, ^{
|
|
|
startTime = [self.timedEvents[viewId] doubleValue];
|
|
|
});
|
|
|
|
|
|
if (startTime <= 0) {
|
|
|
return 0;
|
|
|
} else {
|
|
|
return MAX((endtime - startTime), 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#pragma mark - viewcontroller performance
|
|
|
- (void)timeEventIgnoreWithViewController:(UIViewController *)viewController {
|
|
|
if (!viewController) {
|
|
|
return;
|
|
|
}
|
|
|
NSString *viewId = [NSString stringWithFormat:@"%@%p",[viewController class], viewController];
|
|
|
dispatch_sync(self.serialQueue, ^{
|
|
|
[self.ignoredViewControllers addObject:viewId];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- (void)timeEventIgnoreRemoveWithViewController:(UIViewController *)viewController {
|
|
|
if (!viewController) {
|
|
|
return;
|
|
|
}
|
|
|
NSString *viewId = [NSString stringWithFormat:@"%@%p",[viewController class], viewController];
|
|
|
[self.ignoredViewControllers removeObject:viewId];
|
|
|
}
|
|
|
|
|
|
- (BOOL)timeEventIgnorContainsViewController:(UIViewController *)viewController {
|
|
|
NSString *viewId = [NSString stringWithFormat:@"%@%p",[viewController class], viewController];
|
|
|
__block BOOL isContain = NO;
|
|
|
dispatch_sync(self.serialQueue, ^{
|
|
|
isContain = [self.ignoredViewControllers containsObject:viewId];
|
|
|
});
|
|
|
|
|
|
return isContain;
|
|
|
}
|
|
|
|
|
|
- (void)timeEventStartWithViewController:(UIViewController *)viewController{
|
|
|
NSParameterAssert(viewController);
|
|
|
if (!viewController) {
|
...
|
...
|
@@ -218,6 +265,7 @@ NS_INLINE NSString *YH_Objectkey(id anyObject) { |
|
|
return;
|
|
|
}
|
|
|
NSTimeInterval elapsedTime = 0;
|
|
|
NSTimeInterval endtimeStamp = [[NSDate date] timeIntervalSince1970];
|
|
|
if ([self isTabViewControllerString:NSStringFromClass([viewController class])]) {
|
|
|
UITabBarController *tabBarVC = [viewController yher_tabBarController];
|
|
|
double didSelectTime = [tabBarVC.tabBar.selectedItem.yh_didSelectTime doubleValue];
|
...
|
...
|
@@ -225,13 +273,13 @@ NS_INLINE NSString *YH_Objectkey(id anyObject) { |
|
|
return;
|
|
|
}
|
|
|
if (didSelectTime==0) {
|
|
|
elapsedTime = [self eventElapsedTime:viewController.yh_viewId];
|
|
|
elapsedTime = [self eventElapsedTime:viewController.yh_viewId accurateEndTime:endtimeStamp];
|
|
|
}else{
|
|
|
elapsedTime = [[NSDate date] timeIntervalSince1970] - didSelectTime;
|
|
|
elapsedTime = endtimeStamp - didSelectTime;
|
|
|
viewController.yher_hasReported = YES;
|
|
|
}
|
|
|
}else{
|
|
|
elapsedTime = [self eventElapsedTime:viewController.yh_viewId];
|
|
|
elapsedTime = [self eventElapsedTime:viewController.yh_viewId accurateEndTime:endtimeStamp];
|
|
|
}
|
|
|
|
|
|
if (elapsedTime==0) {
|
...
|
...
|
|