Commit 80a15f6b by Demid Merzlyakov

Analytics: added missing events.

parent f76e0e72
...@@ -39,7 +39,7 @@ class ForecastCellFactory: CellFactoryProtocol { ...@@ -39,7 +39,7 @@ class ForecastCellFactory: CellFactoryProtocol {
//Private //Private
private var cellsToUpdate:CellsToUpdate = [.dailyTimePeriod, .hourlyTimePeriod, .dailyForecastInfoCell, .precipitation, .wind] private var cellsToUpdate:CellsToUpdate = [.dailyTimePeriod, .hourlyTimePeriod, .dailyForecastInfoCell, .precipitation, .wind]
private let forecastViewModel:ForecastViewModel private let forecastViewModel:ForecastViewModel
private var currentTimePeriod = TimePeriod.daily public var timePeriod = TimePeriod.daily
//Public //Public
var numberOfSections: Int { var numberOfSections: Int {
...@@ -47,17 +47,13 @@ class ForecastCellFactory: CellFactoryProtocol { ...@@ -47,17 +47,13 @@ class ForecastCellFactory: CellFactoryProtocol {
} }
public func numberOfRows(inSection section: Int) -> Int { public func numberOfRows(inSection section: Int) -> Int {
return currentTimePeriod == .daily ? DailyForecastCellType.allCases.count : HourlyForecastCellType.allCases.count return timePeriod == .daily ? DailyForecastCellType.allCases.count : HourlyForecastCellType.allCases.count
} }
public init(viewModel: ForecastViewModel) { public init(viewModel: ForecastViewModel) {
self.forecastViewModel = viewModel self.forecastViewModel = viewModel
} }
public func setTimePeriod(timePeriod:TimePeriod) {
self.currentTimePeriod = timePeriod
}
public func registerCells(on tableView:UITableView) { public func registerCells(on tableView:UITableView) {
registerCell(type: ForecastDailyCell.self, tableView: tableView) registerCell(type: ForecastDailyCell.self, tableView: tableView)
registerCell(type: ForecastDayCell.self, tableView: tableView) registerCell(type: ForecastDayCell.self, tableView: tableView)
...@@ -70,7 +66,7 @@ class ForecastCellFactory: CellFactoryProtocol { ...@@ -70,7 +66,7 @@ class ForecastCellFactory: CellFactoryProtocol {
} }
public func cellFromTableView(tableView:UITableView, indexPath:IndexPath) -> UITableViewCell { public func cellFromTableView(tableView:UITableView, indexPath:IndexPath) -> UITableViewCell {
switch currentTimePeriod { switch timePeriod {
case .daily: case .daily:
return dailyCellFor(tableView: tableView, indexPath: indexPath) return dailyCellFor(tableView: tableView, indexPath: indexPath)
case .hourly: case .hourly:
......
...@@ -49,11 +49,26 @@ class ForecastViewController: UIViewController { ...@@ -49,11 +49,26 @@ class ForecastViewController: UIViewController {
refreshDayButtons() refreshDayButtons()
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_FORECAST)
analyticsLogCurrentTimePeriod()
}
override func viewDidLayoutSubviews() { override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews() super.viewDidLayoutSubviews()
self.tableView.layoutTableHeaderView() self.tableView.layoutTableHeaderView()
} }
private func analyticsLogCurrentTimePeriod() {
switch forecastCellFactory.timePeriod {
case .daily:
analytics(log: .ANALYTICS_VIEW_FORECAST_EXTENDED)
case .hourly:
analytics(log: .ANALYTICS_VIEW_FORECAST_HOURLY)
}
}
private func refreshCityButton() { private func refreshCityButton() {
cityButton.configure(with: viewModel.location) cityButton.configure(with: viewModel.location)
cityButton.isHidden = false cityButton.isHidden = false
...@@ -72,9 +87,10 @@ class ForecastViewController: UIViewController { ...@@ -72,9 +87,10 @@ class ForecastViewController: UIViewController {
if self.timePeriodControl.selectedSegmentIndex != timePeriod.rawValue { if self.timePeriodControl.selectedSegmentIndex != timePeriod.rawValue {
self.timePeriodControl.selectedSegmentIndex = timePeriod.rawValue self.timePeriodControl.selectedSegmentIndex = timePeriod.rawValue
} }
forecastCellFactory.setTimePeriod(timePeriod: timePeriod) forecastCellFactory.timePeriod = timePeriod
self.forecastCellFactory.setNeedsUpdate() self.forecastCellFactory.setNeedsUpdate()
self.tableView.reloadData() self.tableView.reloadData()
analyticsLogCurrentTimePeriod()
} }
@objc private func handleSegmentDidChange() { @objc private func handleSegmentDidChange() {
......
...@@ -30,6 +30,11 @@ class NWSAlertViewController: UIViewController { ...@@ -30,6 +30,11 @@ class NWSAlertViewController: UIViewController {
prepareTableView() prepareTableView()
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_ALERT_DETAILS)
}
deinit { deinit {
if let observer = localizationObserver { if let observer = localizationObserver {
NotificationCenter.default.removeObserver(observer) NotificationCenter.default.removeObserver(observer)
......
...@@ -33,6 +33,11 @@ class NotificationsViewController: UIViewController { ...@@ -33,6 +33,11 @@ class NotificationsViewController: UIViewController {
tableView.reloadData() tableView.reloadData()
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_ALERTS)
}
deinit { deinit {
if let observer = localizationObserver { if let observer = localizationObserver {
......
...@@ -81,6 +81,11 @@ class RadarViewController: UIViewController { ...@@ -81,6 +81,11 @@ class RadarViewController: UIViewController {
initialConfigure() initialConfigure()
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_RADAR)
}
//Private //Private
private func updateUI() { private func updateUI() {
view.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor view.backgroundColor = ThemeManager.currentTheme.baseBackgroundColor
...@@ -212,6 +217,7 @@ class RadarViewController: UIViewController { ...@@ -212,6 +217,7 @@ class RadarViewController: UIViewController {
} }
isFullScreen = true isFullScreen = true
fullScreenButton.setImage(image: UIImage(named: "cross_icon")) fullScreenButton.setImage(image: UIImage(named: "cross_icon"))
analytics(log: .ANALYTICS_VIEW_RADAR_FULLSCREEN)
} }
self.view.setNeedsLayout() self.view.setNeedsLayout()
......
...@@ -35,6 +35,11 @@ class SettingsViewController: UIViewController { ...@@ -35,6 +35,11 @@ class SettingsViewController: UIViewController {
updateUI() updateUI()
} }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
analytics(log: .ANALYTICS_VIEW_SETTINGS)
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection) super.traitCollectionDidChange(previousTraitCollection)
updateUI() updateUI()
......
...@@ -61,6 +61,7 @@ class MenuViewModel: NSObject, ViewModelProtocol { ...@@ -61,6 +61,7 @@ class MenuViewModel: NSObject, ViewModelProtocol {
public func viewAboutUs() { public func viewAboutUs() {
self.delegate?.presentWebView(url: ONE_WEATHER_ABOUT_US_URL) self.delegate?.presentWebView(url: ONE_WEATHER_ABOUT_US_URL)
analytics(log: .ANALYTICS_VIEW_ABOUT)
} }
public func viewAdChoices() { public func viewAdChoices() {
......
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