Skip to content

Commit

Permalink
Remember my choice pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Oct 29, 2024
1 parent f366dc1 commit 9433591
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
22 changes: 8 additions & 14 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,10 @@ extension Pixel {
case duckPlayerSettingAlwaysSettings
case duckPlayerSettingNeverSettings
case duckPlayerSettingBackToDefault
case duckPlayerSettingsAlwaysOverlaySERP
case duckPlayerSettingsAlwaysOverlayYoutube
case duckPlayerSettingsNeverOverlaySERP
case duckPlayerSettingsNeverOverlayYoutube
case duckPlayerWatchOnYoutube
case duckPlayerSettingAlwaysOverlayYoutube
case duckPlayerSettingNeverOverlayYoutube
Expand Down Expand Up @@ -820,13 +824,6 @@ extension Pixel {
case pproFeedbackSubcategoryScreenShow(source: String, reportType: String, category: String)
case pproFeedbackSubmitScreenShow(source: String, reportType: String, category: String, subcategory: String)
case pproFeedbackSubmitScreenFAQClick(source: String, reportType: String, category: String, subcategory: String)

// MARK: DuckPlayer Pixel Experiment
case duckplayerExperimentCohortAssign
case duckplayerExperimentSearch
case duckplayerExperimentDailySearch
case duckplayerExperimentWeeklySearch
case duckplayerExperimentYoutubePageView

// MARK: WebView Error Page Shown
case webViewErrorPageShown
Expand Down Expand Up @@ -1612,6 +1609,10 @@ extension Pixel.Event {
case .duckPlayerViewFromOther: return "duckplayer_view-from_other"
case .duckPlayerSettingAlwaysSettings: return "duckplayer_setting_always_settings"
case .duckPlayerSettingAlwaysDuckPlayer: return "duckplayer_setting_always_duck-player"
case .duckPlayerSettingsAlwaysOverlaySERP: return "duckplayer_setting_always_overlay_serp"
case .duckPlayerSettingsAlwaysOverlayYoutube: return "duckplayer_setting_always_overlay_youtube"
case .duckPlayerSettingsNeverOverlaySERP: return "duckplayer_setting_never_overlay_serp"
case .duckPlayerSettingsNeverOverlayYoutube: return "duckplayer_setting_never_overlay_youtube"
case .duckPlayerOverlayYoutubeImpressions: return "duckplayer_overlay_youtube_impressions"
case .duckPlayerOverlayYoutubeWatchHere: return "duckplayer_overlay_youtube_watch_here"
case .duckPlayerSettingNeverSettings: return "duckplayer_setting_never_settings"
Expand Down Expand Up @@ -1645,13 +1646,6 @@ extension Pixel.Event {
case .pproFeedbackSubmitScreenShow: return "m_ppro_feedback_submit-screen_show"
case .pproFeedbackSubmitScreenFAQClick: return "m_ppro_feedback_submit-screen-faq_click"

// MARK: Duckplayer experiment
case .duckplayerExperimentCohortAssign: return "duckplayer_experiment_cohort_assign_v2"
case .duckplayerExperimentSearch: return "duckplayer_experiment_search_v2"
case .duckplayerExperimentDailySearch: return "duckplayer_experiment_daily_search_v2"
case .duckplayerExperimentWeeklySearch: return "duckplayer_experiment_weekly_search_v2"
case .duckplayerExperimentYoutubePageView: return "duckplayer_experiment_youtube_page_view_v2"

// MARK: - WebView Error Page shown
case .webViewErrorPageShown: return "m_errorpageshown"
}
Expand Down
30 changes: 27 additions & 3 deletions DuckDuckGo/DuckPlayer/DuckPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,34 @@ final class DuckPlayer: DuckPlayerControlling {
return
}
guard let feature = messageData.featureName else { return }
let event: Pixel.Event = feature == FeatureName.page.rawValue ? .duckPlayerSettingAlwaysDuckPlayer : .duckPlayerSettingAlwaysDuckPlayer
if userValues.duckPlayerMode == .enabled {
Pixel.fire(pixel: event)

// Get the webView URL
let webView = message.webView
guard let webView = message.webView, let url = webView.url else {
return
}

let isSERP = url.isDuckDuckGoSearch

var event: Pixel.Event
if isSERP {
switch userValues.duckPlayerMode {
case .enabled:
event = .duckPlayerSettingsAlwaysOverlaySERP
default:
event = .duckPlayerSettingsNeverOverlaySERP
}
} else {
switch userValues.duckPlayerMode {
case .enabled:
event = .duckPlayerSettingsAlwaysOverlayYoutube
default:
event = .duckPlayerSettingsNeverOverlayYoutube
}
}

Pixel.fire(pixel: event)


}

Expand Down

0 comments on commit 9433591

Please sign in to comment.