Skip to content

Commit

Permalink
Merge branch 'main' into dominik/xcode-16
Browse files Browse the repository at this point in the history
* main:
  adding impression pixels for duckplayer in landscape mode (#3493)
  Update autoconsent to v10.17.0 (#3504)
  Onboarding Add to Dock Tutorial (#3482)
  Blind attempt to fix Omnibar-related crash (#3500)
  Add to Dock Localised strings (#3494)
  Add to Dock Onboarding feature flag (#3476)
  Remove HomePageViewController code (#3454)
  • Loading branch information
samsymons committed Oct 30, 2024
2 parents 17abbed + 374492a commit 0865e5e
Show file tree
Hide file tree
Showing 64 changed files with 907 additions and 1,945 deletions.
3 changes: 3 additions & 0 deletions Core/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum FeatureFlag: String {
case syncPromotionBookmarks
case syncPromotionPasswords
case onboardingHighlights
case onboardingAddToDock
case autofillSurveys
case autcompleteTabs

Expand Down Expand Up @@ -94,6 +95,8 @@ extension FeatureFlag: FeatureFlagSourceProviding {
return .remoteReleasable(.subfeature(SyncPromotionSubfeature.passwords))
case .onboardingHighlights:
return .internalOnly
case .onboardingAddToDock:
return .internalOnly
case .autofillSurveys:
return .remoteReleasable(.feature(.autofillSurveys))
case .autcompleteTabs:
Expand Down
4 changes: 4 additions & 0 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ extension Pixel {
case duckPlayerViewFromSERP
case duckPlayerViewFromOther
case duckPlayerOverlayYoutubeImpressions
case duckPlayerLandscapeLayoutImpressions
case duckPlayerOverlayYoutubeWatchHere
case duckPlayerSettingAlwaysDuckPlayer
case duckPlayerSettingAlwaysSettings
Expand Down Expand Up @@ -1664,6 +1665,9 @@ extension Pixel.Event {

// MARK: - WebView Error Page shown
case .webViewErrorPageShown: return "m_errorpageshown"

// MARK: - DuckPlayer FE Application Telemetry
case .duckPlayerLandscapeLayoutImpressions: return "duckplayer_landscape_layout_impressions"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Core/UserDefaultsPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ public struct UserDefaultsWrapper<T> {
// Debug keys
case debugNewTabPageSectionsEnabledKey = "com.duckduckgo.ios.debug.newTabPageSectionsEnabled"
case debugOnboardingHighlightsEnabledKey = "com.duckduckgo.ios.debug.onboardingHighlightsEnabled"

case debugOnboardingAddToDockEnabledKey = "com.duckduckgo.ios.debug.onboardingAddToDockEnabled"

// Duck Player Pixel Experiment
case duckPlayerPixelExperimentInstalled = "com.duckduckgo.ios.duckplayer.pixel.experiment.installed.v2"
case duckPlayerPixelExperimentCohort = "com.duckduckgo.ios.duckplayer.pixel.experiment.cohort.v2"
Expand Down
180 changes: 62 additions & 118 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions DuckDuckGo/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ protocol AppSettings: AnyObject, AppDebugSettings {

protocol AppDebugSettings {
var onboardingHighlightsEnabled: Bool { get set }
var onboardingAddToDockEnabled: Bool { get set }
}
4 changes: 3 additions & 1 deletion DuckDuckGo/AppUserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,12 @@ public class AppUserDefaults: AppSettings {

@UserDefaultsWrapper(key: .duckPlayerOpenInNewTab, defaultValue: true)
var duckPlayerOpenInNewTab: Bool


@UserDefaultsWrapper(key: .debugOnboardingHighlightsEnabledKey, defaultValue: false)
var onboardingHighlightsEnabled: Bool

@UserDefaultsWrapper(key: .debugOnboardingAddToDockEnabledKey, defaultValue: false)
var onboardingAddToDockEnabled: Bool
}

extension AppUserDefaults: AppConfigurationFetchStatistics {
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

123 changes: 0 additions & 123 deletions DuckDuckGo/Base.lproj/Home.storyboard

This file was deleted.

64 changes: 63 additions & 1 deletion DuckDuckGo/DuckPlayer/DuckPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,50 @@ public enum DuckPlayerReferrer {
}
}

// Wrapper to allow sibling properties on each event in the future.
struct TelemetryEvent: Decodable {
let attributes: Attributes
}

// This is the first example of a new telemetry event
struct ImpressionAttributes: Decodable {
enum Layout: String, Decodable {
case landscape = "landscape-layout"
}

let name: String
let value: Layout
}

// Designed to represent the discriminated union used by the FE (where all events are schema-driven)
enum Attributes: Decodable {

// more events can be added here later, without needing a new handler
case impression(ImpressionAttributes)

private enum CodingKeys: String, CodingKey {
case name
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let name = try container.decode(String.self, forKey: .name)

switch name {
case "impression":
let attributes = try ImpressionAttributes(from: decoder)
self = .impression(attributes)

default:
throw DecodingError.dataCorruptedError(
forKey: .name,
in: container,
debugDescription: "Unknown name value: \(name)"
)
}
}
}

protocol DuckPlayerProtocol: AnyObject {

var settings: DuckPlayerSettings { get }
Expand All @@ -104,7 +148,8 @@ protocol DuckPlayerProtocol: AnyObject {
func openVideoInDuckPlayer(url: URL, webView: WKWebView)
func openDuckPlayerSettings(params: Any, message: WKScriptMessage) async -> Encodable?
func openDuckPlayerInfo(params: Any, message: WKScriptMessage) async -> Encodable?

func telemetryEvent(params: Any, message: WKScriptMessage) async -> Encodable?

func initialSetupPlayer(params: Any, message: WKScriptMessage) async -> Encodable?
func initialSetupOverlay(params: Any, message: WKScriptMessage) async -> Encodable?

Expand Down Expand Up @@ -239,6 +284,23 @@ final class DuckPlayer: DuckPlayerProtocol {
return nil
}

@MainActor
public func telemetryEvent(params: Any, message: WKScriptMessage) async -> Encodable? {
guard let event: TelemetryEvent = DecodableHelper.decode(from: params) else {
return nil
}

switch event.attributes {
case .impression(let attrs):
switch attrs.value {
case .landscape:
Pixel.fire(pixel: .duckPlayerLandscapeLayoutImpressions)
}
}

return nil
}

private func encodeUserValues() -> UserValues {
return UserValues(
duckPlayerMode: featureFlagger.isFeatureOn(.duckPlayer) ? settings.mode : .disabled,
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/DuckPlayer/YoutubePlayerUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final class YoutubePlayerUserScript: NSObject, Subfeature {
static let initialSetup = "initialSetup"
static let openSettings = "openSettings"
static let openInfo = "openInfo"
static let telemetryEvent = "telemetryEvent"
}

init(duckPlayer: DuckPlayerProtocol) {
Expand Down Expand Up @@ -79,6 +80,8 @@ final class YoutubePlayerUserScript: NSObject, Subfeature {
return duckPlayer.openDuckPlayerSettings
case Handlers.openInfo:
return duckPlayer.openDuckPlayerInfo
case Handlers.telemetryEvent:
return duckPlayer.telemetryEvent
default:
assertionFailure("YoutubePlayerUserScript: Failed to parse User Script message: \(methodName)")
return nil
Expand Down
14 changes: 4 additions & 10 deletions DuckDuckGo/FavoritesHomeViewSectionRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protocol FavoritesHomeViewSectionRendererDelegate: AnyObject {
favoriteDeleted favorite: BookmarkEntity)
}

class FavoritesHomeViewSectionRenderer: NSObject, HomeViewSectionRenderer {
class FavoritesHomeViewSectionRenderer {

struct Constants {

Expand All @@ -43,7 +43,8 @@ class FavoritesHomeViewSectionRenderer: NSObject, HomeViewSectionRenderer {
static let defaultHeaderHeight: CGFloat = 20
static let horizontalMargin: CGFloat = 2
static let largeModeMargin: CGFloat = 24

static let sideInsets: CGFloat = 25

}

let viewModel: FavoritesListInteracting
Expand Down Expand Up @@ -83,13 +84,6 @@ class FavoritesHomeViewSectionRenderer: NSObject, HomeViewSectionRenderer {
return Constants.defaultHeaderHeight
}

func install(into controller: HomeViewController) {
self.controller = controller
if numberOfItems > 0 {
controller.hideLogo()
}
}

func install(into controller: UIViewController & FavoritesHomeViewSectionRendererDelegate) {
self.controller = controller
}
Expand All @@ -103,7 +97,7 @@ class FavoritesHomeViewSectionRenderer: NSObject, HomeViewSectionRenderer {
if isPad {
margin = (collectionView.frame.width - Constants.searchWidthPad) / 2
} else {
let defaultMargin = HomeViewSectionRenderers.Constants.sideInsets
let defaultMargin = FavoritesHomeViewSectionRenderer.Constants.sideInsets
let landscapeMargin = (collectionView.frame.width - Constants.searchWidth + defaultMargin) / 2
margin = isPortrait ? defaultMargin : landscapeMargin
}
Expand Down
Loading

0 comments on commit 0865e5e

Please sign in to comment.