Add native Datadog Flags Flutter client#1044
Draft
leoromanovsky wants to merge 16 commits into
Draft
Conversation
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.
Motivation
Flutter customers need a Dart-native Datadog Flags client that matches the mobile precompute model without bridging through iOS or Android SDKs. The SDK also needs a dogfood path that proves the example app is making real precompute, exposure, and flagevaluation EVP intake requests.
Changes
This PR adds a new
datadog_flagsFlutter package that fetches precomputed assignments, resolves typed values and details synchronously after context load, persists last-known assignments, reports RUM feature flag evaluations, sends deduped exposure events to EVP intake whendoLogis true, and aggregates flagevaluation metrics for EVP intake. It also stores the initialized Datadog SDK configuration so the flags package can derive the default Datadog context from the existing SDK.The simple example app now includes a live Flags dogfood screen that can run against Datadog endpoints with dart-defines for
DD_SITE,DD_ENV,DD_CLIENT_TOKEN,DD_APPLICATION_ID, targeting context, and flag key lists. By default, it evaluates the boolean, string, integer, float, and JSON dogfooding flags. The screen renders each resolved value under its flag key so long keys and JSON values have room, and it keeps only the counters that are useful while dogfooding the app: evaluations recorded and exposures. The counters wrap a real forwarding HTTP client; they observe outgoing requests before forwarding them to the live precompute and EVP intake endpoints.The package tests include mirrored precomputed fixtures from DataDog/ffe-system-test-data#12 until that fixture PR can be consumed directly.
Decisions
The implementation is native Dart and intentionally does not depend on or bridge to native flag SDKs. It follows the precompute API shape accepted by the live CDN endpoint:
/precompute-assignments.Gov sites fall back to US1, and future OpenFeature work stays separate from this MVP. Dogfood validation uses real Datadog requests. The forwarding counter only observes requests at the HTTP boundary and forwards them, which keeps it useful for the example app without creating a local backend that could obscure request shape, auth issues, exposure logging, or flagevaluation EVP tracks.
Validation
DD_SITE=datad0g.com,DD_ENV=staging, and the default dogfooding flag set: assignments ready, evaluations recorded = 5, exposures = 1; boolean =false, string =variant_2, integer =-5, float =1.0, JSON ={ "ai_model": "openai", "enabled": true }. All five flags fit on the first screen with values under keys.DD_SITE=datad0g.com,DD_ENV=staging, andFLAGS_STRING_KEYS=ffe-dogfooding-string-flag: assignments ready, evaluations recorded = 1, exposures = 1, string flag value =variant_2.https://browser-intake-datadoghq.com/api/v2/exposures?ddsource=flutterwith EVP headers and that flagevaluation metrics are posted tohttps://browser-intake-datadoghq.com/api/v2/flagevaluation?ddsource=flutterwith EVP headers.Question for developers