Commit dad43b2e by Dmitriy Stepanets

Added analytics to widget promo controller

parent a7dbecdb
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key> <key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>2</integer>
</dict> </dict>
<key>OneWeatherWidgetExtension.xcscheme_^#shared#^_</key> <key>OneWeatherWidgetExtension.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>4</integer>
</dict> </dict>
<key>PG (Playground) 1.xcscheme</key> <key>PG (Playground) 1.xcscheme</key>
<dict> <dict>
......
...@@ -17,7 +17,6 @@ import OneWeatherCore ...@@ -17,7 +17,6 @@ import OneWeatherCore
import AppsFlyerLib import AppsFlyerLib
import OneWeatherAnalytics import OneWeatherAnalytics
import WDTWeatherSource import WDTWeatherSource
import BlendHealthSource import BlendHealthSource
import BlendFIPSSource import BlendFIPSSource
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
// //
import UIKit import UIKit
import OneWeatherAnalytics
@available(iOS 14, *) @available(iOS 14, *)
class WidgetPromotionController: UIViewController { class WidgetPromotionController: UIViewController {
//Private //Private
private let kPanTopInset: CGFloat = 10 private let kPanTopInset: CGFloat = 10
private let kScrollViewTopInset: CGFloat = 36 private let kScrollViewTopInset: CGFloat = 42
private let coordinator: WidgetPromotionCoordinator private let coordinator: WidgetPromotionCoordinator
private let controllerPanView = UIView() private let controllerPanView = UIView()
private let closeButton = UIButton() private let closeButton = UIButton()
...@@ -35,7 +36,7 @@ class WidgetPromotionController: UIViewController { ...@@ -35,7 +36,7 @@ class WidgetPromotionController: UIViewController {
let safeAreaInset = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 let safeAreaInset = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
let contentHeight = pan + kScrollViewTopInset + stackHeight + scrollViewBottomInset + footerHeight + safeAreaInset let contentHeight = pan + kScrollViewTopInset + stackHeight + scrollViewBottomInset + footerHeight + safeAreaInset
let height = min(contentHeight, UIScreen.main.bounds.height * 0.85) let height = min(contentHeight, UIScreen.main.bounds.height * 0.9)
return height return height
} }
...@@ -57,6 +58,20 @@ class WidgetPromotionController: UIViewController { ...@@ -57,6 +58,20 @@ class WidgetPromotionController: UIViewController {
prepareScrollView() prepareScrollView()
prepareStackView() prepareStackView()
updateUI() updateUI()
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_PROMO_SEEN)
#warning("--LOOK-")
//In this version the promo controller opens fully everytime
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_PROMO_EXPAND)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if scrollView.frame.height > scrollView.contentSize.height {
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_BOTTOM_SCROLLED)
}
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
...@@ -66,6 +81,7 @@ class WidgetPromotionController: UIViewController { ...@@ -66,6 +81,7 @@ class WidgetPromotionController: UIViewController {
private func close() { private func close() {
self.dismiss(animated: true) { self.dismiss(animated: true) {
self.coordinator.viewControllerDidEnd(controller: self) self.coordinator.viewControllerDidEnd(controller: self)
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_PROMO_DISMISS)
} }
} }
...@@ -78,6 +94,7 @@ class WidgetPromotionController: UIViewController { ...@@ -78,6 +94,7 @@ class WidgetPromotionController: UIViewController {
if UIApplication.shared.canOpenURL(learnURL) { if UIApplication.shared.canOpenURL(learnURL) {
UIApplication.shared.open(learnURL, options: [:]) UIApplication.shared.open(learnURL, options: [:])
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_PROMO_LEARN_CTA)
close() close()
} }
} }
...@@ -169,7 +186,7 @@ private extension WidgetPromotionController { ...@@ -169,7 +186,7 @@ private extension WidgetPromotionController {
scrollView.snp.makeConstraints { make in scrollView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalToSuperview().inset(kScrollViewTopInset) make.top.equalToSuperview().inset(kScrollViewTopInset)
make.bottom.equalTo(footerView.snp.top).offset(8) make.bottom.equalTo(footerView.snp.top).offset(-8)
} }
} }
...@@ -236,6 +253,9 @@ extension WidgetPromotionController: UIViewControllerTransitioningDelegate { ...@@ -236,6 +253,9 @@ extension WidgetPromotionController: UIViewControllerTransitioningDelegate {
@available(iOS 14, *) @available(iOS 14, *)
extension WidgetPromotionController: UIScrollViewDelegate { extension WidgetPromotionController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y == scrollView.contentSize.height - scrollView.frame.height {
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_BOTTOM_SCROLLED)
}
// if scrollView.contentOffset.y < 0 { // if scrollView.contentOffset.y < 0 {
// let originalOffsetY = UIScreen.main.bounds.height - self.view.bounds.height // let originalOffsetY = UIScreen.main.bounds.height - self.view.bounds.height
// view.frame.origin.y = originalOffsetY - (scrollView.contentOffset.y - initialTouchPoint.y) // view.frame.origin.y = originalOffsetY - (scrollView.contentOffset.y - initialTouchPoint.y)
......
...@@ -89,6 +89,12 @@ public enum AnalyticsEvent: String { ...@@ -89,6 +89,12 @@ public enum AnalyticsEvent: String {
case ANALYTICS_A9_BID_RECEIVED = "A9_BID_RECEIVED" case ANALYTICS_A9_BID_RECEIVED = "A9_BID_RECEIVED"
case ANALYTICS_AD_CLICKED = "AD_CLICKED" case ANALYTICS_AD_CLICKED = "AD_CLICKED"
case ANALYTICS_APP_OPEN = "APP_OPEN" case ANALYTICS_APP_OPEN = "APP_OPEN"
case ANALYTICS_WIDGET_PROMO_SEEN = "WIDGET_PROMO_SEEN"
case ANALYTICS_WIDGET_PROMO_DISMISS = "WIDGET_PROMO_DISMISS"
case ANALYTICS_WIDGET_PROMO_EXPAND = "WIDGET_PROMO_EXPAND"
case ANALYTICS_WIDGET_BOTTOM_SCROLLED = "WIDGET_PROMO_BOTTOM_SCROLLED"
case ANALYTICS_WIDGET_PROMO_LEARN_CTA = "WIDGET_PROMO_LEARN_CTA"
/// 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"
......
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