Skip to content

Commit

Permalink
Fix some issues with handling when the adapter is started up (#2496)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1206634919441353/f
macOS PR: duckduckgo/macos-browser#2251
BSK PR: duckduckgo/BrowserServicesKit#674

## Description

Fixes how we handle the event of the tunnel adapter started.  More broadly, this PR tries to ensure we don't "histerically" start and stop our monitors, since that could result in a lot of noise in our metrics.
  • Loading branch information
diegoreymendez authored Feb 24, 2024
1 parent 2700cb9 commit 592a7ba
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9908,7 +9908,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 110.0.0;
version = 110.0.1;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
{
"identity" : "browserserviceskit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "d56b90bd229288f681f0a3a6a325ef25e3ce5f3c",
"version" : "110.0.0"
"revision" : "483427db845410f10121cf2200f5a940c9bbf70b",
"version" : "110.0.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DuckUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let package = Package(
targets: ["DuckUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "110.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "110.0.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let package = Package(
],
dependencies: [
.package(path: "../DuckUI"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "110.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "110.0.1"),
.package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Waitlist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
targets: ["Waitlist", "WaitlistMocks"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "110.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "110.0.1"),
.package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0")
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
settings: settings)
startMonitoringMemoryPressureEvents()
observeServerChanges()
observeStatusChanges()
APIRequest.Headers.setUserAgent(DefaultUserAgentManager.duckDuckGoUserAgent)
}

Expand Down Expand Up @@ -259,14 +258,11 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {

private let activationDateStore = DefaultVPNWaitlistActivationDateStore()

private func observeStatusChanges() {
connectionStatusPublisher.sink { [weak self] status in
if case .connected = status {
self?.activationDateStore.setActivationDateIfNecessary()
self?.activationDateStore.updateLastActiveDate()
}
}
.store(in: &cancellables)
public override func handleConnectionStatusChange(old: ConnectionStatus, new: ConnectionStatus) {
super.handleConnectionStatusChange(old: old, new: new)

activationDateStore.setActivationDateIfNecessary()
activationDateStore.updateLastActiveDate()
}

}
Expand Down

0 comments on commit 592a7ba

Please sign in to comment.