Skip to content

Commit

Permalink
Add WireGuard NetP Error Pixels (#2023)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Rey Mendez <[email protected]>
Co-authored-by: Dax Mobile <[email protected]>
Co-authored-by: Brad Slayter <[email protected]>
  • Loading branch information
4 people authored Sep 21, 2023
1 parent d5fc52d commit b906d12
Show file tree
Hide file tree
Showing 18 changed files with 520 additions and 67 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Make TestFlight Alpha Build

on:
workflow_dispatch:
inputs:
destination:
description: "TestFlight Group"
required: true
default: "Latest Alpha Group"
type: string
workflow_call:
inputs:
destination:
description: "TestFlight Group"
required: true
default: "Latest Alpha Group"
type: string
secrets:
SSH_PRIVATE_KEY_FASTLANE_MATCH:
required: true
APPLE_API_KEY_BASE64:
required: true
APPLE_API_KEY_ID:
required: true
APPLE_API_KEY_ISSUER:
required: true
MATCH_PASSWORD:
required: true
ASANA_ACCESS_TOKEN:
required: true

jobs:
make-alpha:
runs-on: macos-13
name: Make TestFlight Alpha Build

env:
destination: ${{ github.event.inputs.destination || inputs.destination }}

steps:

- name: Assert develop branch
run: |
case "${{ github.ref }}" in
*develop/*) ;;
*) echo "👎 Not develop branch"; exit 1 ;;
esac
- name: Register SSH keys for access to certificates
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY_FASTLANE_MATCH }}

- name: Check out the code
uses: actions/checkout@v3
with:
submodules: recursive

- name: Set cache key hash
run: |
has_only_tags=$(jq '[ .object.pins[].state | has("version") ] | all' DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved)
if [[ "$has_only_tags" == "true" ]]; then
echo "cache_key_hash=${{ hashFiles('DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}" >> $GITHUB_ENV
else
echo "Package.resolved contains dependencies specified by branch or commit, skipping cache."
fi
- name: Cache SPM
if: env.cache_key_hash
uses: actions/cache@v3
with:
path: DerivedData/SourcePackages
key: ${{ runner.os }}-spm-${{ env.cache_key_hash }}
restore-keys: |
${{ runner.os }}-spm-
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_$(<.xcode-version).app/Contents/Developer

- name: Prepare fastlane
run: bundle install

- name: Archive and upload the app
env:
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
run: |
app_version="$(cut -d ' ' -f 3 < Configuration/Version.xcconfig)"
bundle exec fastlane increment_build_number_for_version version:$app_version app_identifier:"com.duckduckgo.mobile.ios.alpha"
bundle exec fastlane release_alpha groups:"${{ env.destination }}"
build_version="$(xcodebuild -configuration Alpha -showBuildSettings | grep CURRENT_PROJECT_VERSION | tr -d 'CURRENT_PROJECT_VERSION =')"
echo "dsyms_path=${{ github.workspace }}/DuckDuckGo-Alpha.app.dSYM.zip" >> $GITHUB_ENV
echo "app_version=${app_version}" >> $GITHUB_ENV
echo "build_version=${build_version}" >> $GITHUB_ENV
- name: Upload dSYMs artifact
uses: actions/upload-artifact@v3
with:
name: DuckDuckGo-Alpha-dSYM-${{ env.app_version }}
path: ${{ env.dsyms_path }}

- name: Upload debug symbols to Asana
env:
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
run: |
asana_dsyms_path="${{ github.workspace }}/DuckDuckGo-Alpha-${{ env.app_version }}(${{ env.build_version }})-dSYM.zip"
mv -f "${{ env.dsyms_path }}" "$asana_dsyms_path"
curl -s "https://app.asana.com/api/1.0/tasks/1205344386326139/attachments" \
-H "Authorization: Bearer ${{ secrets.ASANA_ACCESS_TOKEN }}" \
--form "file=@${asana_dsyms_path};type=application/zip"
14 changes: 13 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nightly Integration Tests
name: Nightly Test and Deploy

on:
schedule:
Expand Down Expand Up @@ -94,3 +94,15 @@ jobs:
with:
report_paths: unittests.xml

deploy-alpha:
name: Deploy Nightly Alpha Build
uses: ./.github/workflows/alpha.yml
with:
destination: "Nightly Alpha Group"
secrets:
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_KEY_ISSUER: ${{ secrets.APPLE_API_KEY_ISSUER }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
SSH_PRIVATE_KEY_FASTLANE_MATCH: ${{ secrets.SSH_PRIVATE_KEY_FASTLANE_MATCH }}
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
1 change: 1 addition & 0 deletions Core/Pixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public struct PixelParameters {
// Network Protection
public static let keychainFieldName = "fieldName"
public static let keychainErrorCode = errorCode
public static let wireguardErrorCode = errorCode
public static let function = "function"
public static let line = "line"
public static let reason = "reason"
Expand Down
6 changes: 0 additions & 6 deletions Core/URLFileExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ extension URL {
(try? resourceValues(forKeys: [.creationDateKey]))?.creationDate
}

/// The time at which the resource was most recently modified.
/// This key corresponds to an Date value, or nil if the volume doesn't support modification dates.
public var contentModification: Date? {
(try? resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate
}

/// The time at which the resource was most recently accessed.
/// This key corresponds to an Date value, or nil if the volume doesn't support access dates.
/// When you set the contentAccessDateKey for a resource, also set contentModificationDateKey in the same call to the setResourceValues(_:) method. Otherwise, the file system may set the contentAccessDateKey value to the current contentModificationDateKey value.
Expand Down
2 changes: 2 additions & 0 deletions Core/UserDefaultsPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public struct UserDefaultsWrapper<T> {
case defaultBrowserUsageLastSeen = "com.duckduckgo.ios.default-browser-usage-last-seen"

case syncEnvironment = "com.duckduckgo.ios.sync-environment"

case networkProtectionDebugOptionAlwaysOnEnabled = "com.duckduckgo.network-protection.always-on.enabled"
}

private let key: Key
Expand Down
18 changes: 17 additions & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
02CA904924F6BFE700D41DDF /* navigatorsharepatch.js in Resources */ = {isa = PBXBuildFile; fileRef = 02CA904824F6BFE700D41DDF /* navigatorsharepatch.js */; };
02CA904B24F6C11A00D41DDF /* NavigatorSharePatchUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CA904A24F6C11A00D41DDF /* NavigatorSharePatchUserScript.swift */; };
02EC02C429AFA33000557F1A /* AppTPBreakageFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02EC02C329AFA33000557F1A /* AppTPBreakageFormView.swift */; };
02F880642AB206740020C2DF /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 02ECEC602A965074009F0654 /* PrivacyInfo.xcprivacy */; };
0A6CC0EF23904D5400E4F627 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 0A6CC0EE23904D5400E4F627 /* Settings.bundle */; };
1CB7B82123CEA1F800AA24EA /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB7B82023CEA1F800AA24EA /* DateExtension.swift */; };
1CB7B82323CEA28300AA24EA /* DateExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB7B82223CEA28300AA24EA /* DateExtensionTests.swift */; };
Expand Down Expand Up @@ -299,6 +300,7 @@
56244C1D2A137B1900EDF259 /* WaitlistViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56244C1C2A137B1900EDF259 /* WaitlistViews.swift */; };
6AC6DAB328804F97002723C0 /* BarsAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AC6DAB228804F97002723C0 /* BarsAnimator.swift */; };
6AC98419288055C1005FA9CA /* BarsAnimatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AC98418288055C1005FA9CA /* BarsAnimatorTests.swift */; };
7B5E1F9E2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5E1F9D2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift */; };
83004E802193BB8200DA013C /* WKNavigationExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83004E7F2193BB8200DA013C /* WKNavigationExtension.swift */; };
83004E862193E5ED00DA013C /* TabViewControllerBrowsingMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83004E852193E5ED00DA013C /* TabViewControllerBrowsingMenuExtension.swift */; };
83004E882193E8C700DA013C /* TabViewControllerLongPressMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83004E872193E8C700DA013C /* TabViewControllerLongPressMenuExtension.swift */; };
Expand Down Expand Up @@ -1102,6 +1104,7 @@
02CA904A24F6C11A00D41DDF /* NavigatorSharePatchUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigatorSharePatchUserScript.swift; sourceTree = "<group>"; };
02CA904C24FD2DB000D41DDF /* ContentBlockingRulesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentBlockingRulesTests.swift; sourceTree = "<group>"; };
02EC02C329AFA33000557F1A /* AppTPBreakageFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTPBreakageFormView.swift; sourceTree = "<group>"; };
02ECEC602A965074009F0654 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
0A6CC0EE23904D5400E4F627 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
1CB7B82023CEA1F800AA24EA /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
1CB7B82223CEA28300AA24EA /* DateExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtensionTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1286,6 +1289,7 @@
6AC6DAB228804F97002723C0 /* BarsAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsAnimator.swift; sourceTree = "<group>"; };
6AC98418288055C1005FA9CA /* BarsAnimatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarsAnimatorTests.swift; sourceTree = "<group>"; };
6FB030C7234331B400A10DB9 /* Configuration.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Configuration.xcconfig; path = Configuration/Configuration.xcconfig; sourceTree = "<group>"; };
7B5E1F9D2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionDebugFeatures.swift; sourceTree = "<group>"; };
83004E7F2193BB8200DA013C /* WKNavigationExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WKNavigationExtension.swift; sourceTree = "<group>"; };
83004E832193E14C00DA013C /* UIAlertControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UIAlertControllerExtension.swift; path = ../Core/UIAlertControllerExtension.swift; sourceTree = "<group>"; };
83004E852193E5ED00DA013C /* TabViewControllerBrowsingMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewControllerBrowsingMenuExtension.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3349,6 +3353,14 @@
name = AppTrackingProtection;
sourceTree = "<group>";
};
7B5E1F9C2AB9E1D000DA1172 /* DebugFeatures */ = {
isa = PBXGroup;
children = (
7B5E1F9D2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift */,
);
name = DebugFeatures;
sourceTree = "<group>";
};
830FA79B1F8E81FB00FCE105 /* ContentBlocker */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3563,6 +3575,7 @@
F1C4A70C1E5771F800A6CA1B /* OmniBar */,
F1AE54DB1F0425BB00D9A700 /* Privacy */,
1E87615728A1515400C7C5CE /* PrivacyDashboard */,
02ECEC602A965074009F0654 /* PrivacyInfo.xcprivacy */,
C1B7B51D28941F160098FD6A /* RemoteMessaging */,
F1AB2B401E3F75A000868554 /* Settings */,
0A6CC0EE23904D5400E4F627 /* Settings.bundle */,
Expand Down Expand Up @@ -4362,6 +4375,7 @@
EECD94B22A28B8580085C66E /* NetworkProtection */ = {
isa = PBXGroup;
children = (
7B5E1F9C2AB9E1D000DA1172 /* DebugFeatures */,
EE0153E22A6FE031002A8B26 /* Root */,
EE0153DF2A6EABAF002A8B26 /* Helpers */,
EEFD562D2A65B68B00DAEC48 /* Invite */,
Expand Down Expand Up @@ -5592,6 +5606,7 @@
AA4D6AA223DE4CC4007E8790 /* [email protected] in Resources */,
AA4D6AB823DE4D15007E8790 /* [email protected] in Resources */,
984147C024F026A300362052 /* Tab.storyboard in Resources */,
02F880642AB206740020C2DF /* PrivacyInfo.xcprivacy in Resources */,
AA4D6AE123DE4D33007E8790 /* [email protected] in Resources */,
AA4D6A9123DE49A5007E8790 /* [email protected] in Resources */,
AA4D6A8E23DE49A5007E8790 /* [email protected] in Resources */,
Expand Down Expand Up @@ -6126,6 +6141,7 @@
98AA92B32456FBE100ED4B9E /* SearchFieldContainerView.swift in Sources */,
3157B43827F4C8490042D3D7 /* FaviconsHelper.swift in Sources */,
85F200042216F5D8006BB258 /* FindInPageView.swift in Sources */,
7B5E1F9E2AB9E1E900DA1172 /* NetworkProtectionDebugFeatures.swift in Sources */,
8548D95E25262B1B005AAE49 /* ViewHighlighter.swift in Sources */,
F4D7221026F29A70007D6193 /* BookmarkDetailsCell.swift in Sources */,
F1617C131E572E0300DEDCAF /* TabSwitcherViewController.swift in Sources */,
Expand Down Expand Up @@ -8894,7 +8910,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 78.2.2;
version = 80.0.0;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit",
"state": {
"branch": null,
"revision": "781e68decc81dc33a6a7593ab88b1e074a8ee051",
"version": "78.2.2"
"revision": "ec5dc5931efc496aef2573b2f082607a3c82b655",
"version": "80.0.0"
}
},
{
Expand Down Expand Up @@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/duckduckgo/duckduckgo-autofill.git",
"state": {
"branch": null,
"revision": "21aa20e272b7de06e471c6e646d25e26a5887b60",
"version": "8.3.0"
"revision": "f3eccad8647fdba2b5d180a02a0513c61375b8fb",
"version": "8.4.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Alpha"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Alpha">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Alpha"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
11 changes: 7 additions & 4 deletions DuckDuckGo/EventMapping+NetworkProtectionError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,19 @@ extension EventMapping where Event == NetworkProtectionError {
.failedToDecodeServerList,
.failedToWriteServerList,
.couldNotCreateServerListDirectory,
.failedToReadServerList:
.failedToReadServerList,
.wireGuardCannotLocateTunnelFileDescriptor,
.wireGuardInvalidState,
.wireGuardDnsResolution,
.wireGuardSetNetworkSettings,
.startWireGuardBackend:
pixelEvent = .networkProtectionUnhandledError
params[PixelParameters.function] = #function
params[PixelParameters.line] = String(#line)
// Should never be sent from from the app
case .unhandledError(function: let function, line: let line, error: let error):
pixelEvent = .networkProtectionUnhandledError
params[PixelParameters.function] = function
params[PixelParameters.line] = String(line)
pixelError = error

}

DailyPixel.fireDailyAndCount(pixel: pixelEvent, error: pixelError, withAdditionalParameters: params)
Expand Down
Loading

0 comments on commit b906d12

Please sign in to comment.