Skip to content

Commit

Permalink
Merge branch 'graeme/netp-error-pixels' into graeme/add-wireguard-pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme authored Sep 20, 2023
2 parents cfb1b6e + cb729df commit f0d513f
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 93 deletions.
7 changes: 6 additions & 1 deletion Core/FileLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ class FileLoader {
let baseName = fileUrl.deletingPathExtension().path
let ext = fileUrl.pathExtension

guard let path = bundle.path(forResource: baseName, ofType: ext) else { throw FileError.unknownFile }
var path = bundle.path(forResource: baseName, ofType: ext)
if path == nil {
let fileName = fileName.dropping(suffix: ext).dropping(suffix: ".")
path = bundle.path(forResource: fileName, ofType: ext)
}
guard let path else { throw FileError.unknownFile }
let url = URL(fileURLWithPath: path)
guard let data = try? Data(contentsOf: url, options: [.mappedIfSafe]) else { throw FileError.invalidFileContents }
return data
Expand Down
2 changes: 0 additions & 2 deletions Core/Pixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ public struct PixelParameters {
public static let message = "message"
public static let sheetResult = "success"

public static let defaultBrowser = "default_browser"

// Network Protection
public static let keychainFieldName = "fieldName"
public static let keychainErrorCode = errorCode
Expand Down
12 changes: 0 additions & 12 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,6 @@ extension Pixel {
case remoteMessageSecondaryActionClicked
case remoteMessageSheet

// MARK: Set as Default
case onboardingSetDefaultOpened
case onboardingSetDefaultSkipped

// MARK: Return user measurement
case returnUser

Expand Down Expand Up @@ -492,8 +488,6 @@ extension Pixel {

case invalidPayload(Configuration)

case dailyActiveUser

case emailIncontextPromptDisplayed
case emailIncontextPromptConfirmed
case emailIncontextPromptDismissed
Expand Down Expand Up @@ -833,10 +827,6 @@ extension Pixel.Event {
case .remoteMessageSecondaryActionClicked: return "m_remote_message_secondary_action_clicked"
case .remoteMessageSheet: return "m_remote_message_sheet"

// MARK: Set as default measuring
case .onboardingSetDefaultOpened: return "m_onboarding_set-default-opened"
case .onboardingSetDefaultSkipped: return "m_onboarding_set-default-skipped"

// MARK: debug pixels

case .dbCrashDetected: return "m_d_crash"
Expand Down Expand Up @@ -969,8 +959,6 @@ extension Pixel.Event {

case .invalidPayload(let configuration): return "m_d_\(configuration.rawValue)_invalid_payload".lowercased()

case .dailyActiveUser: return "m_daily_active_user"

// MARK: - InContext Email Protection
case .emailIncontextPromptDisplayed: return "m_email_incontext_prompt_displayed"
case .emailIncontextPromptConfirmed: return "m_email_incontext_prompt_confirmed"
Expand Down
55 changes: 0 additions & 55 deletions Core/SetAsDefaultStatistics.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Core/StatisticsLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public class StatisticsLoader {
return
}

SetAsDefaultStatistics().fireDailyActiveUser()

let configuration = APIRequest.Configuration(url: url)
let request = APIRequest(configuration: configuration, urlSession: .session())

Expand All @@ -116,8 +114,6 @@ public class StatisticsLoader {
return
}

SetAsDefaultStatistics().fireDailyActiveUser()

let configuration = APIRequest.Configuration(url: url)
let request = APIRequest(configuration: configuration, urlSession: .session())

Expand Down
8 changes: 2 additions & 6 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@
8565A34B1FC8D96B00239327 /* LaunchTabNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8565A34A1FC8D96B00239327 /* LaunchTabNotification.swift */; };
8565A34D1FC8DFE400239327 /* LaunchTabNotificationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8565A34C1FC8DFE400239327 /* LaunchTabNotificationTests.swift */; };
8577A1C5255D2C0D00D43FCD /* HitTestingToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8577A1C4255D2C0D00D43FCD /* HitTestingToolbar.swift */; };
8577C6602A964BAC00788B3A /* SetAsDefaultStatistics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8577C65F2A964BAC00788B3A /* SetAsDefaultStatistics.swift */; };
857EEB752095FFAC008A005C /* HomeRowInstructionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EEB742095FFAC008A005C /* HomeRowInstructionsViewController.swift */; };
858566E8252E4F56007501B8 /* Debug.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 858566E7252E4F56007501B8 /* Debug.storyboard */; };
858566FB252E55D6007501B8 /* ImageCacheDebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 858566FA252E55D6007501B8 /* ImageCacheDebugViewController.swift */; };
Expand Down Expand Up @@ -1404,7 +1403,6 @@
8565A34A1FC8D96B00239327 /* LaunchTabNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchTabNotification.swift; sourceTree = "<group>"; };
8565A34C1FC8DFE400239327 /* LaunchTabNotificationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchTabNotificationTests.swift; sourceTree = "<group>"; };
8577A1C4255D2C0D00D43FCD /* HitTestingToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HitTestingToolbar.swift; sourceTree = "<group>"; };
8577C65F2A964BAC00788B3A /* SetAsDefaultStatistics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetAsDefaultStatistics.swift; sourceTree = "<group>"; };
857EEB742095FFAC008A005C /* HomeRowInstructionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeRowInstructionsViewController.swift; sourceTree = "<group>"; };
858566E7252E4F56007501B8 /* Debug.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Debug.storyboard; sourceTree = "<group>"; };
858566FA252E55D6007501B8 /* ImageCacheDebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCacheDebugViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4403,7 +4401,6 @@
853A717520F62FE800FE60BC /* Pixel.swift */,
1E05D1D729C46EDA00BF9A1F /* TimedPixel.swift */,
1E05D1D529C46EBB00BF9A1F /* DailyPixel.swift */,
8577C65F2A964BAC00788B3A /* SetAsDefaultStatistics.swift */,
85E242162AB1B54D000F3E28 /* ReturnUserMeasurement.swift */,
);
name = Statistics;
Expand Down Expand Up @@ -6646,7 +6643,6 @@
85F21DC621145DD5002631A6 /* global.swift in Sources */,
F41C2DA326C1925700F9A760 /* BookmarksAndFolders.xcdatamodeld in Sources */,
F4F6DFBA26EFF28A00ED7E12 /* BookmarkObjects.swift in Sources */,
8577C6602A964BAC00788B3A /* SetAsDefaultStatistics.swift in Sources */,
836A941D247F23C600BF8EF5 /* UserAgentManager.swift in Sources */,
4B83397329AFB8D2003F7EA9 /* AppTrackingProtectionFeedbackModel.swift in Sources */,
85CA53A824BB343700A6288C /* Favicons.swift in Sources */,
Expand Down Expand Up @@ -8897,8 +8893,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = revision;
revision = c7e614d92877866029a0ed057f5ba7aac99ce240;
kind = revision;
revision = c7e614d92877866029a0ed057f5ba7aac99ce240;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state": {
"branch": null,
"revision": "20a6aeddbd86b43fd83c42aa45fdd9ec6db0e0f7",
"version": "8.2.0"
"revision": "21aa20e272b7de06e471c6e646d25e26a5887b60",
"version": "8.3.0"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
showKeyboardIfSettingOn = false

