Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Geoswitching pixels #2235

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ extension Pixel {
case networkProtectionWaitlistNotificationShown
case networkProtectionWaitlistNotificationLaunched

case networkProtectionGeoswitchingOpened
case networkProtectionGeoswitchingSetNearest
case networkProtectionGeoswitchingSetCustom
case networkProtectionGeoswitchingNoLocations

// MARK: remote messaging pixels

case remoteMessageShown
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9157,7 +9157,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 91.0.2;
version = 92.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": "c871e62fd8d07f9e3136948614003fbe7e582963",
"version": "91.0.2"
"revision": "11a5fb5e7bf1f4fb4e2a79ce8dbe2eb39b583495",
"version": "92.0.0"
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ extension NetworkProtectionLocationListCompositeRepository {
let settings = VPNSettings(defaults: .networkProtectionGroupDefaults)
self.init(
environment: settings.selectedEnvironment,
tokenStore: NetworkProtectionKeychainTokenStore()
tokenStore: NetworkProtectionKeychainTokenStore(),
errorEvents: .networkProtectionAppDebugEvents
)
}
}
Expand Down
7 changes: 7 additions & 0 deletions DuckDuckGo/NetworkProtectionVPNLocationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import Foundation
import Combine
import NetworkProtection
import Core

final class NetworkProtectionVPNLocationViewModel: ObservableObject {
private let locationListRepository: NetworkProtectionLocationListRepository
Expand Down Expand Up @@ -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()
Expand All @@ -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

Expand Down
Loading