Feature Flags Reference

Links to external documentation and relevant API information.

External Documentation

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 URL

    • app_name - Application identifier

    • custom_headers - Headers for authentication

    • environment - Runtime environment

    • project_name - Project identifier

    • refresh_interval - Toggle refresh timing

    • metrics_interval - Metrics sending timing

    • disable_metrics - Turn off metrics

    • cache_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 identifier

    • sessionId - Session identifier

    • remoteAddress - IP address

    • properties - 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

  1. Registration with Unleash server

  2. Periodic toggle fetching

  3. On-disk caching

  4. 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 URL

    • clientKey - Client-side API token

    • appName - Application identifier

    • context - Initial Unleash context

    • refreshInterval - Toggle refresh timing (seconds)

    • disableRefresh - Turn off auto-refresh

    • metricsInterval - Metrics sending timing

    • disableMetrics - Turn off metrics

    • storageProvider - Custom storage implementation

    • bootstrap - Initial toggle configuration

    • environment - Context environment property

    • usePOSTrequests - 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 data

    • ready - Connected to Unleash API

    • update - New toggle configuration

    • error - SDK error occurred

    • recovered - SDK recovered from error

    • sent - 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

Resources