-
Notifications
You must be signed in to change notification settings - Fork 909
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
Add isReturningUser and isPrivacyProEligible targets and modularize target management #5277
base: develop
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
8a8227e
to
65aaec5
Compare
65aaec5
to
3df6012
Compare
} | ||
|
||
// In the remote config, targets is a list, but it should not be. So we pick the first one (?) | ||
if (!containsAndMatchCohortTargets(targets.firstOrNull())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was certainly wrong before, but we never added more than one target so far so 🤷
@ContributesMultibinding(AppScope::class) | ||
class LocaleToggleTargetMatcher @Inject constructor( | ||
private val appBuildConfig: AppBuildConfig, | ||
) : TargetMatcherPlugin { | ||
override fun matchesTargetProperty(target: Target): Boolean { | ||
val country = appBuildConfig.deviceLocale.country.lowercase() | ||
val language = appBuildConfig.deviceLocale.language.lowercase() | ||
|
||
val isCountryMatching = target.localeCountry?.let { | ||
country == it.lowercase() | ||
} ?: true | ||
val isLanguageMatching = target.localeLanguage?.let { | ||
language == it.lowercase() | ||
} ?: true | ||
|
||
return isCountryMatching && isLanguageMatching | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this logic, I realised we only support one language and one country as a target. If we wanted to test multiple languages, it wouldn’t work, right? Shouldn't it be an array instead of a String?
cc/ @marcosholgado
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it supports multiple languages, targets is an array already, i.e.
"targets": [
{
"variantKey": "mh"
},
{
"variantKey": "mp"
}
]
) : TargetMatcherPlugin { | ||
override fun matchesTargetProperty(target: Target): Boolean { | ||
return target.isPrivacyProEligible?.let { isPrivacyProEligible -> | ||
// runBlocking sucks I know :shrug: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works as expected 💯 I added a question but it is not related to this PR so feel free to merge it
Task/Issue URL: https://app.asana.com/0/1198194956794324/1208710375047087/f
Description
This PR adds couple new targets for FF, ie. isReturningUser and isPrivacyProEligible, both of type
Boolean
The PR also modularizes the way we hande targets, turning them into plugins so that it's easier in the future to add targets without (almost) touching the toggles API
Steps to test this PR
Feature 1