Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit ae9e3f4

Browse files
authored
Fix some issues with NetP pixels (#2033)
Task/Issue URL: https://app.asana.com/0/0/1205551137818435/f Tech Design URL: CC: Description: I made a couple of mistakes when initially adding the error pixels for Network Protection. This addresses those mistakes: Not sending the disconnect pixel Not making the memory warnings daily
1 parent 6c76d66 commit ae9e3f4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

PacketTunnelProvider/NetworkProtectionPacketTunnelProvider.swift

+16-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import NetworkProtection
2222
import Common
2323
import Core
2424
import Networking
25+
import NetworkExtension
2526

2627
// Initial implementation for initial Network Protection tests. Will be fleshed out with https://app.asana.com/0/1203137811378537/1204630829332227/f
2728
final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
@@ -148,6 +149,19 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
148149
}
149150
}
150151

152+
public override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
153+
switch reason {
154+
case .appUpdate, .userInitiated:
155+
break
156+
default:
157+
DailyPixel.fireDailyAndCount(
158+
pixel: .networkProtectionDisconnected,
159+
withAdditionalParameters: [PixelParameters.reason: String(reason.rawValue)]
160+
)
161+
}
162+
super.stopTunnel(with: reason, completionHandler: completionHandler)
163+
}
164+
151165
@objc init() {
152166
let tokenStore = NetworkProtectionKeychainTokenStore(keychainType: .dataProtection(.unspecified),
153167
errorEvents: nil)
@@ -175,9 +189,9 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
175189
case DispatchSource.MemoryPressureEvent.normal:
176190
break
177191
case DispatchSource.MemoryPressureEvent.warning:
178-
Pixel.fire(pixel: .networkProtectionMemoryWarning)
192+
DailyPixel.fire(pixel: .networkProtectionMemoryWarning)
179193
case DispatchSource.MemoryPressureEvent.critical:
180-
Pixel.fire(pixel: .networkProtectionMemoryCritical)
194+
DailyPixel.fire(pixel: .networkProtectionMemoryCritical)
181195
default:
182196
break
183197
}

0 commit comments

Comments
 (0)