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

Fix for survey answered event not being tracked when not setting a customerCenterActionHandler #4777

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
8 changes: 8 additions & 0 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@
354895D6267BEDE3001DC5B1 /* ReservedSubscriberAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 354895D5267BEDE3001DC5B1 /* ReservedSubscriberAttributes.swift */; };
3551E39D2C4A6A1400D27C25 /* TintedProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3551E39C2C4A6A1400D27C25 /* TintedProgressView.swift */; };
35549323269E298B005F9AE9 /* OfferingsFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35549322269E298B005F9AE9 /* OfferingsFactory.swift */; };
35617C762D5A3BC500612B7A /* FeedbackSurveyViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35617C752D5A3BC000612B7A /* FeedbackSurveyViewModelTests.swift */; };
35617C782D5A460400612B7A /* MockLoadPromotionalOfferUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35617C772D5A45F900612B7A /* MockLoadPromotionalOfferUseCase.swift */; };
356523A82CF7719C00B6E3EA /* CustomerCenterPresentationMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356523A72CF7719B00B6E3EA /* CustomerCenterPresentationMode.swift */; };
356523AA2CF885D300B6E3EA /* MockCustomerCenterPurchases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356523A92CF885CE00B6E3EA /* MockCustomerCenterPurchases.swift */; };
356523AC2CF890F400B6E3EA /* CustomerCenterEventsRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356523AB2CF890EA00B6E3EA /* CustomerCenterEventsRequestTests.swift */; };
Expand Down Expand Up @@ -1637,6 +1639,8 @@
354895D5267BEDE3001DC5B1 /* ReservedSubscriberAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservedSubscriberAttributes.swift; sourceTree = "<group>"; };
3551E39C2C4A6A1400D27C25 /* TintedProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TintedProgressView.swift; sourceTree = "<group>"; };
35549322269E298B005F9AE9 /* OfferingsFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfferingsFactory.swift; sourceTree = "<group>"; };
35617C752D5A3BC000612B7A /* FeedbackSurveyViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbackSurveyViewModelTests.swift; sourceTree = "<group>"; };
35617C772D5A45F900612B7A /* MockLoadPromotionalOfferUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockLoadPromotionalOfferUseCase.swift; sourceTree = "<group>"; };
356523A72CF7719B00B6E3EA /* CustomerCenterPresentationMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerCenterPresentationMode.swift; sourceTree = "<group>"; };
356523A92CF885CE00B6E3EA /* MockCustomerCenterPurchases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockCustomerCenterPurchases.swift; sourceTree = "<group>"; };
356523AB2CF890EA00B6E3EA /* CustomerCenterEventsRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerCenterEventsRequestTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3872,6 +3876,7 @@
FD6186522D1393E2007843DA /* Mocks */,
35A99C822CCB95950074AB41 /* SubscriptionInformationFixtures.swift */,
3544DA692C2C848E00704E9D /* CustomerCenterViewModelTests.swift */,
35617C752D5A3BC000612B7A /* FeedbackSurveyViewModelTests.swift */,
3544DA6A2C2C848E00704E9D /* ManageSubscriptionsViewModelTests.swift */,
1E2F911A2CC918ED00BDB016 /* ContactSupportUtilitiesTests.swift */,
35A99C802CCB8D530074AB41 /* PurchaseInformationTests.swift */,
Expand Down Expand Up @@ -5202,6 +5207,7 @@
FD6186522D1393E2007843DA /* Mocks */ = {
isa = PBXGroup;
children = (
35617C772D5A45F900612B7A /* MockLoadPromotionalOfferUseCase.swift */,
356523A92CF885CE00B6E3EA /* MockCustomerCenterPurchases.swift */,
FD6186532D1393FA007843DA /* MockCustomerCenterStoreKitUtilities.swift */,
);
Expand Down Expand Up @@ -6931,6 +6937,7 @@
buildActionMask = 2147483647;
files = (
8834AFA52C2B9375005A72FE /* PresentIfNeededTests.swift in Sources */,
35617C762D5A3BC500612B7A /* FeedbackSurveyViewModelTests.swift in Sources */,
887A632B2C1D177800E1A461 /* LocalizedAlertErrorTests.swift in Sources */,
887A632C2C1D177800E1A461 /* PackageVariablesTests.swift in Sources */,
887A632D2C1D177800E1A461 /* PaywallDataValidationTests.swift in Sources */,
Expand Down Expand Up @@ -6962,6 +6969,7 @@
030F918C2D55C9DC0085103F /* LocaleFinderTests.swift in Sources */,
887A633F2C1D177800E1A461 /* Template4ViewTests.swift in Sources */,
887A63402C1D177800E1A461 /* Template5ViewTests.swift in Sources */,
35617C782D5A460400612B7A /* MockLoadPromotionalOfferUseCase.swift in Sources */,
887A63412C1D177800E1A461 /* BaseSnapshotTest.swift in Sources */,
887A63422C1D177800E1A461 /* ImageLoaderTests.swift in Sources */,
887A63432C1D177800E1A461 /* LocalizationTests.swift in Sources */,
Expand Down
6 changes: 5 additions & 1 deletion RevenueCatUI/CustomerCenter/Data/FeedbackSurveyData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import RevenueCat
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
class FeedbackSurveyData: ObservableObject {
class FeedbackSurveyData: ObservableObject, Equatable {

var configuration: CustomerCenterConfigData.HelpPath.FeedbackSurvey
var path: CustomerCenterConfigData.HelpPath
Expand All @@ -36,6 +36,10 @@ class FeedbackSurveyData: ObservableObject {
self.onOptionSelected = onOptionSelected
}

static func == (lhs: FeedbackSurveyData, rhs: FeedbackSurveyData) -> Bool {
return lhs.configuration == rhs.configuration &&
lhs.path == rhs.path
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation
import RevenueCat

struct PromotionalOfferData: Identifiable {
struct PromotionalOfferData: Identifiable, Equatable {

let id = UUID()
let promotionalOffer: PromotionalOffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class FeedbackSurveyViewModel: ObservableObject {
for option: CustomerCenterConfigData.HelpPath.FeedbackSurvey.Option,
darkMode: Bool,
displayMode: CustomerCenterPresentationMode,
locale: Locale = .current,
dismissView: () -> Void
) async {
if let customerCenterActionHandler = self.customerCenterActionHandler {
trackSurveyAnswerSubmitted(option: option, darkMode: darkMode, displayMode: displayMode)
customerCenterActionHandler(.feedbackSurveyCompleted(option.id))
}
trackSurveyAnswerSubmitted(option: option, darkMode: darkMode, displayMode: displayMode, locale: locale)

self.customerCenterActionHandler?(.feedbackSurveyCompleted(option.id))

if let promotionalOffer = option.promotionalOffer,
promotionalOffer.eligible {
Expand Down Expand Up @@ -117,9 +117,10 @@ private extension FeedbackSurveyViewModel {

func trackSurveyAnswerSubmitted(option: CustomerCenterConfigData.HelpPath.FeedbackSurvey.Option,
darkMode: Bool,
displayMode: CustomerCenterPresentationMode) {
displayMode: CustomerCenterPresentationMode,
locale: Locale) {
let isSandbox = purchasesProvider.isSandbox
let surveyOptionData = CustomerCenterAnswerSubmittedEvent.Data(locale: .current,
let surveyOptionData = CustomerCenterAnswerSubmittedEvent.Data(locale: locale,
darkMode: darkMode,
isSandbox: isSandbox,
displayMode: displayMode,
Expand Down
30 changes: 15 additions & 15 deletions Sources/CustomerCenter/CustomerCenterConfigData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
// swiftlint:disable missing_docs nesting file_length type_body_length
public typealias RCColor = PaywallColor

public struct CustomerCenterConfigData {
public struct CustomerCenterConfigData: Equatable {

public let screens: [Screen.ScreenType: Screen]
public let appearance: Appearance
Expand All @@ -41,7 +41,7 @@ public struct CustomerCenterConfigData {
self.productId = productId
}

public struct Localization {
public struct Localization: Equatable {

let locale: String
let localizedStrings: [String: String]
Expand All @@ -51,7 +51,7 @@ public struct CustomerCenterConfigData {
self.localizedStrings = localizedStrings
}

public enum CommonLocalizedString: String {
public enum CommonLocalizedString: String, Equatable {

case copy = "copy"
case noThanks = "no_thanks"
Expand Down Expand Up @@ -327,7 +327,7 @@ public struct CustomerCenterConfigData {
}
}

public struct HelpPath {
public struct HelpPath: Equatable {

public let id: String
public let title: String
Expand All @@ -350,14 +350,14 @@ public struct CustomerCenterConfigData {
self.detail = detail
}

public enum PathDetail {
public enum PathDetail: Equatable {

case promotionalOffer(PromotionalOffer)
case feedbackSurvey(FeedbackSurvey)

}

public enum PathType: String {
public enum PathType: String, Equatable {

case missingPurchase = "MISSING_PURCHASE"
case refundRequest = "REFUND_REQUEST"
Expand Down Expand Up @@ -385,7 +385,7 @@ public struct CustomerCenterConfigData {

}

public enum OpenMethod: String {
public enum OpenMethod: String, Equatable {

case inApp = "IN_APP"
case external = "EXTERNAL"
Expand All @@ -403,7 +403,7 @@ public struct CustomerCenterConfigData {

}

public struct PromotionalOffer {
public struct PromotionalOffer: Equatable {

public let iosOfferId: String
public let eligible: Bool
Expand All @@ -425,7 +425,7 @@ public struct CustomerCenterConfigData {

}

public struct FeedbackSurvey {
public struct FeedbackSurvey: Equatable {

public let title: String
public let options: [Option]
Expand All @@ -435,7 +435,7 @@ public struct CustomerCenterConfigData {
self.options = options
}

public struct Option {
public struct Option: Equatable {

public let id: String
public let title: String
Expand All @@ -453,7 +453,7 @@ public struct CustomerCenterConfigData {

}

public struct Appearance {
public struct Appearance: Equatable {

public let accentColor: ColorInformation
public let textColor: ColorInformation
Expand All @@ -473,7 +473,7 @@ public struct CustomerCenterConfigData {
self.buttonBackgroundColor = buttonBackgroundColor
}

public struct ColorInformation {
public struct ColorInformation: Equatable {

public var light: RCColor?
public var dark: RCColor?
Expand Down Expand Up @@ -506,7 +506,7 @@ public struct CustomerCenterConfigData {

}

public struct Screen {
public struct Screen: Equatable {

public let type: ScreenType
public let title: String
Expand All @@ -520,7 +520,7 @@ public struct CustomerCenterConfigData {
self.paths = paths
}

public enum ScreenType: String {
public enum ScreenType: String, Equatable {
case management = "MANAGEMENT"
case noActive = "NO_ACTIVE"
case unknown
Expand All @@ -539,7 +539,7 @@ public struct CustomerCenterConfigData {

}

public struct Support {
public struct Support: Equatable {

public let email: String
public let shouldWarnCustomerToUpdate: Bool
Expand Down
Loading