Skip to content

Commit

Permalink
fix: last page path on Flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Sep 27, 2024
1 parent 3a65c10 commit 31f2648
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions GrowingAutotrackerCore/Page/GrowingPageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

@interface GrowingPageManager () <GrowingULViewControllerLifecycleDelegate, GrowingEventInterceptor>

@property (nonatomic, strong) GrowingPage *lastPage;
@property (nonatomic, copy) NSString *lastPagePath;
@property (nonatomic, assign) long long lastPageTimestamp;
@property (nonatomic, strong) NSPointerArray *visiblePages;
@property (nonatomic, strong) NSMutableArray<NSString *> *ignoredPrivateControllers;

Expand Down Expand Up @@ -62,11 +63,15 @@ - (void)start {
#pragma mark - GrowingEventInterceptor

- (void)growingEventManagerEventWillBuild:(GrowingBaseBuilder *_Nullable)builder {
if (builder && [builder isMemberOfClass:[GrowingCustomBuilder class]]) {
GrowingPage *page = self.lastPage;
if (page) {
NSString *path = [NSString stringWithFormat:@"/%@", page.alias];
((GrowingCustomBuilder *)builder).setPath(path);
if (builder) {
if ([builder isMemberOfClass:[GrowingCustomBuilder class]]) {
if (self.lastPagePath && self.lastPagePath.length > 0) {
((GrowingCustomBuilder *)builder).setPath(self.lastPagePath);
}
} else if ([builder isMemberOfClass:[GrowingPageBuilder class]]) {
GrowingPageBuilder *pageBuilder = (GrowingPageBuilder *)builder;
self.lastPagePath = pageBuilder.path;
self.lastPageTimestamp = pageBuilder.timestamp;
}
}
}
Expand Down Expand Up @@ -139,7 +144,6 @@ - (void)sendPageEventWithPage:(GrowingPage *)page {
.setTimestamp(page.showTimestamp)
.setAttributes(page.attributes);
[[GrowingEventManager sharedInstance] postEventBuilder:builder];
self.lastPage = page;
}

- (GrowingPage *)createdPage:(UIViewController *)viewController {
Expand Down

0 comments on commit 31f2648

Please sign in to comment.