Skip to content

Commit

Permalink
Bugfix FXIOS-10863 Homepage telemetry fix (#23728)
Browse files Browse the repository at this point in the history
* Move when we record telemetry

* Adjust test

* Revert changes for viewWillAppearEventThrottler

* Move Experiments.events.recordEvent out of recordViewAppeared

* Revert unit test change
  • Loading branch information
lmarceau authored Dec 18, 2024
1 parent cd731c3 commit 46718b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 0 additions & 5 deletions firefox-ios/Client/Frontend/Home/HomepageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class HomepageViewModel: FeatureFlaggable, InjectedThemeUUIDIdentifiable {
weak var delegate: HomepageViewModelDelegate?
private var wallpaperManager: WallpaperManager
private var logger: Logger
private let viewWillAppearEventThrottler = Throttler(seconds: 0.5)

// Child View models
private var childViewModels: [HomepageViewModelProtocol]
Expand Down Expand Up @@ -199,10 +198,6 @@ class HomepageViewModel: FeatureFlaggable, InjectedThemeUUIDIdentifiable {
guard !viewAppeared else { return }

viewAppeared = true
// TODO: FXIOS-9428 - Need to fix issue where viewWillAppear is called twice so we can remove the throttle workaround
viewWillAppearEventThrottler.throttle {
Experiments.events.recordEvent(BehavioralTargetingEvent.homepageViewed)
}
nimbus.features.homescreenFeature.recordExposure()
TelemetryWrapper.recordEvent(category: .action,
method: .view,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class LegacyHomepageViewController:
private var collectionView: UICollectionView! = nil
private var lastContentOffsetY: CGFloat = 0
private var logger: Logger
private let viewWillAppearEventThrottler = Throttler(seconds: 0.5)

var windowUUID: WindowUUID { return tabManager.windowUUID }
var currentWindowUUID: UUID? { return windowUUID }

Expand Down Expand Up @@ -151,7 +153,12 @@ class LegacyHomepageViewController:

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
viewModel.recordViewAppeared()

// TODO: FXIOS-9428 - Need to fix issue where viewWillAppear is called twice so we can remove the throttle workaround
// This can then be moved back inside the `viewModel.recordViewAppeared()`
viewWillAppearEventThrottler.throttle {
Experiments.events.recordEvent(BehavioralTargetingEvent.homepageViewed)
}

notificationCenter.post(name: .ShowHomepage, withUserInfo: windowUUID.userInfo)
notificationCenter.post(name: .HistoryUpdated)
Expand All @@ -162,6 +169,8 @@ class LegacyHomepageViewController:

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// FXIOS-9428 - Record telemetry in viewDidAppear since viewWillAppear is sometimes triggered twice
viewModel.recordViewAppeared()

DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { [weak self] in
self?.displayWallpaperSelector()
Expand Down

0 comments on commit 46718b8

Please sign in to comment.