Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class DeveloperOptionsFragment : BaseFragment() {
ToastUtils.showToast(context, event.message)
}

is DeveloperOptionsViewModel.DeveloperOptionsEvents.ShowToastText -> {
ToastUtils.showToast(context, event.message)
}

is DeveloperOptionsViewModel.DeveloperOptionsEvents.ShowUpdateOptionsDialog -> {
showUpdateOptionsDialog(
values = event.options,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.woocommerce.android.ui.prefs.developer

import com.automattic.android.tracks.crashlogging.CrashLogging
import com.woocommerce.android.AppPrefs
import com.woocommerce.android.cardreader.CardReaderManager
import com.woocommerce.android.di.AppCoroutineScope
Expand All @@ -16,6 +17,7 @@ class DeveloperOptionsRepository @Inject constructor(
private val appPrefs: AppPrefs,
private val clearCardReaderDataAction: ClearCardReaderDataAction,
private val cardReaderManager: CardReaderManager,
private val crashLogging: CrashLogging,
@AppCoroutineScope appScope: CoroutineScope
) {
private val appPrefsTrigger = appPrefs.observePrefs().shareIn(appScope, started = SharingStarted.WhileSubscribed())
Expand Down Expand Up @@ -71,4 +73,14 @@ class DeveloperOptionsRepository @Inject constructor(
)
}
}

fun sendTestSentryReport() {
appPrefs.setCrashReportingEnabled(true)

crashLogging.sendReport(
exception = Exception("Test Sentry report from Developer Options"),
tags = mapOf("source" to "developer_options"),
message = "This is a test report triggered from Developer Options"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,23 @@ class DeveloperOptionsViewModel @Inject constructor(
)
)

private val sendSentryReportFlow = flowOf(
NonToggleableListItem(
icon = R.drawable.ic_email,
iconTint = R.color.color_primary,
label = UiString.UiStringText("Send Sentry Report"),
isEnabled = true,
onClick = ::onSendSentryReportClicked
)
)

val viewState = combine(
simulatedCardReaderFlow,
readerUpdateFrequencyFlow,
interacPaymentEnabledFlow,
savedPrivacySettingsOnDialogFlow,
apiFakerFlow
apiFakerFlow,
sendSentryReportFlow
) { items ->
DeveloperOptionsViewState(
rows = items.filterNotNull()
Expand Down Expand Up @@ -131,8 +142,16 @@ class DeveloperOptionsViewModel @Inject constructor(
developerOptionsRepository.updateSimulatedReaderOption(selectedOption.toDomainModel())
}

private fun onSendSentryReportClicked() {
developerOptionsRepository.sendTestSentryReport()
triggerEvent(
DeveloperOptionsEvents.ShowToastText("Sentry report sent")
)
}

sealed class DeveloperOptionsEvents : MultiLiveEvent.Event() {
data class ShowToastString(val message: Int) : DeveloperOptionsEvents()
data class ShowToastText(val message: String) : DeveloperOptionsEvents()
data class ShowUpdateOptionsDialog(
val options: List<UpdateFrequencyUiModel>,
var selectedValue: UpdateFrequencyUiModel,
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ androidx-work = '2.10.5'
apache-commons-text = '1.14.0'
apache-http-client-android = '4.3.5.1'
automattic-about = '1.7.0'
automattic-encryptedlogging = '1.1.1'
automattic-encryptedlogging = '1.1.2'
automattic-measure-builds = '3.2.1'
automattic-tracks = '6.0.6'
assertj = '3.27.3'
Expand Down
Loading