Skip to content

Commit

Permalink
fix: fix notification by preventing countly form blocking the app sta…
Browse files Browse the repository at this point in the history
…rt [WPB-10072] (#3173)
  • Loading branch information
MohamadJaara authored Jul 9, 2024
1 parent ba32a7d commit 0ff7cc0
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,26 @@ class WireApplication : BaseApp() {
private suspend fun initializeAnonymousAnalytics() {
if (!BuildConfig.ANALYTICS_ENABLED) return

val anonymousAnalyticsRecorder = AnonymousAnalyticsRecorderImpl()
val analyticsSettings = AnalyticsSettings(
countlyAppKey = BuildConfig.ANALYTICS_APP_KEY,
countlyServerUrl = BuildConfig.ANALYTICS_SERVER_URL,
enableDebugLogging = BuildConfig.DEBUG
)
globalAppScope.launch {
val anonymousAnalyticsRecorder = AnonymousAnalyticsRecorderImpl()
val analyticsSettings = AnalyticsSettings(
countlyAppKey = BuildConfig.ANALYTICS_APP_KEY,
countlyServerUrl = BuildConfig.ANALYTICS_SERVER_URL,
enableDebugLogging = BuildConfig.DEBUG
)

coreLogic.get().getGlobalScope().session.currentSessionFlow().collectLatest { sessionResult ->
if (sessionResult is CurrentSessionResult.Success && sessionResult.accountInfo.isValid()) {
val userDataStore = userDataStoreProvider.get().getOrCreate(sessionResult.accountInfo.userId)

AnonymousAnalyticsManagerImpl.init(
context = this,
analyticsSettings = analyticsSettings,
isEnabledFlowProvider = userDataStore::isAnonymousUsageDataEnabled,
anonymousAnalyticsRecorder = anonymousAnalyticsRecorder,
dispatcher = Dispatchers.IO
)
coreLogic.get().getGlobalScope().session.currentSessionFlow().collectLatest { sessionResult ->
if (sessionResult is CurrentSessionResult.Success && sessionResult.accountInfo.isValid()) {
val userDataStore = userDataStoreProvider.get().getOrCreate(sessionResult.accountInfo.userId)

AnonymousAnalyticsManagerImpl.init(
context = this@WireApplication,
analyticsSettings = analyticsSettings,
isEnabledFlowProvider = userDataStore::isAnonymousUsageDataEnabled,
anonymousAnalyticsRecorder = anonymousAnalyticsRecorder,
dispatcher = Dispatchers.IO
)
}
}
}
}
Expand Down

0 comments on commit 0ff7cc0

Please sign in to comment.