From 2b0a743397a4756fc8a026931f3e4bf68fa6b795 Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Tue, 19 Nov 2019 17:52:45 +0300 Subject: [PATCH] [iOS] Statistics for onboarding https://jira.mail.ru/browse/MAPSME-12295 --- .../MWMMapViewControlsManager.mm | 1 + .../PromoButton/PromoCoordinator.swift | 1 + .../Maps/Common/Statistics/StatisticsStrings.h | 17 +++++++++++++++-- iphone/Maps/Maps.xcodeproj/project.pbxproj | 4 ---- .../DeepLinkInfo/DeepLinkInfoPresenter.swift | 4 ---- .../FirstLaunch/FirstLaunchBuilder.swift | 3 +++ .../FirstLaunch/FirstLaunchController.swift | 3 --- .../FirstLaunch/FirstLaunchPresenter.swift | 7 +++---- .../PromoDiscoveryPresenter.swift | 12 +++++++----- .../TermsOfUse/TermsOfUsePresenter.swift | 8 ++------ .../Maps/UI/Welcome/WelcomePageController.swift | 12 ------------ .../Welcome/WelcomeView/WelcomeProtocols.swift | 1 - .../WelcomeView/WelcomeViewController.swift | 4 ---- .../UI/Welcome/WhatsNew/WhatsNewPresenter.swift | 12 +++++++----- 14 files changed, 39 insertions(+), 50 deletions(-) delete mode 100644 iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchController.swift diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index a4274b922d..908ba880c7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -70,6 +70,7 @@ NSString * const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; [NSLayoutConstraint activateConstraints: @[[self.promoButton.centerXAnchor constraintEqualToAnchor:self.trafficButton.view.centerXAnchor], [self.promoButton.topAnchor constraintEqualToAnchor:self.sideButtons.view.topAnchor]]]; + [Statistics logEvent:kStatMapSponsoredButtonShow withParameters:@{kStatTarget : kStatGuidesSubscription}]; } return self; } diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift index 5abe69abb2..24b23f0d01 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PromoButton/PromoCoordinator.swift @@ -17,6 +17,7 @@ import UIKit func onPromoButtonPress(completion: @escaping () -> Void) { presentPromoDiscoveryOnboarding(completion: completion) + Statistics.logEvent(kStatMapSponsoredButtonClick, withParameters: [kStatTarget: kStatGuidesSubscription]) } private func presentPromoDiscoveryOnboarding(completion: @escaping () -> Void) { diff --git a/iphone/Maps/Common/Statistics/StatisticsStrings.h b/iphone/Maps/Common/Statistics/StatisticsStrings.h index 1fd583e2f2..7db2501980 100644 --- a/iphone/Maps/Common/Statistics/StatisticsStrings.h +++ b/iphone/Maps/Common/Statistics/StatisticsStrings.h @@ -20,6 +20,7 @@ static NSString * const kStatAddDescription = @"add_description"; static NSString * const kStatAddPlace = @"add_place"; static NSString * const kStatAfterSave = @"after_save"; static NSString * const kStatAppsflyer = @"appsflyer"; +static NSString * const kStatAgreement = @"agreement"; static NSString * const kStatAlert = @"Alert"; static NSString * const kStatAllMaps = @"all_maps"; static NSString * const kStatAlways = @"Always"; @@ -202,7 +203,7 @@ static NSString * const kStatGuestHouse = @"guestHouse"; static NSString * const kStatGuidesBookmarkSelect = @"Bookmarks_BookmarksList_Bookmark_select"; static NSString * const kStatGuidesShown = @"Bookmarks_Downloaded_Guides_list"; static NSString * const kStatGuidesOpen = @"Bookmarks_Downloaded_Guide_open"; -static NSString * const kStatGuidesSubscription = @"GuidesSubscription"; +static NSString * const kStatGuidesSubscription = @"OnboardingGuidesSubscription"; static NSString * const kStatGuidesTrackSelect = @"Bookmarks_BookmarksList_Track_select"; static NSString * const kStatHasAuthorization = @"has_auth"; static NSString * const kStatHelp = @"Help"; @@ -247,6 +248,8 @@ static NSString * const kStatLocation = @"Location"; static NSString * const kStatLogout = @"Logout"; static NSString * const kStatMakeInvisibleOnMap = @"make_invisible_on_map"; static NSString * const kStatMap = @"map"; +static NSString * const kStatMapSponsoredButtonShow = @"Map_SponsoredButton_show"; +static NSString * const kStatMapSponsoredButtonClick = @"Map_SponsoredButton_click"; static NSString * const kStatMapDataSize = @"map_data_size"; static NSString * const kStatMapSearch = @"Map search"; static NSString * const kStatMapViewStyle = @"Map view style"; @@ -299,6 +302,15 @@ static NSString * const kStatOn = @"On"; static NSString * const kStatOnboardingDlShow= @"OnboardingDeeplinkScreen_show"; static NSString * const kStatOnboardingDlAccept = @"OnboardingDeeplinkScreen_accept"; static NSString * const kStatOnboardingGuidesSubscription = @"onboarding_guides_subscription"; +static NSString * const kStatOnboardingScreenShow = @"OnboardingScreen_show"; +static NSString * const kStatOnboardingScreenAccept = @"OnboardingScreen_accept"; +static NSString * const kStatOnboardingScreenDecline = @"OnboardingScreen_decline"; +static NSString * const kStatOnboardingDream = @"dream_and_plan"; +static NSString * const kStatOnboardingExperience = @"experience"; +static NSString * const kStatOnboardingShare = @"share_emotions"; +static NSString * const kStatOnboardingCatalog = @"catalog_discovery"; +static NSString * const kStatOnboardingSubscription = @"buy_subscription"; +static NSString * const kStatOnboardingSample = @"sample_discovery"; static NSString * const kStatOnline = @"online"; static NSString * const kStatOpen = @"Open"; static NSString * const kStatOpenActionSheet = @"Open action sheet"; @@ -505,11 +517,12 @@ static NSString * const kStatUserInterrupted = @"user_interrupted"; static NSString * const kStatValue = @"Value"; static NSString * const kStatVehicle = @"Vehicle"; static NSString * const kStatVendor = @"vendor"; +static NSString * const kStatVersion = @"version"; static NSString * const kStatVezet = @"Vezet"; static NSString * const kStatViewOnMap = @"view_on_map"; static NSString * const kStatVisible = @"Visible"; static NSString * const kStatWebView = @"webview"; -static NSString * const kStatWhatsNew = @"What's New"; +static NSString * const kStatWhatsNew = @"WhatsNew_action"; static NSString * const kStatWifi = @"wifi"; static NSString * const kStatWikipedia = @"wikipedia"; static NSString * const kStatYandex = @"Yandex"; diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index aa5e207080..8f175802e1 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -599,7 +599,6 @@ 995739042355CAA30019AEE7 /* PageIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 995739032355CAA30019AEE7 /* PageIndicator.swift */; }; 995739062355CAC40019AEE7 /* ImageViewCrossDisolve.swift in Sources */ = {isa = PBXBuildFile; fileRef = 995739052355CAC40019AEE7 /* ImageViewCrossDisolve.swift */; }; 995739082355CB660019AEE7 /* AllPassSubscriptionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 995739072355CB660019AEE7 /* AllPassSubscriptionViewController.swift */; }; - 9975225A236B187400ADF673 /* FirstLaunchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99752259236B187400ADF673 /* FirstLaunchController.swift */; }; 999D3A67237BFA4600C5F7A8 /* SubscriptionViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999D3A66237BFA4600C5F7A8 /* SubscriptionViewBuilder.swift */; }; 99B6A74C2362F5AA002C94CB /* PromoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99B6A74B2362F5AA002C94CB /* PromoButton.swift */; }; 99B6A74E2362F5CD002C94CB /* PromoCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99B6A74D2362F5CD002C94CB /* PromoCoordinator.swift */; }; @@ -1682,7 +1681,6 @@ 9957FAE0237AE04900855F48 /* MWMMapViewControlsManager+AddPlace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MWMMapViewControlsManager+AddPlace.h"; sourceTree = ""; }; 9957FAE3237AE3CF00855F48 /* DeepLinkCatalogueStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkCatalogueStrategy.swift; sourceTree = ""; }; 9957FAEA237AF22800855F48 /* DeepLinkIncorrectStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkIncorrectStrategy.swift; sourceTree = ""; }; - 99752259236B187400ADF673 /* FirstLaunchController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstLaunchController.swift; sourceTree = ""; }; 999D3A60237B088C00C5F7A8 /* DeepLinkSubscriptionStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkSubscriptionStrategy.swift; sourceTree = ""; }; 999D3A66237BFA4600C5F7A8 /* SubscriptionViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionViewBuilder.swift; sourceTree = ""; }; 999D3A68237C0ADD00C5F7A8 /* DeepLinkMapStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinkMapStrategy.swift; sourceTree = ""; }; @@ -3828,7 +3826,6 @@ children = ( 99CB34952369C281001D28AD /* FirstLaunchBuilder.swift */, 99CB34972369C291001D28AD /* FirstLaunchPresenter.swift */, - 99752259236B187400ADF673 /* FirstLaunchController.swift */, ); path = FirstLaunch; sourceTree = ""; @@ -5885,7 +5882,6 @@ 34AB66531FC5AA330078E451 /* MWMiPadRoutePreview.m in Sources */, 3454D7E31E07F045004AF2AD /* UITextView+RuntimeAttributes.m in Sources */, F6A2184A1CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm in Sources */, - 9975225A236B187400ADF673 /* FirstLaunchController.swift in Sources */, F6E2FED61E097BA00083EBEC /* MWMSearchChangeModeView.mm in Sources */, 33603C85219F0F6300B11FFE /* SharingPropertiesViewController.swift in Sources */, 47699A0821F08E37009E6585 /* NSDate+TimeDistance.m in Sources */, diff --git a/iphone/Maps/UI/Welcome/DeepLinkInfo/DeepLinkInfoPresenter.swift b/iphone/Maps/UI/Welcome/DeepLinkInfo/DeepLinkInfoPresenter.swift index 54e89ed52a..7f196c873c 100644 --- a/iphone/Maps/UI/Welcome/DeepLinkInfo/DeepLinkInfoPresenter.swift +++ b/iphone/Maps/UI/Welcome/DeepLinkInfo/DeepLinkInfoPresenter.swift @@ -46,10 +46,6 @@ extension DeepLinkInfoPresenter: IDeepLinkInfoPresenter { Statistics.logEvent(kStatOnboardingDlAccept, withParameters: [kStatType : host]) } - func key() -> String { - return "" - } - func onClose() { } diff --git a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchBuilder.swift b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchBuilder.swift index 6361623978..64517de9bf 100644 --- a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchBuilder.swift +++ b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchBuilder.swift @@ -5,18 +5,21 @@ class FirstLaunchBuilder { title: "new_onboarding_step2_header", text: "new_onboarding_step2_message", buttonNextTitle: "new_onboarding_button", + statType: kStatOnboardingDream, isCloseButtonHidden: true, requestPermission: .nothing), FirstLaunchPresenter.FirstLaunchConfig(image: UIImage(named: "img_onboarding_offlinemaps"), title: "new_onboarding_step3_header", text: "new_onboarding_step3_message", buttonNextTitle: "new_onboarding_button", + statType: kStatOnboardingExperience, isCloseButtonHidden: true, requestPermission: .notifications), FirstLaunchPresenter.FirstLaunchConfig(image: UIImage(named: "img_onboarding_sharebookmarks"), title: "new_onboarding_step4_header", text: "new_onboarding_step4_message", buttonNextTitle: "new_onboarding_button_2", + statType: kStatOnboardingShare, isCloseButtonHidden: true, requestPermission: .location), ] diff --git a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchController.swift b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchController.swift deleted file mode 100644 index a63eb04906..0000000000 --- a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchController.swift +++ /dev/null @@ -1,3 +0,0 @@ -class FirstLaunchController: WelcomeViewController { - class var key: String { return toString(self) } -} diff --git a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift index d8ee5aba55..fb9c195871 100644 --- a/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift +++ b/iphone/Maps/UI/Welcome/FirstLaunch/FirstLaunchPresenter.swift @@ -13,6 +13,7 @@ class FirstLaunchPresenter { var title: String var text: String var buttonNextTitle: String + var statType: String var isCloseButtonHidden: Bool let requestPermission: Permission } @@ -35,10 +36,6 @@ extension FirstLaunchPresenter: IFirstLaunchPresenter { viewController?.configure(config: config) } - func key() -> String { - return FirstLaunchController.key - } - func onAppear() { switch config.requestPermission { case .location: @@ -52,9 +49,11 @@ extension FirstLaunchPresenter: IFirstLaunchPresenter { func onNext() { router.onNext() + Statistics.logEvent(kStatOnboardingScreenShow, withParameters: [kStatType: config.statType]) } func onClose() { router.onClose() + Statistics.logEvent(kStatOnboardingScreenAccept, withParameters: [kStatType: config.statType]) } } diff --git a/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift b/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift index c35dfc92e4..9ed47f956b 100644 --- a/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift +++ b/iphone/Maps/UI/Welcome/PromoDiscovery/PromoDiscoveryPresenter.swift @@ -6,6 +6,7 @@ class PromoDiscoveryPresenter { private weak var viewController: IWelcomeView? private let router: IPromoDiscoveryRouter private let campaign: PromoDiscoveryCampaign + private var statType: String = "" init(viewController: IWelcomeView, router: IPromoDiscoveryRouter, @@ -24,32 +25,33 @@ extension PromoDiscoveryPresenter: IPromoRouterPresenter { viewController?.setTitle(L("new_onboarding_step5.1_header")) viewController?.setText(L("new_onboarding_step5.1_message")) viewController?.setNextButtonTitle(L("new_onboarding_step5.1_button")) + statType = kStatOnboardingCatalog case .buySubscription: viewController?.setTitleImage(UIImage(named: "img_onboarding_subscribeguides")) viewController?.setTitle(L("new_onboarding_step5.1_header")) viewController?.setText(L("new_onboarding_step5.2_message")) viewController?.setNextButtonTitle(L("new_onboarding_step5.2_button")) + statType = kStatOnboardingSubscription case .downloadSamples: viewController?.setTitleImage(UIImage(named: "img_onboarding_samples")) viewController?.setTitle(L("new_onboarding_step5.1_header")) viewController?.setText(L("new_onboarding_step5.3_message")) viewController?.setNextButtonTitle(L("new_onboarding_step5.3_button")) + statType = kStatOnboardingSample } } - func key() -> String { - return "" - } - func onAppear() { - + Statistics.logEvent(kStatOnboardingScreenShow, withParameters: [kStatType: statType]) } func onNext() { router.presentNext() + Statistics.logEvent(kStatOnboardingScreenAccept, withParameters: [kStatType: statType]) } func onClose() { router.dissmiss() + Statistics.logEvent(kStatOnboardingScreenDecline, withParameters: [kStatType: statType]) } } diff --git a/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUsePresenter.swift b/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUsePresenter.swift index 029fab96ec..8d40ddbae2 100644 --- a/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUsePresenter.swift +++ b/iphone/Maps/UI/Welcome/TermsOfUse/TermsOfUsePresenter.swift @@ -25,12 +25,8 @@ extension TermsOfUsePresenter: ITermsOfUsePresenter { view?.setTermsOfUseTitle(String(coreFormat: L("sign_agree_tof_gdpr"), arguments: [termsOfUseLink])) } - func key() -> String { - return "" - } - func onAppear() { - Statistics.logEvent("OnStart_MapsMeConsent_shown") + Statistics.logEvent(kStatOnboardingScreenShow, withParameters: [kStatType: kStatAgreement]) } func onNext() { @@ -39,7 +35,7 @@ extension TermsOfUsePresenter: ITermsOfUsePresenter { WelcomeStorage.termsOfUseLink = termsOfUseLink WelcomeStorage.acceptTime = Date() router.onNext() - Statistics.logEvent("OnStart_MapsMeConsent_accepted") + Statistics.logEvent(kStatOnboardingScreenAccept, withParameters: [kStatType: kStatAgreement]) } func onClose() { diff --git a/iphone/Maps/UI/Welcome/WelcomePageController.swift b/iphone/Maps/UI/Welcome/WelcomePageController.swift index b0e1d39b5b..c4b80858ff 100644 --- a/iphone/Maps/UI/Welcome/WelcomePageController.swift +++ b/iphone/Maps/UI/Welcome/WelcomePageController.swift @@ -88,17 +88,9 @@ final class WelcomePageController: UIPageViewController { func nextPage() { currentController = pageViewController(self, viewControllerAfter: currentController) - if let controller = currentController as? WelcomeViewController { - Statistics.logEvent(kStatEventName(kStatWhatsNew, controller.key), - withParameters: [kStatAction: kStatNext]) - } } func close() { - if let controller = currentController as? WelcomeViewController { - Statistics.logEvent(kStatEventName(kStatWhatsNew, controller.key), - withParameters: [kStatAction: kStatClose]) - } iPadBackgroundView?.removeFromSuperview() view.removeFromSuperview() removeFromParent() @@ -107,10 +99,6 @@ final class WelcomePageController: UIPageViewController { } @objc func show() { - if let controller = currentController as? WelcomeViewController { - Statistics.logEvent(kStatEventName(kStatWhatsNew, controller.key), - withParameters: [kStatAction: kStatOpen]) - } parentController.addChildViewController(self) parentController.view.addSubview(view) updateFrame() diff --git a/iphone/Maps/UI/Welcome/WelcomeView/WelcomeProtocols.swift b/iphone/Maps/UI/Welcome/WelcomeView/WelcomeProtocols.swift index ece457220c..9d40a27ac7 100644 --- a/iphone/Maps/UI/Welcome/WelcomeView/WelcomeProtocols.swift +++ b/iphone/Maps/UI/Welcome/WelcomeView/WelcomeProtocols.swift @@ -8,7 +8,6 @@ protocol IWelcomeConfig { protocol IWelcomePresenter: class { func configure() - func key() -> String func onAppear() func onNext() func onClose() diff --git a/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift b/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift index ba1612a758..caae066e26 100644 --- a/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift +++ b/iphone/Maps/UI/Welcome/WelcomeView/WelcomeViewController.swift @@ -51,10 +51,6 @@ class WelcomeViewController: MWMViewController, UIAdaptivePresentationController @IBAction func onCloseButton(_ sender: UIButton) { presenter?.onClose() } - - var key: String { - return presenter?.key() ?? "" - } } extension WelcomeViewController: IWelcomeView { diff --git a/iphone/Maps/UI/Welcome/WhatsNew/WhatsNewPresenter.swift b/iphone/Maps/UI/Welcome/WhatsNew/WhatsNewPresenter.swift index 08901dc189..908dbba2c2 100644 --- a/iphone/Maps/UI/Welcome/WhatsNew/WhatsNewPresenter.swift +++ b/iphone/Maps/UI/Welcome/WhatsNew/WhatsNewPresenter.swift @@ -14,6 +14,7 @@ class WhatsNewPresenter { private weak var view: IWelcomeView? private let router: WelcomeRouter private let config: WhatsNewConfig + private let appVersion = AppInfo.shared()?.bundleVersion ?? "" init(view: IWelcomeView, router: WelcomeRouter, config: WhatsNewConfig) { self.view = view @@ -27,19 +28,20 @@ extension WhatsNewPresenter: IWhatsNewPresenter { view?.configure(config: config) } - func key() -> String { - return WhatsNewController.key - } - func onAppear() { - + Statistics.logEvent(kStatWhatsNew, withParameters: [kStatAction: kStatOpen, + kStatVersion: appVersion]) } func onNext() { router.onNext() + Statistics.logEvent(kStatWhatsNew, withParameters: [kStatAction: kStatNext, + kStatVersion: appVersion]) } func onClose() { router.onClose() + Statistics.logEvent(kStatWhatsNew, withParameters: [kStatAction: kStatClose, + kStatVersion: appVersion]) } }