Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix bug where New Tab Page ad viewed events fail on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey authored and kylehickinson committed Jun 5, 2023
1 parent 8891c52 commit cc33904
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,17 @@ class NewTabPageViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

reportSponsoredImageBackgroundEvent(.viewed)
reportSponsoredImageBackgroundEvent(.served)

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
// As a temporary fix until 1.53.x, we trigger the .viewed event after 1 second to
// give time for the .served event to be triggered; otherwise, the sponsored image
// viewed event will fail because it needs a corresponding served event. In 1.53.x
// and above we should trigger the .served event and in the completion block if
// successful we should trigger a .viewed event.
self.reportSponsoredImageBackgroundEvent(.viewed)
}

presentNotification()

DispatchQueue.main.asyncAfter(deadline: .now() + 0.50) {
Expand Down

0 comments on commit cc33904

Please sign in to comment.