diff --git a/Example/Example/MeasurementProtocol/PageEvent/GIOFirstViewController.m b/Example/Example/MeasurementProtocol/PageEvent/GIOFirstViewController.m index e8619406a..8a790b431 100644 --- a/Example/Example/MeasurementProtocol/PageEvent/GIOFirstViewController.m +++ b/Example/Example/MeasurementProtocol/PageEvent/GIOFirstViewController.m @@ -16,29 +16,13 @@ @implementation GIOFirstViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor blueColor]; -} - -- (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - NSLog(@"GIOFirstViewController viewWillAppear"); -} -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - NSLog(@"GIOFirstViewController viewDidAppear"); -} -- (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; - NSLog(@"GIOFirstViewController viewWillDisappear"); -} -- (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear: animated]; - NSLog(@"GIOFirstViewController viewDidDisappear"); -} -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + +#if defined(AUTOTRACKER) +#if defined(SDK3rd) + [[GrowingAutotracker sharedInstance] autotrackPage:self alias:@"子页面1"]; +#endif +#endif } @end diff --git a/Example/Example/MeasurementProtocol/PageEvent/GIOSecondViewController.m b/Example/Example/MeasurementProtocol/PageEvent/GIOSecondViewController.m index 0c1ca6fd2..b00a9d5be 100644 --- a/Example/Example/MeasurementProtocol/PageEvent/GIOSecondViewController.m +++ b/Example/Example/MeasurementProtocol/PageEvent/GIOSecondViewController.m @@ -16,30 +16,13 @@ @implementation GIOSecondViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor redColor]; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - NSLog(@"GIOSecondViewController viewWillAppear"); -} -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - NSLog(@"GIOSecondViewController viewDidAppear"); -} -- (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; - NSLog(@"GIOSecondViewController viewWillDisappear"); -} -- (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear:animated]; - NSLog(@"GIOSecondViewController viewDidDisappear"); + +#if defined(AUTOTRACKER) +#if defined(SDK3rd) + [[GrowingAutotracker sharedInstance] autotrackPage:self alias:@"子页面2"]; +#endif +#endif } @end diff --git a/GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m b/GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m index db51f4a15..04b755dd4 100644 --- a/GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m +++ b/GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m @@ -36,9 +36,11 @@ + (void)recalculateXpath:(UIView *)view NSMutableArray *originxindexArray = [NSMutableArray array]; BOOL isSimilar = YES; while (node && [node isKindOfClass:[UIView class]]) { - if (node.growingNodeSubPath == nil) { + if (node.growingNodeSubPath == nil || [self isIgnoredPrivateView:node]) { + node = node.growingNodeParent; continue; } + [viewPathArray addObject:node.growingNodeSubPath]; [originxindexArray addObject:node.growingNodeSubIndex]; if (isSimilar) { @@ -110,7 +112,9 @@ + (GrowingViewNode *)getTopViewNode:(UIView *)view array:(NSPointerArray *)weakA id parent = view; do { - [weakArray addPointer:(void *)parent]; + if (![self isIgnoredPrivateView:parent]) { + [weakArray addPointer:(void *)parent]; + } parent = parent.growingNodeParent; } while ([parent isKindOfClass:[UIView class]]); @@ -125,6 +129,11 @@ + (GrowingViewNode *)getTopViewNode:(UIView *)view array:(NSPointerArray *)weakA .build; } ++ (BOOL)isIgnoredPrivateView:(id)view { + NSArray *ignoredViews = @[@"_UIAlertControllerPhoneTVMacView", @"_UIAlertControllerView", @"UITableViewWrapperView"]; + return [ignoredViews containsObject:NSStringFromClass(view.class)]; +} + // 文本 static NSString *const kGrowingViewNodeText = @"TEXT"; // 按钮