Commit d24e62b4 by Dmitry Stepanets

IOS-155: Added instrumentation

parent ba553919
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
ReferencedContainer = "container:1Weather.xcodeproj"> ReferencedContainer = "container:1Weather.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<StoreKitConfigurationFileReference
identifier = "../1Weather/InApps/Configuration.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"
......
...@@ -75,10 +75,6 @@ class MenuHeaderView: UIView { ...@@ -75,10 +75,6 @@ class MenuHeaderView: UIView {
@objc private func handleBuyButton() { @objc private func handleBuyButton() {
onTapBuy?() onTapBuy?()
} }
@objc private func handleButton(button:MenuHeaderButton) {
}
} }
//MARK:- Prepare //MARK:- Prepare
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import SafariServices import SafariServices
import OneWeatherCore import OneWeatherCore
import OneWeatherAnalytics
class MenuViewController: UIViewController { class MenuViewController: UIViewController {
//Private //Private
...@@ -92,6 +93,13 @@ private extension MenuViewController { ...@@ -92,6 +93,13 @@ private extension MenuViewController {
func prepareTableViewHeader() { func prepareTableViewHeader() {
menuHeaderView.onTapBuy = { [weak self] in menuHeaderView.onTapBuy = { [weak self] in
if StoreManager.shared.removeAdsPurchased {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_UPGRADE_CARD_CLICK)
}
else {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_PREMIUM_CARD_CLICK)
}
self?.coordinator.openSubscriptions() self?.coordinator.openSubscriptions()
} }
} }
...@@ -157,6 +165,7 @@ extension MenuViewController: UITableViewDelegate { ...@@ -157,6 +165,7 @@ extension MenuViewController: UITableViewDelegate {
case .deviceId: case .deviceId:
viewModel.showDeviceId() viewModel.showDeviceId()
case .subscriptionOverview: case .subscriptionOverview:
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_PREMIUM_HAMBURGER_CLICK)
coordinator.openSubscriptionOverview() coordinator.openSubscriptionOverview()
case .restorePurchases: case .restorePurchases:
viewModel.restorePurchases() viewModel.restorePurchases()
......
...@@ -158,7 +158,7 @@ class ShortsViewController: UIViewController { ...@@ -158,7 +158,7 @@ class ShortsViewController: UIViewController {
//Check for the last row //Check for the last row
if rowIndex == viewModel.shorts.count - 1 { if rowIndex == viewModel.shorts.count - 1 {
swipeHelperView.configure(forState: .downViewedAll) swipeHelperView.configure(forState: .downViewedAll)
analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_SHORTS_NUDGE_VIEW_TYPE: "last_card"]) analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_GENERAL_TYPE: "last_card"])
UIView.animate(withDuration: 0.3) { UIView.animate(withDuration: 0.3) {
self.swipeHelperView.alpha = 1 self.swipeHelperView.alpha = 1
} }
...@@ -168,7 +168,7 @@ class ShortsViewController: UIViewController { ...@@ -168,7 +168,7 @@ class ShortsViewController: UIViewController {
if Settings.shared.shortsSwipeUpNudgeShowedCount <= ConfigManager.shared.config.shortsSwipeUpNudgeCount { if Settings.shared.shortsSwipeUpNudgeShowedCount <= ConfigManager.shared.config.shortsSwipeUpNudgeCount {
swipeHelperView.configure(forState: .upNext) swipeHelperView.configure(forState: .upNext)
analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_SHORTS_NUDGE_VIEW_TYPE: "swipe_up"]) analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_GENERAL_TYPE: "swipe_up"])
UIView.animate(withDuration: 0.3) { UIView.animate(withDuration: 0.3) {
self.swipeHelperView.alpha = 1 self.swipeHelperView.alpha = 1
} }
...@@ -190,7 +190,7 @@ class ShortsViewController: UIViewController { ...@@ -190,7 +190,7 @@ class ShortsViewController: UIViewController {
} }
private func showUnreadShortsView(willShowRowIndex index:Int) { private func showUnreadShortsView(willShowRowIndex index:Int) {
analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_SHORTS_NUDGE_VIEW_TYPE: "left_below"]) analytics(log:.ANALYTICS_SHORTS_NUDGE_VIEW, params: [.ANALYTICS_KEY_GENERAL_TYPE: "left_below"])
swipeUpCounter = 0 swipeUpCounter = 0
let unreadCount = max(0, viewModel.shorts.count - index) let unreadCount = max(0, viewModel.shorts.count - index)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// //
import UIKit import UIKit
import OneWeatherAnalytics
/// A screen where the user is thanked for purchasing a subscription. It is shown after a successful subscription purchase or if the user goes into the Menu and chooses "Premium" item there. /// A screen where the user is thanked for purchasing a subscription. It is shown after a successful subscription purchase or if the user goes into the Menu and chooses "Premium" item there.
/// https://zpl.io/aBPo75K /// https://zpl.io/aBPo75K
...@@ -34,6 +34,16 @@ class SubscriptionOverviewViewController: UIViewController { ...@@ -34,6 +34,16 @@ class SubscriptionOverviewViewController: UIViewController {
//Verify new subscription //Verify new subscription
StoreManager.shared.verifyPurchases() StoreManager.shared.verifyPurchases()
if StoreManager.shared.removeAdsPurchased {
//Pro
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_SUCCESS,
params: [.ANALYTICS_KEY_GENERAL_TYPE : "pro"])
}
else {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_SUCCESS,
params: [.ANALYTICS_KEY_GENERAL_TYPE : "regular"])
}
} }
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import UIKit import UIKit
import SnapKit import SnapKit
import StoreKit import StoreKit
import OneWeatherAnalytics
/// A screen containing buttons to purchase a subscription. /// A screen containing buttons to purchase a subscription.
/// Relevant design URLs: /// Relevant design URLs:
...@@ -85,10 +86,12 @@ extension SubscriptionStoreViewController { ...@@ -85,10 +86,12 @@ extension SubscriptionStoreViewController {
let descriptionView: UIView let descriptionView: UIView
if viewModel.isProUser { if viewModel.isProUser {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_PRO_SCREEN)
descriptionView = SubscriptionProDescriptionView() descriptionView = SubscriptionProDescriptionView()
} }
else { else {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_SCREEN)
descriptionView = SubscriptionDescriptionView(alreadyPurchased: false) descriptionView = SubscriptionDescriptionView(alreadyPurchased: false)
} }
dynamicContentView.addSubview(descriptionView) dynamicContentView.addSubview(descriptionView)
...@@ -135,6 +138,24 @@ extension SubscriptionStoreViewController: SubscriptionTopViewDelegate { ...@@ -135,6 +138,24 @@ extension SubscriptionStoreViewController: SubscriptionTopViewDelegate {
extension SubscriptionStoreViewController: SubscriptionPurchaseButtonDelegate { extension SubscriptionStoreViewController: SubscriptionPurchaseButtonDelegate {
func button(_ button: SubscriptionPurchaseButton, triggeredPurchaseOf product: SKProduct) { func button(_ button: SubscriptionPurchaseButton, triggeredPurchaseOf product: SKProduct) {
if viewModel.isProUser {
if button.subscriptionType == .yearly {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_UPGRADE_YEARLY_CLICK)
}
else {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_UPGRADE_MONTHLY_CLICK)
}
}
else {
if button.subscriptionType == .yearly {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_SUBSCRIBE_YEARLY_CLICK)
}
else {
AppAnalytics.shared.log(event: .ANALYTICS_SUBSCRIPTION_SUBSCRIBE_MONTHLY_CLICK)
}
}
viewModel.purchase(subscription: product) viewModel.purchase(subscription: product)
} }
} }
......
...@@ -20,7 +20,7 @@ class SubscriptionPurchaseButton: UIButton { ...@@ -20,7 +20,7 @@ class SubscriptionPurchaseButton: UIButton {
private let discountSubscription: SKProduct? private let discountSubscription: SKProduct?
private let subscription: SKProduct private let subscription: SKProduct
private let subscriptionType: SubscriptionPurchaseButton.SubscriptionType public let subscriptionType: SubscriptionPurchaseButton.SubscriptionType
public weak var delegate: SubscriptionPurchaseButtonDelegate? public weak var delegate: SubscriptionPurchaseButtonDelegate?
public init(type: SubscriptionPurchaseButton.SubscriptionType, subscription: SKProduct, discountSubscription: SKProduct? = nil) { public init(type: SubscriptionPurchaseButton.SubscriptionType, subscription: SKProduct, discountSubscription: SKProduct? = nil) {
......
...@@ -136,6 +136,18 @@ public enum AnalyticsEvent: String { ...@@ -136,6 +136,18 @@ public enum AnalyticsEvent: String {
case ANALYTICS_ONBOARDING_SKIP = "ONBOARDING_SKIP" case ANALYTICS_ONBOARDING_SKIP = "ONBOARDING_SKIP"
case ANALYTICS_ONBOARDING_SWIPE = "ONBOARDING_SWIPE" case ANALYTICS_ONBOARDING_SWIPE = "ONBOARDING_SWIPE"
///Premium
case ANALYTICS_SUBSCRIPTION_PREMIUM_CARD_CLICK = "PREMIUM_CARD_CLICK"
case ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_SCREEN = "VIEW_PREMIUM_SCREEN"
case ANALYTICS_SUBSCRIPTION_SUBSCRIBE_YEARLY_CLICK = "SUBSCRIBE_YEARLY_CLICK"
case ANALYTICS_SUBSCRIPTION_SUBSCRIBE_MONTHLY_CLICK = "SUBSCRIBE_MONTHLY_CLICK"
case ANALYTICS_SUBSCRIPTION_UPGRADE_CARD_CLICK = "UPGRADE_CARD_CLICK"
case ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_PRO_SCREEN = "VIEW_PREMIUM_PRO_SCREEN"
case ANALYTICS_SUBSCRIPTION_UPGRADE_YEARLY_CLICK = "UPGRADE_YEARLY_CLICK"
case ANALYTICS_SUBSCRIPTION_UPGRADE_MONTHLY_CLICK = "UPGRADE_MONTHLY_CLICK"
case ANALYTICS_SUBSCRIPTION_VIEW_PREMIUM_SUCCESS = "VIEW_PREMIUM_SUCCESS"
case ANALYTICS_SUBSCRIPTION_PREMIUM_HAMBURGER_CLICK = "PREMIUM_HAMBURGER_CLICK"
/// FTUE Funnel: User has saved his first city after installing the app. /// FTUE Funnel: User has saved his first city after installing the app.
case ANALYTICS_USER_QUALIFIED = "USER_QUALIFIED" case ANALYTICS_USER_QUALIFIED = "USER_QUALIFIED"
/// FTUE Funnel: User comes back to the app between the 3rd day after being qualified and 6th day. /// FTUE Funnel: User comes back to the app between the 3rd day after being qualified and 6th day.
......
...@@ -10,6 +10,7 @@ import Foundation ...@@ -10,6 +10,7 @@ import Foundation
public enum AnalyticsParameter: String { public enum AnalyticsParameter: String {
//TODO: rename to Swifty names. This is a legacy from the old app. //TODO: rename to Swifty names. This is a legacy from the old app.
case ANALYTICS_KEY_SOURCE = "source" case ANALYTICS_KEY_SOURCE = "source"
case ANALYTICS_KEY_GENERAL_TYPE = "type"
case ANALYTICS_KEY_CCPA_TODAY_DISMISS_ACTION = "ACTION" case ANALYTICS_KEY_CCPA_TODAY_DISMISS_ACTION = "ACTION"
case ANALYTICS_KEY_CCPA_TODAY_CCPA_EXPT_3_VERSION = "CCPA_EXPT_3_VERSION" case ANALYTICS_KEY_CCPA_TODAY_CCPA_EXPT_3_VERSION = "CCPA_EXPT_3_VERSION"
case ANALYTICS_KEY_LAST_SEEN_CITY_CITY_ID = "cityId" case ANALYTICS_KEY_LAST_SEEN_CITY_CITY_ID = "cityId"
...@@ -28,5 +29,4 @@ public enum AnalyticsParameter: String { ...@@ -28,5 +29,4 @@ public enum AnalyticsParameter: String {
case ANALYTICS_KEY_SHORTS_CARD_ID = "card_id" case ANALYTICS_KEY_SHORTS_CARD_ID = "card_id"
case ANALYTICS_KEY_SHORTS_TIME_SPENT = "time_spent" case ANALYTICS_KEY_SHORTS_TIME_SPENT = "time_spent"
case ANALYTICS_KEY_SHORTS_READ_MORE_VIEW = "view" case ANALYTICS_KEY_SHORTS_READ_MORE_VIEW = "view"
case ANALYTICS_KEY_SHORTS_NUDGE_VIEW_TYPE = "type"
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment