From 89b4d0bfdac08e8498396542022ce8af3f161fed Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Fri, 19 Jan 2024 11:00:15 -0500 Subject: [PATCH] Fix #8673: Move NTP P3A helper creation outside of NTP There was a chance that a user would simply never load a NTP during their session which means that P3A rotations wouldn't trigger new NTP-SI reports each day. This report was supposed to occur each rotation, not specifically per NTP view. --- .../BrowserViewController/BrowserViewController.swift | 5 ++++- .../Browser/New Tab Page/NewTabPageViewController.swift | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift index e575ec52b4a..4b823977a36 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController.swift @@ -270,6 +270,8 @@ public class BrowserViewController: UIViewController { /// In app purchase obsever for VPN Subscription action let iapObserver: IAPObserver + + private let ntpP3AHelper: NewTabPageP3AHelper public init( windowId: UUID, @@ -334,6 +336,7 @@ public class BrowserViewController: UIViewController { } iapObserver = BraveVPN.iapObserver + ntpP3AHelper = .init(p3aUtils: braveCore.p3aUtils) super.init(nibName: nil, bundle: nil) didInit() @@ -1419,7 +1422,7 @@ public class BrowserViewController: UIViewController { feedDataSource: feedDataSource, rewards: rewards, privateBrowsingManager: privateBrowsingManager, - p3aUtils: braveCore.p3aUtils + p3aHelper: ntpP3AHelper ) // Donate NewTabPage Activity For Custom Suggestions let newTabPageActivity = diff --git a/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift b/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift index c4c0817808f..36dc2f58d31 100644 --- a/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift +++ b/Sources/Brave/Frontend/Browser/New Tab Page/NewTabPageViewController.swift @@ -140,14 +140,14 @@ class NewTabPageViewController: UIViewController { feedDataSource: FeedDataSource, rewards: BraveRewards, privateBrowsingManager: PrivateBrowsingManager, - p3aUtils: BraveP3AUtils + p3aHelper: NewTabPageP3AHelper ) { self.tab = tab self.rewards = rewards self.feedDataSource = feedDataSource self.privateBrowsingManager = privateBrowsingManager self.backgroundButtonsView = NewTabPageBackgroundButtonsView(privateBrowsingManager: privateBrowsingManager) - self.p3aHelper = .init(p3aUtils: p3aUtils) + self.p3aHelper = p3aHelper background = NewTabPageBackground(dataSource: dataSource) notifications = NewTabPageNotifications(rewards: rewards) collectionView = NewTabCollectionView(frame: .zero, collectionViewLayout: layout)