diff --git a/DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift b/DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift index dc00d0cc3d..f337ef4334 100644 --- a/DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift +++ b/DuckDuckGo/DuckPlayer/DuckPlayerNavigationHandler.swift @@ -575,7 +575,7 @@ final class DuckPlayerNavigationHandler: NSObject { // Watch in YT videos always open in new tab redirectToYouTubeVideo(url: url, webView: webView, forceNewTab: true) } - } + } } @@ -671,11 +671,6 @@ extension DuckPlayerNavigationHandler: DuckPlayerNavigationHandling { // Update the Referrer based on the first URL change detected setReferrer(webView: webView) - // Overlay Usage Pixel handling - if let url = webView.url { - duckPlayerOverlayUsagePixels?.handleNavigationAndFirePixels(url: url, duckPlayerMode: duckPlayerMode) - } - // We don't want YouTube redirects happening while default navigation is happening // This can be caused by Duplicate Nav events, and quick URL changes if let lastTimestamp = lastNavigationHandling, @@ -683,6 +678,11 @@ extension DuckPlayerNavigationHandler: DuckPlayerNavigationHandling { return .notHandled(.duplicateNavigation) } + // Overlay Usage Pixel handling + if let url = webView.url { + duckPlayerOverlayUsagePixels?.handleNavigationAndFirePixels(url: url, duckPlayerMode: duckPlayerMode) + } + // Check if DuckPlayer feature is enabled guard isDuckPlayerFeatureEnabled else { return .notHandled(.featureOff) diff --git a/DuckDuckGo/DuckPlayer/DuckPlayerOverlayUsagePixels.swift b/DuckDuckGo/DuckPlayer/DuckPlayerOverlayUsagePixels.swift index 54c94f428e..6d4cf85f79 100644 --- a/DuckDuckGo/DuckPlayer/DuckPlayerOverlayUsagePixels.swift +++ b/DuckDuckGo/DuckPlayer/DuckPlayerOverlayUsagePixels.swift @@ -89,9 +89,8 @@ final class DuckPlayerOverlayUsagePixels: DuckPlayerOverlayPixelFiring { } } - // Refined truncation logic: + // Truncation logic: Remove all URLs up to the last occurrence of the current URL in normalized form if let lastOccurrenceIndex = (0..