Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaunchDarkly sample Apex application

We've built a simple application that demonstrates how LaunchDarkly's SDK works.

Below, you'll find the basic build procedure, but for more comprehensive instructions, you can visit the Apex SDK reference guide.

This guide requires you to install the Salesforce CLI and the Go compiler, version 1.26 or newer, which the bridge requires to build.

Build instructions

  1. Clone the Apex SDK.
git clone https://github.com/launchdarkly/apex-server-sdk.git
  1. Deploy the SDK to Salesforce.
cd apex-server-sdk
sf project deploy start --target-org 'YOUR TARGET ORG' --source-dir 'force-app'
  1. Build the Salesforce LaunchDarkly bridge.
cd apex-server-sdk/bridge
go build .
  1. Set the environment variable LD_SDK_KEY to your LaunchDarkly SDK key. Set environment variables for your Salesforce account. This example uses the client credentials flow, which needs no user credential; enable Enable Client Credentials Flow on the connected app or External Client App in Salesforce first. See the bridge configuration reference for all supported options, including JWT authentication.
  • SALESFORCE_URL must name the org's My Domain host (https://MyDomainName.my.salesforce.com/services/apexrest/), not the Lightning host from your browser's address bar. The bridge derives the OAuth token endpoint from it when OAUTH_URI is unset.
  • The client credentials flow is not accepted on login.salesforce.com or test.salesforce.com, so leave OAUTH_URI unset for both production and sandbox orgs.
  1. Start the Salesforce bridge.
cd apex-server-sdk/bridge

export LD_SDK_KEY='Your LaunchDarkly SDK key'
export SALESFORCE_URL='Your Salesforce Apex REST URL'
export OAUTH_GRANT_TYPE='client-credentials'
export OAUTH_ID='Your Salesforce OAuth Id'
export OAUTH_SECRET='Your Salesforce OAuth secret'

./bridge
  1. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, edit hello.apex and set the value of flagKey to the flag key.
String flagKey = 'my-boolean-flag';
  1. Use the SDK with hello.apex
sf apex run --target-org 'YOUR TARGET ORG' --file 'hello.apex'

Releases

Packages

Used by

Contributors

Languages