mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
Remove the BugReportService from the ServiceLocator.
It is directly injected everywhere now.
This commit is contained in:
@@ -40,7 +40,6 @@ class AccessibilityTestsAppCoordinator: AppCoordinatorProtocol {
|
|||||||
AppSettings.configureWithSuiteName("io.element.elementx.accessibilitytests")
|
AppSettings.configureWithSuiteName("io.element.elementx.accessibilitytests")
|
||||||
AppSettings.resetAllSettings()
|
AppSettings.resetAllSettings()
|
||||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||||
ServiceLocator.shared.register(bugReportService: BugReportServiceMock(.init()))
|
|
||||||
|
|
||||||
let analyticsClient = AnalyticsClientMock()
|
let analyticsClient = AnalyticsClientMock()
|
||||||
analyticsClient.isRunning = false
|
analyticsClient.isRunning = false
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
private let appSettings: AppSettings
|
private let appSettings: AppSettings
|
||||||
private let appDelegate: AppDelegate
|
private let appDelegate: AppDelegate
|
||||||
private let appHooks: AppHooks
|
private let appHooks: AppHooks
|
||||||
|
private let bugReportService: BugReportServiceProtocol
|
||||||
private let elementCallService: ElementCallServiceProtocol
|
private let elementCallService: ElementCallServiceProtocol
|
||||||
|
|
||||||
/// Common background task to continue long-running tasks in the background.
|
/// Common background task to continue long-running tasks in the background.
|
||||||
@@ -115,8 +116,13 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
notificationManager = NotificationManager(notificationCenter: UNUserNotificationCenter.current(),
|
notificationManager = NotificationManager(notificationCenter: UNUserNotificationCenter.current(),
|
||||||
appSettings: appSettings)
|
appSettings: appSettings)
|
||||||
|
|
||||||
|
bugReportService = BugReportService(rageshakeURLPublisher: appSettings.bugReportRageshakeURL.publisher,
|
||||||
|
applicationID: appSettings.bugReportApplicationID,
|
||||||
|
sdkGitSHA: sdkGitSha(),
|
||||||
|
maxUploadSize: appSettings.bugReportMaxUploadSize,
|
||||||
|
appHooks: appHooks)
|
||||||
Self.setupServiceLocator(appSettings: appSettings, appHooks: appHooks)
|
Self.setupServiceLocator(appSettings: appSettings, appHooks: appHooks)
|
||||||
Self.setupSentry(appSettings: appSettings)
|
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings)
|
||||||
|
|
||||||
ServiceLocator.shared.analytics.signpost.start()
|
ServiceLocator.shared.analytics.signpost.start()
|
||||||
ServiceLocator.shared.analytics.startIfEnabled()
|
ServiceLocator.shared.analytics.startIfEnabled()
|
||||||
@@ -151,8 +157,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
|
|
||||||
appSettings.$analyticsConsentState
|
appSettings.$analyticsConsentState
|
||||||
.dropFirst() // Called above before configuring the ServiceLocator
|
.dropFirst() // Called above before configuring the ServiceLocator
|
||||||
.sink { _ in
|
.sink { [bugReportService] _ in
|
||||||
Self.setupSentry(appSettings: appSettings)
|
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings)
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
@@ -375,11 +381,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
private static func setupServiceLocator(appSettings: AppSettings, appHooks: AppHooks) {
|
private static func setupServiceLocator(appSettings: AppSettings, appHooks: AppHooks) {
|
||||||
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController())
|
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController())
|
||||||
ServiceLocator.shared.register(appSettings: appSettings)
|
ServiceLocator.shared.register(appSettings: appSettings)
|
||||||
ServiceLocator.shared.register(bugReportService: BugReportService(rageshakeURLPublisher: appSettings.bugReportRageshakeURL.publisher,
|
|
||||||
applicationID: appSettings.bugReportApplicationID,
|
|
||||||
sdkGitSHA: sdkGitSha(),
|
|
||||||
maxUploadSize: appSettings.bugReportMaxUploadSize,
|
|
||||||
appHooks: appHooks))
|
|
||||||
let posthogAnalyticsClient = PostHogAnalyticsClient()
|
let posthogAnalyticsClient = PostHogAnalyticsClient()
|
||||||
posthogAnalyticsClient.updateSuperProperties(AnalyticsEvent.SuperProperties(appPlatform: .EXI, cryptoSDK: .Rust, cryptoSDKVersion: sdkGitSha()))
|
posthogAnalyticsClient.updateSuperProperties(AnalyticsEvent.SuperProperties(appPlatform: .EXI, cryptoSDK: .Rust, cryptoSDKVersion: sdkGitSha()))
|
||||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: posthogAnalyticsClient,
|
ServiceLocator.shared.register(analytics: AnalyticsService(client: posthogAnalyticsClient,
|
||||||
@@ -556,7 +558,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
appHooks: appHooks)
|
appHooks: appHooks)
|
||||||
|
|
||||||
let coordinator = AuthenticationFlowCoordinator(authenticationService: authenticationService,
|
let coordinator = AuthenticationFlowCoordinator(authenticationService: authenticationService,
|
||||||
bugReportService: ServiceLocator.shared.bugReportService,
|
bugReportService: bugReportService,
|
||||||
navigationRootCoordinator: navigationRootCoordinator,
|
navigationRootCoordinator: navigationRootCoordinator,
|
||||||
appMediator: appMediator,
|
appMediator: appMediator,
|
||||||
appSettings: appSettings,
|
appSettings: appSettings,
|
||||||
@@ -642,7 +644,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
}
|
}
|
||||||
|
|
||||||
let flowParameters = CommonFlowParameters(userSession: userSession,
|
let flowParameters = CommonFlowParameters(userSession: userSession,
|
||||||
bugReportService: ServiceLocator.shared.bugReportService,
|
bugReportService: bugReportService,
|
||||||
elementCallService: elementCallService,
|
elementCallService: elementCallService,
|
||||||
timelineControllerFactory: TimelineControllerFactory(),
|
timelineControllerFactory: TimelineControllerFactory(),
|
||||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||||
@@ -901,7 +903,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func setupSentry(appSettings: AppSettings) {
|
private static func setupSentry(bugReportService: BugReportServiceProtocol, appSettings: AppSettings) {
|
||||||
guard let bugReportSentryURL = appSettings.bugReportSentryURL else { return }
|
guard let bugReportSentryURL = appSettings.bugReportSentryURL else { return }
|
||||||
|
|
||||||
let options: Options = .init()
|
let options: Options = .init()
|
||||||
@@ -954,7 +956,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
// multiple callbacks if there are multiple crash events to send (see method documentation)
|
// multiple callbacks if there are multiple crash events to send (see method documentation)
|
||||||
options.onCrashedLastRun = { event in
|
options.onCrashedLastRun = { event in
|
||||||
MXLog.error("Sentry detected a crash in the previous run: \(event.eventId.sentryIdString)")
|
MXLog.error("Sentry detected a crash in the previous run: \(event.eventId.sentryIdString)")
|
||||||
ServiceLocator.shared.bugReportService.lastCrashEventID = event.eventId.sentryIdString
|
bugReportService.lastCrashEventID = event.eventId.sentryIdString
|
||||||
}
|
}
|
||||||
|
|
||||||
SentrySDK.start(options: options) // Swift
|
SentrySDK.start(options: options) // Swift
|
||||||
|
|||||||
@@ -29,10 +29,4 @@ class ServiceLocator {
|
|||||||
func register(analytics: AnalyticsService) {
|
func register(analytics: AnalyticsService) {
|
||||||
self.analytics = analytics
|
self.analytics = analytics
|
||||||
}
|
}
|
||||||
|
|
||||||
private(set) var bugReportService: BugReportServiceProtocol!
|
|
||||||
|
|
||||||
func register(bugReportService: BugReportServiceProtocol) {
|
|
||||||
self.bugReportService = bugReportService
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate
|
|||||||
AppSettings.configureWithSuiteName("io.element.elementx.uitests")
|
AppSettings.configureWithSuiteName("io.element.elementx.uitests")
|
||||||
AppSettings.resetAllSettings()
|
AppSettings.resetAllSettings()
|
||||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||||
ServiceLocator.shared.register(bugReportService: BugReportServiceMock(.init()))
|
|
||||||
|
|
||||||
let analyticsClient = AnalyticsClientMock()
|
let analyticsClient = AnalyticsClientMock()
|
||||||
analyticsClient.isRunning = false
|
analyticsClient.isRunning = false
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class UnitTestsAppCoordinator: AppCoordinatorProtocol {
|
|||||||
AppSettings.configureWithSuiteName("io.element.elementx.unittests")
|
AppSettings.configureWithSuiteName("io.element.elementx.unittests")
|
||||||
AppSettings.resetAllSettings()
|
AppSettings.resetAllSettings()
|
||||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||||
ServiceLocator.shared.register(bugReportService: BugReportServiceMock(.init()))
|
|
||||||
|
|
||||||
let analyticsClient = AnalyticsClientMock()
|
let analyticsClient = AnalyticsClientMock()
|
||||||
analyticsClient.isRunning = false
|
analyticsClient.isRunning = false
|
||||||
|
|||||||
Reference in New Issue
Block a user