Skip to content

Commit

Permalink
Rolls back some bad changes
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Apr 15, 2024
1 parent 9d0cb88 commit e2fddef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extension NetworkProtectionIPCTunnelController: TunnelController {

@MainActor
func start() async {
try? await pixelKit?.fire(StartAttempt.begin)
pixelKit?.fire(StartAttempt.begin)

do {
guard try await enableLoginItems() else {
Expand All @@ -70,16 +70,16 @@ extension NetworkProtectionIPCTunnelController: TunnelController {
}

ipcClient.start()
try? await pixelKit?.fire(StartAttempt.success, frequency: .dailyAndContinuous)
pixelKit?.fire(StartAttempt.success, frequency: .dailyAndContinuous)
} catch {
os_log("🔴 IPC Controller found en error when starting the VPN: \(error)", log: .networkProtection)
try? await pixelKit?.fire(StartAttempt.failure(error), frequency: .dailyAndContinuous)
pixelKit?.fire(StartAttempt.failure(error), frequency: .dailyAndContinuous)
}
}

@MainActor
func stop() async {
try? await pixelKit?.fire(StopAttempt.begin)
pixelKit?.fire(StopAttempt.begin)

do {
guard try await enableLoginItems() else {
Expand All @@ -88,10 +88,10 @@ extension NetworkProtectionIPCTunnelController: TunnelController {
}

ipcClient.stop()
try? await pixelKit?.fire(StopAttempt.success, frequency: .dailyAndContinuous)
pixelKit?.fire(StopAttempt.success, frequency: .dailyAndContinuous)
} catch {
os_log("🔴 IPC Controller found en error when starting the VPN: \(error)", log: .networkProtection)
try? await pixelKit?.fire(StopAttempt.failure(error), frequency: .dailyAndContinuous)
pixelKit?.fire(StopAttempt.failure(error), frequency: .dailyAndContinuous)
}
}

Expand Down
24 changes: 6 additions & 18 deletions LocalPackages/PixelKit/Sources/PixelKit/PixelKitEventV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,20 @@ public protocol PixelKitEventV2: PixelKitEvent {
/// and the call to `fire` should process those properties to serialize in the requests.
///
public protocol PixelFiring {
@discardableResult
func fire(_ event: PixelKitEventV2) async throws -> Bool
func fire(_ event: PixelKitEventV2)

@discardableResult
func fire(_ event: PixelKitEventV2,
frequency: PixelKit.Frequency) async throws -> Bool
frequency: PixelKit.Frequency)
}

extension PixelKit: PixelFiring {
@discardableResult
public func fire(_ event: PixelKitEventV2) async throws -> Bool {
try await fire(event, frequency: .standard)
public func fire(_ event: PixelKitEventV2) {
fire(event, frequency: .standard)
}

@discardableResult
public func fire(_ event: PixelKitEventV2,
frequency: PixelKit.Frequency) async throws -> Bool {
try await withCheckedThrowingContinuation { continuation in
fire(event, frequency: frequency) { fired, error in
if let error {
continuation.resume(throwing: error)
return
}
frequency: PixelKit.Frequency) {

continuation.resume(returning: fired)
}
}
fire(event, frequency: frequency, onComplete: { _, _ in })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ public final class PixelKitMock: PixelFiring {
self.expectedFireCalls = expectedFireCalls
}

public func fire(_ event: PixelKitEventV2) async throws -> Bool {
try await fire(event, frequency: .standard)
public func fire(_ event: PixelKitEventV2) {
fire(event, frequency: .standard)
}

public func fire(_ event: PixelKitEventV2, frequency: PixelKit.Frequency) async throws -> Bool {
public func fire(_ event: PixelKitEventV2, frequency: PixelKit.Frequency) {
let fireCall = ExpectedFireCall(pixel: event, frequency: frequency)
actualFireCalls.append(fireCall)
return true
}

public var expectationsMet: Bool {
Expand Down

0 comments on commit e2fddef

Please sign in to comment.