Skip to content

Commit

Permalink
Merge pull request #20938 from wordpress-mobile/task/os-version-rules
Browse files Browse the repository at this point in the history
Adds os_version parameter in feature flags and dynamic dashboard cards
  • Loading branch information
Antonis Lilis committed Jun 11, 2024
2 parents a0b6ece + 8521e72 commit 71b4b52
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class CardViewModelSlice @Inject constructor(
identifier = buildConfigWrapper.getApplicationId(),
marketingVersion = buildConfigWrapper.getAppVersionName(),
platform = FEATURE_FLAG_PLATFORM_PARAMETER,
osVersion = buildConfigWrapper.androidVersion
)
val result = cardsStore.fetchCards(payload)
val error = result.error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.util

import android.os.Build
import org.wordpress.android.BuildConfig
import javax.inject.Inject

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

val isWhatsNewFeatureEnabled = BuildConfig.ENABLE_WHATS_NEW_FEATURE

val androidVersion: String = Build.VERSION.RELEASE
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.coroutines.launch
import org.wordpress.android.BuildConfig
import org.wordpress.android.analytics.AnalyticsTracker
import org.wordpress.android.analytics.AnalyticsTracker.Stat
import org.wordpress.android.fluxc.network.rest.wpcom.mobile.FeatureFlagsRestClient
import org.wordpress.android.fluxc.persistence.FeatureFlagConfigDao.FeatureFlag
import org.wordpress.android.fluxc.store.NotificationStore.Companion.WPCOM_PUSH_DEVICE_UUID
import org.wordpress.android.fluxc.store.mobile.FeatureFlagsStore
Expand Down Expand Up @@ -72,12 +73,15 @@ class FeatureFlagConfig

private suspend fun fetchRemoteFlags() {
val response = featureFlagStore.fetchFeatureFlags(
buildNumber = BuildConfig.VERSION_CODE.toString(),
deviceId = preferences.getString(WPCOM_PUSH_DEVICE_UUID, null)
?: generateAndStoreUUID(),
identifier = BuildConfig.APPLICATION_ID,
marketingVersion = BuildConfig.VERSION_NAME,
platform = FEATURE_FLAG_PLATFORM_PARAMETER
FeatureFlagsRestClient.FeatureFlagsPayload(
buildNumber = BuildConfig.VERSION_CODE.toString(),
deviceId = preferences.getString(WPCOM_PUSH_DEVICE_UUID, null)
?: generateAndStoreUUID(),
identifier = BuildConfig.APPLICATION_ID,
marketingVersion = BuildConfig.VERSION_NAME,
platform = FEATURE_FLAG_PLATFORM_PARAMETER,
osVersion = android.os.Build.VERSION.RELEASE
)
)
response.featureFlags?.let { configValues ->
AppLog.e(UTILS, "Feature flag values synced")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private const val DEVICE_ID_PARAM = "device_id_param"
private const val IDENTIFIER_PARAM = "identifier_param"
private const val MARKETING_VERSION_PARAM = "marketing_version_param"
private const val PLATFORM_PARAM = "android"
private const val ANDROID_VERSION_PARAM = "14.0"

/* MODEL */

Expand Down Expand Up @@ -296,7 +297,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
DEVICE_ID_PARAM,
IDENTIFIER_PARAM,
MARKETING_VERSION_PARAM,
PLATFORM_PARAM
PLATFORM_PARAM,
ANDROID_VERSION_PARAM,
)

viewModelSlice.initialize(testScope())
Expand Down Expand Up @@ -330,6 +332,7 @@ class CardsViewModelSliceTest : BaseUnitTest() {
whenever(buildConfigWrapper.getAppVersionCode()).thenReturn(BUILD_NUMBER_PARAM.toInt())
whenever(buildConfigWrapper.getApplicationId()).thenReturn(IDENTIFIER_PARAM)
whenever(buildConfigWrapper.getAppVersionName()).thenReturn(MARKETING_VERSION_PARAM)
whenever(buildConfigWrapper.androidVersion).thenReturn(ANDROID_VERSION_PARAM)
whenever(preferenceUtilsWrapper.getFluxCPreferences()).thenReturn(sharedPreferences)
whenever(sharedPreferences.getString(any(), anyOrNull())).thenReturn(DEVICE_ID_PARAM)
}
Expand Down Expand Up @@ -500,7 +503,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
DEVICE_ID_PARAM,
IDENTIFIER_PARAM,
MARKETING_VERSION_PARAM,
PLATFORM_PARAM
PLATFORM_PARAM,
ANDROID_VERSION_PARAM,
)
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(CardsResult()))
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(apiError)
Expand All @@ -522,7 +526,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
DEVICE_ID_PARAM,
IDENTIFIER_PARAM,
MARKETING_VERSION_PARAM,
PLATFORM_PARAM
PLATFORM_PARAM,
ANDROID_VERSION_PARAM,
)
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(data))
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(success)
Expand Down Expand Up @@ -558,7 +563,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
DEVICE_ID_PARAM,
IDENTIFIER_PARAM,
MARKETING_VERSION_PARAM,
PLATFORM_PARAM
PLATFORM_PARAM,
ANDROID_VERSION_PARAM,
)
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(data))
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(success)
Expand All @@ -581,7 +587,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
DEVICE_ID_PARAM,
IDENTIFIER_PARAM,
MARKETING_VERSION_PARAM,
PLATFORM_PARAM
PLATFORM_PARAM,
ANDROID_VERSION_PARAM,
)
whenever(cardsStore.getCards(siteModel)).thenReturn(flowOf(data))
whenever(cardsStore.fetchCards(fetchCardsPayload)).thenReturn(success)
Expand Down Expand Up @@ -638,7 +645,8 @@ class CardsViewModelSliceTest : BaseUnitTest() {
DEVICE_ID_PARAM,
IDENTIFIER_PARAM,
MARKETING_VERSION_PARAM,
PLATFORM_PARAM
PLATFORM_PARAM,
ANDROID_VERSION_PARAM,
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ext {
automatticTracksVersion = '5.1.0'
gutenbergMobileVersion = 'v1.120.0'
wordPressAztecVersion = 'v2.1.3'
wordPressFluxCVersion = '2.84.0'
wordPressFluxCVersion = 'trunk-b5d95fda4257bd1b3c94b33088f5e2a3f48ff1c2'
wordPressLoginVersion = '1.15.0'
wordPressPersistentEditTextVersion = '1.0.2'
wordPressUtilsVersion = '3.14.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"marketing_version": {
"matches": "(.*)"
},
"os_version": {
"matches": "(.*)"
},
"platform": {
"matches": "android"
},
Expand Down

0 comments on commit 71b4b52

Please sign in to comment.