-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds VPN PPro pixels. Makes sure tests all run in App Store target too
- Loading branch information
1 parent
cb3b645
commit 65fa647
Showing
7 changed files
with
217 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
LocalPackages/NetworkProtectionMac/Sources/VPNPrivacyPro/Pixels/VPNPrivacyProPixel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// VPNPrivacyProPixel.swift | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import PixelKit | ||
|
||
/// PrivacyPro pixels. | ||
/// | ||
/// Ref: https://app.asana.com/0/0/1206836019887720/f | ||
/// | ||
public enum VPNPrivacyProPixel: PixelKitEventV2 { | ||
|
||
/// Fired when PrivacyPro VPN access is revoked, and the dialog is shown. | ||
/// | ||
case vpnAccessRevokedDialogShown | ||
|
||
/// Fired only once when the VPN beta becomes disabled due to the start of PrivacyPro.. | ||
/// | ||
case vpnBetaStoppedWhenPrivacyProEnabled | ||
|
||
/// Fired only once when the thank you alert is shown. | ||
/// | ||
case vpnBetaThankYouShown | ||
|
||
public var name: String { | ||
switch self { | ||
case .vpnAccessRevokedDialogShown: | ||
return "vpn_access_revoked_dialog_shown" | ||
case .vpnBetaStoppedWhenPrivacyProEnabled: | ||
return "vpn_beta_stopped_when_privacy_pro_enabled" | ||
case .vpnBetaThankYouShown: | ||
return "privacy_pro_promotion_dialog_shown" | ||
} | ||
} | ||
|
||
public var error: Error? { | ||
nil | ||
} | ||
|
||
public var parameters: [String : String]? { | ||
nil | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
LocalPackages/NetworkProtectionMac/Tests/VPNPrivacyProTests/VPNPrivacyProPixelTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// VPNPrivacyProPixel.swift | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import PixelKit | ||
import PixelKitTestingUtilities | ||
import XCTest | ||
@testable import VPNPrivacyPro | ||
|
||
final class VPNPrivacyProPixelTests: XCTestCase { | ||
|
||
private enum TestError: CustomNSError { | ||
case testError | ||
case underlyingError | ||
|
||
/// The domain of the error. | ||
static var errorDomain: String { | ||
"testDomain" | ||
} | ||
|
||
/// The error code within the given domain. | ||
var errorCode: Int { | ||
switch self { | ||
case .testError: return 1 | ||
case .underlyingError: return 2 | ||
} | ||
} | ||
|
||
/// The user-info dictionary. | ||
var errorUserInfo: [String: Any] { | ||
switch self { | ||
case .testError: | ||
return [NSUnderlyingErrorKey: TestError.underlyingError] | ||
case .underlyingError: | ||
return [:] | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Test Firing Pixels | ||
|
||
/// This test verifies validates expectations when firing `VPNPrivacyProPixel`. | ||
/// | ||
/// This test verifies a few different things: | ||
/// - That the pixel name is not changed by mistake. | ||
/// - That when the pixel is fired its name and parameters are exactly what's expected. | ||
/// | ||
func testVPNPixelFireExpectations() { | ||
fire(VPNPrivacyProPixel.vpnAccessRevokedDialogShown, | ||
and: .expect(pixelName: "m_mac_vpn_access_revoked_dialog_shown"), | ||
file: #filePath, | ||
line: #line) | ||
fire(VPNPrivacyProPixel.vpnBetaStoppedWhenPrivacyProEnabled, | ||
and: .expect(pixelName: "m_mac_vpn_beta_stopped_when_privacy_pro_enabled"), | ||
file: #filePath, | ||
line: #line) | ||
fire(VPNPrivacyProPixel.vpnBetaThankYouShown, | ||
and: .expect(pixelName: "m_mac_privacy_pro_promotion_dialog_shown"), | ||
file: #filePath, | ||
line: #line) | ||
} | ||
} |