Skip to content

Commit

Permalink
refactor: 无埋点逻辑重构
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Jul 11, 2023
1 parent f48fe64 commit 50272d2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ + (void)recalculateXpath:(UIView *)view
NSMutableArray *originxindexArray = [NSMutableArray array];
BOOL isSimilar = YES;

Check warning on line 37 in GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m

View check run for this annotation

Codecov / codecov/patch

GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m#L34-L37

Added lines #L34 - L37 were not covered by tests
while (node && [node isKindOfClass:[UIView class]]) {
if (node.growingNodeSubPath == nil) {
if (node.growingNodeSubPath == nil || [self isIgnoredPrivateView:node]) {
node = node.growingNodeParent;
continue;

Check warning on line 41 in GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m

View check run for this annotation

Codecov / codecov/patch

GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m#L39-L41

Added lines #L39 - L41 were not covered by tests
}

[viewPathArray addObject:node.growingNodeSubPath];
[originxindexArray addObject:node.growingNodeSubIndex];

Check warning on line 45 in GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m

View check run for this annotation

Codecov / codecov/patch

GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m#L44-L45

Added lines #L44 - L45 were not covered by tests
if (isSimilar) {
Expand Down Expand Up @@ -110,7 +112,9 @@ + (GrowingViewNode *)getTopViewNode:(UIView *)view array:(NSPointerArray *)weakA

id<GrowingNode> parent = view;
do {
[weakArray addPointer:(void *)parent];
if (![self isIgnoredPrivateView:parent]) {
[weakArray addPointer:(void *)parent];
}
parent = parent.growingNodeParent;
} while ([parent isKindOfClass:[UIView class]]);

Expand All @@ -125,6 +129,11 @@ + (GrowingViewNode *)getTopViewNode:(UIView *)view array:(NSPointerArray *)weakA
.build;
}

+ (BOOL)isIgnoredPrivateView:(id<GrowingNode>)view {
NSArray <NSString *>*ignoredViews = @[@"_UIAlertControllerPhoneTVMacView", @"_UIAlertControllerView", @"UITableViewWrapperView"];
return [ignoredViews containsObject:NSStringFromClass(view.class)];
}

// 文本
static NSString *const kGrowingViewNodeText = @"TEXT";
// 按钮
Expand Down

0 comments on commit 50272d2

Please sign in to comment.