Make AnalyticsService mockable via `AnalyticsServiceProtocol (#5599)

* Create AnalyticsServiceProtocol and conform AnalyticsService

* Replace AnalyticsService properties and arguments with AnalyticsServiceProtocol

* Inline AnalyticsServiceMock replacing old mock

* handle more complex AnalyticsServiceMock callsites

* move documentation from AnalyticsService to AnalyticsServiceProtocol
This commit is contained in:
Michael
2026-05-20 00:23:58 -05:00
committed by GitHub
parent 946cb53559
commit 5a07c98afc
118 changed files with 1218 additions and 505 deletions
@@ -16,7 +16,7 @@ struct LocationSharingScreenCoordinatorParameters {
let timelineController: TimelineControllerProtocol
let liveLocationManager: LiveLocationManagerProtocol
let appMediator: AppMediatorProtocol
let analytics: AnalyticsService
let analytics: AnalyticsServiceProtocol
let userIndicatorController: UserIndicatorControllerProtocol
let mediaProvider: MediaProviderProtocol
}
@@ -17,7 +17,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
private let roomProxy: JoinedRoomProxyProtocol
private let timelineController: TimelineControllerProtocol
private let liveLocationManager: LiveLocationManagerProtocol
private let analytics: AnalyticsService
private let analytics: AnalyticsServiceProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
private let notificationCenter: NotificationCenter
@@ -36,7 +36,7 @@ class LocationSharingScreenViewModel: LocationSharingScreenViewModelType, Locati
roomProxy: JoinedRoomProxyProtocol,
timelineController: TimelineControllerProtocol,
liveLocationManager: LiveLocationManagerProtocol,
analytics: AnalyticsService,
analytics: AnalyticsServiceProtocol,
userIndicatorController: UserIndicatorControllerProtocol,
mediaProvider: MediaProviderProtocol,
notificationCenter: NotificationCenter = .default) {
@@ -389,15 +389,12 @@ extension LocationSharingScreenViewModel {
let roomProxy = JoinedRoomProxyMock(.init(members: .allMembers, ownUserID: RoomMemberProxyMock.mockMe.userID))
roomProxy.makeLiveLocationServiceReturnValue = liveLocationServiceMock
let appSettings = AppSettings()
let analytics = AnalyticsService.mock(settings: appSettings)
return LocationSharingScreenViewModel(interactionMode: interactionMode,
mapURLBuilder: appSettings.mapTilerConfiguration,
mapURLBuilder: AppSettings().mapTilerConfiguration,
roomProxy: roomProxy,
timelineController: MockTimelineController(),
liveLocationManager: LiveLocationManagerMock(),
analytics: analytics,
analytics: AnalyticsServiceMock.default(),
userIndicatorController: UserIndicatorControllerMock(),
mediaProvider: MediaProviderMock(configuration: .init()))
}