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

Coupons: Remove outdated survey #14891

Merged
merged 12 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Internal] Removed feedback survey for Store Setup feature [https://github.com/woocommerce/woocommerce-ios/pull/14888]
- [Internal] Removed feedback survey for shipping label creation [https://github.com/woocommerce/woocommerce-ios/pull/14889]
- [Internal] Removed feedback survey for product creation AI [https://github.com/woocommerce/woocommerce-ios/pull/14890]
- [Internal] Removed feedback survey for coupons list [https://github.com/woocommerce/woocommerce-ios/pull/14891]

21.4
-----
Expand Down
5 changes: 0 additions & 5 deletions WooCommerce/Classes/System/WooConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ extension WooConstants {
case orderCreationFeedback = "https://automattic.survey.fm/woo-app-order-creation-production"
#endif

#if DEBUG
case couponManagementFeedback = "https://automattic.survey.fm/woo-app-coupon-management-testing"
#else
case couponManagementFeedback = "https://automattic.survey.fm/woo-app-coupon-management-production"
#endif
/// URL for the Enable Cash on Delivery (or Pay in Person) onboarding step's learn more link using the Stripe plugin
///
case stripeCashOnDeliveryLearnMore = "https://woocommerce.com/document/stripe/accept-in-person-payments-with-stripe/#section-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ struct CouponListView: UIViewControllerRepresentable {

func makeUIViewController(context: Self.Context) -> CouponListViewController {
let viewController = CouponListViewController(siteID: siteID,
showFeedbackBannerIfAppropriate: false,
emptyStateActionTitle: emptyStateActionTitle,
emptyStateAction: emptyStateAction,
onCouponSelected: onCouponSelected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,19 @@ final class CouponListViewController: UIViewController, GhostableViewController
private var subscriptions: Set<AnyCancellable> = []

private lazy var dataSource: UITableViewDiffableDataSource<Section, CouponListViewModel.CellViewModel> = makeDataSource()
private lazy var topBannerView: TopBannerView = createFeedbackBannerView()

private var onDataLoaded: ((Bool) -> Void)?
private let emptyStateAction: (() -> Void)
private let emptyStateActionTitle: String
private let onCouponSelected: ((Coupon) -> Void)

init(siteID: Int64,
showFeedbackBannerIfAppropriate: Bool,
emptyStateActionTitle: String,
onDataLoaded: ((Bool) -> Void)? = nil,
emptyStateAction: @escaping (() -> Void),
onCouponSelected: @escaping ((Coupon) -> Void)) {
self.siteID = siteID
self.viewModel = CouponListViewModel(siteID: siteID, showFeedbackBannerIfAppropriate: showFeedbackBannerIfAppropriate)
self.viewModel = CouponListViewModel(siteID: siteID)
self.onDataLoaded = onDataLoaded
self.emptyStateAction = emptyStateAction
self.emptyStateActionTitle = emptyStateActionTitle
Expand Down Expand Up @@ -101,25 +99,6 @@ final class CouponListViewController: UIViewController, GhostableViewController
}
.store(in: &subscriptions)

viewModel.$shouldDisplayFeedbackBanner
.removeDuplicates()
.sink { [weak self] isVisible in
guard let self = self else { return }
if isVisible {
// Configure header container view
let headerContainer = UIView(frame: CGRect(x: 0, y: 0, width: Int(self.tableView.frame.width), height: 0))
headerContainer.addSubview(self.topBannerView)
headerContainer.pinSubviewToSafeArea(self.topBannerView)

self.tableView.tableHeaderView = headerContainer
self.tableView.updateHeaderHeight()
} else {
self.topBannerView.removeFromSuperview()
self.tableView.tableHeaderView = nil
}
}
.store(in: &subscriptions)

viewModel.$couponViewModels
.map { viewModels -> Bool in
viewModels.isNotEmpty
Expand Down Expand Up @@ -236,39 +215,6 @@ private extension CouponListViewController {
}
)
}

func createFeedbackBannerView() -> TopBannerView {
let giveFeedbackAction = TopBannerViewModel.ActionButton(title: Localization.giveFeedbackAction) { [weak self] _ in
ServiceLocator.analytics.track(event: .featureFeedbackBanner(context: .couponManagement, action: .gaveFeedback))
self?.presentCouponsFeedback()
}
let dismissAction = TopBannerViewModel.ActionButton(title: Localization.dismissAction) { [weak self] _ in
ServiceLocator.analytics.track(event: .featureFeedbackBanner(context: .couponManagement, action: .dismissed))
self?.viewModel.dismissFeedbackBanner()
}
let expandedStateChangeHandler: (() -> Void)? = { [weak self] in
self?.tableView.updateHeaderHeight()
}
let actions = [giveFeedbackAction, dismissAction]
let viewModel = TopBannerViewModel(title: Localization.feedbackBannerTitle,
infoText: Localization.feedbackBannerContent,
icon: .speakerIcon.withRenderingMode(.alwaysTemplate),
iconTintColor: .wooCommercePurple(.shade50),
isExpanded: false,
topButton: .chevron(handler: expandedStateChangeHandler),
actionButtons: actions)
let topBannerView = TopBannerView(viewModel: viewModel)
topBannerView.translatesAutoresizingMaskIntoConstraints = false
return topBannerView
}

/// Presents coupons survey
///
func presentCouponsFeedback() {
// Present survey
let navigationController = SurveyCoordinatingController(survey: .couponManagement)
present(navigationController, animated: true, completion: nil)
}
}


Expand Down Expand Up @@ -393,12 +339,6 @@ private extension CouponListViewController {
comment: "The action button on the placeholder overlay on the coupon list screen when coupons are disabled for the store."
)

static let feedbackBannerTitle = NSLocalizedString("View and edit coupons", comment: "Title of the feedback banner on the coupon list screen")
static let feedbackBannerContent = NSLocalizedString(
"We’ve been working on making it possible to view and edit coupons from your device!",
comment: "Content of the feedback banner on the coupon list screen"
)

static let giveFeedbackAction = NSLocalizedString("Give feedback", comment: "Title of the feedback action button on the coupon list screen")
static let dismissAction = NSLocalizedString("Dismiss", comment: "Title of the dismiss action button on the coupon list screen")

Expand Down
44 changes: 0 additions & 44 deletions WooCommerce/Classes/ViewRelated/Coupons/CouponListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ final class CouponListViewModel {
///
@Published private(set) var state: CouponListState = .initialized

@Published private(set) var shouldDisplayFeedbackBanner: Bool = false

@Published private var isFeedbackBannerEnabledInAppSettings: Bool = false

/// couponViewModels: ViewModels for the cells representing Coupons
///
@Published private(set) var couponViewModels: [CellViewModel] = []
Expand Down Expand Up @@ -64,7 +60,6 @@ final class CouponListViewModel {
// MARK: - Initialization and setup
//
init(siteID: Int64,
showFeedbackBannerIfAppropriate: Bool = true,
syncingCoordinator: SyncingCoordinatorProtocol = SyncingCoordinator(),
storesManager: StoresManager = ServiceLocator.stores,
storageManager: StorageManagerType = ServiceLocator.storageManager,
Expand All @@ -78,10 +73,6 @@ final class CouponListViewModel {

configureSyncingCoordinator()
configureResultsController()

if showFeedbackBannerIfAppropriate {
configureFeedbackBannerVisibility()
}
}

func buildCouponViewModels() {
Expand Down Expand Up @@ -127,19 +118,6 @@ final class CouponListViewModel {
syncingCoordinator.ensureNextPageIsSynchronized(lastVisibleIndex: indexPath.row)
}

/// Mark feedback request as dismissed and update banner visibility
///
func dismissFeedbackBanner() {
let action = AppSettingsAction.updateFeedbackStatus(type: .couponManagement,
status: .dismissed) { [weak self] result in
if let error = result.failure {
DDLogError("⛔️ Error updating feedback visibility for coupon management: \(error)")
}
self?.isFeedbackBannerEnabledInAppSettings = false
}
storesManager.dispatch(action)
}

/// Enable coupons for the store
///
func enableCoupons() {
Expand Down Expand Up @@ -193,28 +171,6 @@ private extension CouponListViewModel {
syncingCoordinator.delegate = self
}

func configureFeedbackBannerVisibility() {
checkAppSettingsForFeedbackBannerVisibility()
$state.combineLatest($isFeedbackBannerEnabledInAppSettings)
.map { state, feedbackBannerVisibility -> Bool in
state.shouldShowTopBanner && feedbackBannerVisibility
}
.assign(to: &$shouldDisplayFeedbackBanner)
}

func checkAppSettingsForFeedbackBannerVisibility() {
let action = AppSettingsAction.loadFeedbackVisibility(type: .couponManagement) { [weak self] result in
switch result {
case .success(let visible):
self?.isFeedbackBannerEnabledInAppSettings = visible
case.failure(let error):
self?.isFeedbackBannerEnabledInAppSettings = false
DDLogError("⛔️ Error load feedback visibility for coupon management: \(error)")
}
}
storesManager.dispatch(action)
}

/// Check whether coupons are enabled for this store.
///
func loadCouponSetting(completionHandler: @escaping ((Result<Bool, Error>) -> Void)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ final class EnhancedCouponListViewController: UIViewController {
private extension EnhancedCouponListViewController {
func configureCouponListViewController() {
let couponListViewController = CouponListViewController(siteID: siteID,
showFeedbackBannerIfAppropriate: true,
emptyStateActionTitle: Localization.createCouponAction,
onDataLoaded: configureNavigationBarItems,
emptyStateAction: displayCouponTypeBottomSheet,
onCouponSelected: showDetails)
emptyStateActionTitle: Localization.createCouponAction,
onDataLoaded: configureNavigationBarItems,
emptyStateAction: displayCouponTypeBottomSheet,
onCouponSelected: showDetails)

couponListViewController.view.translatesAutoresizingMaskIntoConstraints = false
addChild(couponListViewController)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ extension SurveyViewController {
case productsFeedback
case addOnsI1
case orderCreation
case couponManagement
case orderFormShippingLines

fileprivate var url: URL {
Expand All @@ -91,11 +90,6 @@ extension SurveyViewController {
.asURL()
.tagPlatform("ios")
.tagAppVersion(Bundle.main.bundleVersion())
case .couponManagement:
return WooConstants.URLs.couponManagementFeedback
.asURL()
.tagPlatform("ios")
.tagAppVersion(Bundle.main.bundleVersion())
case .orderFormShippingLines:
return WooConstants.URLs.orderCreationShippingFeedback
.asURL()
Expand All @@ -111,7 +105,6 @@ extension SurveyViewController {
case .productsFeedback,
.addOnsI1,
.orderCreation,
.couponManagement,
.orderFormShippingLines:
return Localization.giveFeedback
}
Expand All @@ -128,8 +121,6 @@ extension SurveyViewController {
return .addOnsI1
case .orderCreation:
return .orderCreation
case .couponManagement:
return .couponManagement
case .orderFormShippingLines:
return .orderFormShippingLines
}
Expand Down
Loading