From 315a1477ae13aa8ca5d6a9cab098e40c72dc206e Mon Sep 17 00:00:00 2001 From: Graeme Arthur Date: Wed, 6 Dec 2023 19:19:37 +0100 Subject: [PATCH] Add Geoswitching pixels (#2235) --- Core/PixelEvent.swift | 10 ++++++++++ DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../NetworkProtectionConvenienceInitialisers.swift | 3 ++- DuckDuckGo/NetworkProtectionVPNLocationViewModel.swift | 7 +++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 621cdbd961..b5c54cf168 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -374,6 +374,11 @@ extension Pixel { case networkProtectionWaitlistNotificationShown case networkProtectionWaitlistNotificationLaunched + case networkProtectionGeoswitchingOpened + case networkProtectionGeoswitchingSetNearest + case networkProtectionGeoswitchingSetCustom + case networkProtectionGeoswitchingNoLocations + // MARK: remote messaging pixels case remoteMessageShown @@ -889,6 +894,11 @@ extension Pixel.Event { case .networkProtectionWaitlistNotificationShown: return "m_netp_waitlist_notification_shown" case .networkProtectionWaitlistNotificationLaunched: return "m_netp_waitlist_notification_launched" + case .networkProtectionGeoswitchingOpened: return "m_netp_imp_geoswitching" + case .networkProtectionGeoswitchingSetNearest: return "m_netp_ev_geoswitching_set_nearest" + case .networkProtectionGeoswitchingSetCustom: return "m_netp_ev_geoswitching_set_custom" + case .networkProtectionGeoswitchingNoLocations: return "m_netp_ev_geoswitching_no_locations" + // MARK: remote messaging pixels case .remoteMessageShown: return "m_remote_message_shown" diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 3bdff36d16..d57d1b8478 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -9157,7 +9157,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 91.0.2; + version = 92.0.0; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 5a423c6bbc..8162b05ed5 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", "state": { "branch": null, - "revision": "c871e62fd8d07f9e3136948614003fbe7e582963", - "version": "91.0.2" + "revision": "11a5fb5e7bf1f4fb4e2a79ce8dbe2eb39b583495", + "version": "92.0.0" } }, { diff --git a/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift b/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift index 193e9c959b..18e83a83a9 100644 --- a/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift +++ b/DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift @@ -83,7 +83,8 @@ extension NetworkProtectionLocationListCompositeRepository { let settings = VPNSettings(defaults: .networkProtectionGroupDefaults) self.init( environment: settings.selectedEnvironment, - tokenStore: NetworkProtectionKeychainTokenStore() + tokenStore: NetworkProtectionKeychainTokenStore(), + errorEvents: .networkProtectionAppDebugEvents ) } } diff --git a/DuckDuckGo/NetworkProtectionVPNLocationViewModel.swift b/DuckDuckGo/NetworkProtectionVPNLocationViewModel.swift index 0a13bf75cb..dfe0e162f3 100644 --- a/DuckDuckGo/NetworkProtectionVPNLocationViewModel.swift +++ b/DuckDuckGo/NetworkProtectionVPNLocationViewModel.swift @@ -22,6 +22,7 @@ import Foundation import Combine import NetworkProtection +import Core final class NetworkProtectionVPNLocationViewModel: ObservableObject { private let locationListRepository: NetworkProtectionLocationListRepository @@ -51,15 +52,18 @@ final class NetworkProtectionVPNLocationViewModel: ObservableObject { } func onViewAppeared() async { + Pixel.fire(pixel: .networkProtectionGeoswitchingOpened) await reloadList() } func onNearestItemSelection() async { + DailyPixel.fireDailyAndCount(pixel: .networkProtectionGeoswitchingSetNearest) settings.selectedLocation = .nearest await reloadList() } func onCountryItemSelection(id: String, cityId: String? = nil) async { + DailyPixel.fireDailyAndCount(pixel: .networkProtectionGeoswitchingSetCustom) let location = NetworkProtectionSelectedLocation(country: id, city: cityId) settings.selectedLocation = .location(location) await reloadList() @@ -68,6 +72,9 @@ final class NetworkProtectionVPNLocationViewModel: ObservableObject { @MainActor private func reloadList() async { guard let list = try? await locationListRepository.fetchLocationList() else { return } + if list.isEmpty { + DailyPixel.fireDailyAndCount(pixel: .networkProtectionGeoswitchingNoLocations) + } let selectedLocation = self.settings.selectedLocation let isNearestSelected = selectedLocation == .nearest