Skip to content

Commit

Permalink
Merge pull request #20545 from wordpress-mobile/tracks_4_0_1
Browse files Browse the repository at this point in the history
feat: assign "debug" release, when app is not in `release` variant
  • Loading branch information
wzieba authored Mar 28, 2024
2 parents 562d46d + 293969a commit 693db93
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.automattic.android.tracks.crashlogging.CrashLoggingDataProvider
import com.automattic.android.tracks.crashlogging.CrashLoggingUser
import com.automattic.android.tracks.crashlogging.EventLevel
import com.automattic.android.tracks.crashlogging.ExtraKnownKey
import com.automattic.android.tracks.crashlogging.ReleaseName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
Expand Down Expand Up @@ -48,7 +49,11 @@ class WPCrashLoggingDataProvider @Inject constructor(
override val enableCrashLoggingLogs: Boolean = false
override val locale: Locale
get() = localeManager.getLocale()
override val releaseName: String = BuildConfig.VERSION_NAME
override val releaseName: ReleaseName = if (buildConfig.isDebug()) {
ReleaseName.SetByApplication("debug")
} else {
ReleaseName.SetByTracksLibrary
}
override val sentryDSN: String = BuildConfig.SENTRY_DSN

override val applicationContextProvider = flowOf(mapOf(WEBVIEW_VERSION to webviewVersionProvider.getVersion()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.wordpress.android.util.crashlogging
import android.content.SharedPreferences
import com.automattic.android.tracks.crashlogging.EventLevel.DEBUG
import com.automattic.android.tracks.crashlogging.PerformanceMonitoringConfig
import com.automattic.android.tracks.crashlogging.ReleaseName
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
Expand Down Expand Up @@ -201,6 +202,22 @@ class WPCrashLoggingDataProviderTest : BaseUnitTest() {
assertThat(sut.crashLoggingEnabled()).isTrue
}

@Test
fun `should assign debug release in debug`() {
whenever(buildConfig.isDebug()).thenReturn(true)
reinitialize()

assertThat(sut.releaseName).isEqualTo(ReleaseName.SetByApplication("debug"))
}

@Test
fun `should delegate release name creation to tracks in release`() {
whenever(buildConfig.isDebug()).thenReturn(false)
reinitialize()

assertThat(sut.releaseName).isEqualTo(ReleaseName.SetByTracksLibrary)
}

companion object {
val TEST_ACCOUNT = AccountModel().apply {
userId = 123L
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ext {
// libs
automatticAboutVersion = '1.4.0'
automatticRestVersion = '1.0.8'
automatticTracksVersion = '3.6.0'
automatticTracksVersion = '4.0.2'
gutenbergMobileVersion = 'v1.116.0'
wordPressAztecVersion = 'v2.1.1'
wordPressFluxCVersion = '2.72.0'
Expand Down

0 comments on commit 693db93

Please sign in to comment.