Skip to content

Commit

Permalink
Fix issue sending the duckPlayerWatchOnYoutube pixel (#3114)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1207252092703676/1208089112886056/f

**Description**:
Fix issue sending the watch on youtube pixel
  • Loading branch information
Bunn authored Aug 19, 2024
1 parent 292fa4f commit 8128f72
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions DuckDuckGo/Tab/TabExtensions/DuckPlayerTabExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ extension DuckPlayerTabExtension: NavigationResponder {

// “Watch in YouTube” selected
// when currently displayed content is the Duck Player and loading a YouTube URL, don‘t override it
if navigationAction.targetFrame?.url.isDuckPlayer == true,
navigationAction.targetFrame?.url.youtubeVideoID == videoID {
if didUserSelectWatchInYoutubeFromDuckPlayer(navigationAction, preferences: preferences, videoID: videoID) {
PixelKit.fire(GeneralPixel.duckPlayerWatchOnYoutube)
return .next

Expand Down Expand Up @@ -344,6 +343,11 @@ extension DuckPlayerTabExtension: NavigationResponder {
return .next
}

private func didUserSelectWatchInYoutubeFromDuckPlayer(_ navigationAction: NavigationAction, preferences: DuckPlayerPreferences, videoID: String) -> Bool {
let url = preferences.duckPlayerOpenInNewTab ? navigationAction.sourceFrame.url : navigationAction.targetFrame?.url
return url?.isDuckPlayer == true && url?.youtubeVideoID == videoID
}

func didCommit(_ navigation: Navigation) {
guard duckPlayer.isAvailable, duckPlayer.mode != .disabled else {
return
Expand Down

0 comments on commit 8128f72

Please sign in to comment.