Skip to content

Commit

Permalink
Merge branch 'trunk' into bump_aztec_2_1_4
Browse files Browse the repository at this point in the history
  • Loading branch information
wzieba authored Aug 19, 2024
2 parents 8498241 + 0698fe9 commit 2f5dca0
Show file tree
Hide file tree
Showing 116 changed files with 3,521 additions and 2,599 deletions.
2 changes: 1 addition & 1 deletion .configure
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"project_name": "woocommerce-android",
"branch": "trunk",
"pinned_hash": "b76cc454e9bb5f58a6bb59de6232b20f477e8014",
"pinned_hash": "126ffacbbfc7abf1f4bf14670d72418846f04673",
"files_to_copy": [
{
"file": "android/WCAndroid/gradle.properties",
Expand Down
Binary file modified .configure-files/gradle.properties.enc
Binary file not shown.
10 changes: 8 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ Closes: #
### Images/gif
<!-- Include before and after images or gifs when appropriate. -->


- [ ] I have considered adding unit tests for this change. If I decided not to add them, I have provided a brief explanation below (optional):
- [ ] I have considered if this change warrants release notes and have added them to `RELEASE-NOTES.txt` if necessary. Use the "[Internal]" label for non-user-facing changes.

## Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

- [ ] The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
- [ ] Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
- [ ] Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

<!-- Pull request guidelines: https://github.com/woocommerce/woocommerce-android/blob/develop/docs/pull-request-guidelines.md -->
11 changes: 10 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
*** PLEASE FOLLOW THIS FORMAT: [<priority indicator, more stars = higher priority>] <description> [<PR URL>]
*** Use [*****] to indicate smoke tests of all critical flows should be run on the final APK before release (e.g. major library or targetSdk updates).
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
20.0
20.1
-----
- [*****] [Internal] Update Aztec from v1.3.45 to v2.1.4 [https://github.com/woocommerce/woocommerce-android/pull/12316]

20.0
-----
- [*] Fixed missing pictures in card reader tutorial on tablets [https://github.com/woocommerce/woocommerce-android/pull/12274]
- [*] Disable QR code scanning from login flow [https://github.com/woocommerce/woocommerce-android/pull/12303]
- [*] Fixed the hidden “Write with AI” issue that occurs when the keyboard is open. [https://github.com/woocommerce/woocommerce-android/pull/12311]
- [*] Allowed collecting card-present payments for orders with `failed` status [https://github.com/woocommerce/woocommerce-android/pull/12349]
- [*] [Internal] [Login] Switched back to using the `/token` endpoint for WordPress.com authentication, this fixes an issue where the SMS OTP is not triggered automatically after submitting the password [https://github.com/woocommerce/woocommerce-android/pull/12319]
- [*] [Internal] [WEAR] Introduces Sentry support to the Wear app

19.9
-----
Expand All @@ -15,6 +23,7 @@
- [*****] [Internal] Update Androidx-fragment from 1.6.2 to 1.8.2 [https://github.com/woocommerce/woocommerce-android/pull/12231]
- [*****] [Internal] Update Material to 1.12.0 and Transition to 1.5.1 [https://github.com/woocommerce/woocommerce-android/pull/12237]
- [*****] [Internal] Update Stripe Terminal SDK from 3.1.1 to 3.7.1 [https://github.com/woocommerce/woocommerce-android/pull/12239]
- [*] [Login] Fixed an issue with the "send SMS" button during the 2FA login [https://github.com/woocommerce/woocommerce-android/pull/12306]
- [***] Fix logic behind handling enabled/disabled states of "+ Add coupon" and "+ Add discount" buttons in the Order creation/edition flow [https://github.com/woocommerce/woocommerce-android/pull/12263].

19.8
Expand Down
28 changes: 28 additions & 0 deletions WooCommerce-Wear/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import io.sentry.android.gradle.extensions.InstrumentationFeature

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.parcelize'
id 'com.google.dagger.hilt.android'
id 'com.google.devtools.ksp'
id 'io.sentry.android.gradle'
}

repositories {
Expand All @@ -14,6 +17,8 @@ repositories {
includeGroup "org.wordpress.fluxc"
includeGroup "org.wordpress.fluxc.plugins"
includeGroup "org.wordpress.wellsql"
includeGroup "com.automattic"
includeGroup "com.automattic.tracks"
}
}
mavenCentral()
Expand All @@ -25,6 +30,27 @@ repositories {
}
}

sentry {
includeSourceContext = true
autoUploadSourceContext = true
tracingInstrumentation {
enabled = true
features = [InstrumentationFeature.DATABASE]
logcat {
enabled = false
}
}
autoInstallation {
enabled = false
}
includeDependenciesReport = false
/* Sentry won't send source context or add performance instrumentations for debug builds
so we can save build times. Sending events will still work in debug builds
(if enabled in WCCrashLoggingDataProvider).
*/
ignoredBuildTypes = ["debug"]
}

def versionProperties = loadPropertiesFromFile(file("${rootDir}/version.properties"))
def versionCodeDifferenceBetweenAppAndWear = 50000

Expand Down Expand Up @@ -113,6 +139,8 @@ dependencies {
exclude group: "com.mcxiaoke.volley"
exclude group: "com.android.support"
}
implementation "com.automattic:Automattic-Tracks-Android:$automatticTracksVersion"
implementation "com.automattic.tracks:crashlogging:$automatticTracksVersion"

// WearOS
implementation "com.google.android.gms:play-services-wearable:$googlePlayWearableVersion"
Expand Down
8 changes: 8 additions & 0 deletions WooCommerce-Wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
android:pathPrefix="/order-products-data"
android:scheme="wear" />
</intent-filter>

<intent-filter>
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<data
android:host="*"
android:pathPrefix="/app-settings-data"
android:scheme="wear" />
</intent-filter>
</service>

<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
package com.woocommerce.android.app

import android.app.Application
import com.automattic.android.tracks.crashlogging.CrashLogging
import com.yarolegovich.wellsql.WellSql
import dagger.Lazy
import dagger.hilt.android.HiltAndroidApp
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.wordpress.android.fluxc.persistence.WellSqlConfig
import org.wordpress.android.fluxc.persistence.WellSqlConfig.Companion.ADDON_WOOCOMMERCE
import org.wordpress.android.fluxc.utils.ErrorUtils.OnUnexpectedError
import javax.inject.Inject

@HiltAndroidApp
open class WooCommerceWear : Application() {

@Inject
lateinit var crashLogging: Lazy<CrashLogging>

override fun onCreate() {
super.onCreate()
WellSql.init(WellSqlConfig(applicationContext, ADDON_WOOCOMMERCE))
crashLogging.get().initialize()
}

@Suppress("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
fun onUnexpectedError(event: OnUnexpectedError) {
with(event) {
crashLogging.get().sendReport(exception = exception, message = "FluxC: ${exception.message}: $description")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.woocommerce.android.wear.crashlogging

import com.automattic.android.tracks.crashlogging.CrashLogging
import org.wordpress.android.fluxc.logging.FluxCCrashLogger

class FluxCCrashLoggerImpl(private val crashLogging: CrashLogging) : FluxCCrashLogger {
override fun recordEvent(message: String, category: String?) {
crashLogging.recordEvent(message, category)
}

override fun recordException(exception: Throwable, category: String?) {
crashLogging.recordException(exception, category)
}

override fun sendReport(exception: Throwable?, tags: Map<String, String>, message: String?) {
crashLogging.sendReport(exception, tags, message)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.woocommerce.android.wear.crashlogging

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.PerformanceMonitoringConfig
import com.automattic.android.tracks.crashlogging.ReleaseName
import com.woocommerce.android.BuildConfig
import com.woocommerce.android.wear.di.AppCoroutineScope
import com.woocommerce.android.wear.settings.SettingsRepository
import com.woocommerce.android.wear.ui.login.LoginRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.wordpress.android.fluxc.Dispatcher
import org.wordpress.android.fluxc.model.AccountModel
import org.wordpress.android.fluxc.store.AccountStore
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class WCWearCrashLoggingDataProvider @Inject constructor(
@AppCoroutineScope private val appScope: CoroutineScope,
private val accountStore: AccountStore,
private val providedLocale: Locale,
private val settingsRepository: SettingsRepository,
loginRepository: LoginRepository,
dispatcher: Dispatcher,
) : CrashLoggingDataProvider {

init { dispatcher.register(this) }

private val crashLoggingUser = MutableStateFlow(accountStore.account?.toCrashLoggingUser())

override val user: Flow<CrashLoggingUser?> = crashLoggingUser
override val sentryDSN: String = BuildConfig.WEAR_SENTRY_DSN
override val buildType = BuildConfig.BUILD_TYPE
override val enableCrashLoggingLogs = BuildConfig.DEBUG
override val releaseName: ReleaseName = if (BuildConfig.DEBUG) {
ReleaseName.SetByApplication(DEBUG_RELEASE_NAME)
} else {
ReleaseName.SetByTracksLibrary
}
override val locale: Locale get() = providedLocale

@Suppress("unused", "unused_parameter")
@Subscribe(threadMode = ThreadMode.MAIN)
fun onAccountChanged(event: AccountStore.OnAccountChanged) {
appScope.launch {
crashLoggingUser.emit(accountStore.account.toCrashLoggingUser())
}
}

override fun provideExtrasForEvent(
currentExtras: Map<ExtraKnownKey, String>,
eventLevel: EventLevel
) = emptyMap<ExtraKnownKey, String>()

override fun shouldDropWrappingException(module: String, type: String, value: String) = false

override val applicationContextProvider: Flow<Map<String, String>> =
loginRepository.selectedSiteFlow
.map { site ->
site?.let {
mutableMapOf<String, String>(
SITE_URL_KEY to site.url
).apply {
site.siteId.takeIf { it != 0L }?.toString()?.let {
this[SITE_ID_KEY] = it
}
}
}.orEmpty()
}

override val performanceMonitoringConfig: PerformanceMonitoringConfig
get() = PerformanceMonitoringConfig.Disabled

override fun crashLoggingEnabled() = settingsRepository.crashReportEnabled.value

override fun extraKnownKeys(): List<ExtraKnownKey> = emptyList()

private fun AccountModel.toCrashLoggingUser(): CrashLoggingUser? {
if (userId == 0L) return null

return CrashLoggingUser(
userID = userId.toString(),
email = email,
username = userName
)
}

companion object {
const val SITE_ID_KEY = "site_id"
const val SITE_URL_KEY = "site_url"
const val DEBUG_RELEASE_NAME = "debug"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.woocommerce.android.wear.di

import android.app.Application
import com.automattic.android.tracks.crashlogging.CrashLogging
import com.automattic.android.tracks.crashlogging.CrashLoggingDataProvider
import com.automattic.android.tracks.crashlogging.CrashLoggingProvider
import com.woocommerce.android.wear.crashlogging.FluxCCrashLoggerImpl
import com.woocommerce.android.wear.crashlogging.WCWearCrashLoggingDataProvider
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.CoroutineScope
import org.wordpress.android.fluxc.logging.FluxCCrashLogger
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
abstract class CrashLoggingModule {
companion object {
@Provides
@Singleton
fun provideCrashLogging(
context: Application,
crashLoggingDataProvider: CrashLoggingDataProvider,
@AppCoroutineScope appScope: CoroutineScope
): CrashLogging {
return CrashLoggingProvider.createInstance(context, crashLoggingDataProvider, appScope)
}

@Provides
fun provideFluxCCrashLogger(crashLogging: CrashLogging): FluxCCrashLogger {
return FluxCCrashLoggerImpl(crashLogging)
}
}

@Binds
abstract fun bindCrashLoggingDataProvider(dataProvider: WCWearCrashLoggingDataProvider): CrashLoggingDataProvider
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import com.google.android.gms.wearable.DataMap
import com.google.android.gms.wearable.DataMapItem
import com.google.android.gms.wearable.MessageClient
import com.google.android.gms.wearable.PutDataMapRequest
import com.woocommerce.android.wear.settings.SettingsRepository
import com.woocommerce.android.wear.ui.login.LoginRepository
import com.woocommerce.android.wear.ui.orders.OrdersRepository
import com.woocommerce.android.wear.ui.stats.datasource.StatsRepository
import com.woocommerce.commons.DataParameters
import com.woocommerce.commons.DataPath
import com.woocommerce.commons.DataPath.APP_SETTINGS_DATA
import com.woocommerce.commons.DataPath.ORDERS_DATA
import com.woocommerce.commons.DataPath.ORDER_PRODUCTS_DATA
import com.woocommerce.commons.DataPath.SITE_DATA
Expand All @@ -30,6 +32,7 @@ class PhoneConnectionRepository @Inject constructor(
private val loginRepository: LoginRepository,
private val statsRepository: StatsRepository,
private val ordersRepository: OrdersRepository,
private val settingsRepository: SettingsRepository,
private val capabilityClient: CapabilityClient,
private val dataClient: DataClient,
private val messageClient: MessageClient,
Expand All @@ -47,6 +50,7 @@ class PhoneConnectionRepository @Inject constructor(
STATS_DATA.value -> statsRepository.receiveStatsDataFromPhone(dataMap)
ORDERS_DATA.value -> ordersRepository.receiveOrdersDataFromPhone(dataMap)
ORDER_PRODUCTS_DATA.value -> ordersRepository.receiveOrderProductsDataFromPhone(dataMap)
APP_SETTINGS_DATA.value -> settingsRepository.receiveAppSettingsDataFromPhone(dataMap)
else -> Log.d(TAG, "Unknown path data received")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.woocommerce.android.wear.settings

import android.content.SharedPreferences
import com.woocommerce.commons.prefs.PreferenceUtils

sealed class AppSettings<T> {
abstract var value: T
abstract val key: String

data class CrashReportEnabledSettings(
private val preferences: SharedPreferences
) : AppSettings<Boolean>() {
override val key = this::class.simpleName.orEmpty()

override var value: Boolean
get() = PreferenceUtils.getBoolean(preferences, key, true)
set(value) = PreferenceUtils.setBoolean(preferences, key, value)
}
}
Loading

0 comments on commit 2f5dca0

Please sign in to comment.