Skip to content

Support internal FF default value #5978

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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 @@ -19,6 +19,7 @@ package com.duckduckgo.adclick.impl.remoteconfig
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue

@ContributesRemoteFeature(
scope = AppScope::class,
Expand All @@ -33,13 +34,13 @@ interface AdClickAttributionFeature {
* @return `true` when the remote config has the global "adClickAttribution" feature flag enabled
* If the remote feature is not present defaults to `false`
*/
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun self(): Toggle

/**
* @return `true` when the remote config has the global "persistExemptions" adClickAttribution sub-feature flag enabled
* If the remote feature is not present defaults to `false`
*/
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun persistExemptions(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.duckduckgo.data.store.api.SharedPreferencesProvider
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.RemoteFeatureStoreNamed
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.feature.toggles.api.Toggle.State
import com.squareup.anvil.annotations.ContributesBinding
import com.squareup.moshi.JsonAdapter
Expand All @@ -41,14 +42,14 @@ import kotlinx.coroutines.launch
toggleStore = NativeCrashFeatureMultiProcessStore::class,
)
interface NativeCrashFeature {
@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
@Toggle.InternalAlwaysEnabled
fun self(): Toggle

@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
fun nativeCrashHandling(): Toggle

@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
fun nativeCrashHandlingSecondaryProcess(): Toggle
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.duckduckgo.anvil.annotations

import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import kotlin.reflect.KClass

/**
Expand Down Expand Up @@ -50,7 +51,7 @@ annotation class ContributesActivePlugin(
* The default value of remote feature flag.
* Default is true (ie. enabled)
*/
val defaultActiveValue: Boolean = true,
val defaultActiveValue: DefaultFeatureValue = DefaultFeatureValue.TRUE,

/**
* The priority for the plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.anvil.annotations.PriorityKey
import com.duckduckgo.feature.toggles.api.RemoteFeatureStoreNamed
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.feature.toggles.api.Toggle.Experiment
import com.duckduckgo.feature.toggles.api.Toggle.InternalAlwaysEnabled
import com.google.auto.service.AutoService
Expand Down Expand Up @@ -143,6 +144,10 @@ class ContributesActivePluginPointCodeGenerator : CodeGenerator {
}

val content = FileSpec.buildFile(generatedPackage, pluginPointClassFileName) {
addImport(DefaultFeatureValue::class.fqName.parent().asString(), DefaultFeatureValue::class.fqName.shortName().asString())
addImport(DefaultFeatureValue::class.fqName.asString(), DefaultFeatureValue.TRUE.toString())
addImport(DefaultFeatureValue::class.fqName.asString(), DefaultFeatureValue.FALSE.toString())
addImport(DefaultFeatureValue::class.fqName.asString(), DefaultFeatureValue.INTERNAL.toString())
// This is the normal plugin point
addType(
TypeSpec.interfaceBuilder(pluginPointClassName)
Expand Down Expand Up @@ -176,7 +181,7 @@ class ContributesActivePluginPointCodeGenerator : CodeGenerator {
.addModifiers(ABSTRACT)
.addAnnotation(
AnnotationSpec.builder(Toggle.DefaultValue::class)
.addMember("defaultValue = %L", true)
.addMember("defaultValue = %L", "DefaultFeatureValue.TRUE")
.build(),
)
.returns(Toggle::class)
Expand Down Expand Up @@ -313,7 +318,7 @@ class ContributesActivePluginPointCodeGenerator : CodeGenerator {
val boundType = vmClass.annotations.firstOrNull { it.fqName == ContributesActivePlugin::class.fqName }?.boundTypeOrNull()!!
val featureDefaultValue = vmClass.annotations.firstOrNull {
it.fqName == ContributesActivePlugin::class.fqName
}?.defaultActiveValueOrNull() ?: true
}?.defaultActiveValueOrNull() ?: DefaultFeatureValue.TRUE
// the parent feature name is taken from the plugin interface name implemented by this class
val parentFeatureName = "pluginPoint${boundType.shortName}"
val featureName = "plugin${vmClass.shortName}"
Expand Down Expand Up @@ -346,6 +351,10 @@ class ContributesActivePluginPointCodeGenerator : CodeGenerator {
}

val content = FileSpec.buildFile(generatedPackage, pluginClassName) {
addImport(DefaultFeatureValue::class.fqName.parent().asString(), DefaultFeatureValue::class.fqName.shortName().asString())
addImport(DefaultFeatureValue::class.fqName.asString(), DefaultFeatureValue.TRUE.toString())
addImport(DefaultFeatureValue::class.fqName.asString(), DefaultFeatureValue.FALSE.toString())
addImport(DefaultFeatureValue::class.fqName.asString(), DefaultFeatureValue.INTERNAL.toString())
// First create the class that will contribute the active plugin.
// We do expect that the plugins are define using the "ContributesActivePlugin" annotation but are also injected
// using @Inject in the constructor, as the concrete plugin type is use as delegate.
Expand Down Expand Up @@ -416,7 +425,7 @@ class ContributesActivePluginPointCodeGenerator : CodeGenerator {
.addAnnotation(
AnnotationSpec.builder(Toggle.DefaultValue::class)
// The parent feature toggle is the one guarding the plugin point, for convention is default enabled.
.addMember("defaultValue = %L", true)
.addMember("defaultValue = %L", "DefaultFeatureValue.TRUE")
.build(),
)
.returns(Toggle::class)
Expand Down Expand Up @@ -604,7 +613,15 @@ class ContributesActivePluginPointCodeGenerator : CodeGenerator {
}

@OptIn(ExperimentalAnvilApi::class)
private fun AnnotationReference.defaultActiveValueOrNull(): Boolean? = argumentAt("defaultActiveValue", 2)?.value()
private fun AnnotationReference.defaultActiveValueOrNull(): DefaultFeatureValue? {
val rawValue = argumentAt("defaultActiveValue", 2)?.value() as FqName? ?: return null

return if (rawValue.parent() == DefaultFeatureValue::class.fqName) {
DefaultFeatureValue.valueOf(rawValue.shortName().toString())
} else {
null
}
}

@OptIn(ExperimentalAnvilApi::class)
private fun AnnotationReference.priorityOrNull(): Int? = argumentAt("priority", 3)?.value()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.mobile.android.vpn.feature
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue

/**
* Local feature/settings - they will never be in remote config
Expand All @@ -28,9 +29,9 @@ import com.duckduckgo.feature.toggles.api.Toggle
featureName = "appTpLocalFeature",
)
interface AppTpLocalFeature {
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun self(): Toggle

@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun verboseLogging(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.duckduckgo.feature.toggles.api.MetricsPixel
import com.duckduckgo.feature.toggles.api.MetricsPixelPlugin
import com.duckduckgo.feature.toggles.api.RemoteFeatureStoreNamed
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.feature.toggles.api.Toggle.DefaultValue
import com.duckduckgo.feature.toggles.api.Toggle.State
import com.duckduckgo.feature.toggles.api.Toggle.State.CohortName
Expand All @@ -54,43 +55,43 @@ import kotlinx.coroutines.withContext
settingsStore = ExceptionListsSettingStore::class,
)
interface AppTpRemoteFeatures {
@Toggle.DefaultValue(true)
@DefaultValue(DefaultFeatureValue.TRUE)
fun self(): Toggle

@Toggle.DefaultValue(true)
@DefaultValue(DefaultFeatureValue.TRUE)
fun restartOnConnectivityLoss(): Toggle

@DefaultValue(true)
@DefaultValue(DefaultFeatureValue.TRUE)
fun setSearchDomains(): Toggle // kill switch

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment001(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment002(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment003(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment004(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment005(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment006(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment007(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment008(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment009(): Toggle

@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsExperiment010(): Toggle

enum class Cohorts(override val cohortName: String) : CohortName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.di.scopes.ViewScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.mobile.android.vpn.databinding.ViewApptpSettingsItemBinding
import com.duckduckgo.mobile.android.vpn.feature.removal.VpnFeatureRemover
import com.duckduckgo.mobile.android.vpn.ui.newtab.AppTrackingProtectionNewTabSettingsViewModel.ViewState
Expand Down Expand Up @@ -119,6 +120,6 @@ class AppTrackingProtectionNewTabSettingViewPlugin @Inject constructor(
featureName = "newTabAppTPSectionSetting",
)
interface NewTabAppTrackingProtectionSectionSetting {
@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
fun self(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.duckduckgo.feature.toggles.api.FakeToggleStore
import com.duckduckgo.feature.toggles.api.FeatureToggles
import com.duckduckgo.feature.toggles.api.FeatureTogglesInventory
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.feature.toggles.api.Toggle.DefaultValue
import com.duckduckgo.feature.toggles.api.Toggle.State
import com.duckduckgo.mobile.android.app.tracking.AppTrackingProtection
Expand Down Expand Up @@ -272,15 +273,15 @@ abstract class TriggerTestScope private constructor()
featureName = "appTrackerProtection",
)
interface TestBlockListFeature {
@DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun self(): Toggle

@Toggle.DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsNextExperimentTest(): Toggle

@Toggle.DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun atpTdsNextExperimentAnotherTest(): Toggle

@Toggle.DefaultValue(false)
@DefaultValue(DefaultFeatureValue.FALSE)
fun nonMatchingFeatureName(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.browser.webview
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.squareup.anvil.annotations.ContributesBinding
import javax.inject.Inject

Expand All @@ -39,9 +40,9 @@ class InternalWebContentDebugging @Inject constructor(
featureName = "InternalWebContentDebuggingFlag",
)
interface WebContentDebuggingFeature {
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun self(): Toggle

@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun webContentDebugging(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package com.duckduckgo.app.autocomplete
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue

@ContributesRemoteFeature(
scope = AppScope::class,
featureName = "autocompleteTabs",
)
interface AutocompleteTabsFeature {
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun self(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import com.duckduckgo.common.utils.SingleLiveEvent
import com.duckduckgo.di.scopes.ActivityScope
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -456,6 +457,6 @@ class BrowserViewModel @Inject constructor(
featureName = "androidSkipUrlConversionOnNewTab",
)
interface SkipUrlConversionOnNewTabFeature {
@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
fun self(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.browser
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.feature.toggles.api.Toggle.InternalAlwaysEnabled

@ContributesRemoteFeature(
Expand All @@ -27,20 +28,20 @@ import com.duckduckgo.feature.toggles.api.Toggle.InternalAlwaysEnabled
)
interface SwipingTabsFeature {
// The main kill switch for the feature
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
@InternalAlwaysEnabled
fun self(): Toggle

// The toggle used for staged rollout to external users
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
@InternalAlwaysEnabled
fun enabledForUsers(): Toggle

// The toggle used to enable a potential fix for https://app.asana.com/0/1207418217763355/1209914129786590/f
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun tabSwipingFix1(): Toggle

// The toggle used to enable a potential fix for https://app.asana.com/0/1207418217763355/1209914129786590/f
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun tabSwipingFix2(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.duckduckgo.app.browser.applinks
import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue

@ContributesRemoteFeature(
scope = AppScope::class,
Expand All @@ -28,6 +29,6 @@ import com.duckduckgo.feature.toggles.api.Toggle
// A safeguard for this fix: https://app.asana.com/0/0/1207374732742336/1207383486029585/f
interface ExternalAppIntentFlagsFeature {

@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
fun self(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.duckduckgo.common.utils.DispatcherProvider
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.RemoteFeatureStoreNamed
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue
import com.duckduckgo.feature.toggles.api.Toggle.State
import com.squareup.anvil.annotations.ContributesBinding
import com.squareup.moshi.JsonAdapter
Expand All @@ -46,14 +47,14 @@ interface SSLCertificatesFeature {
* @return `true` when the remote config has the global "sslCertificates" feature flag enabled
* If the remote feature is not present defaults to `true`
*/
@Toggle.DefaultValue(true)
@Toggle.DefaultValue(DefaultFeatureValue.TRUE)
fun self(): Toggle

/**
* @return `true` when the remote config has the "allowBypass" flag enabled
* If the remote feature is not present defaults to `false`
*/
@Toggle.DefaultValue(false)
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun allowBypass(): Toggle
}

Expand Down
Loading
Loading