Repository navigation
Conversation
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 2 Pipeline jobs failed
ℹ️ InfoNo other issues found (see more)🧪 All tests passed Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: c4075a8 | Docs | View more details | Give us feedback! |
Draft
4 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Summary: Adds a
flagSelectionoption toDdFlags.enable(). With it, the native SDKs request only the flags that match any of the given tags or key patterns. React Native checks the shape of the value and passes it to the native Flags configuration. The native SDKs canonicalize it, enforce the limits, send it in the precompute request, handle theDD-Flag-Selection-Ignoredresponse header, and log and report drops.Important
Draft until dd-sdk-android 3.17.0 is released.
FlagsConfiguration.Builder.flagSelectionis on dd-sdk-androiddevelop(dd-sdk-android#4031) but not in 3.16.0, which this branch pins. The Android build fails until the Android pin is bumped to 3.17.0. The bump follows the release, and this PR leaves draft after it.Stacked on #1559 (iOS SDK 3.22.0), which adds
Flags.Configuration.flagSelection. The base branch is #1559's branch, so the diff shows only this change.Changes:
@datadog/mobile-react-native): an exportedFlagSelectiontype,{ tags?: readonly string[]; keyPatterns?: readonly string[] }, andFlagsConfiguration.flagSelection. The name and shape match theFlagSelectionthat [FFL-3355] feat: add standalone rules configuration fetching #1508 exports from@datadog/mobile-react-native-openfeature/rules-based, so both entry points take the same object.DdFlags.enable): only what the bridges can't carry. A selection that is not an object, a list that is not an array, a non-string or null element, a hole, or an unpaired UTF-16 surrogate is malformed. So is a selection whose getters throw.DdFlags.enable()logs this error once per call throughInternalLog, and sends no selection, so every flag loads:flagSelection was not sent (malformed_selection: flagSelection must be an object with optional tags and keyPatterns string arrays). Loading the full flag configuration.The text is the browser SDK's, also used by [FFL-3355] feat: add standalone rules configuration fetching #1508.
nullor absent list is omitted, and a selection with neither list is not sent.Flags.FlagSelection(tags:keyPatterns:).FlagsConfiguration.Builder.flagSelection(tags, keyPatterns).packages/react-native-openfeature/README.md.Why JS rejects unpaired surrogates and null elements: iOS's option is typed and has no
malformed_selectioncheck, while Android rejects both. Rejecting them before the bridge gives both platforms the same result: an error log and no selection.Logs: the malformed log above comes from JS and uses
flagSelection. The limit and "ignored by the server" logs come from the native SDKs, with their own option names:Flags.Configuration.flagSelectionon iOS andflagSelectionon Android. All of them are visible only when the core configuration setsverbosity, which also sets the native verbosity.Motivation
FFL-3726. The browser, iOS (dd-sdk-ios#3344, in 3.22.0) and Android (dd-sdk-android#4031, in 3.17.0) Flags SDKs support flag selection. React Native apps could not set it.
Additional Notes
QA:
yarn lint,yarn test,yarn preparepass.yarn jest packages/core/src/flags.flagSelection.test.tscovers each malformed shape, lone high and low surrogates, reversed pairs, well-formed pairs, throwing getters and proxies, and copying.DdFlags.test.tscovers pass-through, omitted lists, the exact log text, one log perenable()call, and that no selection is sent when malformed.3.17.0-SNAPSHOTwith a temporary, uncommitted pin and snapshot-repository override:./gradlew ktlintCheck detekt testDebugUnitTest -PDdSdkReactNative_minSdkVersion=24passes (210 tests), andcompileDebugKotlinandcompileReleaseKotlinsucceed. The full./gradlew buildstops atverifyReleaseResourceson the linux arm64 host used, because AAPT2 ships only as x86_64. NewDdFlagsImplementationTestcases compare the builtFlagsConfigurationwith one made through the public builder: both lists, one list, none, a non-map value, non-string values dropped, and surrogates passed unchanged.test:native-ios,test:native-ios-newarchandtest:native-ios-sron iOS 3.22.0. NewDdFlagsTestscases: dictionary toflagSelection, one list, surrogate pair kept, non-string values dropped, non-dictionary ignored, absent tonil.example/on iOS and Android, checking the precompute request body: pending, after the Android bump.Expo: JS-only option, no native project changes, so
expo-datadogneeds no change.Out of scope: the JS rules-based helper (#1508), and the offline provider, which serves a configuration the app supplies and is not filtered.
Review checklist (to be filled by reviewers)