forked from organicmaps/organicmaps
[iOS] ads removal stats
This commit is contained in:
parent
dd6b3fef91
commit
c0be2a972d
7 changed files with 43 additions and 3 deletions
iphone/Maps
Common/Statistics
Core/Subscriptions
UI/Ads
|
@ -163,6 +163,16 @@ static NSString * const kStatHotel = @"hotel";
|
|||
static NSString * const kStatHotelLocation = @"hotel_location";
|
||||
static NSString * const kStatImport = @"Import";
|
||||
static NSString * const kStatIn = @"In";
|
||||
static NSString * const kStatInappBannerClose = @"Placepage_Banner_close";
|
||||
static NSString * const kStatInappCancel = @"InAppPurchase_Preview_cancel";
|
||||
static NSString * const kStatInappPay = @"InAppPurchase_Preview_pay";
|
||||
static NSString * const kStatInappPaymentError = @"InAppPurchase_Store_error";
|
||||
static NSString * const kStatInappPaymentSuccess = @"InAppPurchase_Store_success";
|
||||
static NSString * const kStatInappProductDelivered = @"InAppPurchase_Product_delivered";
|
||||
static NSString * const kStatInappSelect = @"InAppPurchase_Preview_select";
|
||||
static NSString * const kStatInappShow = @"InAppPurchase_Preview_show";
|
||||
static NSString * const kStatInappValidationSuccess = @"InAppPurchase_Validation_success";
|
||||
static NSString * const kStatInappValidationError = @"InAppPurchase_Validation_error";
|
||||
static NSString * const kStatInvalidCall = @"invalid_call";
|
||||
static NSString * const kStatIsAuthenticated = @"is_authenticated";
|
||||
static NSString * const kStatIsAuto = @"is_auto";
|
||||
|
@ -255,6 +265,7 @@ static NSString * const kStatPortrait = @"Portrait";
|
|||
static NSString * const kStatPosition = @"position";
|
||||
static NSString * const kStatPriceCategory = @"price_category";
|
||||
static NSString * const kStatProblem = @"Problem";
|
||||
static NSString * const kStatProduct = @"product";
|
||||
static NSString * const kStatProfile = @"Profile";
|
||||
static NSString * const kStatProgress = @"Progress";
|
||||
static NSString * const kStatProvider = @"Provider";
|
||||
|
@ -376,6 +387,7 @@ static NSString * const kStatUpdateAll = @"update_all";
|
|||
static NSString * const kStatUserInterrupted = @"user_interrupted";
|
||||
static NSString * const kStatValue = @"Value";
|
||||
static NSString * const kStatVehicle = @"Vehicle";
|
||||
static NSString * const kStatVendor = @"vendor";
|
||||
static NSString * const kStatViator = @"Viator.com";
|
||||
static NSString * const kStatVisible = @"Visible";
|
||||
static NSString * const kStatWhatsNew = @"What's New";
|
||||
|
@ -386,6 +398,7 @@ static NSString * const kStatZoom = @"Zoom";
|
|||
static NSString * const kStatiPad = @"iPad";
|
||||
static NSString * const kStatiPhone = @"iPhone";
|
||||
|
||||
|
||||
static inline NSString * const kStatEventName(NSString * component, NSString * action)
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@ %@", component, action];
|
||||
|
|
|
@ -12,6 +12,7 @@ typedef void (^ValidateReceiptCallback)(NSString * _Nonnull serverId, MWMValidat
|
|||
@interface MWMPurchaseManager : NSObject
|
||||
|
||||
+ (NSString * _Nonnull)adsRemovalServerId;
|
||||
+ (NSString * _Nonnull)adsRemovalVendorId;
|
||||
+ (NSArray<NSString *> * _Nonnull)productIds;
|
||||
+ (MWMPurchaseManager * _Nonnull)sharedManager;
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
return @(ADS_REMOVAL_SERVER_ID);
|
||||
}
|
||||
|
||||
+ (NSString *)adsRemovalVendorId
|
||||
{
|
||||
return @(ADS_REMOVAL_VENDOR);
|
||||
}
|
||||
|
||||
+ (NSArray *)productIds
|
||||
{
|
||||
return @[@(ADS_REMOVAL_WEEKLY_PRODUCT_ID),
|
||||
|
|
|
@ -57,8 +57,16 @@ class SubscriptionManager: NSObject {
|
|||
MWMPurchaseManager.shared()
|
||||
.validateReceipt(MWMPurchaseManager.adsRemovalServerId()) { (serverId, validationResult) in
|
||||
if validationResult == .error {
|
||||
Statistics.logEvent(kStatInappValidationError, withParameters: [kStatErrorCode : 2])
|
||||
return
|
||||
} else {
|
||||
if validationResult == .valid {
|
||||
Statistics.logEvent(kStatInappValidationSuccess)
|
||||
Statistics.logEvent(kStatInappProductDelivered,
|
||||
withParameters: [kStatVendor : MWMPurchaseManager.adsRemovalVendorId()])
|
||||
} else {
|
||||
Statistics.logEvent(kStatInappValidationError, withParameters: [kStatErrorCode : 0])
|
||||
}
|
||||
MWMPurchaseManager.shared().setAdsDisabled(validationResult == .valid)
|
||||
self.paymentQueue.transactions
|
||||
.filter { $0.transactionState == .purchased || $0.transactionState == .restored }
|
||||
|
@ -70,6 +78,8 @@ class SubscriptionManager: NSObject {
|
|||
|
||||
extension SubscriptionManager: SKProductsRequestDelegate {
|
||||
func request(_ request: SKRequest, didFailWithError error: Error) {
|
||||
Statistics.logEvent(kStatInappPaymentError,
|
||||
withParameters: [kStatError : error.localizedDescription])
|
||||
subscriptionsComplection?(nil, error)
|
||||
subscriptionsComplection = nil
|
||||
productsRequest = nil
|
||||
|
@ -121,6 +131,7 @@ extension SubscriptionManager: SKPaymentTransactionObserver {
|
|||
MWMPurchaseManager.shared().setAdsDisabled(true)
|
||||
paymentQueue.finishTransaction(transaction)
|
||||
if let ps = pendingSubscription, transaction.payment.productIdentifier == ps.productId {
|
||||
Statistics.logEvent(kStatInappPaymentSuccess)
|
||||
listeners.allObjects.forEach { $0.didSubsribe(ps) }
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +147,8 @@ extension SubscriptionManager: SKPaymentTransactionObserver {
|
|||
private func processFailed(_ transaction: SKPaymentTransaction, error: Error?) {
|
||||
paymentQueue.finishTransaction(transaction)
|
||||
if let ps = pendingSubscription, transaction.payment.productIdentifier == ps.productId {
|
||||
Statistics.logEvent(kStatInappPaymentError,
|
||||
withParameters: [kStatError : error?.localizedDescription ?? ""])
|
||||
listeners.allObjects.forEach { $0.didFailToSubscribe(ps, error: error) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,10 @@ final class AdBanner: UITableViewCell {
|
|||
}
|
||||
|
||||
@IBAction
|
||||
private func removeAction() {
|
||||
private func removeAction(_ sender: UIButton) {
|
||||
Statistics.logEvent(kStatInappBannerClose, withParameters: [
|
||||
kStatBanner : state == .detailed ? 1 : 0,
|
||||
kStatButton : sender == removeAdsLargeButton ? 1 : 0])
|
||||
onRemoveAds?()
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="removeAction" destination="WK2-gA-ocn" eventType="touchUpInside" id="dCc-Ww-mvy"/>
|
||||
<action selector="removeAction:" destination="WK2-gA-ocn" eventType="touchUpInside" id="NKe-Xb-A8N"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NKM-3R-3g1">
|
||||
|
@ -196,7 +196,7 @@
|
|||
<constraint firstAttribute="width" constant="32" id="Bmc-z7-zKC"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<action selector="removeAction" destination="WK2-gA-ocn" eventType="touchUpInside" id="Jtb-b8-Ihy"/>
|
||||
<action selector="removeAction:" destination="WK2-gA-ocn" eventType="touchUpInside" id="4YU-ca-y1D"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
|
|
|
@ -95,6 +95,8 @@
|
|||
VC.formatPrice(monthlyDiscount, locale: locale)]), for: .normal)
|
||||
self.weekButton.setTitle(String(coreFormat: L("options_dropdown_item2"),
|
||||
arguments: [VC.formatPrice(weeklyPrice ?? 0, locale: locale)]), for: .normal)
|
||||
Statistics.logEvent(kStatInappShow, withParameters: [kStatVendor : MWMPurchaseManager.adsRemovalVendorId(),
|
||||
kStatProduct : subscriptions[0].productId])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +109,7 @@
|
|||
}
|
||||
|
||||
@IBAction func onClose(_ sender: Any) {
|
||||
Statistics.logEvent(kStatInappCancel)
|
||||
delegate?.didCancelSubscribtion(self)
|
||||
}
|
||||
|
||||
|
@ -147,6 +150,8 @@
|
|||
self.delegate?.didCancelSubscribtion(self)
|
||||
return
|
||||
}
|
||||
Statistics.logEvent(kStatInappSelect, withParameters: [kStatProduct : subscription.productId])
|
||||
Statistics.logEvent(kStatInappPay)
|
||||
showPurchaseProgress()
|
||||
SubscriptionManager.shared.subscribe(to: subscription)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue