Skip to content

Commit

Permalink
Fix some issues with NetP pixels (#2033)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
graeme authored Sep 22, 2023
1 parent 6c76d66 commit ae9e3f4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions PacketTunnelProvider/NetworkProtectionPacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import NetworkProtection
import Common
import Core
import Networking
import NetworkExtension

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

public override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
switch reason {
case .appUpdate, .userInitiated:
break
default:
DailyPixel.fireDailyAndCount(
pixel: .networkProtectionDisconnected,
withAdditionalParameters: [PixelParameters.reason: String(reason.rawValue)]
)
}
super.stopTunnel(with: reason, completionHandler: completionHandler)
}

@objc init() {
let tokenStore = NetworkProtectionKeychainTokenStore(keychainType: .dataProtection(.unspecified),
errorEvents: nil)
Expand Down Expand Up @@ -175,9 +189,9 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
case DispatchSource.MemoryPressureEvent.normal:
break
case DispatchSource.MemoryPressureEvent.warning:
Pixel.fire(pixel: .networkProtectionMemoryWarning)
DailyPixel.fire(pixel: .networkProtectionMemoryWarning)
case DispatchSource.MemoryPressureEvent.critical:
Pixel.fire(pixel: .networkProtectionMemoryCritical)
DailyPixel.fire(pixel: .networkProtectionMemoryCritical)
default:
break
}
Expand Down

0 comments on commit ae9e3f4

Please sign in to comment.