$ 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");
flagsmith.init({
environmentID: 'QjgYur4LQTwe5HpvbvhpzK',
});
const featureEnabled =
await flagsmith.hasFeature('chat_widget');
implementation 'com.flagsmith:flagsmith-java-client:2.3'
FlagsmithClient flagsmithClient =
FlagsmithClient.newBuilder()
.setApiKey("QjgYur4LQTwe5HpvbvhpzK")
.build();
if (flagsmithClient.hasFeatureFlag("chat_widget");) {
userInterface.chatWidgetEnable()
} else {
return false;
}
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: 'QjgYur4LQTwe5HpvbvhpzK')
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;
fs = Flagsmith(environment_id="QjgYur4LQTwe5HpvbvhpzK")
if fs.has_feature("header"):
if fs.feature_enabled("header"):
value = fs.get_value("header", '<My User Id>')
value = fs.get_value("header")
fs.set_trait("accept-cookies", "true", "ben@flagsmith.com))
fs.get_trait("accept-cookies", "ben@flagsmith.com"))
$ gem install flagsmith
require "flagsmith"
flagsmith = Flagsmith.new("<<Your API KEY>>")
if flagsmith.get_value("font_size")
end
if flagsmith.feature_enabled?("does_not_exist")
else
end
$ dotnet add package Flagsmith --version 3.0.0
FlagsmithConfiguration configuration = new FlagsmithConfiguration()
{
ApiUrl = "https://api.flagsmith.com/api/v1/",
EnvironmentKey = "QjgYur4LQTwe5HpvbvhpzK"
};
FlagsmithClient client = new FlagsmithClient(configuration);
bool featureEnabled = await FlagsmithClient.instance.HasFeatureFlag("chat_widget");
if (featureEnabled) {
} else {
}
composer require flagsmith/flagsmith-php-client
$fs = new Flagsmith('QjgYur4LQTwe5HpvbvhpzK');
$flags = $fs->getFlags();
foreach ($flags as &$value) {
print_r($value);
}
$ go get github.com/flagsmith/flagsmith-go-client
import (
"github.com/flagsmith/flagsmith-go-client"
)
bt := bullettrain.DefaultBulletTrainClient("QjgYur4LQTwe5HpvbvhpzK")
enabled, err := bt.FeatureEnabled("chat_widget")
if err != nil {
log.Fatal(err)
} else {
if (enabled) {
fmt.Printf("Feature enabled")
}
}
# Cargo.toml
flagsmith = "0.2.0"
let fs = flagsmith::Client::new("QjgYur4LQTwe5HpvbvhpzK");
if fs.feature_enabled("chat_widget")? {
println!("Feature enabled");
}
if let Some(Value::String(s)) = fs.get_value("cart_abundant_notification_ab_test")? {
println!("{}", s);
}