### E2E SDK Tests Setup and Run Source: https://github.com/featurehub-io/featurehub/blob/main/CLAUDE.md Installs dependencies and runs end-to-end SDK tests. Requires a running FeatureHub instance and specific environment variables for configuration. ```sh cd adks/e2e-sdk pnpm install sh run.sh # run all e2e tests sh run.sh @flag-lock # run tests with a specific tag pnpm run test # directly via npm script ``` -------------------------------- ### Create Portfolio Usage Example Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Example of how to create a portfolio using the PortfolioServiceApi. Note that groups and applications cannot be created simultaneously. ```java Portfolio portfolio = portfolioService.createPortfolio(new Portfolio().name("name").description("description"), null, null) ``` -------------------------------- ### Configure and Run Example App Server Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/evaluation.adoc Sets environment variables for FeatureHub API keys and IP address, then runs the example Node.js backend application using Docker. This app connects to the FeatureHub server. ```bash # set the Client eval API key used by the example server, e.g: export FEATUREHUB_CLIENT_API_KEY="default/82afd7ae-e7de-4567-817b-dd684315adf7/SHxmTA83AJupii4TsIciWvhaQYBIq2*JxIKxiUoswZPmLQAIIWN" # Set the Server eval API key used by the React front-end, e.g: export FEATUREHUB_SERVER_API_KEY="default/d8ba747d-7d3c-4454-9c58-130390848412/5EE3vua1NqY0ez6Zd4TXU7XnsZdAPHtR96XaDmhfegitKGiQ9aCdmtmeNUNPubkRZLJLUUpaC7b05ELk" export MY_IP=192.168.XX.XX export FEATUREHUB_EDGE_URL=http://$MY_IP:8085/ docker run --rm -e FEATUREHUB_EDGE_URL=$FEATUREHUB_EDGE_URL -e FEATUREHUB_CLIENT_API_KEY=$FEATUREHUB_CLIENT_API_KEY -e FEATUREHUB_SERVER_API_KEY=$FEATUREHUB_SERVER_API_KEY -p 5000:5000 featurehub/example_node:1.3.0 ``` -------------------------------- ### Example: Importing Features with Specific Details Source: https://github.com/featurehub-io/featurehub/blob/main/admin-frontend/cli/README.adoc An example demonstrating the import features command with actual credentials and URLs. This shows the expected output during the feature update process. ```bash docker run --rm -v $PWD:/imports docker.io/featurehub/cli:0.0.1 --username irina@i.com --password password123 --mr-host=http://192.168.86.36:8085 --features-wu=/imports/test/sample-features.json --portfolio=portfo1 --application=app1 lib/main.dart: Warning: Interpreting this as package URI, 'package:fh_cli/main.dart'. checking features for app1 updating features for environment production in application app1 updating features for environment test in application app1 updating features for environment dev in application app1 ``` -------------------------------- ### Java Use: Get Portfolio Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Example of retrieving a portfolio's details, including its groups, applications, and environments. ```java Portfolio portfolio = portfolioService.getPortfolio(id, true, true, true) ``` -------------------------------- ### Example SAML Configuration Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/identity.adoc This is an example of a Google-style SAML configuration for FeatureHub, demonstrating how to set up IdP providers, metadata files, login button appearance, and base URLs. ```properties saml.idp-providers=google saml.google.idp.metadata-file=/etc/config/GoogleIDPMetadata.xml saml.google.login.icon-url=https://some-icon saml.google.login.button-background-color=0xCAE8DC saml.google.login.button-text=Your company saml.google.sp.base-url=https://c6a0-203-118-154-3.ngrok.io ``` -------------------------------- ### Run Example App Server on Linux (Host Network) Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/evaluation.adoc Runs the example Node.js backend application using Docker on Linux with host networking. This is an alternative to the default bridge network for better performance or specific network configurations. ```bash docker run --network host --rm -e FEATUREHUB_EDGE_URL=$FEATUREHUB_EDGE_URL -e FEATUREHUB_CLIENT_API_KEY=$FEATUREHUB_CLIENT_API_KEY -e FEATUREHUB_SERVER_API_KEY=$FEATUREHUB_SERVER_API_KEY -p 5000:5000 featurehub/example_node:1.3.0 ``` -------------------------------- ### All-in-One MySQL Setup Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Use this command to set up all necessary components including the FeatureHub Admin Console using a MySQL database. ```bash cd docker-compose-options/all-in-one-mysql docker compose up ``` -------------------------------- ### Java Use: Create Portfolio Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Example of creating a portfolio using the PortfolioService. Note: This is an example of creating a portfolio, not deleting it as the method name might suggest. ```java Portfolio portfolio = portfolioService.createPortfolio(id, null, null, null) ``` -------------------------------- ### Build FeatureHub Backend and Install Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/developers.adoc Builds the FeatureHub backend stack, including dependencies, and installs it locally. This command requires Java 11 and Maven 3.5+. ```bash cd backend && mvn -f pom-first.xml clean install && cd .. && mvn -T4C clean install ``` -------------------------------- ### All-in-One Postgres Setup Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Use this command to set up all necessary components including the FeatureHub Admin Console using a PostgreSQL database. ```bash cd docker-compose-options/all-in-one-postgres docker compose up ``` -------------------------------- ### Example Login Histogram Metric Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/metrics.adoc This example shows how a login histogram metric might appear. It helps monitor repeated login attempts. ```text # HELP login_histogram Login to Feature Hub Histogram ``` -------------------------------- ### Install AdoptOpenJDK 11 on macOS Source: https://github.com/featurehub-io/featurehub/blob/main/admin-frontend/README.adoc Installs AdoptOpenJDK 11 using Homebrew. Ensure you have Java 11.0.7+ notarized version for Docker compatibility. ```bash brew tap adoptopenjdk/openjdk brew cask install adoptopenjdk11 --no-quarantine ``` -------------------------------- ### Deploy Namespace Initialization with Helm Source: https://github.com/featurehub-io/featurehub/blob/main/pipeline/app-build-pipeline/README.adoc Upgrades or installs the 'namespace-init' Helm release, applying initial configurations to the 'ci' namespace. ```bash helm upgrade namespace-init namespace-init -i ``` -------------------------------- ### Install Dart Dependencies Source: https://github.com/featurehub-io/featurehub/blob/main/e2e/README.adoc Installs project dependencies using the Dart package manager. Ensure the Dart SDK is installed and configured. ```bash pub get ``` -------------------------------- ### Create GCP Project Source: https://github.com/featurehub-io/featurehub/blob/main/pipeline/app-build-pipeline/README.adoc Creates a new Google Cloud project. Ensure you have gcloud installed and configured. ```bash gcloud projects create featurehub ``` -------------------------------- ### Low Volume REST-Only Postgres Setup Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc This command sets up a simpler, cheaper deployment suitable for lower volumes, bundling Management Repository and Edge into a single process with PostgreSQL. ```bash cd docker-compose-options/party-server-ish-postgres docker compose up ``` -------------------------------- ### Example of Generated Logs with Environment Variables Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/configuration.adoc Illustrates how environment variables configured via `connect.logging.environment` appear in the logs, providing context like Kubernetes node and zone. ```json {"@timestamp":"2022-01-22T18:12:56.767+1300","message":"1 * Server has received a request on thread grizzly-http-server-0\n1 > GET http://localhost:8903/info/version\n1 > accept: */*\n1 > host: localhost:8903\n1 > user-agent: curl/7.77.0\n","priority":"TRACE","path":"jersey-logging","thread":"grizzly-http-server-0","kubernetes":{"node":"peabody","zone":"amelia"},"host":"thepolishedbrasstack.lan","connect.rest.method":"received: GET - http://localhost:8903/info/version"} ``` -------------------------------- ### Scalable Streaming + REST Postgres Setup Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc This command initiates a scalable deployment with separate instances for Edge, Cache, NATS, and FeatureHub MR Server, using PostgreSQL. ```bash cd docker-compose-options/all-separate-postgres docker compose up ``` -------------------------------- ### Example Log Output with User Information Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/configuration.adoc Shows the JSON log format when user logging is enabled, including a 'user' object with 'id' and 'email'. ```json {"@timestamp":"2022-01-22T14:58:15.854+1300","message":"txn[1109] select t0.id, t0.when_archived, t0.feature_key, t0.alias, t0.name, t0.secret, t0.link, t0.value_type, t0.when_updated, t0.when_created, t0.version, t0.fk_app_id from fh_app_feature t0 where t0.id = ?; --bind(2b86605b-1a81-4fc7-80b7-17edc5e3206e, ) --micros(697)","priority":"DEBUG","path":"io.ebean.SQL","thread":"grizzly-http-server-1","host":"my-computer","user":{"id":"68c09a3d-6e44-4379-bfc1-3e75af59af38","email":"irina@i.com"}} ``` -------------------------------- ### Scalable REST-Only Postgres Setup Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc This command deploys a scalable solution separating the Admin App (mr) from the Edge server (edge-rest) using PostgreSQL. ```bash cd docker-compose-options/mr-edge-rest-postgres docker compose up ``` -------------------------------- ### SDK Feature Properties Example Output Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/configuration.adoc This is an example of the JSON output you might see when curling your SDK endpoint, reflecting the feature properties defined via templates. ```json "fp":{"appName":"D2nbUfr8LH1i","portfolio":"D2nbUfr8LH1i","category":"shoes"} ``` -------------------------------- ### Example Log Output with HTTP Headers Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/configuration.adoc Illustrates the JSON log format when specific HTTP headers are configured to be logged. Includes headers like 'user-agent', 'origin', and 'Sec-fetch-Mode'. ```json {"@timestamp":"2022-01-22T14:46:19.374+1300","message":"txn[1106] Begin","priority":"TRACE","path":"io.ebean.TXN","thread":"grizzly-http-server-0","host":"my-computer","http-headers":{"user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36","origin":"http://localhost:53000","Sec-fetch-Mode":"cors"}} ``` -------------------------------- ### Install FeatureHub Open Source with Docker Source: https://github.com/featurehub-io/featurehub/blob/main/readme.adoc Run FeatureHub as a Docker container for evaluation purposes. Ensure the volume mount for the database is correctly configured. ```bash $ docker run -p 8085:8085 --user 999:999 -v $HOME/party:/db featurehub/party-server:latest ``` -------------------------------- ### TypeScript Strategy Matcher Example Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/sdks-development.adoc This TypeScript code provides an example implementation for matching strategy attributes. It is referenced as an instance for understanding how different types and conditions are handled. ```typescript import { StrategyMatcher } from "./strategy_matcher"; const matcher = new StrategyMatcher(); // Example usage: const context = { "user_id": "123e4567-e89b-12d3-a456-426614174000", "country": "US", "plan": "premium", "sign_up_date": "2023-01-01T00:00:00Z" }; const strategy = { "name": "Example Strategy", "percentage": 50, "attributes": [ { "fieldName": "country", "type": "string", "condition": "equals", "values": ["US"] }, { "fieldName": "plan", "type": "string", "condition": "includes", "values": ["premium", "enterprise"] }, { "fieldName": "sign_up_date", "type": "datetime", "condition": "lesser-equals", "values": ["2023-12-31T23:59:59Z"] } ] }; const isMatch = matcher.match(context, strategy); console.log(`Strategy match: ${isMatch}`); // Example with percentage: const contextForPercentage = { "user_id": "another-user-id", "country": "CA" }; const percentageStrategy = { "name": "Percentage Strategy", "percentage": 25, "attributes": [] }; const isPercentageMatch = matcher.match(contextForPercentage, percentageStrategy); console.log(`Percentage strategy match: ${isPercentageMatch}`); ``` -------------------------------- ### Run Evaluation Deployment Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Use this command to start an all-in-one evaluation deployment using H2 database. Not recommended for production. ```bash cd docker-compose-options/all-in-one-h2 docker compose up ``` -------------------------------- ### Java Use: Create Feature Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Example of creating a new feature with a name, key, and value type. ```java List allFeatures = featureService.createFeaturesForApplication(appId, new Feature().name("Feature's Name").key("FEATURE_KEY").valueType(FeatureValueType.BOOLEAN)) ``` -------------------------------- ### Java Use: Update Portfolio Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Example of updating a portfolio's name and description, with options to include related data. ```java Portfolio portfolio = portfolioService.updatePortfolio(id, new Portfolio().name("newName").description("new description"), true, true, true) ``` -------------------------------- ### Clone FeatureHub Install Repository Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Clone the featurehub-install repository to your local machine to access Docker-based deployment options. ```bash curl -sL https://github.com/featurehub-io/featurehub-install/tarball/main | tar -xvz ``` -------------------------------- ### Build Country Targeting Rule in JS SDK Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/strategies.adoc Example of how to build a targeting rule for a specific country using the JS SDK. Ensure the SDK is initialized and context is available. ```javascript await fhContext.country(StrategyAttributeCountryName.NewZealand).build(); ``` -------------------------------- ### Java Use: Find Portfolios Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Example of searching for portfolios, including groups and applications, in ascending order. Filters and parent ID are not specified. ```java List portfolios = portfolioService.findPortfolios(true, true, SortOrder.ASC, null, null) ``` -------------------------------- ### Run FeatureHub Party Server on Linux Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/evaluation.adoc Starts the FeatureHub Party Server using Docker on Linux. It uses host networking, maps port 8085, and mounts a local directory for database storage. ```bash docker run --network host --user 999:999 -p 8085:8085 -v $HOME/party:/db featurehub/party-server:latest ``` -------------------------------- ### Set Java 11 Home on Mac OS X (AdoptOpenJDK) Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/developers.adoc Sets the JAVA_HOME environment variable for Java 11 installed from AdoptOpenJDK on Mac OS X. Ensure Java 11 is downloaded and extracted to the correct directory. ```bash export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home ``` -------------------------------- ### Setting Repository and Registering Plugin Source: https://github.com/featurehub-io/featurehub/blob/main/docs/machine-usage/SDK-USAGE.md Demonstrates how to set a new repository on the config and register a custom plugin with the adapter. ```go config.SetRepository(repo) config.RegisterUsagePlugin(myPlugin) // adds to the adapter ``` -------------------------------- ### Building and Emitting Custom Usage Event Source: https://github.com/featurehub-io/featurehub/blob/main/docs/machine-usage/SDK-USAGE.md Demonstrates how to manually build a usage event and then record it using the context. ```go // Or build and emit directly: event := provider.NewUsageContextCollectionEvent(userKey) ctx.RecordUsageEvent(goCtx, event) ``` -------------------------------- ### Initialize Redoc with SDK API Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/sdk-api-definition.adoc This snippet shows how to initialize Redoc to display the SDK API documentation. It requires a Redoc container element and the path to the SDK API YAML definition. ```html ``` -------------------------------- ### Initialize Redoc for API Documentation Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/api-definition.adoc This snippet shows how to initialize Redoc, a tool for rendering OpenAPI specifications, using a local API definition file and a CDN. ```html
``` -------------------------------- ### Get Portfolio Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Retrieves the details of a specific portfolio by its ID, with options to include related data. ```APIDOC ## GET /portfolio/{id} ### Description Retrieves the details of a portfolio by ID. ### Method GET ### Endpoint /portfolio/{id} ### Parameters #### Path Parameters - **id** (UUID) - Required - The ID of the portfolio to retrieve. #### Query Parameters - **includeGroups** (Boolean) - Optional - If true, will fill in the groups available to each portfolio. - **includeApplications** (Boolean) - Optional - If true, will fill in the applications available to each portfolio. - **includeEnvironments** (Boolean) - Optional - If true, all applications will have their environments listed. ### Response #### Success Response (200) - **Portfolio** - The details of the requested portfolio. ``` -------------------------------- ### Admin Frontend Build Source: https://github.com/featurehub-io/featurehub/blob/main/CLAUDE.md Builds the Flutter admin frontend. Requires Flutter installed or can use Docker. ```sh cd admin-frontend sh build-frontend.sh # e.g., sh build-frontend.sh 1.9.3 # Or with Docker if Flutter not installed: # The script auto-detects and uses featurehub/flutter_web Docker image ``` -------------------------------- ### Instantiate PortfolioServiceApi Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Create an instance of the PortfolioServiceApi to manage portfolios. ```java PortfolioServiceApi portfolioService = new PortfolioServiceApi(); ``` -------------------------------- ### Build Client Context with Attributes Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/sdks-development.adoc Demonstrates how to build a client context with various attributes, including single values, lists, country, platform, device, user key, version, and session key. This is used for server-side evaluation. ```csharp await _fhConfig.NewContext() .Attr("city", "Istanbul City") .Attrs("family", new List {"Bambam", "DJ Elif"}) .Country(StrategyAttributeCountryName.Turkey) .Platform(StrategyAttributePlatformName.Ios) .Device(StrategyAttributeDeviceName.Mobile) .UserKey("tv-show") .Version("6.2.3") .SessionKey("session-key").Build(); ``` -------------------------------- ### Java Definition: Get Portfolio Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Defines the signature for retrieving a specific portfolio by its ID, with options to include related data. ```java Portfolio getPortfolio(UUID id, Boolean includeGroups, Boolean includeApplications, Boolean includeEnvironments) ``` -------------------------------- ### Get String Feature Flag (Old Way) Source: https://github.com/featurehub-io/featurehub/wiki/Migration-notes Shows the legacy method for retrieving a string value for a feature flag. ```typescript const color = featureHubRepository.getString('SUBMIT_COLOR_BUTTON'); ``` -------------------------------- ### Full Backend Build Source: https://github.com/featurehub-io/featurehub/blob/main/CLAUDE.md Builds all backend modules in parallel. Requires Maven and should be run from the root directory. ```sh # Step 1: Build tiles (Maven build infrastructure) first — required once per environment or after tile changes cd backend && mvn -f pom-first.xml install && cd .. # Step 2: Build all backend modules in parallel mvn -T4C clean install # Combined (as used in CI): sh build_all_and_test.sh ``` -------------------------------- ### Configure Flutter for Master Channel and Web Source: https://github.com/featurehub-io/featurehub/blob/main/admin-frontend/open_admin_app/README.adoc Sets up the Flutter environment by switching to the master channel, updating, resetting to a specific commit, enabling web support, and running the application in Chrome. ```bash flutter channel master flutter update cd $FLUTTER && git reset --hard f654346777603871f32cbf339c6652ef7b658ec0 && echo "1.22.0-10.0.pre.340" >> $FLUTTER/version flutter config --no-analytics --enable-web flutter run -d chrome ``` -------------------------------- ### Link Project to Billing Account Source: https://github.com/featurehub-io/featurehub/blob/main/pipeline/app-build-pipeline/README.adoc Links the new project to an existing billing account. First, list available billing accounts, then link the project using the account ID. ```bash gcloud alpha billing accounts list gcloud alpha billing projects link featurehub --billing-account XXXX ``` -------------------------------- ### Get Cloud Build Service Account Source: https://github.com/featurehub-io/featurehub/blob/main/pipeline/app-build-pipeline/README.adoc Retrieves the Cloud Build service account email address for the project, which is needed to grant KMS permissions. ```bash gcloud projects get-iam-policy featurehub --flatten="bindings[].members" --format="table(bindings.members)" | grep "@cloudbuild.gserviceaccount.com" ``` -------------------------------- ### Create Cloud SQL Database Instance Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Creates a small, zonal Cloud SQL instance for PostgreSQL 13 with public IP and SSL connectivity. This step can take a significant amount of time. ```bash export FH_DB_NAME=featurehub-db export FH_DB_PASSWORD=FeatureHub17# export FH_DB_SCHEMA=featurehub gcloud sql instances create $FH_DB_NAME --database-version=POSTGRES_13 --zone=$GCP_ZONE --tier=db-f1-micro "--root-password=$FH_DB_PASSWORD" --assign-ip --require-ssl --storage-type=SSD ``` -------------------------------- ### Build All Artifacts and Docker Images Source: https://github.com/featurehub-io/featurehub/blob/main/backend/HOW_TO_RELEASE_OS.adoc Builds all backend artifacts and Docker images, tagging them with the specified version. Also builds frontend images. ```shell sh build_all_and_test.sh cd backend sh build.sh 1.3.5 ``` -------------------------------- ### Get String Feature Flag (New Way) Source: https://github.com/featurehub-io/featurehub/wiki/Migration-notes Demonstrates the updated method for retrieving a string feature flag value using a built client context. ```typescript const fhClient = await fhConfig.newContext().build(); const color = fhClient.getString('SUBMIT_COLOR_BUTTON'); ``` -------------------------------- ### List Cloud SQL Databases Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Verifies the creation of the default 'postgres' database schema on the newly created Cloud SQL instance. ```bash gcloud sql databases list --instance=$FH_DB_NAME ``` -------------------------------- ### Run NATS Server in Docker Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/developers.adoc Starts a NATS server instance in detached mode using a specific Docker image and version. It exposes the standard NATS ports. ```bash docker run -d --name nats-main -p 4222:4222 -p 6222:6222 -p 8222:8222 nats:2.1.2-scratch ``` -------------------------------- ### Build and Dependency Commands Source: https://github.com/featurehub-io/featurehub/blob/main/admin-frontend/app_mr_layer/README.adoc Execute these commands from the command line to clean the project, generate sources, and fetch Dart dependencies. ```bash mvn clean generate-sources pub get ``` -------------------------------- ### Generic OAuth2 Provider Configuration Source: https://github.com/featurehub-io/featurehub/blob/main/backend/security-oauth/README.adoc Configuration properties for a generic OAuth2 provider. This setup requires an additional Nginx container to serve icons and may need adjustments for CORS. ```properties oauth2.adminUiUrlSuccess=http://localhost:8085/# oauth2.adminUiUrlFailure=http://localhost:8085/#oauth2-failure oauth2.providers=oauth2-generic oauth2.redirectUrl=http://localhost:8085/oauth/auth oauth2.providers.generic.secret=cf58f851-ae24-4fad-a017-8f08118b46fc oauth2.providers.generic.auth-url=http://localhost:8900/auth/realms/myrealm/protocol/openid-connect/auth oauth2.providers.generic.id=myclient oauth2.providers.generic.token-url=http://host.docker.internal:8900/auth/realms/myrealm/protocol/openid-connect/token oauth2.providers.generic.icon.url=http://localhost:8097/tech-leaders.png oauth2.providers.generic.icon.background-color=0xCAE8DC oauth2.providers.generic.icon.text=Sign in with Tech Leaders ``` -------------------------------- ### Recording Feature Usage Event Source: https://github.com/featurehub-io/featurehub/blob/main/docs/machine-usage/usage-triggering.md After a successful feature read (e.g., `GetBoolean`), this process obtains the user key, builds a usage event, and emits it through the repository. ```go // Assuming cc is a Context object and contextAttributes are available userKey := cc.UniqueKey() // Assuming resolvedFeatureState and evaluatedValue are obtained from a feature getter usageValue := models.NewUsageValue(resolvedFeatureState, evaluatedValue) // Create a BaseWithFeature event event := UsageProvider().NewUsageFeature(usageValue, contextAttributes, userKey) // Emit the event through the repository featureRepository.EmitUsageEvent(fillEvent(event)) ``` -------------------------------- ### FeatureHub MR Properties Configuration Source: https://github.com/featurehub-io/featurehub/blob/main/backend/mr-db-sql/docker-databases/postgres/README.adoc Configure your application's database connection properties to point to the FeatureHub PostgreSQL instance. Ensure the URL, username, and password match the database setup. ```properties db.url=jdbc:postgresql://localhost:5432/featurehub db.username=featurehub db.password=featurehub ``` -------------------------------- ### Create API Client for Java 11 Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/admin-development-kit.adoc Instantiate and configure the API client for Java 11. Set the host and port for your server's location. Optionally set it as the default client. ```java import io.featurehub.admin.ApiClient; ApiClient api = new ApiClient(); // wherever your host is located api.setHost("localhost").setPort(8085) // if you are running a single authenticated client, you can now do this: Configuration.setDefaultApiClient(api); // and you won't have to pass the api around ``` -------------------------------- ### Encoded x-featurehub Header Example Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/sdks-development.adoc Illustrates the expected format of the x-featurehub header after encoding attributes, where special characters like '=' and ',' are URL-encoded. The header is sorted by key name for easier testing. ```text city=Istanbul+City,country=turkey,device=mobile,family=Bambam%2cDJ+Elif,platform=ios,session=session-key,userkey=tv-show,version=6.2.3 ``` -------------------------------- ### Set GCP Environment Variables Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/installation.adoc Configure your Google Cloud project and zone for subsequent commands. ```bash export GCP_REGION=us-east1 export GCP_ZONE=us-east1-b gcloud config set project your-project gcloud config set compute/zone $GCP_ZONE ``` -------------------------------- ### Release Build and Deployment Source: https://github.com/featurehub-io/featurehub/blob/main/CLAUDE.md Builds all artifacts, generates APIs, and handles Docker image creation and pushing for releases. ```sh sh build_all_and_test.sh # builds all artifacts + generates APIs cd backend && sh build.sh # builds and tags Docker images cd backend && sh push.sh # pushes Docker images ``` -------------------------------- ### Example SSE Request and Response Source: https://github.com/featurehub-io/featurehub/blob/main/docs/modules/ROOT/pages/sdks-development.adoc Demonstrates a curl request to a FeatureHub endpoint and the subsequent Server-Sent Events (SSE) stream received. This shows the 'event: data' pairs that represent feature updates. ```http request curl -v http://localhost:8553/features/default/fc5b929b-8296-4920-91ef-6e5b58b499b9/VNftuX5LV6PoazPZsEEIBujM4OBqA1Iv9f9cBGho2LJylvxXMXKGxwD14xt2d7Ma3GHTsdsSO8DTvAYF * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8553 (#0) > GET /features/default/fc5b929b-8296-4920-91ef-6e5b58b499b9/VNftuX5LV6PoazPZsEEIBujM4OBqA1Iv9f9cBGho2LJylvxXMXKGxwD14xt2d7Ma3GHTsdsSO8DTvAYF HTTP/1.1 > Host: localhost:8553 > User-Agent: curl/7.64.1 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: text/event-stream < Transfer-Encoding: chunked < event: ack data: {"status":"discover"} event: features data: [{"id":"6c376de1-3cb8-4297-b641-8f27e0d11612","key":"FEATURE_SAMPLE","version":1,"type":"BOOLEAN","value":false},{"id":"b8d9b3a0-2972-4f56-a57f-3f74fe9c7e4f","key":"NEW_BUTTON","version":1,"type":"BOOLEAN","value":false},{"id":"5f562e19-aedf-44d5-ab5f-c2994e2b7f57","key":"NEW_BOAT","version":4,"type":"BOOLEAN","value":false}] event: feature data: {"id":"5f562e19-aedf-44d5-ab5f-c2994e2b7f57","key":"NEW_BOAT","version":5,"type":"BOOLEAN","value":true} event: feature data: {"id":"ae5e1af5-ac7d-475c-9862-7a3f88fa20d3","key":"dunk","type":"BOOLEAN"} event: feature data: {"id":"ae5e1af5-ac7d-475c-9862-7a3f88fa20d3","key":"dunk","version":1,"type":"BOOLEAN","value":false} event: delete_feature data: {"id":"ae5e1af5-ac7d-475c-9862-7a3f88fa20d3","key":"dunk","type":"BOOLEAN"} event: bye data: {"status":"closed"} ```