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

Add text in default language to feedbackSurveyCompleted callback #4625

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion RevenueCatUI/CustomerCenter/Data/CustomerCenterAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public enum CustomerCenterAction {
/// - Parameter refundRequestStatus: The status of the refund request
case refundRequestCompleted(_ refundRequestStatus: RefundRequestStatus)
/// An option of the feedback survey has been selected
/// - Parameter feedbackSurveyOptionId: The id of the feedback survey option selected
/// - Parameter feedbackSurveyOptionId: The id of the selected feedback survey option
case feedbackSurveyCompleted(_ feedbackSurveyOptionId: String)
/// An option of the feedback survey has been selected
/// - Parameter option: The ``CustomerCenterConfigData.HelpPath.FeedbackSurvey.Option`` that was selected
case feedbackSurveyCompletedWithOption(_ option: CustomerCenterConfigData.HelpPath.FeedbackSurvey.Option)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up changing the name of the case because I coudln't find a way where the Swift compiler wouldn't get confused.

I tried adding another parameter and keeping the name and got this:

Screenshot 2025-01-21 at 12 42 55

I also tried returning the whole option (keeping one parameter only) and got this:
Screenshot 2025-01-21 at 12 58 59

I am also concerned because Switch must be exhaustive, meaning this is a breaking change:
Screenshot 2025-01-21 at 13 03 52


}
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@ enum CustomerCenterConfigTestData {
.init(
id: "1",
title: "Too expensive",
titleInDefaultLocale: "Too expensive",
promotionalOffer: nil
),
.init(
id: "2",
title: "Don't use the app",
titleInDefaultLocale: "Don't use the app",
promotionalOffer: nil
),
.init(
id: "3",
title: "Bought by mistake",
titleInDefaultLocale: "Bought by mistake",
promotionalOffer: nil
)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class FeedbackSurveyViewModel: ObservableObject {
if let customerCenterActionHandler = self.customerCenterActionHandler {
trackSurveyAnswerSubmitted(option: option, darkMode: darkMode, displayMode: displayMode)
customerCenterActionHandler(.feedbackSurveyCompleted(option.id))
customerCenterActionHandler(.feedbackSurveyCompletedWithOption(option))
}

if let promotionalOffer = option.promotionalOffer,
Expand Down
9 changes: 7 additions & 2 deletions Sources/CustomerCenter/CustomerCenterConfigData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,16 @@ public struct CustomerCenterConfigData {

public let id: String
public let title: String
public let titleInDefaultLocale: String
public let promotionalOffer: PromotionalOffer?

public init(id: String, title: String, promotionalOffer: PromotionalOffer?) {
public init(id: String,
title: String,
titleInDefaultLocale: String,
promotionalOffer: PromotionalOffer?) {
self.id = id
self.title = title
self.titleInDefaultLocale = titleInDefaultLocale
self.promotionalOffer = promotionalOffer
}

Expand Down Expand Up @@ -541,12 +546,12 @@ extension CustomerCenterConfigData.HelpPath.FeedbackSurvey.Option {
init(from response: CustomerCenterConfigResponse.HelpPath.FeedbackSurvey.Option) {
self.id = response.id
self.title = response.title
self.titleInDefaultLocale = response.titleInDefaultLocale
if let promotionalOffer = response.promotionalOffer {
self.promotionalOffer = CustomerCenterConfigData.HelpPath.PromotionalOffer(from: promotionalOffer)
} else {
self.promotionalOffer = nil
}

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct CustomerCenterConfigResponse {

let id: String
let title: String
let titleInDefaultLocale: String
let promotionalOffer: PromotionalOffer?

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ extension SamplePaywallsList {
print("CustomerCenter: refundRequestCompleted. Result: \(status)")
case .feedbackSurveyCompleted(let surveyOptionID):
print("CustomerCenter: feedbackSurveyCompleted. Result: \(surveyOptionID)")
case .feedbackSurveyCompletedWithOption(let option):
print("CustomerCenter: feedbackSurveyCompleted. Result: \(option)")
}
}
}
Expand Down