Skip to content

Latest commit

 

History

History
80 lines (54 loc) · 3.21 KB

README.md

File metadata and controls

80 lines (54 loc) · 3.21 KB

APEX SDK For Harness Feature Flags

SFDX Test Run on Push

Table of Contents

Intro
Requirements
Quickstart
Further Reading
Build Instructions

Intro

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.

FeatureFlags

Requirements

SalesForce SFDX cli

Quickstart

To follow along with our test code sample, make sure you’ve:

Install the SDK

Install the APEX SDK using

sfdx force:source:deploy --targetusername='YOUR TARGET ORG' --sourcepath='force-app'

Code Sample

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');

Running the example

sfdx force:apex:execute --targetusername='YOUR TARGET ORG' --apexcodefile='YOUR_FILENAME.apex'

Additional Reading

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.