• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
launchdarkly.com

EDIT ON GITHUB

Getting all flags

Read time: 4 minutes
Last edited: Jun 18, 2021

Overview

This topic explains how the all flags feature works in the LaunchDarkly SDKs that support it. The all flags feature is available for both client-side and server-side SDKs.

Understanding the all flags feature

The all flags feature returns the state of all feature flags targeted to a user. This includes the flag values, and, for server-side SDKs, metadata for use on the front end.

In most of the client- and server-side SDKs, getting all flags does not create users or other analytic events in your LaunchDarkly account. Unlike evaluating individual flags or identifying users, getting all flags usually does not send events that create a user within LaunchDarkly or populate the "Insights" for a flag.

For client-side SDKs, The all flags feature may return a null value in cases where a flag's fallback variation would be served to the user.

For server-side SDKs, you can use the all flags feature to pass feature flags to your front end. In particular, you can use it to provide bootstrap flag settings for our JavaScript SDK. To learn more about bootstrapping from a client-side SDK, read Bootstrapping.

Details about each SDK's configuration are available in the SDK-specific sections below.

  • Client-side SDKs
  • Server-side SDKs

Client-side SDKs

Before you implement this feature, read Understanding the all flags feature.

This feature is available in the following client-side SDKs:

Android

The allFlags method produces a map of feature flag keys to their values for a specific user.

1ldClient.allFlags();

Flutter

The allFlags method produces a map of feature flag keys to their values for a specific user.

1Map<String, LDValue> flagValues = await LDClient.allFlags();

iOS

All flags returns a dictionary with the flag keys and their values. If the LDClient is not started, it returns nil.

The dictionary does not contain feature flags from the server with null values. LDClient does not provide any source or change information, only flag keys and flag values. The client app should convert the feature flag value into the desired type.

1let allFlags = LDClient.get()!.allFlags

JavaScript

The allFlags method returns a key/value map of all your feature flags.

The map contains null values for any flags that would return the fallback value. The fallback value is the second argument that you normally pass to variation.

Unlike most of our SDKs, our JavaScript SDK's allFlags method sends analytic events to LaunchDarkly. If you do not want allFlags to generate any analytic events, you can turn this off with the sendEventsOnlyForVariation configuration option.

Node.js (client-side)

The allFlags method returns a key/value map of all your feature flags.

The map contains null values for any flags that would return the fallback value. The fallback value is the second argument that you normally pass to variation.

Unlike most of our SDKs, our Node.js (client-side) SDK's allFlags method sends analytic events to LaunchDarkly. If you do not want allFlags to generate any analytic events, you can turn this off with the sendEventsOnlyForVariation configuration option.

React Native

The allFlags method returns an object containing flag keys and values. You can also register a listener that fires when any flag in your environment changes.

1let allFlagsResult = client.allFlags();
2allFlagsResult.then(values => {
3 console.log(values);
4});
5
6// All Flags Listener
7let listenerId = "ARBITRARY_VALUE"
8let listener = value => Alert.alert('All Flags Listener Callback', value);
9client.registerAllFlagsListener(listenerId, listener);

Roku

You can get an associative array of flagKey -> flagValue for all flags from the client with:

1allFlags = launchDarkly.allFlags()

Xamarin

The AllFlags method produces a map of feature flag keys to their values for the current user.

1ldClient.AllFlags();

Server-side SDKs

Before you implement this feature, read Understanding the all flags feature.

This feature is available in the following server-side SDKs:

.NET

The AllFlagsState method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

1var state = ldClient.AllFlagsState(user);

Apex

The allFlags method produces a map of feature flag keys to their values for a specific user. This does not send any evaluation events to LaunchDarkly.

1Map<String, LDValue> values = client.allFlags(user);

C/C++ (server-side)

The LDAllFlags function captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

This method can be useful for passing feature flags to your front end. In particular, it can be used to provide bootstrap flag settings for our JavaScript SDK.

1struct LDJSON *allFlags = LDAllFlags(client, user);

Erlang

The all_flags_state function captures the state of all feature flag keys as evaluated for a specific user. This includes their values and other metadata.

ldclient:all_flags_state(#{key => <<"aa0ceb">>})

Go

The AllFlagsState method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

In this example, the extra ClientSideOnly option is specified so that only the feature flags designated for client-side use are included in the result.

1import (
2 "gopkg.in/launchdarkly/go-server-sdk.v5/interfaces/flagstate"
3)
4
5state := ldClient.AllFlagsState(user, flagstate.OptionClientSideOnly())

Haskell

The allFlags function captures the state of all feature flag keys as evaluated for a specific user. This includes their values, as well as other metadata.

1state = allFlags client user

Java

The allFlagsState method captures the state of all feature flags with regard to a specific user. This includes their values as well as other metadata.

This method can be useful for passing feature flags to your front end. In particular, it can be used to provide bootstrap flag settings for our JavaScript SDK.

1FeatureFlagsState state = ldClient.allFlagsState(user);

Lua

The allFlags method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

1local allFlags = client:allFlags(user)

Node.js (server-side)

The allFlagsState method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

1ldClient.allFlagsState(user, (err, flagsState) => {
2 // this object can be converted to JSON or can be queried for flag values
3});

PHP

The allFlagsState method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

This method can be useful for passing feature flags to your front end. In particular, it can be used to provide bootstrap flag settings for our JavaScript SDK.

1$state = $client->allFlagsState($user);

Python

The all_flags_state method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

This method can be useful for passing feature flags to your front end. In particular, it can be used to provide bootstrap flag settings for our JavaScript SDK.

1state = ldclient.get().all_flags_state(user)

Ruby

The all_flags_state method captures the state of all feature flag keys with regard to a specific user. This includes their values, as well as other metadata.

This method can be useful for passing feature flags to your front end. In particular, it can be used to provide bootstrap flag settings for our JavaScript SDK.

1state = ld_client.all_flags_state(user)