Skip to content

Commit 71b4b52

Browse files
authored
Merge pull request #20938 from wordpress-mobile/task/os-version-rules
Adds os_version parameter in feature flags and dynamic dashboard cards
2 parents a0b6ece + 8521e72 commit 71b4b52

6 files changed

Lines changed: 32 additions & 13 deletions

File tree

WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/CardViewModelSlice.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class CardViewModelSlice @Inject constructor(
153153
identifier = buildConfigWrapper.getApplicationId(),
154154
marketingVersion = buildConfigWrapper.getAppVersionName(),
155155
platform = FEATURE_FLAG_PLATFORM_PARAMETER,
156+
osVersion = buildConfigWrapper.androidVersion
156157
)
157158
val result = cardsStore.fetchCards(payload)
158159
val error = result.error

WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.wordpress.android.util
22

3+
import android.os.Build
34
import org.wordpress.android.BuildConfig
45
import javax.inject.Inject
56

@@ -33,4 +34,6 @@ class BuildConfigWrapper @Inject constructor() {
3334
val isFollowedSitesSettingsEnabled = BuildConfig.ENABLE_FOLLOWED_SITES_SETTINGS
3435

3536
val isWhatsNewFeatureEnabled = BuildConfig.ENABLE_WHATS_NEW_FEATURE
37+
38+
val androidVersion: String = Build.VERSION.RELEASE
3639
}

WordPress/src/main/java/org/wordpress/android/util/config/FeatureFlagConfig.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import kotlinx.coroutines.launch
66
import org.wordpress.android.BuildConfig
77
import org.wordpress.android.analytics.AnalyticsTracker
88
import org.wordpress.android.analytics.AnalyticsTracker.Stat
9+
import org.wordpress.android.fluxc.network.rest.wpcom.mobile.FeatureFlagsRestClient
910
import org.wordpress.android.fluxc.persistence.FeatureFlagConfigDao.FeatureFlag
1011
import org.wordpress.android.fluxc.store.NotificationStore.Companion.WPCOM_PUSH_DEVICE_UUID
1112
import org.wordpress.android.fluxc.store.mobile.FeatureFlagsStore
@@ -72,12 +73,15 @@ class FeatureFlagConfig
7273

