Optimizely Full Stack
- Platform:
- Compute@Edge
- Language:
- JavaScript
- Repo:
- https://github.com/optimizely/fastly-compute-starter-kit
Use this starter
Using the Fastly CLI, create a new project using this starter somewhere on your computer:
$ fastly compute init --from=https://github.com/optimizely/fastly-compute-starter-kit
Or click the button below to create a GitHub repository, provision a Fastly service, and set up continuous deployment:
External Calls via Fastly Backends
This starter kit overrides the standard Optimizely Javascript SDK's external calls to use Compute@Edge's fetch against registered backend endpoints. This backend setup also provides performant caching for the Optimizely Datafile.
Identity Management
Out of the box, Optimizely's Full Stack SDKs require a user-provided identifier to be passed in at runtime to drive experiment and feature flag decisions. This example generates a unique ID, stores it in a cookie and reuses it to make the decisions sticky. Alternatively, you can use an existing unique identifier available within your application and pass it in as the value for the OPTIMIZELY_USER_ID
cookie.
Bucketing
For more information on how Optimizely Full Stack SDKs assign users to feature flags and experiments, see the documentation on how bucketing works.
How to use
Prerequisites
You will need to complete the following prerequisites to use this template:
- Have a Compute@Edge account and the Fastly CLI installed. For more information view the Compute@Edge getting started documentation.
- Have an Optimizely account. If you do not have an account, you can register for a free account.
Get started
Create a new folder and initialize a Fastly Compute@Edge service using the Fastly CLI from this template.
fastly compute init --from https://github.com/optimizely/fastly-compute-starter-kitFollow the wizard and provide the service name, description and any other information. a) Add your
service_id
tofastly.toml
, if you want to use an existing Fastly service.Update your Optimizely
sdkKey
andflagKey
insrc/index.js
. Your SDK keys can be found in the Optimizely application under Settings.Build and publish:
fastly compute publishMonitor logs:
fastly log-tail
Additional resources
- Fastly - Compute@Edge official documentation
- Compute@Edge application code in JavaScript
- Fastly Compute@Edge with Optimizely documentation
Next steps
Starters are a good way to bootstrap a project. For more specific use cases, and answers to common problems, try our library of code examples.