- Notifications
You must be signed in to change notification settings - Fork0
A provider for DatadogFlags in dd-sdk-ios with OpenFeature's swift-sdk
License
DataDog/dd-openfeature-provider-swift
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This package provides a bridge betweenOpenFeature and Datadog feature flags, allowing applications to use OpenFeature's standardized interface with Datadog's feature flagging services running under the hood.
- Xcode 15.0+
- Swift 5.9+
- iOS 14.0+ / macOS 12.0+ / watchOS 7.0+ / tvOS 14.0+
- Install Xcode from the Mac App Store or Apple Developer portal
- Verify Xcode Command Line Tools are installed:
xcode-select --install
Add this package to yourPackage.swift file:
dependencies:[.package(url:"https://github.com/Datadog/dd-openfeature-provider-swift.git", from:"0.1.0")]
Checkreleases for available versions.
Requirements:
- Datadog SDK: 3.2.0+
- OpenFeature Swift SDK: 0.4.0
Or add it through Xcode:
- File →Add Package Dependencies
- Enter:
https://github.com/Datadog/dd-openfeature-provider-swift.git
SeeDEVELOPMENT.md for detailed development setup, testing, and contribution guidelines.
import OpenFeatureimport DatadogOpenFeatureProviderimport DatadogCoreimport DatadogFlags// 1. Initialize Datadog SDK and enable flagsletconfig=Datadog.Configuration.builderUsing( clientToken:"YOUR_CLIENT_TOKEN", environment:"production").build()Datadog.initialize(with: config, trackingConsent:.granted)letflagsConfig=Flags.Configuration()Flags.enable(with: flagsConfig)// 2. Create user context for targetingletcontext=ImmutableContext(targetingKey:"user123")// 3. Create and register the OpenFeature providerletprovider=DatadogProvider()awaitOpenFeatureAPI.shared.setProviderAndWait(provider: provider, initialContext: context)// 4. Get OpenFeature client and evaluate flagsletclient=OpenFeatureAPI.shared.getClient()letflagValue= client.getBooleanValue(key:"my-feature-flag", defaultValue:false)
// Create detailed user context for advanced targetingletnewContext=ImmutableContext( targetingKey:"user123", structure:ImmutableStructure(attributes:["segment":Value.string("premium"),"beta_user":Value.boolean(true),"region":Value.string("us-west")]))awaitOpenFeatureAPI.shared.setEvaluationContextAndWait(evaluationContext: newContext)// Flag evaluations will now use the new contextletclient=OpenFeatureAPI.shared.getClient()letflagValue= client.getBooleanValue(key:"my-feature-flag", defaultValue:false)
┌─────────────────┐ ┌──────────────────┐│ Your App │────│ OpenFeature SDK ││ │ │ ││ - App code │ │ - Client API ││ - Flag requests │ │ - Provider mgmt ││ - Context mgmt │ │ - Type system │└─────────────────┘ │ - Hook system │ └──────────────────┘ │ ▼ ┌──────────────────┐ │ DatadogProvider │ │ │ │ - Creates & │ │ delegates to │ │ FlagsClient │ │ - Context conv. │ │ - Type mapping │ └──────────────────┘ │ ▼ ┌──────────────────┐ ┌──────────────────┐ │ DatadogFlags │────│ Datadog Backend │ │ SDK Client │ │ │ │ (dd-sdk-ios) │ │ - Flag configs │ │ │ │ - User targeting │ │ - HTTP requests │ │ - A/B testing │ │ - Caching │ └──────────────────┘ │ - Networking │ └──────────────────┘- Your App: Your application using OpenFeature's standard API
- OpenFeature SDK: The core OpenFeature Swift SDK that provides the client API, provider management, type system, and hook system
- DatadogProvider: A bridge that creates a DatadogFlags client, converts between OpenFeature and Datadog types, and delegates flag operations to the client
- DatadogFlags SDK Client: The client from dd-sdk-ios that communicates with Datadog's backend (created automatically by the provider)
- Datadog Backend: Datadog's service that serves flag configurations and handles targeting
We welcome contributions! Please seeCONTRIBUTING.md for contribution guidelines andDEVELOPMENT.md for detailed setup instructions, testing guidelines, and development workflow.
This project is licensed under the Apache License 2.0 - see theLICENSE file for details.
About
A provider for DatadogFlags in dd-sdk-ios with OpenFeature's swift-sdk
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.