7374
private suspend fun fetchRemoteFlags() {
7475
val response = featureFlagStore.fetchFeatureFlags(
75-
buildNumber = BuildConfig.VERSION_CODE.toString(),
76-
deviceId = preferences.getString(WPCOM_PUSH_DEVICE_UUID, null)
77-
?: generateAndStoreUUID(),
78-
identifier = BuildConfig.APPLICATION_ID,
79-
marketingVersion = BuildConfig.VERSION_NAME,
80-
platform = FEATURE_FLAG_PLATFORM_PARAMETER
76+
FeatureFlagsRestClient.FeatureFlagsPayload(
77+
buildNumber = BuildConfig.VERSION_CODE.toString(),
78+
deviceId = preferences.getString(WPCOM_PUSH_DEVICE_UUID, null)
79+
?: generateAndStoreUUID(),
80+
identifier = BuildConfig.APPLICATION_ID,
81+
marketingVersion = BuildConfig.VERSION_NAME,
82+
platform = FEATURE_FLAG_PLATFORM_PARAMETER,
83+
osVersion = android.os.Build.VERSION.RELEASE
84+
)
8185
)
8286
response.featureFlags?.let { configValues ->
8387
AppLog.e(UTILS, "Feature flag values synced")

WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/dashboard/CardsViewModelSliceTest.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ private const val DEVICE_ID_PARAM = "device_id_param"
106106
private const val IDENTIFIER_PARAM = "identifier_param"
107107
private const val MARKETING_VERSION_PARAM = "marketing_version_param"
108108
private const val PLATFORM_PARAM = "android"
109+
private const val ANDROID_VERSION_PARAM = "14.0"
109110

110111
/* MODEL */
111112

@@ -296,7 +297,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
296297
DEVICE_ID_PARAM,
297298
IDENTIFIER_PARAM,
298299
MARKETING_VERSION_PARAM,
299-
PLATFORM_PARAM
300+
PLATFORM_PARAM,
301+
ANDROID_VERSION_PARAM,
300302
)
301303

302304
viewModelSlice.initialize(testScope())
@@ -330,6 +332,7 @@ class CardsViewModelSliceTest : BaseUnitTest() {
330332
whenever(buildConfigWrapper.getAppVersionCode()).thenReturn(BUILD_NUMBER_PARAM.toInt())
331333
whenever(buildConfigWrapper.getApplicationId()).thenReturn(IDENTIFIER_PARAM)
332334
whenever(buildConfigWrapper.getAppVersionName()).thenReturn(MARKETING_VERSION_PARAM)
335+
whenever(buildConfigWrapper.androidVersion).thenReturn(ANDROID_VERSION_PARAM)
333336
whenever(preferenceUtilsWrapper.getFluxCPreferences()).thenReturn(sharedPreferences)
334337
whenever(sharedPreferences.getString(any(), anyOrNull())).thenReturn(DEVICE_ID_PARAM)
335338
}
@@ -500,7 +503,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
500503
DEVICE_ID_PARAM,
501504
IDENTIFIER_PARAM,
502505
MARKETING_VERSION_PARAM,
503-
PLATFORM_PARAM
506+
PLATFORM_PARAM,
507+
ANDROID_VERSION_PARAM,
504508
)
505509
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(CardsResult()))
506510
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(apiError)
@@ -522,7 +526,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
522526
DEVICE_ID_PARAM,
523527
IDENTIFIER_PARAM,
524528
MARKETING_VERSION_PARAM,
525-
PLATFORM_PARAM
529+
PLATFORM_PARAM,
530+
ANDROID_VERSION_PARAM,
526531
)
527532
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(data))
528533
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(success)
@@ -558,7 +563,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
558563
DEVICE_ID_PARAM,
559564
IDENTIFIER_PARAM,
560565
MARKETING_VERSION_PARAM,
561-
PLATFORM_PARAM
566+
PLATFORM_PARAM,
567+
ANDROID_VERSION_PARAM,
562568
)
563569
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(data))
564570
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(success)
@@ -581,7 +587,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
581587
DEVICE_ID_PARAM,
582588
IDENTIFIER_PARAM,
583589
MARKETING_VERSION_PARAM,
584-
PLATFORM_PARAM
590+
PLATFORM_PARAM,
591+
ANDROID_VERSION_PARAM,
585592
)
586593
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(data))
587594
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(success)
@@ -638,7 +645,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
638645
DEVICE_ID_PARAM,
639646
IDENTIFIER_PARAM,
640647
MARKETING_VERSION_PARAM,
641-
PLATFORM_PARAM
648+
PLATFORM_PARAM,
649+
ANDROID_VERSION_PARAM,
642650
)
643651
)
644652
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ext {
2525
automatticTracksVersion = '5.1.0'
2626
gutenbergMobileVersion = 'v1.120.0'
2727
wordPressAztecVersion = 'v2.1.3'
28-
wordPressFluxCVersion = '2.84.0'
28+
wordPressFluxCVersion = 'trunk-b5d95fda4257bd1b3c94b33088f5e2a3f48ff1c2'
2929
wordPressLoginVersion = '1.15.0'
3030
wordPressPersistentEditTextVersion = '1.0.2'
3131
wordPressUtilsVersion = '3.14.0'

libs/mocks/src/main/assets/mocks/mappings/wpcom/mobile/feature-flags.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"marketing_version": {
1616
"matches": "(.*)"
1717
},
18+
"os_version": {
19+
"matches": "(.*)"
20+
},
1821
"platform": {
1922
"matches": "android"
2023
},

0 commit comments

Comments
 (0)