Skip to content

Commit

Permalink
refactor: 无埋点逻辑重构
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Jul 7, 2023
1 parent 690a5a3 commit 1ec80de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ - (void)testWebCircleElement {
XCTAssertEqualObjects(dic[@"nodeType"], @"Button");
XCTAssertEqualObjects(dic[@"isContainer"], @1);
XCTAssertEqualObjects(dic[@"index"], @10);
XCTAssertEqualObjects(dic[@"parentXpath"], @"parentXpath");
XCTAssertEqualObjects(dic[@"parentXPath"], @"parentXpath");
XCTAssertEqualObjects(dic[@"page"], @"page");
XCTAssertEqualObjects(dic[@"domain"], [GrowingDeviceInfo currentDeviceInfo].bundleID);
}
Expand Down
4 changes: 2 additions & 2 deletions GrowingAutotrackerCore/GrowingNode/GrowingNodeHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ + (void)recalculateXpath:(UIView *)view

NSString * (^toStringBlock)(NSArray *) = ^(NSArray *array) {
NSArray *reverse = array.reverseObjectEnumerator.allObjects;
return [@"/" stringByAppendingString:[reverse componentsJoinedByString:@"/"]];
return [reverse componentsJoinedByString:@"/"];
};

NSString *xpath = toStringBlock(viewPathArray);
Expand Down Expand Up @@ -94,7 +94,7 @@ + (NSString *)buildElementContentForNode:(id<GrowingNode> _Nullable)view {
+ (GrowingViewNode *)getViewNode:(UIView *)view {
NSPointerArray *weakArray = [NSPointerArray weakObjectsPointerArray];
GrowingViewNode *viewNode = [self getTopViewNode:view array:weakArray];
for (int i = (int)weakArray.count - 1; i >= 0; i--) {
for (int i = (int)weakArray.count - 2; i >= 0; i--) {
UIView *parent = [weakArray pointerAtIndex:i];
if (parent) {
viewNode = [viewNode appendNode:parent isRecalculate:NO];
Expand Down
28 changes: 15 additions & 13 deletions Modules/WebCircle/GrowingWebCircle.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,21 @@ - (NSMutableDictionary *)dictFromNode:(GrowingViewNode *)node {
NSDictionary *pathInfo = page.pathInfo;
NSString *pagexpath = pathInfo[@"xpath"];
NSString *pagexindex = pathInfo[@"xindex"];
GrowingWebCircleElement *element =
GrowingWebCircleElement.builder.setRect(node.view.growingNodeFrame)
.setContent(node.viewContent)
.setZLevel(self.zLevel++)
.setIndex(node.index)
.setXpath([NSString stringWithFormat:@"%@%@", pagexpath, node.xpath])
.setXindex([NSString stringWithFormat:@"%@%@", pagexindex, node.xindex])
.setParentXpath([NSString stringWithFormat:@"%@%@", pagexpath, node.clickableParentXpath])
.setParentXindex([NSString stringWithFormat:@"%@%@", pagexpath, node.clickableParentXindex])
.setNodeType(node.nodeType)
.setPage(autotrackPage ? autotrackPage.alias : @"")
.build;

GrowingWebCircleElementBuilder *builder = GrowingWebCircleElement.builder
.setRect(node.view.growingNodeFrame)
.setContent(node.viewContent)
.setZLevel(self.zLevel++)
.setIndex(node.index)
.setXpath([NSString stringWithFormat:@"%@/%@", pagexpath, node.xpath])
.setXindex([NSString stringWithFormat:@"%@/%@", pagexindex, node.xindex])
.setNodeType(node.nodeType)
.setPage(autotrackPage ? autotrackPage.alias : @"");
if (node.clickableParentXpath) {
builder = builder.setParentXpath([NSString stringWithFormat:@"%@/%@", pagexpath, node.clickableParentXpath])
.setParentXindex([NSString stringWithFormat:@"%@/%@", pagexindex, node.clickableParentXindex]);
}
GrowingWebCircleElement *element = builder.build;

return [NSMutableDictionary dictionaryWithDictionary:element.toDictionary];
}

Expand Down

0 comments on commit 1ec80de

Please sign in to comment.