Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into anya/hackdays-passwor…
Browse files Browse the repository at this point in the history
…d-mgr-shortcut
  • Loading branch information
amddg44 committed Apr 3, 2024
2 parents bb5d24a + 22ebea9 commit b86f78d
Show file tree
Hide file tree
Showing 77 changed files with 1,619 additions and 1,130 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
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 7.112.0
MARKETING_VERSION = 7.113.0
4 changes: 2 additions & 2 deletions Core/AppPrivacyConfigurationDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import BrowserServicesKit
final public class AppPrivacyConfigurationDataProvider: EmbeddedDataProvider {

public struct Constants {
public static let embeddedDataETag = "\"c595f46fe54bfa96bbff4f30fc3940d8\""
public static let embeddedDataSHA = "911e6616b6869c0940c492240d43c0cf60274755dd45a50cc635c8b7c792cb87"
public static let embeddedDataETag = "\"4cac4f65624262686a265d3b95a8374b\""
public static let embeddedDataSHA = "6da9ab104a4b2adca51862ad942821e629a24929a95016b045f7bdd0028e1f71"
}

public var embeddedDataEtag: String {
Expand Down
20 changes: 15 additions & 5 deletions Core/DataStoreWarmup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,36 @@ public class DataStoreWarmup {

private class BlockingNavigationDelegate: NSObject, WKNavigationDelegate {

let finished = PassthroughSubject<Void, Never>()
var finished: PassthroughSubject? = PassthroughSubject<Void, Never>()

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy {
return .allow
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
finished.send()
if let finished {
finished.send()
self.finished = nil
} else {
Pixel.fire(pixel: .webKitWarmupUnexpectedDidFinish, includedParameters: [.appVersion])
}
}

func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
Pixel.fire(pixel: .webKitDidTerminateDuringWarmup)
// We won't get a `didFinish` if the webview crashes
finished.send()

if let finished {
finished.send()
self.finished = nil
} else {
Pixel.fire(pixel: .webKitWarmupUnexpectedDidTerminate, includedParameters: [.appVersion])
}
}

var cancellable: AnyCancellable?
func waitForLoad() async {
await withCheckedContinuation { continuation in
cancellable = finished.sink { _ in
cancellable = finished?.sink { _ in
continuation.resume()
}
}
Expand Down
15 changes: 1 addition & 14 deletions Core/Pixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,27 +271,14 @@ private extension Pixel.Event {

}

/// NSError supports this through `NSUnderlyingError`, but there's no support for this for Swift's `Error`. This protocol does that.
///
/// The reason why this protocol returns a code and a domain instead of just an `Error` or `NSError` is so that the error implementing
/// this protocol has full control over these values, and is able to override them as it best sees fit.
///
protocol ErrorWithUnderlyingError: Error {
var underlyingErrorCode: Int { get }
var underlyingErrorDomain: String { get }
}

extension Dictionary where Key == String, Value == String {
mutating func appendErrorPixelParams(error: Error) {
let nsError = error as NSError

self[PixelParameters.errorCode] = "\(nsError.code)"
self[PixelParameters.errorDomain] = nsError.domain

if let underlyingError = error as? ErrorWithUnderlyingError {
self[PixelParameters.underlyingErrorCode] = "\(underlyingError.underlyingErrorCode)"
self[PixelParameters.underlyingErrorDomain] = underlyingError.underlyingErrorDomain
} else if let underlyingError = nsError.userInfo["NSUnderlyingError"] as? NSError {
if let underlyingError = nsError.userInfo["NSUnderlyingError"] as? NSError {
self[PixelParameters.underlyingErrorCode] = "\(underlyingError.code)"
self[PixelParameters.underlyingErrorDomain] = underlyingError.domain
} else if let sqlErrorCode = nsError.userInfo["NSSQLiteErrorDomain"] as? NSNumber {
Expand Down
30 changes: 19 additions & 11 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ extension Pixel {
case networkProtectionClientFailedToParseRedeemResponse
case networkProtectionClientInvalidAuthToken

case networkProtectionServerListStoreFailedToEncodeServerList
case networkProtectionServerListStoreFailedToDecodeServerList
case networkProtectionServerListStoreFailedToWriteServerList
case networkProtectionServerListStoreFailedToReadServerList

case networkProtectionKeychainErrorFailedToCastKeychainValueToData
case networkProtectionKeychainReadError
case networkProtectionKeychainWriteError
Expand Down Expand Up @@ -413,7 +408,10 @@ extension Pixel {
case webKitDidTerminate
case webKitTerminationDidReloadCurrentTab
case webKitDidTerminateDuringWarmup


case webKitWarmupUnexpectedDidFinish
case webKitWarmupUnexpectedDidTerminate

case backgroundTaskSubmissionFailed

case blankOverlayNotDismissed
Expand Down Expand Up @@ -580,6 +578,7 @@ extension Pixel {
case privacyProPurchaseFailureAccountNotCreated
case privacyProPurchaseSuccess
case privacyProRestorePurchaseOfferPageEntry
case privacyProRestorePurchaseClick
case privacyProRestorePurchaseEmailStart
case privacyProRestorePurchaseStoreStart
case privacyProRestorePurchaseEmailSuccess
Expand All @@ -601,6 +600,10 @@ extension Pixel {
case privacyProSubscriptionManagementEmail
case privacyProSubscriptionManagementPlanBilling
case privacyProSubscriptionManagementRemoval
case privacyProFeatureEnabled
case privacyProPromotionDialogShownVPN
case privacyProVPNAccessRevokedDialogShown
case privacyProVPNBetaStoppedWhenPrivacyProEnabled

// Full site address setting
case settingsShowFullSiteAddressEnabled
Expand Down Expand Up @@ -906,10 +909,6 @@ extension Pixel.Event {
case .networkProtectionClientFailedToRedeemInviteCode: return "m_netp_backend_api_error_failed_to_redeem_invite_code"
case .networkProtectionClientFailedToParseRedeemResponse: return "m_netp_backend_api_error_parsing_redeem_response_failed"
case .networkProtectionClientInvalidAuthToken: return "m_netp_backend_api_error_invalid_auth_token"
case .networkProtectionServerListStoreFailedToEncodeServerList: return "m_netp_storage_error_failed_to_encode_server_list"
case .networkProtectionServerListStoreFailedToDecodeServerList: return "m_netp_storage_error_failed_to_decode_server_list"
case .networkProtectionServerListStoreFailedToWriteServerList: return "m_netp_storage_error_server_list_file_system_write_failed"
case .networkProtectionServerListStoreFailedToReadServerList: return "m_netp_storage_error_server_list_file_system_read_failed"
case .networkProtectionKeychainErrorFailedToCastKeychainValueToData: return "m_netp_keychain_error_failed_to_cast_keychain_value_to_data"
case .networkProtectionKeychainReadError: return "m_netp_keychain_error_read_failed"
case .networkProtectionKeychainWriteError: return "m_netp_keychain_error_write_failed"
Expand Down Expand Up @@ -995,7 +994,10 @@ extension Pixel.Event {
case .webKitDidTerminate: return "m_d_wkt"
case .webKitDidTerminateDuringWarmup: return "m_d_webkit-terminated-during-warmup"
case .webKitTerminationDidReloadCurrentTab: return "m_d_wktct"


case .webKitWarmupUnexpectedDidFinish: return "m_d_webkit-warmup-unexpected-did-finish"
case .webKitWarmupUnexpectedDidTerminate: return "m_d_webkit-warmup-unexpected-did-terminate"

case .backgroundTaskSubmissionFailed: return "m_bt_rf"

case .blankOverlayNotDismissed: return "m_d_ovs"
Expand Down Expand Up @@ -1163,6 +1165,7 @@ extension Pixel.Event {
case .privacyProPurchaseFailureBackendError: return "m_privacy-pro_app_subscription-purchase_failure_account-creation"
case .privacyProPurchaseSuccess: return "m_privacy-pro_app_subscription-purchase_success"
case .privacyProRestorePurchaseOfferPageEntry: return "m_privacy-pro_offer_restore-purchase_click"
case .privacyProRestorePurchaseClick: return "m_privacy-pro_app-settings_restore-purchase_click"
case .privacyProRestorePurchaseEmailStart: return "m_privacy-pro_activate-subscription_enter-email_click"
case .privacyProRestorePurchaseStoreStart: return "m_privacy-pro_activate-subscription_restore-purchase_click"
case .privacyProRestorePurchaseEmailSuccess: return "m_privacy-pro_app_subscription-restore-using-email_success"
Expand All @@ -1186,6 +1189,11 @@ extension Pixel.Event {
case .privacyProSubscriptionManagementRemoval: return "m_privacy-pro_settings_remove-from-device_click"
case .settingsShowFullSiteAddressEnabled: return "m_settings_show_full_url_on"
case .settingsShowFullSiteAddressDisabled: return "m_settings_show_full_url_off"
// Launch
case .privacyProFeatureEnabled: return "m_privacy-pro_feature_enabled"
case .privacyProPromotionDialogShownVPN: return "m_privacy-pro_promotion-dialog_shown_vpn"
case .privacyProVPNAccessRevokedDialogShown: return "m_privacy-pro_vpn-access-revoked-dialog_shown"
case .privacyProVPNBetaStoppedWhenPrivacyProEnabled: return "m_privacy-pro_vpn-beta-stopped-when-privacy-pro-enabled"
// Web
case .privacyProOfferMonthlyPriceClick: return "m_privacy-pro_offer_monthly-price_click"
case .privacyProOfferYearlyPriceClick: return "m_privacy-pro_offer_yearly-price_click"
Expand Down
4 changes: 4 additions & 0 deletions Core/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import BrowserServicesKit

extension String {

public func truncated(length: Int, trailing: String = "") -> String {
return (self.count > length) ? self.prefix(length) + trailing : self
}

/// Useful if loaded from UserText, for example
public func format(arguments: CVarArg...) -> String {
return String(format: self, arguments: arguments)
Expand Down
2 changes: 1 addition & 1 deletion Core/SyncBookmarksAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public final class SyncBookmarksAdapter {
)
if !didMigrateToImprovedListsHandling {
didMigrateToImprovedListsHandling = true
provider.lastSyncTimestamp = nil
provider.updateSyncTimestamps(server: nil, local: nil)
}

bindSyncErrorPublisher(provider)
Expand Down
Loading

0 comments on commit b86f78d

Please sign in to comment.