Intro
Requirements
Quickstart
Further Reading
Build Instructions
Use this README to get started with our Feature Flags (FF) SDK for APEX. This guide outlines the basics of getting started with the SDK and provides a full code sample for you to try out. This sample doesn’t include configuration options, for in depth steps and configuring the SDK, for example, using our Relay Proxy, see the APEX SDK Reference.
For a sample FF APEX SDK project, see our test APEX project.
To follow along with our test code sample, make sure you’ve:
- Created a Feature Flag on the Harness Platform called harnessappdemodarkmode
- Created a server SDK key and made a copy of it
Install the APEX SDK using
sfdx force:source:deploy --targetusername='YOUR TARGET ORG' --sourcepath='force-app'
The following is a complete code example that you can use to test the harnessappdemodarkmode
Flag you created on the Harness Platform. When you run the code it will:
- Connect to the FF service.
- Report the value of the Flag until the connection is closed. Every time the harnessappdemodarkmode Flag is toggled on or off on the Harness Platform, the updated value is reported.
- Close the SDK.
// Set flagKey to the feature flag key you want to evaluate.
String flag = 'harnessappdemodarkmode';
// set cache Namespace and Partition
FFOrgCache cache = new FFOrgCache('local', 'basic');
FFConfig config = new FFConfig.builder().cache(cache).build();
// Set up the target properties.
FFTarget target = FFTarget.builder().identifier('Harness').name('Harness').build();
FFClient client = new FFClient('Your SDK Key', target, config);
// Bool evaluation
Boolean value = client.evaluate(flag, false);
System.debug('Feature flag ' + flag + ' is '+ value + ' for this user');
sfdx force:apex:execute --targetusername='YOUR TARGET ORG' --apexcodefile='YOUR_FILENAME.apex'
For further examples and config options, see the APEX SDK Reference.
For more information about Feature Flags, see our Feature Flags documentation.
Harness is a feature management platform that helps teams to build better software and to test features quicker.