Feature Flags Reference
Links to external documentation and relevant API information.
External Documentation
GitLab Feature Flags:
Unleash (Open Source):
Unleash Client SDKs: Select v5.0 for the below SDKs as Gitlab does not support v6.
SKAO Specific:
GitLab API (for programmatic management, e.g., via CI/CD)
Unleash Proxy Environment Variables (for configuration)
UNLEASH_PROXY_SECRETS
: Shared secret used to configure an Unleash Proxy client.UNLEASH_URL
: Your project’s API URL. For more details, read Get access credentials.UNLEASH_INSTANCE_ID
: Your project’s Instance ID. For more details, read Get access credentials.UNLEASH_APP_NAME
: The name of the environment the application runs in. For more details, read Get access credentials.UNLEASH_API_TOKEN
: Required to start the Unleash Proxy, but not used to connect to GitLab. Can be set to any value.
Unleash Python SDK Reference (unleash-client)
Installation
Install from PyPI
pip install UnleashClient
Initialisation
Basic setup
from UnleashClient import UnleashClient
client = UnleashClient(
url="http://gitlab.com/api/v4/feature_flags/unleash/42", // 42 is the project ID
app_name="my-python-app",
custom_headers={'Authorization': '<API token>'}
)
client.initialize_client()
Key parameters:
url
- Unleash server URLapp_name
- Application identifiercustom_headers
- Headers for authenticationenvironment
- Runtime environmentproject_name
- Project identifierrefresh_interval
- Toggle refresh timingmetrics_interval
- Metrics sending timingdisable_metrics
- Turn off metricscache_directory
- Local cache location
Core Features
Check if feature is enabled
# Simple check
is_enabled = client.is_enabled("my_toggle")
# With context
app_context = {"userId": "user@example.com"}
is_enabled = client.is_enabled("user_toggle", app_context)
Get feature variant
context = {'userId': '2'}
variant = client.get_variant("variant_toggle", context)
Context
Supported context fields:
userId
- User identifiersessionId
- Session identifierremoteAddress
- IP addressproperties
- Custom properties dictionary
Fallbacks
Custom fallback function
def fallback(feature_name, context):
return True
client.is_enabled("toggle", fallback_function=fallback)
Lambda default
client.is_enabled("toggle",
fallback_function=lambda feature_name, context: True)
Client Lifecycle
Registration with Unleash server
Periodic toggle fetching
On-disk caching
Metrics reporting
Strategies
Supported strategies:
Default
UserID
IP
Gradual Rollout
Flexible Rollout
Resources
Unleash React Client (@unleash/proxy-client-react)
Warning
This should only be used with a proxy client, not the Unleash client for security reasons. SKAO does not run a global proxy instance for all applications. Please try to use the feature flags server side (e.g., via the Python SDK) if possible.
Installation
Install via npm
npm install unleash-proxy-client
Initialisation
Basic setup
import { UnleashClient } from 'unleash-proxy-client';
const unleash = new UnleashClient({
url: 'https://YOUR-UNLEASH-INSTANCE/api/frontend',
clientKey: '<your-client-side-token>',
appName: 'my-webapp'
});
unleash.start();
Key parameters:
url
- Front-end API or Edge URLclientKey
- Client-side API tokenappName
- Application identifiercontext
- Initial Unleash contextrefreshInterval
- Toggle refresh timing (seconds)disableRefresh
- Turn off auto-refreshmetricsInterval
- Metrics sending timingdisableMetrics
- Turn off metricsstorageProvider
- Custom storage implementationbootstrap
- Initial toggle configurationenvironment
- Context environment propertyusePOSTrequests
- Use POST instead of GET
Core Features
Wait for client readiness
unleash.on('ready', () => {
// Use client here
});
Check if feature is enabled
const enabled = unleash.isEnabled('featureToggle');
Get feature variant
const variant = unleash.getVariant('featureToggle');
if (variant.name === 'blue') {
// Handle blue variant
}
Context Management
Update entire context
unleash.updateContext({ userId: '123' });
Set specific context field
unleash.setContextField('userId', '456');
Remove context field
unleash.removeContextField('userId');
Events
Key events:
initialized
- Read local cached dataready
- Connected to Unleash APIupdate
- New toggle configurationerror
- SDK error occurredrecovered
- SDK recovered from errorsent
- Metrics sent
Event listener example
unleash.on('update', () => {
// Handle toggle updates
});
Storage Options
Custom storage provider
const unleash = new UnleashClient({
// other options
storageProvider: {
save: (name, data) => {
// Store implementation
},
get: (name) => {
// Retrieval implementation
}
}
});
Bootstrap
Bootstrap with initial data
const unleash = new UnleashClient({
// other options
bootstrap: [{
"enabled": true,
"name": "featureToggle",
"variant": {
"enabled": true,
"name": "blue",
"feature_enabled": true
}
}],
bootstrapOverride: true
});
Manual Refresh
Disable auto-refresh
const unleash = new UnleashClient({
// other options
refreshInterval: 0,
metricsInterval: 0
});
Manual refresh calls
unleash.updateToggles();
unleash.sendMetrics();
Cleanup
Stop the client
unleash.stop();
Usage Environments
Browser
React and React Native
Node.js (requires fetch implementation)
CDN