Skip to content

Commit

Permalink
Merge branch 'main' into sam/vpn-ship-review-problems-2
Browse files Browse the repository at this point in the history
# By Anh Do (1) and others
# Via GitHub
* main:
  Fix incorrect omnibar behavior (#2634)
  Replase glitch.me pages with privacy-test-pages.site (#2632)
  BSK update for Autofill Script performance improvements (#2625)
  Send correct platform value for App Store purchase options (#2633)
  Collect extra metadata (#2622)
  Clarified readme "instruments" section (#2607)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
samsymons committed Mar 25, 2024
2 parents 80e8997 + c5550c5 commit 585e39a
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .maestro/release_tests/bookmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:
id: "searchEntry"
- tapOn:
id: "searchEntry"
- inputText: "https://privacy-test-pages.glitch.me"
- inputText: "https://privacy-test-pages.site"
- pressKey: Enter

# Manage onboarding
Expand Down
2 changes: 1 addition & 1 deletion .maestro/release_tests/browsing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:
id: "searchEntry"
- tapOn:
id: "searchEntry"
- inputText: "https://privacy-test-pages.glitch.me"
- inputText: "https://privacy-test-pages.site"
- pressKey: Enter
- tapOn:
optional: true
Expand Down
2 changes: 1 addition & 1 deletion .maestro/release_tests/favorites.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:
id: "searchEntry"
- tapOn:
id: "searchEntry"
- inputText: "https://privacy-test-pages.glitch.me"
- inputText: "https://privacy-test-pages.site"
- pressKey: Enter

# Manage onboarding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"state" : {
"revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff",
"version" : "1.2.2"
Expand Down
71 changes: 53 additions & 18 deletions DuckDuckGo/Feedback/VPNMetadataCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Common
import NetworkProtection
import NetworkExtension
import Network
import Subscription

struct VPNMetadata: Encodable {

Expand Down Expand Up @@ -61,11 +62,27 @@ struct VPNMetadata: Encodable {
let selectedServer: String
}

struct PrivacyProInfo: Encodable {
// swiftlint:disable nesting
enum Source: String, Encodable {
case `internal`
case waitlist
case other
}
// swiftlint:enable nesting

let enableSource: Source
let betaParticipant: Bool
let hasToken: Bool
let subscriptionActive: Bool
}

let appInfo: AppInfo
let deviceInfo: DeviceInfo
let networkInfo: NetworkInfo
let vpnState: VPNState
let vpnSettingsState: VPNSettingsState
let privacyProInfo: PrivacyProInfo

func toPrettyPrintedJSON() -> String? {
let encoder = JSONEncoder()
Expand Down Expand Up @@ -99,15 +116,21 @@ protocol VPNMetadataCollector {
final class DefaultVPNMetadataCollector: VPNMetadataCollector {
private let statusObserver: ConnectionStatusObserver
private let serverInfoObserver: ConnectionServerInfoObserver
private let accessManager: NetworkProtectionAccessController
private let tokenStore: NetworkProtectionTokenStore
private let settings: VPNSettings
private let defaults: UserDefaults

init(statusObserver: ConnectionStatusObserver = ConnectionStatusObserverThroughSession(),
serverInfoObserver: ConnectionServerInfoObserver = ConnectionServerInfoObserverThroughSession(),
networkProtectionAccessManager: NetworkProtectionAccessController = NetworkProtectionAccessController(),
tokenStore: NetworkProtectionTokenStore = NetworkProtectionKeychainTokenStore(),
settings: VPNSettings = .init(defaults: .networkProtectionGroupDefaults),
defaults: UserDefaults = .networkProtectionGroupDefaults) {
self.statusObserver = statusObserver
self.serverInfoObserver = serverInfoObserver
self.accessManager = networkProtectionAccessManager
self.tokenStore = tokenStore
self.settings = settings
self.defaults = defaults
}
Expand All @@ -118,13 +141,15 @@ final class DefaultVPNMetadataCollector: VPNMetadataCollector {
let networkInfoMetadata = await collectNetworkInformation()
let vpnState = await collectVPNState()
let vpnSettingsState = collectVPNSettingsState()
let privacyProInfo = collectPrivacyProInfo()

return VPNMetadata(
appInfo: appInfoMetadata,
deviceInfo: deviceInfoMetadata,
networkInfo: networkInfoMetadata,
vpnState: vpnState,
vpnSettingsState: vpnSettingsState
vpnSettingsState: vpnSettingsState,
privacyProInfo: privacyProInfo
)
}

Expand Down Expand Up @@ -242,7 +267,7 @@ final class DefaultVPNMetadataCollector: VPNMetadataCollector {
}

func collectVPNSettingsState() -> VPNMetadata.VPNSettingsState {
return .init(
.init(
connectOnLoginEnabled: settings.connectOnLogin,
includeAllNetworksEnabled: settings.includeAllNetworks,
enforceRoutesEnabled: settings.enforceRoutes,
Expand All @@ -251,25 +276,35 @@ final class DefaultVPNMetadataCollector: VPNMetadataCollector {
selectedServer: settings.selectedServer.stringValue ?? "automatic"
)
}
}

extension Network.NWPath {
/// A description that's safe from a privacy standpoint.
///
/// Ref: https://app.asana.com/0/0/1206712493935053/1206712516729780/f
///
var anonymousDescription: String {
var description = "NWPath("

description += "status: \(status), "

if #available(iOS 14.2, *), case .unsatisfied = status {
description += "unsatisfiedReason: \(unsatisfiedReason), "
func collectPrivacyProInfo() -> VPNMetadata.PrivacyProInfo {
let accessType = accessManager.networkProtectionAccessType()
var hasToken: Bool {
guard let token = try? tokenStore.fetchToken(),
!token.hasPrefix(NetworkProtectionKeychainTokenStore.authTokenPrefix) else {
return false
}
return true
}

description += "availableInterfaces: \(availableInterfaces)"
description += ")"
return .init(
enableSource: .init(from: accessManager.networkProtectionAccessType()),
betaParticipant: accessType == .waitlistJoined,
hasToken: hasToken,
subscriptionActive: AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)).accessToken != nil
)
}
}

return description
extension VPNMetadata.PrivacyProInfo.Source {
init(from accessType: NetworkProtectionAccessType) {
switch accessType {
case .inviteCodeInvited:
self = .internal
case .waitlistInvited:
self = .waitlist
default:
self = .other
}
}
}
2 changes: 1 addition & 1 deletion DuckDuckGo/OmniBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ class OmniBar: UIView {
}

func refreshText(forUrl url: URL?, forceFullURL: Bool = false) {

guard !textField.isEditing else { return }
guard let url = url else {
textField.text = nil
return
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ We use [SwifLint](https://github.com/realm/SwiftLint) for enforcing Swift style

### Instruments

We have Custom Instruments tool to help visualize and track events that happen during runtime.
We have a Custom Instruments tool to help visualize and track events that happen during runtime.

In order to run it:
1. Build a Debug version and install it on Simulator/Device.
2. Select Instruments target and run it on a Mac. A New instance of Instruments app will be run that has a grayed out icon indicating that it works in debug mode with custom instruments attached.
3. Select 'DDG Trace' template or set up a custom one by importing 'DDG Timeline' instrument from Library.
1. Build a debug version and install it on a simulator or device.
2. Select the Instruments target and run it on a Mac. A new instance of the Instruments app will run. It will have a grayed out icon indicating that it works in debug mode with custom instruments attached.
3. Select the 'DDG Trace' template or set up a custom one by importing the 'DDG Timeline' instrument from Library.
4. Start recording.

See [Instruments Developer Help](https://help.apple.com/instruments/developer/mac/current/) for reference how to create custom instruments.
Expand Down

0 comments on commit 585e39a

Please sign in to comment.