Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-2263] Crash reporting setup #632

Merged
merged 12 commits into from
Jan 16, 2024
56 changes: 55 additions & 1 deletion .github/workflows/pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,29 @@ jobs:
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'sonar'
step_name: 'unit-gpr'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true

- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'unit-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- name: "Run unit tests"
run: ./gradlew testDebugUnitTest
env:
Expand Down Expand Up @@ -156,6 +174,24 @@ jobs:
secret_name: "github-actions/radixdlt/babylon-wallet-android/sonar-token"
parse_json: true

- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'static-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- name: Export vars
run: |
echo "GPR_USER=${{ env.GH_GPR_USER }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -207,6 +243,24 @@ jobs:
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true

- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'build-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- name: "Build"
run: |
./gradlew assembleDebug
Expand Down
74 changes: 73 additions & 1 deletion .github/workflows/publish_releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,31 @@ jobs:
secret_name: "github-actions/radixdlt/babylon-wallet-android/firebase/secrets"
parse_json: true

- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'fbase-alpha-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Google Service account credentials
uses: RDXWorks-actions/base64-to-file@main
id: google_application_credentials
with:
fileName: "service_account.json"
encodedString: ${{ env.GH_GOOGLE_SERVICE_ACCOUNT_JSON_FILE_BASE64 }}

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- name: Fetch GPR credentials
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
Expand Down Expand Up @@ -246,6 +264,24 @@ jobs:
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true

- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'gplay-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- uses: ./.github/actions/google-play-common
with:
gpc_track: "alpha"
Expand Down Expand Up @@ -289,6 +325,24 @@ jobs:
secret_name: "github-actions/radixdlt/babylon-wallet-android/gpr-credentials"
parse_json: true

- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'gplay-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- uses: ./.github/actions/google-play-common
with:
gpc_track: "production"
Expand Down Expand Up @@ -348,7 +402,25 @@ jobs:
secret_prefix: 'GH_KEYSTORE_ENCRYPTED_BASE64'
secret_name: "github-actions/radixdlt/babylon-wallet-android/google-play-console/keystore-asc"
parse_json: false


- name: Fetch Crashlytics info
uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main
with:
role_name: '${{ secrets.ANDROID_WALLET_SECRETS_READ_IAM_ROLE }}'
app_name: 'wallet-android'
step_name: 'gplay-crash'
secret_prefix: 'GH'
secret_name: "github-actions/radixdlt/babylon-wallet-android/crashlytics"
parse_json: true

- name: Decode Firebase Crashlytics json
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e
id: crashlytics_credentials
with:
fileName: "google-services.json"
fileDir: "app/"
encodedString: ${{ env.GH_CRASHLYTICS_GOOGLE_SERVICES_JSON_FILE_BASE64 }}

- name: Decode release keystore credentials
shell: bash
run: |
Expand Down
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
id "jacoco"
id 'kotlinx-serialization'
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}

