Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Freemium PIR Pixel Firing for All Users #3543

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build_notarized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ on:
description: "Branch name"
required: false
type: string
skip-notify:
description: "Skip Mattermost notification"
required: false
default: false
type: boolean
secrets:
APPLE_API_KEY_BASE64:
required: true
Expand Down Expand Up @@ -360,7 +365,7 @@ jobs:
name: Send Mattermost message

needs: [export-notarized-app, create-dmg]
if: always()
if: ${{ always() && inputs.skip-notify == false }}

runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sync_end_to_end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
release-type: review
create-dmg: false
branch: ${{ github.sha }}
skip-notify: true
secrets:
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ui_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
release-type: review
create-dmg: false
branch: ${{ github.sha }}
skip-notify: true
secrets:
APPLE_API_KEY_BASE64: ${{ secrets.APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ final class FreemiumDBPPromotionViewCoordinator: ObservableObject {
/// Published property that determines whether the promotion is visible on the home page.
@Published var isHomePagePromotionVisible: Bool = false

/// The view model representing the promotion, which updates based on the user's state.
var viewModel: PromotionViewModel {
createViewModel()
/// The view model representing the promotion, which updates based on the user's state. Returns `nil` if the feature is not enabled
var viewModel: PromotionViewModel? {
guard freemiumDBPFeature.isAvailable else { return nil }
return createViewModel()
}

/// Stores whether the user has dismissed the home page promotion.
Expand Down
11 changes: 8 additions & 3 deletions DuckDuckGo/HomePage/View/HomePageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,15 @@ extension HomePage.Views {
}
}

@ViewBuilder
func freemiumPromotionView() -> some View {
PromotionView(viewModel: freemiumDBPPromotionViewCoordinator.viewModel)
.padding(.bottom, 16)
.visibility(freemiumDBPPromotionViewCoordinator.isHomePagePromotionVisible ? .visible : .gone)
if let viewModel = freemiumDBPPromotionViewCoordinator.viewModel {
PromotionView(viewModel: viewModel)
.padding(.bottom, 16)
.visibility(freemiumDBPPromotionViewCoordinator.isHomePagePromotionVisible ? .visible : .gone)
} else {
EmptyView()
}
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {
override func setUpWithError() throws {
mockUserStateManager = MockFreemiumDBPUserStateManager()
mockFeature = MockFreemiumDBPFeature()
mockFeature.featureAvailable = true
mockPresenter = MockFreemiumDBPPresenter()
mockPixelHandler = MockFreemiumDBPExperimentPixelHandler()

Expand Down Expand Up @@ -97,7 +98,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {

// When
let viewModel = sut.viewModel
viewModel.proceedAction()
viewModel!.proceedAction()

// Then
XCTAssertTrue(mockUserStateManager.didDismissHomePagePromotion)
Expand All @@ -109,7 +110,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {
func testCloseAction_dismissesPromotion_andFiresPixel() {
// When
let viewModel = sut.viewModel
viewModel.closeAction()
viewModel!.closeAction()

// Then
XCTAssertTrue(mockUserStateManager.didDismissHomePagePromotion)
Expand All @@ -124,7 +125,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {

// When
let viewModel = sut.viewModel
viewModel.proceedAction()
viewModel!.proceedAction()

// Then
XCTAssertTrue(mockUserStateManager.didDismissHomePagePromotion)
Expand All @@ -139,7 +140,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {

// When
let viewModel = sut.viewModel
viewModel.closeAction()
viewModel!.closeAction()

// Then
XCTAssertTrue(mockUserStateManager.didDismissHomePagePromotion)
Expand All @@ -154,7 +155,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {

// When
let viewModel = sut.viewModel
viewModel.proceedAction()
viewModel!.proceedAction()

// Then
XCTAssertTrue(mockUserStateManager.didDismissHomePagePromotion)
Expand All @@ -169,7 +170,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {

// When
let viewModel = sut.viewModel
viewModel.closeAction()
viewModel!.closeAction()

// Then
XCTAssertTrue(mockUserStateManager.didDismissHomePagePromotion)
Expand All @@ -185,7 +186,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {
let viewModel = sut.viewModel

// Then
XCTAssertEqual(viewModel.description, UserText.homePagePromotionFreemiumDBPPostScanEngagementResultPluralDescription(resultCount: 5, brokerCount: 2))
XCTAssertEqual(viewModel!.description, UserText.homePagePromotionFreemiumDBPPostScanEngagementResultPluralDescription(resultCount: 5, brokerCount: 2))
}

@MainActor
Expand All @@ -197,7 +198,19 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase {
let viewModel = sut.viewModel

// Then
XCTAssertEqual(viewModel.description, UserText.homePagePromotionFreemiumDBPDescriptionMarkdown)
XCTAssertEqual(viewModel!.description, UserText.homePagePromotionFreemiumDBPDescriptionMarkdown)
}

@MainActor
func testViewModel_whenFeatureNotEnabled() {
// Given
mockFeature.featureAvailable = false

// When
let viewModel = sut.viewModel

// Then
XCTAssertNil(viewModel)
}

func testNotificationObservation_updatesPromotionVisibility() {
Expand Down
Loading