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

Adds os_version parameter in feature flags and dynamic dashboard cards #20938

Merged
merged 6 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -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-alpha1'
wordPressAztecVersion = 'v2.1.3'
wordPressFluxCVersion = '2.83.0'
wordPressFluxCVersion = '3028-eb0a976762876b228eed98b564ea77ab97659673'
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
Loading