apply from: "$rootDir/config/jacoco.gradle"
Expand Down Expand Up @@ -56,6 +58,7 @@ android {
versionCode 27
versionName "1.3.0"
buildConfigField "boolean", "DEBUG_MODE", "true"
buildConfigField "boolean", "CRASH_REPORTING_AVAILABLE", "false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enabled"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had discussion about this. This controls if switch to turn it on is visible in settings, not if it is enabled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok thanks!

buildConfigField "boolean", "EXPERIMENTAL_FEATURES_ENABLED", "true"
buildConfigField "String", "WELL_KNOWN_URL_SUFFIX", '".well-known/radix.json"'
buildConfigField "String", "IMAGE_HOST_BASE_URL", '"https://image-service-dev.extratools.works"'
Expand Down Expand Up @@ -85,6 +88,7 @@ android {
debugAlpha {
initWith debug
applicationIdSuffix ".alpha"
buildConfigField "boolean", "CRASH_REPORTING_AVAILABLE", "false"
minifyEnabled true
debuggable false
resValue "string", "app_name", "Radix Wallet Alpha"
Expand All @@ -95,6 +99,7 @@ android {
minifyEnabled true
signingConfig signingConfigs.release
buildConfigField "boolean", "DEBUG_MODE", "false"
buildConfigField "boolean", "CRASH_REPORTING_AVAILABLE", "true"
buildConfigField "boolean", "EXPERIMENTAL_FEATURES_ENABLED", "false"
buildConfigField "String", "IMAGE_HOST_BASE_URL", '"https://image-service.radixdlt.com"'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Expand Down
4 changes: 3 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-dontobfuscate
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep public class * extends java.lang.Throwable

# If you keep the line number information, uncomment this to
# hide the original source file name.
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import rdx.works.core.logNonFatalException
import rdx.works.profile.data.model.pernetwork.Network
import rdx.works.profile.data.model.pernetwork.Network.AuthorizedDapp.AuthorizedPersonaSimple
import rdx.works.profile.data.model.pernetwork.PersonaData
Expand Down Expand Up @@ -257,6 +258,7 @@ class DAppAuthorizedLoginViewModel @Inject constructor(

private suspend fun handleRequestError(exception: Throwable) {
if (exception is RadixWalletException.DappRequestException) {
logNonFatalException(exception)
if (exception.cause is RadixWalletException.LedgerCommunicationException) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import rdx.works.core.logNonFatalException
import rdx.works.profile.data.model.pernetwork.Network
import rdx.works.profile.data.model.pernetwork.PersonaData
import rdx.works.profile.domain.GetProfileUseCase
Expand Down Expand Up @@ -148,6 +149,7 @@ class DAppUnauthorizedLoginViewModel @Inject constructor(

private suspend fun handleRequestError(exception: Throwable) {
if (exception is RadixWalletException.DappRequestException) {
logNonFatalException(exception)
if (exception is RadixWalletException.LedgerCommunicationException.FailedToSignAuthChallenge) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ sealed interface SettingsItem {
data object Gateways : AppSettingsItem
data object EntityHiding : AppSettingsItem
data class DeveloperMode(val enabled: Boolean) : AppSettingsItem
data class CrashReporting(val enabled: Boolean) : AppSettingsItem

@StringRes
fun descriptionRes(): Int {
Expand All @@ -89,6 +90,7 @@ sealed interface SettingsItem {
Gateways -> R.string.appSettings_gateways_title
is DeveloperMode -> R.string.appSettings_developerMode_title
EntityHiding -> R.string.appSettings_entityHiding_title
is CrashReporting -> R.string.appSettings_crashReporting_title
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fun NavGraphBuilder.appSettingsScreen(
SettingsItem.AppSettingsItem.Gateways -> {
navController.navigate(Screen.SettingsEditGatewayApiDestination.route)
}

is SettingsItem.AppSettingsItem.CrashReporting,
is SettingsItem.AppSettingsItem.DeveloperMode -> {}
SettingsItem.AppSettingsItem.EntityHiding -> {
navController.hiddenEntitiesScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand All @@ -20,6 +23,7 @@ import com.babylon.wallet.android.R
import com.babylon.wallet.android.designsystem.theme.RadixTheme
import com.babylon.wallet.android.designsystem.theme.RadixWalletTheme
import com.babylon.wallet.android.presentation.settings.SettingsItem
import com.babylon.wallet.android.presentation.ui.composables.BasicPromptAlertDialog
import com.babylon.wallet.android.presentation.ui.composables.DefaultSettingsItem
import com.babylon.wallet.android.presentation.ui.composables.RadixCenteredTopAppBar
import com.babylon.wallet.android.presentation.ui.composables.SwitchSettingsItem
Expand All @@ -39,6 +43,7 @@ fun AppSettingsScreen(
onAppSettingItemClick = onAppSettingItemClick,
onDeveloperModeToggled = viewModel::onDeveloperModeToggled,
onBackClick = onBackClick,
onCrashReportingToggled = viewModel::onCrashReportingToggled
)
}

Expand All @@ -49,7 +54,21 @@ private fun AppSettingsContent(
onAppSettingItemClick: (SettingsItem.AppSettingsItem) -> Unit,
onDeveloperModeToggled: (Boolean) -> Unit,
onBackClick: () -> Unit,
onCrashReportingToggled: (Boolean) -> Unit,
) {
var crashReportingPromptVisible by remember { mutableStateOf(false) }
if (crashReportingPromptVisible) {
BasicPromptAlertDialog(
finish = { accepted ->
if (accepted) {
onCrashReportingToggled(true)
}
crashReportingPromptVisible = false
},
titleText = stringResource(id = R.string.appSettings_crashReporting_title),
messageText = stringResource(id = R.string.appSettings_crashReporting_subtitle)
)
}
Scaffold(
modifier = modifier,
topBar = {
Expand Down Expand Up @@ -91,6 +110,24 @@ private fun AppSettingsContent(
)
}

is SettingsItem.AppSettingsItem.CrashReporting -> {
SwitchSettingsItem(
modifier = Modifier
.fillMaxWidth()
.padding(all = RadixTheme.dimensions.paddingDefault),
titleRes = appSettingsItem.descriptionRes(),
iconResource = appSettingsItem.getIcon(),
checked = appSettingsItem.enabled,
onCheckedChange = { selected ->
if (selected) {
crashReportingPromptVisible = true
} else {
onCrashReportingToggled(false)
}
}
)
}

SettingsItem.AppSettingsItem.EntityHiding -> {
DefaultSettingsItem(
title = stringResource(id = appSettingsItem.descriptionRes()),
Expand Down Expand Up @@ -129,7 +166,8 @@ fun AppSettingsScreenPreview() {
appSettings = AppSettingsUiState.default.settings,
onAppSettingItemClick = {},
onDeveloperModeToggled = {},
onBackClick = {}
onBackClick = {},
onCrashReportingToggled = {}
)
}
}
Loading