Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Remove Search Header experiment code #834

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Core/AppUrls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ public struct AppUrls {
}

var parameters = [String: String]()
if let queryContext = queryContext, isDuckDuckGoSearch(url: queryContext),
variantManager.isSupported(feature: .removeSERPHeader) {
if let queryContext = queryContext, isDuckDuckGoSearch(url: queryContext) {
if queryContext.getParam(name: Param.verticalMaps) == nil,
let vertical = queryContext.getParam(name: Param.vertical),
ParamValue.majorVerticals.contains(vertical) {
Expand Down Expand Up @@ -232,13 +231,10 @@ public struct AppUrls {
}

public func applySearchHeaderParams(for url: URL) -> URL {
guard variantManager.isSupported(feature: .removeSERPHeader) else { return url }

return url.addParam(name: Param.searchHeader, value: ParamValue.searchHeader)
}

public func hasCorrectSearchHeaderParams(url: URL) -> Bool {
guard variantManager.isSupported(feature: .removeSERPHeader) else { return true }
guard let header = url.getParam(name: Param.searchHeader) else { return false }
return header == ParamValue.searchHeader
}
Expand Down
7 changes: 1 addition & 6 deletions Core/VariantManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public enum FeatureName: String {

// Fire button education
case fireButtonEducation

case removeSERPHeader
}

public struct Variant {
Expand Down Expand Up @@ -65,10 +63,7 @@ public struct Variant {
Variant(name: "se", weight: doNotAllocate, isIncluded: When.inRequiredCountry, features: []),

Variant(name: "mc", weight: 1, isIncluded: When.always, features: []),
Variant(name: "mf", weight: 1, isIncluded: When.always, features: [.fireButtonEducation]),

Variant(name: "mi", weight: doNotAllocate, isIncluded: When.always, features: []),
Variant(name: "mo", weight: doNotAllocate, isIncluded: When.always, features: [.removeSERPHeader])
Variant(name: "mf", weight: 1, isIncluded: When.always, features: [.fireButtonEducation])
]

public let name: String
Expand Down
10 changes: 3 additions & 7 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ extension MainViewController: OmniBarDelegate {
}

func onSiteRatingPressed() {
if appUrls.variantManager.isSupported(feature: .removeSERPHeader), isSERPPresented { return }
if isSERPPresented { return }
ViewHighlighter.hideAll()
hideSuggestionTray()
currentTab?.showPrivacyDashboard()
Expand Down Expand Up @@ -971,19 +971,15 @@ extension MainViewController: OmniBarDelegate {
func onTextFieldWillBeginEditing(_ omniBar: OmniBar) {
guard homeController == nil else { return }

if appUrls.variantManager.isSupported(feature: .removeSERPHeader),
!skipSERPFlow, isSERPPresented, let query = omniBar.textField.text {
if !skipSERPFlow, isSERPPresented, let query = omniBar.textField.text {
showSuggestionTray(.autocomplete(query: query))
} else {
showSuggestionTray(.favorites)
}
}

func onTextFieldDidBeginEditing(_ omniBar: OmniBar) -> Bool {
var selectQueryText = true
if appUrls.variantManager.isSupported(feature: .removeSERPHeader) {
selectQueryText = !(isSERPPresented && !skipSERPFlow)
}
let selectQueryText = !(isSERPPresented && !skipSERPFlow)
skipSERPFlow = false

ViewHighlighter.hideAll()
Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/RequeryLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class RequeryLogic {
private var serpState: SerpState = .notLoaded

func onNewNavigation(url: URL) {
guard appUrls.variantManager.isSupported(feature: .removeSERPHeader) else { return }

guard let query = appUrls.searchQuery(fromUrl: url) else {
serpState = .notLoaded
return
Expand All @@ -47,8 +45,6 @@ class RequeryLogic {
}

func onRefresh() {
guard appUrls.variantManager.isSupported(feature: .removeSERPHeader) else { return }

guard case .loaded = serpState else { return }

sendPixel(value: .sameQuery)
Expand Down
4 changes: 1 addition & 3 deletions DuckDuckGo/SiteRatingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public class SiteRatingView: UIView {

private var siteRating: SiteRating?
var mode: DisplayMode = .loading

private let serpHeaderExperimentEnabled = DefaultVariantManager().isSupported(feature: .removeSERPHeader)

public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
Expand Down Expand Up @@ -77,7 +75,7 @@ public class SiteRatingView: UIView {
return
}

if serpHeaderExperimentEnabled && AppUrls().isDuckDuckGoSearch(url: siteRating.url) {
if AppUrls().isDuckDuckGoSearch(url: siteRating.url) {
circleIndicator.image = UIImage(named: "LogoIcon")
return
}
Expand Down