Skip to content

Commit

Permalink
Merge branch 'main' into sam/vpn-clean-up
Browse files Browse the repository at this point in the history
# By Graeme Arthur (4) and others
# Via GitHub (1) and Graeme Arthur (1)
* main:
  Fix VPN memory pressure monitor (#3535)
  Update Ruby to 3.3.4 (#3547)
  Onboarding Add To Dock Pixels (#3543)
  Switch to free runners for tests that run on Maestro (#3546)
  Fix email protection test (#3539)
  Update BSK for PixelKit suffix change (#3534)
  Adding app backgrounded result to rule compilation (#3533)
  Send pixel on sync secure storage failure (#3542)
  Onboarding Add to Dock Refactor for Intro scenario (#3538)
  Update C-S-S to 6.29.0 (#3541)
  Change save password Never for Site button to Not Now (#3471)
  Release 7.144.0-1 (#3540)
  UserDefaults misbehavior monitoring (#3510)
  Send pixel on sync secure storage read failure (#3530)
  Remove NewTabPage retain cycles (#3532)
  Update release notes (#3529)
  Release 7.144.0-0 (#3528)
  Add Privacy Config feature to control ad attribution reporting (#3506)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
samsymons committed Nov 6, 2024
2 parents 99aa718 + f8b9fa5 commit 9b9be64
Show file tree
Hide file tree
Showing 82 changed files with 1,691 additions and 551 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
end-to-end-tests:
name: End to end Tests
needs: build-end-to-end-tests
runs-on: macos-14-xlarge
runs-on: macos-14
timeout-minutes: 90
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
sync-end-to-end-tests:
name: Sync End To End Tests
needs: build-for-sync-end-to-end-tests
runs-on: macos-14-xlarge
runs-on: macos-14
timeout-minutes: 90
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .maestro/release_tests/emailprotection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tags:
- scroll
- assertVisible: Email Protection
- tapOn: Email Protection
- assertVisible: Email privacy, simplified.
- assertVisible: Email privacy, protected.
- assertVisible:
id: searchEntry
- tapOn:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.4
3.3.4
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 7.143.0
MARKETING_VERSION = 7.144.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 = "\"f8b9cfd5f1eb7b77c21d4476f85bd177\""
public static let embeddedDataSHA = "c26c97714d73a9e1e99dbd341d5890da42b49d34a296672be3d3cea00bdd37a0"
public static let embeddedDataETag = "\"516f95a16f7a556c58e14ee6f193cc30\""
public static let embeddedDataSHA = "87314e1ac02784472a722844a27b443b0387a164ac72afaac00d9a70731fc572"
}

public var embeddedDataEtag: String {
Expand Down
55 changes: 55 additions & 0 deletions Core/BoolFileMarker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// BoolFileMarker.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

public struct BoolFileMarker {
let fileManager = FileManager.default
private let url: URL

public var isPresent: Bool {
fileManager.fileExists(atPath: url.path)
}

public func mark() {
if !isPresent {
fileManager.createFile(atPath: url.path, contents: nil, attributes: [.protectionKey: FileProtectionType.none])
}
}

public func unmark() {
if isPresent {
try? fileManager.removeItem(at: url)
}
}

public init?(name: Name) {
guard let applicationSupportDirectory = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else {
return nil
}

self.url = applicationSupportDirectory.appendingPathComponent(name.rawValue)
}

public struct Name: RawRepresentable {
public let rawValue: String

public init(rawValue: String) {
self.rawValue = "\(rawValue).marker"
}
}
}
58 changes: 58 additions & 0 deletions Core/BoolFileMarkerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// BoolFileMarkerTests.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import XCTest
@testable import Core

final class BoolFileMarkerTests: XCTestCase {

private let marker = BoolFileMarker(name: .init(rawValue: "test"))!

override func tearDown() {
super.tearDown()

marker.unmark()
}

private var testFileURL: URL? {
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent("test.marker")
}

func testMarkCreatesCorrectFile() throws {

marker.mark()

let fileURL = try XCTUnwrap(testFileURL)

let attributes = try FileManager.default.attributesOfItem(atPath: fileURL.path)
XCTAssertNil(attributes[.protectionKey])
XCTAssertTrue(FileManager.default.fileExists(atPath: fileURL.path))
XCTAssertEqual(marker.isPresent, true)
}

func testUnmarkRemovesFile() throws {
marker.mark()
marker.unmark()

let fileURL = try XCTUnwrap(testFileURL)

XCTAssertFalse(marker.isPresent)
XCTAssertFalse(FileManager.default.fileExists(atPath: fileURL.path))
}
}
3 changes: 3 additions & 0 deletions Core/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public enum FeatureFlag: String {
case onboardingAddToDock
case autofillSurveys
case autcompleteTabs
case adAttributionReporting

/// https://app.asana.com/0/72649045549333/1208231259093710/f
case networkProtectionUserTips
Expand Down Expand Up @@ -103,6 +104,8 @@ extension FeatureFlag: FeatureFlagSourceProviding {
return .remoteReleasable(.feature(.autocompleteTabs))
case .networkProtectionUserTips:
return .remoteReleasable(.subfeature(NetworkProtectionSubfeature.userTips))
case .adAttributionReporting:
return .remoteReleasable(.feature(.adAttributionReporting))
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ extension Pixel {

case brokenSiteReport

// MARK: - Onboarding

case onboardingIntroShownUnique
case onboardingIntroComparisonChartShownUnique
case onboardingIntroChooseBrowserCTAPressed
Expand Down Expand Up @@ -173,6 +175,15 @@ extension Pixel {
case daxDialogsEndOfJourneyNewTabUnique
case daxDialogsEndOfJourneyDismissed

// MARK: - Onboarding Add To Dock

case onboardingAddToDockPromoImpressionsUnique
case onboardingAddToDockPromoShowTutorialCTATapped
case onboardingAddToDockPromoDismissCTATapped
case onboardingAddToDockTutorialDismissCTATapped

// MARK: - Onboarding Add To Dock

case widgetsOnboardingCTAPressed
case widgetsOnboardingDeclineOptionPressed
case widgetsOnboardingMovedToBackground
Expand Down Expand Up @@ -620,6 +631,7 @@ extension Pixel {
case syncRemoveDeviceError
case syncDeleteAccountError
case syncLoginExistingAccountError
case syncSecureStorageReadError

case syncGetOtherDevices
case syncGetOtherDevicesCopy
Expand Down Expand Up @@ -831,6 +843,11 @@ extension Pixel {

// MARK: WebView Error Page Shown
case webViewErrorPageShown

// MARK: UserDefaults incositency monitoring
case protectedDataUnavailableWhenBecomeActive
case statisticsLoaderATBStateMismatch
case adAttributionReportStateMismatch
}

}
Expand Down Expand Up @@ -994,6 +1011,11 @@ extension Pixel.Event {
case .daxDialogsEndOfJourneyNewTabUnique: return "m_dx_end_new_tab_unique"
case .daxDialogsEndOfJourneyDismissed: return "m_dx_end_dialog_dismissed"

case .onboardingAddToDockPromoImpressionsUnique: return "m_onboarding_add_to_dock_promo_impressions_unique"
case .onboardingAddToDockPromoShowTutorialCTATapped: return "m_onboarding_add_to_dock_promo_show_tutorial_button_tapped"
case .onboardingAddToDockPromoDismissCTATapped: return "m_onboarding_add_to_dock_promo_dismiss_button_tapped"
case .onboardingAddToDockTutorialDismissCTATapped: return "m_onboarding_add_to_dock_tutorial_dismiss_button_tapped"

case .widgetsOnboardingCTAPressed: return "m_o_w_a"
case .widgetsOnboardingDeclineOptionPressed: return "m_o_w_d"
case .widgetsOnboardingMovedToBackground: return "m_o_w_b"
Expand Down Expand Up @@ -1424,6 +1446,7 @@ extension Pixel.Event {
case .syncRemoveDeviceError: return "m_d_sync_remove_device_error"
case .syncDeleteAccountError: return "m_d_sync_delete_account_error"
case .syncLoginExistingAccountError: return "m_d_sync_login_existing_account_error"
case .syncSecureStorageReadError: return "m_d_sync_secure_storage_error"

case .syncGetOtherDevices: return "sync_get_other_devices"
case .syncGetOtherDevicesCopy: return "sync_get_other_devices_copy"
Expand Down Expand Up @@ -1658,6 +1681,11 @@ extension Pixel.Event {

// MARK: - DuckPlayer FE Application Telemetry
case .duckPlayerLandscapeLayoutImpressions: return "duckplayer_landscape_layout_impressions"

// MARK: UserDefaults incositency monitoring
case .protectedDataUnavailableWhenBecomeActive: return "m_protected_data_unavailable_when_become_active"
case .statisticsLoaderATBStateMismatch: return "m_statistics_loader_atb_state_mismatch"
case .adAttributionReportStateMismatch: return "m_ad_attribution_report_state_mismatch"
}
}
}
Expand Down Expand Up @@ -1709,6 +1737,7 @@ extension Pixel.Event {

case tabClosed = "tab_closed"
case appQuit = "app_quit"
case appBackgrounded = "app_backgrounded"
case success

}
Expand Down
25 changes: 23 additions & 2 deletions Core/StatisticsLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,29 @@ public class StatisticsLoader {
private let returnUserMeasurement: ReturnUserMeasurement
private let usageSegmentation: UsageSegmenting
private let parser = AtbParser()
private let atbPresenceFileMarker = BoolFileMarker(name: .isATBPresent)
private let inconsistencyMonitoring: StatisticsStoreInconsistencyMonitoring

init(statisticsStore: StatisticsStore = StatisticsUserDefaults(),
returnUserMeasurement: ReturnUserMeasurement = KeychainReturnUserMeasurement(),
usageSegmentation: UsageSegmenting = UsageSegmentation()) {
usageSegmentation: UsageSegmenting = UsageSegmentation(),
inconsistencyMonitoring: StatisticsStoreInconsistencyMonitoring = StorageInconsistencyMonitor()) {
self.statisticsStore = statisticsStore
self.returnUserMeasurement = returnUserMeasurement
self.usageSegmentation = usageSegmentation
self.inconsistencyMonitoring = inconsistencyMonitoring
}

public func load(completion: @escaping Completion = {}) {
if statisticsStore.hasInstallStatistics {
let hasFileMarker = atbPresenceFileMarker?.isPresent ?? false
let hasInstallStatistics = statisticsStore.hasInstallStatistics

inconsistencyMonitoring.statisticsDidLoad(hasFileMarker: hasFileMarker, hasInstallStatistics: hasInstallStatistics)

if hasInstallStatistics {
// Synchronize file marker with current state
createATBFileMarker()

completion()
return
}
Expand Down Expand Up @@ -85,10 +97,15 @@ public class StatisticsLoader {
self.statisticsStore.installDate = Date()
self.statisticsStore.atb = atb.version
self.returnUserMeasurement.installCompletedWithATB(atb)
self.createATBFileMarker()
completion()
}
}

private func createATBFileMarker() {
atbPresenceFileMarker?.mark()
}

public func refreshSearchRetentionAtb(completion: @escaping Completion = {}) {
guard let url = StatisticsDependentURLFactory(statisticsStore: statisticsStore).makeSearchAtbURL() else {
requestInstallStatistics {
Expand Down Expand Up @@ -169,3 +186,7 @@ public class StatisticsLoader {
processUsageSegmentation(atb: nil, activityType: activityType)
}
}

private extension BoolFileMarker.Name {
static let isATBPresent = BoolFileMarker.Name(rawValue: "atb-present")
}
66 changes: 66 additions & 0 deletions Core/StorageInconsistencyMonitor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// StorageInconsistencyMonitor.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit

public protocol AppActivationInconsistencyMonitoring {
/// See `StorageInconsistencyMonitor` for details
func didBecomeActive(isProtectedDataAvailable: Bool)
}

public protocol StatisticsStoreInconsistencyMonitoring {
/// See `StorageInconsistencyMonitor` for details
func statisticsDidLoad(hasFileMarker: Bool, hasInstallStatistics: Bool)
}

public protocol AdAttributionReporterInconsistencyMonitoring {
/// See `StorageInconsistencyMonitor` for details
func addAttributionReporter(hasFileMarker: Bool, hasCompletedFlag: Bool)
}

/// Takes care of reporting inconsistency in storage availability and/or state.
/// See https://app.asana.com/0/481882893211075/1208618515043198/f for details.
public struct StorageInconsistencyMonitor: AppActivationInconsistencyMonitoring & StatisticsStoreInconsistencyMonitoring & AdAttributionReporterInconsistencyMonitoring {

public init() { }

/// Reports a pixel if data is not available while app is active
public func didBecomeActive(isProtectedDataAvailable: Bool) {
if !isProtectedDataAvailable {
Pixel.fire(pixel: .protectedDataUnavailableWhenBecomeActive)
assertionFailure("This is unexpected state, debug if possible")
}
}

/// Reports a pixel if file marker exists but installStatistics are missing
public func statisticsDidLoad(hasFileMarker: Bool, hasInstallStatistics: Bool) {
if hasFileMarker == true && hasInstallStatistics == false {
Pixel.fire(pixel: .statisticsLoaderATBStateMismatch)
assertionFailure("This is unexpected state, debug if possible")
}
}

/// Reports a pixel if file marker exists but completion flag is false
public func addAttributionReporter(hasFileMarker: Bool, hasCompletedFlag: Bool) {
if hasFileMarker == true && hasCompletedFlag == false {
Pixel.fire(pixel: .adAttributionReportStateMismatch)
assertionFailure("This is unexpected state, debug if possible")
}
}
}
2 changes: 2 additions & 0 deletions Core/SyncErrorHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public class SyncErrorHandler: EventMapping<SyncError> {
Pixel.fire(pixel: .syncFailedToLoadAccount, error: error)
case .failedToSetupEngine:
Pixel.fire(pixel: .syncFailedToSetupEngine, error: error)
case .failedToReadSecureStore:
Pixel.fire(pixel: .syncSecureStorageReadError, error: error)
default:
// Should this be so generic?
let domainEvent = Pixel.Event.syncSentUnauthenticatedRequest
Expand Down
Loading

0 comments on commit 9b9be64

Please sign in to comment.