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

Better logs for promotional offer view #4336

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class LoadPromotionalOfferUseCase: LoadPromotionalOfferUseCaseType {

guard let productIdentifier = customerInfo.earliestExpiringAppStoreEntitlement()?.productIdentifier,
let subscribedProduct = await self.purchasesProvider.products([productIdentifier]).first else {
Logger.warning(Strings.could_not_offer_for_active_subscriptions)
Logger.warning(Strings.could_not_offer_for_any_active_subscriptions)
return .failure(CustomerCenterError.couldNotFindSubscriptionInformation)
}

guard let discount = subscribedProduct.discounts.first(where: {
$0.offerIdentifier == promoOfferDetails.iosOfferId
}) else {
Logger.warning(Strings.could_not_offer_for_active_subscriptions)
Logger.warning(Strings.could_not_offer_for_active_subscriptions(promoOfferDetails.iosOfferId, productIdentifier))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm not sure if these should be warnings or debug... seems like a case that may happen somewhat often if the customer is not eligible by apple? Not a strong opinion though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seems like a case that may happen somewhat often if the customer is not eligible by apple?

That will actually fail later, this will fail if the active product's discounts don't match with the promotional offers in the Customer Center config.

I actually think it could be a debug yes, I will change it

return .failure(CustomerCenterError.couldNotFindSubscriptionInformation)
}

Expand Down
10 changes: 7 additions & 3 deletions RevenueCatUI/Data/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ enum Strings {

// Customer Center
case could_not_find_subscription_information
case could_not_offer_for_active_subscriptions
case could_not_offer_for_any_active_subscriptions
case could_not_offer_for_active_subscriptions(String, String)
case error_fetching_promotional_offer(Error)
case promo_offer_not_loaded

Expand Down Expand Up @@ -176,8 +177,11 @@ extension Strings: CustomStringConvertible {
case .promo_offer_not_loaded:
return "Promotional offer details not loaded"

case .could_not_offer_for_active_subscriptions:
return "Could not find offer for any active subscription"
case .could_not_offer_for_any_active_subscriptions:
return "Could not find offer with id for any active subscription"

case .could_not_offer_for_active_subscriptions(let discount, let subscription):
return "Could not find offer with id \(discount) for active subscription \(subscription)"

}
}
Expand Down
47 changes: 40 additions & 7 deletions Tests/TestingApps/PaywallsTester/PaywallsTester/Products.storekit
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"appPolicies" : {
"eula" : "",
"policies" : [
{
"locale" : "en_US",
"policyText" : "",
"policyURL" : ""
}
]
},
"identifier" : "882C6E98",
"nonRenewingSubscriptions" : [

Expand Down Expand Up @@ -37,8 +47,8 @@
],
"settings" : {
"_failTransactionsEnabled" : false,
"_locale" : "es_ES",
"_storefront" : "ESP",
"_locale" : "en_US",
"_storefront" : "USA",
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking but any reason to change the storefront/locale? I'm ok with the change though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is intentional, should've mention it in the description. This was causing the paywalls tester to have a mix of Spanish (subscription name) and English and figured we didn't want that.

"_storeKitErrors" : [
{
"current" : null,
Expand Down Expand Up @@ -97,7 +107,21 @@
"subscriptions" : [
{
"adHocOffers" : [

{
"internalID" : "35E3C9F3",
"offerID" : "rc-cancel-offer",
"paymentMode" : "free",
"referenceName" : "rc-cancel-offer",
"subscriptionPeriod" : "P1M"
},
{
"displayPrice" : "0.99",
"internalID" : "75357B47",
"offerID" : "rc-refund-offer",
"paymentMode" : "payUpFront",
"referenceName" : "rc-refund-offer",
"subscriptionPeriod" : "P1M"
}
],
"codeOffers" : [

Expand Down Expand Up @@ -132,7 +156,10 @@
"recurringSubscriptionPeriod" : "P1M",
"referenceName" : "Monthly",
"subscriptionGroupID" : "CEEF018E",
"type" : "RecurringSubscription"
"type" : "RecurringSubscription",
"winbackOffers" : [

]
},
{
"adHocOffers" : [
Expand Down Expand Up @@ -167,7 +194,10 @@
"recurringSubscriptionPeriod" : "P1Y",
"referenceName" : "Yearly",
"subscriptionGroupID" : "CEEF018E",
"type" : "RecurringSubscription"
"type" : "RecurringSubscription",
"winbackOffers" : [

]
},
{
"adHocOffers" : [
Expand All @@ -192,13 +222,16 @@
"recurringSubscriptionPeriod" : "P1W",
"referenceName" : "Weekly",
"subscriptionGroupID" : "CEEF018E",
"type" : "RecurringSubscription"
"type" : "RecurringSubscription",
"winbackOffers" : [

]
}
]
}
],
"version" : {
"major" : 3,
"major" : 4,
"minor" : 0
}
}