Feature Flags Reference#
SDK parameters, API endpoints, environment variables, and external documentation.
External documentation#
GitLab Feature Flags#
Unleash (Open Source)#
Client SDKs#
Note
Use SDK v5.0 — GitLab does not yet support v6.
GitLab API endpoints#
Use these endpoints for programmatic flag management (e.g., via CI/CD):
Action |
Endpoint |
|---|---|
List feature flags |
|
Create a feature flag |
|
Update a strategy |
|
Delete a feature flag |
Environment variables#
Unleash Python SDK#
Variable |
Description |
Default |
|---|---|---|
|
Unleash API server URL |
Required |
|
Application identifier |
Required |
|
Unique instance identifier |
Required |
|
Runtime environment |
|
|
Flag refresh interval (seconds) |
|
|
Metrics send interval (seconds) |
|
|
Disable client entirely |
Not set |
Unleash Proxy#
Variable |
Description |
|---|---|
|
Shared secret for Unleash Proxy client |
|
Project’s API URL |
|
Project’s Instance ID |
|
Application environment name |
|
Starts the Proxy (GitLab accepts any value) |
React Proxy Client#
Variable |
Description |
Default |
|---|---|---|
|
Unleash Proxy URL |
Required |
|
Application name |
Required |
|
Runtime environment |
|
|
Proxy client key (if required) |
Empty |
|
Refresh interval (seconds) |
|
|
Disable metrics |
|
Python SDK reference#
Installation#
pip install UnleashClient
Initialisation#
from UnleashClient import UnleashClient
client = UnleashClient(
url="http://gitlab.com/api/v4/feature_flags/unleash/<PROJECT_ID>",
app_name="my-python-app",
custom_headers={'Authorization': '<API token>'}
)
client.initialize_client()
Parameters#
Parameter |
Description |
|---|---|
|
Unleash server URL |
|
Application identifier |
|
Headers for authentication |
|
Runtime environment |
|
Unique instance identifier |
|
Toggle refresh timing (seconds) |
|
Metrics sending timing (seconds) |
|
Turn off metrics |
|
Skip server registration |
|
Local cache location |
Check flag status#
# Simple check
is_enabled = client.is_enabled("my_toggle")
# With context
context = {"userId": "user@example.com"}
is_enabled = client.is_enabled("user_toggle", context)
# With fallback
is_enabled = client.is_enabled(
"my_toggle",
fallback_function=lambda: False
)
Get variant#
context = {'userId': '2'}
variant = client.get_variant("variant_toggle", context)
Context fields#
userId— User identifiersessionId— Session identifierremoteAddress— IP addressproperties— Custom properties dictionary
Supported strategies#
Default
UserID
IP
Gradual Rollout
Flexible Rollout
React Proxy Client reference#
Warning
Use only with the Unleash Proxy, not the Unleash client directly. This protects server-side API tokens.
Installation#
npm install @unleash/proxy-client-react
Initialisation#
import { UnleashClient } from 'unleash-proxy-client';
const unleash = new UnleashClient({
url: 'https://YOUR-PROXY/api/frontend',
clientKey: '<your-client-side-token>',
appName: 'my-webapp'
});
unleash.start();
Parameters#
Parameter |
Description |
|---|---|
|
Front-end API or Edge URL |
|
Client-side API token |
|
Application identifier |
|
Initial Unleash context |
|
Toggle refresh timing (seconds) |
|
Turn off auto-refresh |
|
Metrics sending timing (seconds) |
|
Turn off metrics |
|
Custom storage implementation |
|
Initial toggle configuration |
|
Context environment property |
React hooks#
import { useFlag, useVariant, useFlags, useUnleashContext } from '@unleash/proxy-client-react';
// Check single flag
const isEnabled = useFlag('my-flag');
// Get variant
const variant = useVariant('my-flag');
// Check multiple flags
const flags = useFlags(['flag-one', 'flag-two']);
// Update context
const updateContext = useUnleashContext();
updateContext({ userId: '123' });
Events#
unleash.on('ready', () => {
// Client connected to API
});
unleash.on('update', () => {
// New toggle configuration received
});
unleash.on('error', (error) => {
// Handle error
});
Available events:
initialized— SDK reads local cached dataready— SDK connects to Unleash APIupdate— SDK receives new toggle configurationerror— SDK encounters an errorrecovered— SDK recovers from errorsent— SDK sends metrics
Cleanup#
unleash.stop();