Commit dad43b2e by Dmitriy Stepanets

Added analytics to widget promo controller

parent a7dbecdb
......@@ -12,12 +12,12 @@
<key>OneWeatherNotificationServiceExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>2</integer>
</dict>
<key>OneWeatherWidgetExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>4</integer>
</dict>
<key>PG (Playground) 1.xcscheme</key>
<dict>
......
......@@ -17,7 +17,6 @@ import OneWeatherCore
import AppsFlyerLib
import OneWeatherAnalytics
import WDTWeatherSource
import BlendHealthSource
import BlendFIPSSource
......
......@@ -6,12 +6,13 @@
//
import UIKit
import OneWeatherAnalytics
@available(iOS 14, *)
class WidgetPromotionController: UIViewController {
//Private
private let kPanTopInset: CGFloat = 10
private let kScrollViewTopInset: CGFloat = 36
private let kScrollViewTopInset: CGFloat = 42
private let coordinator: WidgetPromotionCoordinator
private let controllerPanView = UIView()
private let closeButton = UIButton()
......@@ -35,7 +36,7 @@ class WidgetPromotionController: UIViewController {
let safeAreaInset = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0
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
}
......@@ -57,6 +58,20 @@ class WidgetPromotionController: UIViewController {
prepareScrollView()
prepareStackView()
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) {
......@@ -66,6 +81,7 @@ class WidgetPromotionController: UIViewController {
private func close() {
self.dismiss(animated: true) {
self.coordinator.viewControllerDidEnd(controller: self)
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_PROMO_DISMISS)
}
}
......@@ -78,6 +94,7 @@ class WidgetPromotionController: UIViewController {
if UIApplication.shared.canOpenURL(learnURL) {
UIApplication.shared.open(learnURL, options: [:])
AppAnalytics.shared.log(event: .ANALYTICS_WIDGET_PROMO_LEARN_CTA)
close()
}
}
......@@ -169,7 +186,7 @@ private extension WidgetPromotionController {
scrollView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
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 {
@available(iOS 14, *)
extension WidgetPromotionController: UIScrollViewDelegate {
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 {
// let originalOffsetY = UIScreen.main.bounds.height - self.view.bounds.height
// view.frame.origin.y = originalOffsetY - (scrollView.contentOffset.y - initialTouchPoint.y)
......
......@@ -89,6 +89,12 @@ public enum AnalyticsEvent: String {
case ANALYTICS_A9_BID_RECEIVED = "A9_BID_RECEIVED"
case ANALYTICS_AD_CLICKED = "AD_CLICKED"
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.
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