mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
MESSENGER-6142 remove jitsi, sentry, posthog and sublibraries
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#if POSTHOG
|
||||
import PostHog
|
||||
#endif
|
||||
import AnalyticsEvents
|
||||
|
||||
/// A class responsible for managing a variety of analytics clients
|
||||
@@ -34,19 +36,28 @@ import AnalyticsEvents
|
||||
/// The singleton instance to be used within the Riot target.
|
||||
static let shared = Analytics()
|
||||
|
||||
#if POSTHOG
|
||||
/// The analytics client to send events with.
|
||||
private var client: AnalyticsClientProtocol = PostHogAnalyticsClient.shared
|
||||
#endif
|
||||
|
||||
#if SENTRY
|
||||
/// The monitoring client to track crashes, issues and performance
|
||||
private var monitoringClient = SentryMonitoringClient()
|
||||
|
||||
#endif
|
||||
/// The service used to interact with account data settings.
|
||||
private var service: AnalyticsService?
|
||||
|
||||
private var viewRoomActiveSpace: AnalyticsViewRoomActiveSpace = .home
|
||||
|
||||
/// Whether or not the object is enabled and sending events to the server.
|
||||
var isRunning: Bool { client.isRunning }
|
||||
var isRunning: Bool {
|
||||
#if POSTHOG
|
||||
client.isRunning
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Whether to show the user the analytics opt in prompt.
|
||||
var shouldShowAnalyticsPrompt: Bool {
|
||||
@@ -103,8 +114,12 @@ import AnalyticsEvents
|
||||
|
||||
// The order is important here. PostHog ignores the reset if stopped.
|
||||
reset()
|
||||
#if POSTHOG
|
||||
client.stop()
|
||||
#endif
|
||||
#if SENTRY
|
||||
monitoringClient.stop()
|
||||
#endif
|
||||
|
||||
MXLog.debug("[Analytics] Stopped.")
|
||||
}
|
||||
@@ -113,11 +128,18 @@ import AnalyticsEvents
|
||||
func startIfEnabled() {
|
||||
guard RiotSettings.shared.enableAnalytics, !isRunning else { return }
|
||||
|
||||
#if POSTHOG
|
||||
client.start()
|
||||
#endif
|
||||
#if SENTRY
|
||||
monitoringClient.start()
|
||||
|
||||
#endif
|
||||
// Sanity check in case something went wrong.
|
||||
#if POSTHOG
|
||||
guard client.isRunning else { return }
|
||||
#else
|
||||
return
|
||||
#endif
|
||||
|
||||
MXLog.debug("[Analytics] Started.")
|
||||
|
||||
@@ -162,8 +184,12 @@ import AnalyticsEvents
|
||||
/// account used isn't associated with the previous one.
|
||||
/// Note: **MUST** be called before stopping PostHog or the reset is ignored.
|
||||
func reset() {
|
||||
#if POSTHOG
|
||||
client.reset()
|
||||
#endif
|
||||
#if SENTRY
|
||||
monitoringClient.reset()
|
||||
#endif
|
||||
MXLog.debug("[Analytics] Reset.")
|
||||
RiotSettings.shared.isIdentifiedForAnalytics = false
|
||||
|
||||
@@ -175,7 +201,9 @@ import AnalyticsEvents
|
||||
/// Normally events are sent in batches. Call this method when you need an event
|
||||
/// to be sent immediately.
|
||||
func forceUpload() {
|
||||
#if POSTHOG
|
||||
client.flush()
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -187,8 +215,10 @@ import AnalyticsEvents
|
||||
MXLog.error("[Analytics] identify(with:) called before an ID has been generated.")
|
||||
return
|
||||
}
|
||||
|
||||
#if POSTHOG
|
||||
client.identify(id: id)
|
||||
#endif
|
||||
|
||||
MXLog.debug("[Analytics] Identified.")
|
||||
RiotSettings.shared.isIdentifiedForAnalytics = true
|
||||
}
|
||||
@@ -196,7 +226,9 @@ import AnalyticsEvents
|
||||
/// Capture an event in the `client`.
|
||||
/// - Parameter event: The event to capture.
|
||||
private func capture(event: AnalyticsEventProtocol) {
|
||||
#if POSTHOG
|
||||
client.capture(event)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Update `viewRoomActiveSpace` property according to the current value of `exploringSpace` and `activeSpace` properties.
|
||||
@@ -244,7 +276,9 @@ extension Analytics {
|
||||
ftueUseCaseSelection: ftueUseCase?.analyticsName,
|
||||
numFavouriteRooms: numFavouriteRooms,
|
||||
numSpaces: numSpaces)
|
||||
#if POSTHOG
|
||||
client.updateUserProperties(userProperties)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Track the registration of a new user.
|
||||
@@ -260,7 +294,9 @@ extension Analytics {
|
||||
/// - milliseconds: An optional value representing how long the screen was shown for in milliseconds.
|
||||
func trackScreen(_ screen: AnalyticsScreen, duration milliseconds: Int?) {
|
||||
let event = AnalyticsEvent.MobileScreen(durationMs: milliseconds, screenName: screen.screenName)
|
||||
#if POSTHOG
|
||||
client.screen(event)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// The the presentation of a screen without including a duration
|
||||
@@ -276,7 +312,9 @@ extension Analytics {
|
||||
/// - index: The index of the element, if it's in a list of elements
|
||||
func trackInteraction(_ uiElement: AnalyticsUIElement, interactionType: AnalyticsEvent.Interaction.InteractionType, index: Int?) {
|
||||
let event = AnalyticsEvent.Interaction(index: index, interactionType: interactionType, name: uiElement.name)
|
||||
#if POSTHOG
|
||||
client.capture(event)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Track an element that has been tapped without including an index
|
||||
@@ -296,7 +334,9 @@ extension Analytics {
|
||||
func trackAuthUnauthenticatedError(softLogout: Bool, refreshTokenAuth: Bool, errorCode: String, errorReason: String) {
|
||||
let errorCode = AnalyticsEvent.UnauthenticatedError.ErrorCode(rawValue: errorCode) ?? .M_UNKNOWN
|
||||
let event = AnalyticsEvent.UnauthenticatedError(errorCode: errorCode, errorReason: errorReason, refreshTokenAuth: refreshTokenAuth, softLogout: softLogout)
|
||||
#if POSTHOG
|
||||
client.capture(event)
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Track whether the user accepted or declined the terms to an identity server.
|
||||
@@ -346,7 +386,12 @@ extension Analytics: MXAnalyticsDelegate {
|
||||
}
|
||||
|
||||
func startDurationTracking(forName name: String, operation: String) -> StopDurationTracking {
|
||||
|
||||
#if SENTRY
|
||||
return monitoringClient.startPerformanceTracking(name: name, operation: operation)
|
||||
#else
|
||||
return {}
|
||||
#endif
|
||||
}
|
||||
|
||||
func trackCallStarted(withVideo isVideo: Bool, numberOfParticipants: Int, incoming isIncoming: Bool) {
|
||||
@@ -399,7 +444,9 @@ extension Analytics: MXAnalyticsDelegate {
|
||||
}
|
||||
|
||||
func trackNonFatalIssue(_ issue: String, details: [String: Any]?) {
|
||||
monitoringClient.trackNonFatalIssue(issue, details: details)
|
||||
#if SENTRY
|
||||
monitoringClient?.trackNonFatalIssue(issue, details: details)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user