Skip to content

Instantly share code, notes, and snippets.

View asaschachar's full-sized avatar

Asa Schachar asaschachar

View GitHub Profile
app.get('/', function(req, res, next) {
const isEnabled = req.optimizely.client.isFeatureEnabled(
'hello_world', // Feature key connecting feature to UI
'user123', // String ID used for random percentage-based rollout
{
customerId: 123, // Attributes used for targeted audience-based rollout
isVip: true,
}
);
const express = require('express');
const app = express();
const HOST = process.env.HOST || '0.0.0.0';
const PORT = process.env.PORT || 8080;
const optimizelyExpress = require('@optimizely/express');
const optimizely = optimizelyExpress.initialize({
sdkKey: '<Your_SDK_Key>',
datafileOptions: {
const express = require('express');
const app = express();
const HOST = process.env.HOST || '0.0.0.0';
const PORT = process.env.PORT || 8080;
const optimizelyExpress = require('@optimizely/express');
const optimizely = optimizelyExpress.initialize({
sdkKey: '<Your_SDK_Key>',
datafileOptions: {
import React from 'react';
import {
createInstance,
OptimizelyProvider,
OptimizelyFeature,
} from '@optimizely/react-sdk'
const optimizely = createInstance({
sdkKey: '<Your_SDK_Key>',
})
import React from 'react';
import {
createInstance,
OptimizelyProvider,
} from '@optimizely/react-sdk'
const optimizely = createInstance({
sdkKey: '<Your_SDK_Key>',
})
@asaschachar
asaschachar / react-feature-flags__feature.jsx
Last active June 5, 2019 23:36
react-feature-flags-2
<OptimizelyFeature feature="hello_world">
{(isEnabled) => (
isEnabled
? (<p> You got the <strong>hello_world</strong> feature! </p>)
: (<p> You did not get the feature </p>)
)}
</OptimizelyFeature>
@asaschachar
asaschachar / feature_flag_example.jsx
Last active May 30, 2019 23:31
react-feature-flags-blog
<OptimizelyFeature feature="hello_world">
{(isEnabled) => (
isEnabled
? (<p> You got the <strong>hello_world</strong> feature! </p>)
: (<p> You did not get the feature </p>)
)}
</OptimizelyFeature>

Rollouts Node Quickstart

Welcome to the quickstart guide for Optimizely's JavaScript SDK. The instructions below will help you implement Optimizely Rollouts and launch your first feature flag.

This guide will help you:

  1. Install the SDK
  2. Instantiate Optimizely when your app starts
  3. Create a feature flag
  4. Roll out a feature
@asaschachar
asaschachar / Optimizely_Individual_CLA.md
Last active April 17, 2019 18:31
Optimizely Inc. Individual Contributor License Agreement (CLA)

Optimizely Inc. Individual Contributor License Agreement

An Individual Contributor License Agreement (an "Agreement") is required to establish and define the intellectual property license granted in connection with Contributions (defined below) from any person or entity to Optimizely, Inc. ("Optimizely") for inclusion in any of the software, products, content, or services owned or managed by Optimizely (the "Work"). This Agreement is for your protection as well as Optimizely’s. This Agreement does not alter your rights to use your own Contributions for other purposes. By executing this Agreement, You accept and agree to the following terms and conditions for any past, current, or future Contributions submitted to Optimizely. Except for the license granted herein to Optimizely and recipients of software, products, content, or services delivered by Optimizely, you reserve all right, title, and interest in and to the Contributions you create.

1. Definitions.

"Control" shall mean (i) the power, direct or

Wrapper - Rollouts SDK

import OptimizelyManager from '@optimizely/optimizely-rollouts-sdk';
OptimizelyManager.configure({
  sdkKey: 'Ly8FQj6vSaDcZUjySoWnWz'
})

const optimizely = OptimizelyManager.getClient();
const enabled = optimizely.isFeatureEnabled('sale_price');