$ curl 'https://api.flagsmith.com/api/v1/flags/'
-H 'X-Environment-Key: TijpMX6ajA7REC4bf5suYg' | jq
[
{
"id": 131,
"feature": {
"id": 56,
"name": "kyc_button",
"created_date": "2018-06-28T13:30:09.983174Z",
"description": null,
"initial_value": null,
"default_enabled": true,
"type": "FLAG"
},
"feature_state_value": null,
"enabled": true,
"environment": 12,
"identity": null,
"feature_segment": null
}
]
import flagsmith from 'flagsmith';
import { useFlags, FlagsmithProvider } from 'flagsmith/react';
const App = () => (
<FlagsmithProvider options={{ environmentID: "QjgYur4LQTwe5HpvbvhpzK"}} flagsmith={flagsmith}>
<HomePage/>
</FlagsmithProvider>
)
const HomePage = () => {
const flags = useFlags(['chat_widget']);
return (
<>{flags.chat_widget.enabled && <ChatWidget>}</>
);
}
import flagsmith from 'flagsmith/isomorphic';
import { useFlags, FlagsmithProvider } from 'flagsmith/react';
const App = ({ Component, pageProps, flagsmithState }) => (
<FlagsmithProvider serverState={flagsmithState} flagsmith={flagsmith}>
<Component {...pageProps} />
</FlagsmithProvider>
)
App.getInitialProps = async () => {
await flagsmith.init({ environmentID: "QjgYur4LQTwe5HpvbvhpzK"});
return { flagsmithState: flagsmith.getState() }
}
const HomePage = () => {
const flags = useFlags(['chat_widget']);
return <>{flags.chat_widget.enabled && <ChatWidget>}</>
}
const Flagsmith = require('flagsmith-nodejs');
const flagsmith = new Flagsmith({
environmentKey: 'TijpMX6ajA7REC4bf5suYg',
});
const identifier = 'delboy@trotterstraders.co.uk';
const traitList = { car_type: 'robin_reliant' };
const flags = await flagsmith.getIdentityFlags(identifier, traitList);
var showButton = flags.isFeatureEnabled('secret_button');
var buttonData = flags.getFeatureValue('secret_button');
implementation 'com.github.Flagsmith:flagsmith-kotlin-android-client:1.0.1'
lateinit var flagsmith : Flagsmith
override fun onCreate(savedInstanceState: Bundle?) {
initFlagsmith();
}
private fun initFlagsmith() {
flagsmith = Flagsmith(environmentKey = FlagsmithConfigHelper.environmentDevelopmentKey, context = context)
}
flagsmith.getFeatureFlags { result ->
result.fold(
onSuccess = { flagList ->
Log.i("Flagsmith", "Current flags:")
flagList.forEach { Log.i("Flagsmith", "- ${it.feature.name} - enabled: ${it.enabled} value: ${it.featureStateValue ?: "not set"}") }
},
onFailure = { err ->
Log.e("Flagsmith", "Error getting feature flags", err)
})
}
pod 'FlagsmithClient', '~> 1.0'
import FlagsmithClient
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Flagsmith.shared.apiKey = "QjgYur4LQTwe5HpvbvhpzK"
Flagsmith.shared.getFeatureFlags() { (result) in
switch result {
case .success(let flags):
for flag in flags {
let name = flag.feature.name
let value = flag.value
let enabled = flag.enabled
print(name, "= enabled:", enabled, "value:", value ?? "nil")
}
}
dependencies:
flagsmith:
var flagsmith =
FlagsmithClient(apiKey: 'TijpMX6ajA7REC4bf5suYg')
bool featureEnabled =
await flagsmith.hasFeatureFlag("chat_widget");
if (featureEnabled) {
}
var user = FeatureUser(identifier: 'flagsmith_sample_user');
bool featureEnabled = a
wait flagsmith.hasFeatureFlag('chat_widget', user: user);
if (featureEnabled) {
}
$ pip install flagsmith
from flagsmith import Flagsmith;
flagsmith = Flagsmith(
environment_key = "TijpMX6ajA7REC4bf5suYg"
)
identifier = "delboy@trotterstraders.co.uk"
traits = {"car_type": "robin_reliant"}
identity_flags = flagsmith.get_identity_flags(identifier=identifier, traits=traits)
show_button = identity_flags.is_feature_enabled("secret_button")
button_data = json.loads(identity_flags.get_feature_value("secret_button"))
$ gem install flagsmith
require "flagsmith"
$flagsmith = Flagsmith::Client.new(
environment_key: 'TijpMX6ajA7REC4bf5suYg'
)
$identifier = 'delboy@trotterstraders.co.uk'
$traits = {'car_type': 'robin_reliant'}
$flags = $flagsmith.get_identity_flags($identifier, **$traits)
$show_button = $flags.is_feature_enabled('secret_button')
$button_data = $flags.get_feature_value('secret_button')
$ dotnet add package Flagsmith --version 4.0.0
using Flagsmith;
FlagsmithClient _flagsmithClient;
_flagsmithClient = new("TijpMX6ajA7REC4bf5suYg");
var identifier = "delboy@trotterstraders.co.uk";
var traitKey = "car_type";
var traitValue = "robin_reliant";
var traitList = new List<Trait> { new Trait(traitKey, traitValue) };
request
var flags = _flagsmithClient.GetIdentityFlags(identifier, traitList).Result;
var showButton = flags.IsFeatureEnabled("secret_button").Result;
composer require flagsmith/flagsmith-php-client
use Flagsmith\Flagsmith;
$flagsmith = new Flagsmith('TijpMX6ajA7REC4bf5suYg');
$identifier = 'delboy@trotterstraders.co.uk';
$traits = (object) [ 'car_type' => 'robin_reliant' ];
$flags = $flagsmith->getIdentityFlags($identifier, $traits);
$showButton = $flags->isFeatureEnabled('secret_button');
$buttonData = $flags->getFeatureValue('secret_button');
go get github.com/Flagsmith/flagsmith-go-client/v2
import (
flagsmith "github.com/Flagsmith/flagsmith-go-client"
)
client := flagsmith.NewClient('TijpMX6ajA7REC4bf5suYg', flagsmith.WithContext(ctx),)
trait := flagsmith.Trait{TraitKey: "trait", TraitValue: "trait_value"}
traits = []*flagsmith.Trait{&trait}
flags, _ := client.GetIdentityFlags(identifier, traits)
showButton, _ := flags.IsFeatureEnabled("secret_button")
buttonData, _ := flags.GetFeatureValue("secret_button")
# Cargo.toml
flagsmith = "~1"
let options = FlagsmithOptions {..Default::default()};
let flagsmith = Flagsmith::new(
env::var("TijpMX6ajA7REC4bf5suYg").expect("Key not found"), options,);
use flagsmith_flag_engine::identities::Trait;
use flagsmith_flag_engine::types::{FlagsmithValue, FlagsmithValueType};
let identifier = "delboy@trotterstraders.co.uk";
let traits = vec![Trait {
trait_key: "car_type".to_string(),
trait_value: FlagsmithValue {
value: "robin_reliant".to_string(),
value_type: FlagsmithValueType::String,
},
}];
let identity_flags = flagsmith.get_identity_flags(identifier, Some(traits)).unwrap();
let show_button = identity_flags.is_feature_enabled("secret_button").unwrap();
let button_data = identity_flags.get_feature_value_as_string("secret_button").unwrap();