Skip to content

Commit

Permalink
Fix issue that caused the refresh pixel to be fired on back navigatio…
Browse files Browse the repository at this point in the history
…n from DuckPlayer
  • Loading branch information
afterxleep committed Nov 13, 2024
1 parent 09f7795 commit 32c8eff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,9 @@ extension DuckPlayerNavigationHandler: DuckPlayerNavigationHandling {
// Before performing the simulated request
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
self.performRequest(request: newRequest, webView: webView)
self.duckPlayerOverlayUsagePixels?.handleNavigationAndFirePixels(url: url, duckPlayerMode: self.duckPlayerMode)
self.fireDuckPlayerPixels(webView: webView)

}
} else {
redirectToYouTubeVideo(url: url, webView: webView)
Expand Down
5 changes: 3 additions & 2 deletions DuckDuckGo/DuckPlayer/DuckPlayerOverlayUsagePixels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ final class DuckPlayerOverlayUsagePixels: DuckPlayerOverlayPixelFiring {
var isReload = false
// Check for a reload condition: when current videoID is the same as Previous
if let currentVideoID = currentURL.youtubeVideoParams?.videoID,
let previousVideoID = previousURL.youtubeVideoParams?.videoID {
let previousVideoID = previousURL.youtubeVideoParams?.videoID,
!previousURL.isDuckPlayer, !currentURL.isDuckPlayer {
isReload = currentVideoID == previousVideoID
}

Expand All @@ -83,7 +84,7 @@ final class DuckPlayerOverlayUsagePixels: DuckPlayerOverlayPixelFiring {
} else if previousURL.isYoutubeWatch && currentURL.isYoutube {
// Forward navigation within YouTube (including non-video URLs)
pixelFiring.fire(.duckPlayerYouTubeNavigationWithinYouTube, withAdditionalParameters: [:])
} else if previousURL.isYoutubeWatch && !currentURL.isYoutube {
} else if previousURL.isYoutubeWatch && !currentURL.isYoutube && !currentURL.isDuckPlayer {
// Navigation outside YouTube
pixelFiring.fire(.duckPlayerYouTubeOverlayNavigationOutsideYoutube, withAdditionalParameters: [:])
}
Expand Down

0 comments on commit 32c8eff

Please sign in to comment.