if !handleAppDeepLink(app, mainViewController, url) {
SetAsDefaultStatistics().openedAsDefault()
mainViewController?.loadUrlInNewTab(url, reuseExisting: true, inheritedAttribution: nil)
}

Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/OnboardingDefaultBroswerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ class OnboardingDefaultBroswerViewController: OnboardingContentViewController {
}

override func onContinuePressed(navigationHandler: @escaping () -> Void) {
SetAsDefaultStatistics().setAsDefaultOpened()
if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url)
}
super.onContinuePressed(navigationHandler: navigationHandler)
}

override func onSkipPressed(navigationHandler: @escaping () -> Void) {
SetAsDefaultStatistics().setAsDefaultSkipped()
super.onSkipPressed(navigationHandler: navigationHandler)
}
}
7 changes: 6 additions & 1 deletion DuckDuckGoTests/FireButtonReferenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ final class FireButtonReferenceTests: XCTestCase {
}

private func sanitizedSite(_ site: String) -> String {
let url = URL(string: site)!
let url: URL
if site.hasPrefix("http") {
url = URL(string: site)!
} else {
url = URL(string: "https://" + site)!
}
return url.host!
}

Expand Down
12 changes: 6 additions & 6 deletions IntegrationTests/AutoconsentBackgroundTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ final class AutoconsentBackgroundTests: XCTestCase {
webview.navigationDelegate = navigationDelegate
let url = Bundle(for: type(of: self)).url(forResource: "autoconsent-test-page", withExtension: "html")!
webview.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
waitForExpectations(timeout: 4)
waitForExpectations(timeout: 10)

let expectation = expectation(description: "Async call")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
webview.evaluateJavaScript("results.results.includes('button_clicked')", in: nil, in: .page,
completionHandler: { result in
switch result {
Expand All @@ -92,7 +92,7 @@ final class AutoconsentBackgroundTests: XCTestCase {
expectation.fulfill()
})
}
waitForExpectations(timeout: 4)
waitForExpectations(timeout: 10)
}

@MainActor
Expand All @@ -113,10 +113,10 @@ final class AutoconsentBackgroundTests: XCTestCase {
webview.navigationDelegate = navigationDelegate
let url = Bundle(for: type(of: self)).url(forResource: "autoconsent-test-page-banner", withExtension: "html")!
webview.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
waitForExpectations(timeout: 4)
waitForExpectations(timeout: 10)

let expectation = expectation(description: "Async call")
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
webview.evaluateJavaScript("window.getComputedStyle(banner).display === 'none'", in: nil, in: .page,
completionHandler: { result in
switch result {
Expand All @@ -130,7 +130,7 @@ final class AutoconsentBackgroundTests: XCTestCase {
expectation.fulfill()
})
}
waitForExpectations(timeout: 4)
waitForExpectations(timeout: 10)
}
}

Expand Down

0 comments on commit f0d513f

Please sign in to comment.