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

chore: add help us improve option in profile #45

Merged
merged 1 commit into from
Jul 26, 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
2 changes: 2 additions & 0 deletions Core/Core/Analytics/CoreAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public enum AnalyticsEvent: String {
case logistrationSignIn = "Logistration:Sign In"
case logistrationRegister = "Logistration:Register"
case profileEdit = "Profile:Edit Profile"
case profilehelpUsImprove = "Profile:Feedback Form Clicked"
}

public enum EventBIValue: String {
Expand Down Expand Up @@ -410,6 +411,7 @@ public enum EventBIValue: String {
case logistrationSignIn = "edx.bi.app.logistration.signin"
case logistrationRegister = "edx.bi.app.logistration.register"
case profileEdit = "edx.bi.app.profile.edit"
case profilehelpUsImprove = "edx.bi.app.profile.feedback_form.clicked"
}

public struct EventParamKey {
Expand Down
10 changes: 9 additions & 1 deletion Core/Core/Configuration/ServerConfig/ServerConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import Foundation

private enum Keys: String, RawStringExtractable {
case valuePropEnabled = "value_prop_enabled"
case feedbackFormURL = "feedback_form_url"
}

public protocol ServerConfigProtocol {
var valuePropEnabled: Bool { get }
var iapConfig: IAPConfig { get }
func initialize(serverConfig: String?)
var feedbackURL: URL? { get }
}

public class ServerConfig: ServerConfigProtocol {
Expand All @@ -32,7 +34,11 @@ public class ServerConfig: ServerConfigProtocol {
}

public var valuePropEnabled: Bool {
return config[Keys.valuePropEnabled] as? Bool ?? false
config[Keys.valuePropEnabled] as? Bool ?? false
}

public var feedbackURL: URL? {
(config[Keys.feedbackFormURL] as? String).flatMap { URL(string: $0)}
}
}

Expand All @@ -53,6 +59,8 @@ public class ServerConfigProtocolMock: ServerConfigProtocol {

}

public var feedbackURL: URL?

public init() {
valuePropEnabled = false
iapConfig = IAPConfig(dictionary: ["enabled": true, "restore_enabled": true])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Theme
import Core

private enum SupportType {
case contactSupport, tos, privacyPolicy, cookiesPolicy, sellData, faq
case contactSupport, tos, privacyPolicy, cookiesPolicy, sellData, faq, helpUsImprove
}

struct ProfileSupportInfoView: View {
Expand All @@ -31,6 +31,7 @@ struct ProfileSupportInfoView: View {
.padding(.top, 12)

VStack(alignment: .leading, spacing: 24) {
viewModel.serverConfig.feedbackURL.map(helpUsImprove)
viewModel.contactSupport().map(supportInfo)
viewModel.config.agreement.tosURL.map(terms)
viewModel.config.agreement.privacyPolicyURL.map(privacy)
Expand All @@ -46,13 +47,23 @@ struct ProfileSupportInfoView: View {
)
}

private func helpUsImprove(url: URL) -> some View {
button(
linkViewModel: .init(
url: url,
title: ProfileLocalization.helpUsImprove
),
supportType: .helpUsImprove,
identifier: "contact_support"
)
}

private func supportInfo(url: URL) -> some View {
button(
linkViewModel: .init(
url: url,
title: ProfileLocalization.contact
),
isEmailSupport: true,
supportType: .contactSupport,
identifier: "contact_support"
)
Expand Down Expand Up @@ -158,15 +169,15 @@ struct ProfileSupportInfoView: View {
@ViewBuilder
private func button(
linkViewModel: LinkViewModel,
isEmailSupport: Bool = false,
supportType: SupportType,
identifier: String
) -> some View {
Button {
guard UIApplication.shared.canOpenURL(linkViewModel.url) else {
viewModel.errorMessage = isEmailSupport ?
CoreLocalization.Error.cannotSendEmail :
CoreLocalization.Error.unknownError
viewModel.errorMessage = supportType == .contactSupport
? CoreLocalization.Error.cannotSendEmail
: CoreLocalization.Error.unknownError

return
}

Expand All @@ -175,6 +186,8 @@ struct ProfileSupportInfoView: View {
viewModel.trackEmailSupportClicked()
case .faq:
viewModel.trackFAQClicked()
case .helpUsImprove:
viewModel.trackHelpUsImprove()
default:
break
}
Expand All @@ -186,7 +199,13 @@ struct ProfileSupportInfoView: View {
.foregroundColor(Theme.Colors.textPrimary)
.font(Theme.Fonts.titleMedium)
Spacer()
Image(systemName: "chevron.right")
if supportType == .faq || supportType == .helpUsImprove {
CoreAssets.calendarAccess.swiftUIImage
.renderingMode(.template)
.foregroundStyle(Theme.Colors.textPrimary)
} else {
Image(systemName: "chevron.right")
}
}
}
.foregroundColor(.primary)
Expand Down
4 changes: 4 additions & 0 deletions Profile/Profile/Presentation/Settings/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ public class SettingsViewModel: ObservableObject {
analytics.profileTrackEvent(.userLogoutClicked, biValue: .userLogoutClicked)
}

func trackHelpUsImprove() {
analytics.profileTrackEvent(.profilehelpUsImprove, biValue: .profilehelpUsImprove)
}

@MainActor
func restorePurchases() async {
coreAnalytics.trackRestorePurchaseClicked()
Expand Down
2 changes: 2 additions & 0 deletions Profile/Profile/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum ProfileLocalization {
public static let faqTitle = ProfileLocalization.tr("Localizable", "FAQ_TITLE", fallback: "View FAQ")
/// full profile
public static let fullProfile = ProfileLocalization.tr("Localizable", "FULL_PROFILE", fallback: "full profile")
/// Help us Improve
public static let helpUsImprove = ProfileLocalization.tr("Localizable", "HELP_US_IMPROVE", fallback: "Help us Improve")
/// Profile info
public static let info = ProfileLocalization.tr("Localizable", "INFO", fallback: "Profile info")
/// limited profile
Expand Down
1 change: 1 addition & 0 deletions Profile/Profile/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"DO_NOT_SELL_INFORMATION" = "Do not sell my personal information";
"FAQ_TITLE" = "View FAQ";
"MANAGE_ACCOUNT" = "Manage Account";
"HELP_US_IMPROVE" = "Help us Improve";

"LOGOUT" = "Log out";
"SWITCH_TO" = "Switch to";
Expand Down
1 change: 1 addition & 0 deletions Profile/Profile/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"FULL_PROFILE" = "повний профіль";
"LIMITED_PROFILE" = "обмежений профіль";
"MANAGE_ACCOUNT" = "Налаштування Профілю";
"HELP_US_IMPROVE" = "Help us Improve";

"LOGOUT_ALERT.TITLE" = "Підтвердження виходу";
"LOGOUT_ALERT.TEXT" = "Ви впевнені, що бажаєте вийти?";
Expand Down
Loading