Flags Feature#2982
Conversation
Feature flagging [WIP]
Fix detekt issues
feat: context management
Co-authored-by: Nikita Ogorodnikov <[email protected]>
Co-authored-by: Nikita Ogorodnikov <[email protected]>
…ent-manager-or-eliminate' into typo/FFL-1117-pass-default-client-configuration-to-flags-enable
Co-authored-by: Janine Chan <[email protected]>
33c8342
Co-authored-by: Janine Chan <[email protected]>
Co-authored-by: Janine Chan <[email protected]>
|
|
||
| The Datadog Feature Flags SDK for Android allows you to evaluate feature flags and experiments in your Android application and automatically send flag evaluation data to Datadog for monitoring and analysis. | ||
|
|
||
| ## Installation |
There was a problem hiding this comment.
I agree there's ambiguity. I've reflected the same pattern as the core README: Getting Started and Initial Setup sections.
|
|
||
| The `FlagsConfiguration.Builder` supports the following options: | ||
|
|
||
| #### RUM integration |
| .build() | ||
| ``` | ||
|
|
||
| **Note:** This setting only has an effect if you have enabled RUM (see `Prerequisites` section). If RUM is not enabled, flag evaluations are not sent to RUM regardless of this setting. |
janine-c
left a comment
There was a problem hiding this comment.
Looks awesome, thanks for addressing my feedback so quickly! Couple tiny suggestions but no major blockers 🙂
| The Datadog Feature Flags SDK for Android allows you to evaluate feature flags and experiments in your Android application and automatically send flag evaluation data to Datadog for monitoring and analysis. | ||
|
|
||
| ## Installation | ||
| ## Getting Started |
There was a problem hiding this comment.
| ## Getting Started | |
| ## Getting started |
| ``` | ||
|
|
||
| ## Prerequisites | ||
| ### Initial Setup |
There was a problem hiding this comment.
| ### Initial Setup | |
| ### Initial setup |
| ``` | ||
|
|
||
| **Note:** This setting only has an effect if you have enabled RUM (see `Prerequisites` section). If RUM is not enabled, flag evaluations are not sent to RUM regardless of this setting. | ||
| **Note:** This setting only has an effect if you have enabled RUM (see [Initial Setup](#initial-setup) section). If RUM is not enabled, flag evaluations are not sent to RUM regardless of this setting. |
There was a problem hiding this comment.
| **Note:** This setting only has an effect if you have enabled RUM (see [Initial Setup](#initial-setup) section). If RUM is not enabled, flag evaluations are not sent to RUM regardless of this setting. | |
| **Note:** This setting only has an effect if you have enabled RUM (see [Initial setup](#initial-setup)). If RUM is not enabled, flag evaluations are not sent to RUM regardless of this setting. |
| - `flagMetadata: Map<String, Any>?` - Optional metadata associated with the flag | ||
|
|
||
| **Error Codes:** | ||
| ##### Error Codes |
There was a problem hiding this comment.
| ##### Error Codes | |
| ##### Error codes |
My bad for missing this before, sorry!
| ## Prerequisites for RUM Integration | ||
| 1. Add the `dd-sdk-android-rum` dependency to your project | ||
| 2. Enable RUM before initializing the Flags feature (see `Prerequisites` section) | ||
| 2. Enable RUM before initializing the Flags feature (see [Initial Setup](#initial-setup) section) |
There was a problem hiding this comment.
| 2. Enable RUM before initializing the Flags feature (see [Initial Setup](#initial-setup) section) | |
| 2. Enable RUM before initializing the Flags feature (see [Initial setup](#initial-setup)) |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What does this PR do?
This PR introduces DatadogFlags (
dd-sdk-android-flags), a new module for feature flag evaluation in Android applications. The module enables dynamic configuration and A/B testing by integrating with Datadog's Feature Flag product.Key capabilities:
Motivation
This feature allows Android developers to dynamically control application behavior through feature flags, enabling:
This implementation follows similar patterns established in the Datadog iOS SDK and aligns with OpenFeature specification principles for provider API design.
Additional Notes
Module Architecture
Core Components:
FlagsClient- Main API interface for flag evaluation with methods likeresolve(),resolveBooleanValue(),resolveStringValue(),resolveIntValue(),resolveDoubleValue(), andresolveStructureValue()DatadogFlagsClient- Production implementation that integrates with Datadog's flag evaluation system, manages flag resolution, type conversion, and trackingFlagsRepository- Manages Flag and evaluation context storage and, retrieval using DataStore for persistent cachingPrecomputedAssignmentsDownloader- Handles fetching precomputed flag assignments from CDN endpoints via HTTP requestsPrecomputedAssignmentsRequestFactory- Factory for creating authenticated HTTP requests to the Datadog feature flags servicePrecomputeMapper- Parses and maps JSON responses from the CDN into internal flag modelsEvaluationsManager- Orchestrates flag evaluation context updates and triggers background fetching of flag assignmentsExposureEventsProcessor- Tracks flag evaluations with bounded LRU cache for de-duplication, preventing duplicate exposure eventsRumEvaluationLogger- Reports flag evaluations to RUM for correlation with user sessions and application behaviorFlagsFeature- Core feature registration, lifecycle management, and client registrySupporting Components:
FlagsConfiguration- Configuration for RUM integration, exposure tracking, and custom endpointsEvaluationContext- Contains targeting key and attributes for flag evaluationResolutionDetails- Comprehensive resolution information including value, variant, reason, error details, and metadataFlagValueConverter- Type-safe conversion between flag values and expected types with validationNoOpFlagsClient- Fallback client implementation for graceful error handling when feature is not properly initializedRelated PRs
Key Features
Type-Safe Flag Resolution:
resolve()method with comprehensive metadata and error informationExposure Tracking:*
FlagsConfiguration.trackExposuresRUM Integration:
FlagsConfiguration.rumIntegrationEnabledNamed Client Support:
FlagsFeatureFlagsClient.get(name)Persistent Storage:
Error Handling:
Configuration Options
Usage Example
Review checklist (to be filled by reviewers)