optimizely-as-code

1.0.1 • Public • Published

optimizely-as-code

optimizely-as-code

Configuring your project

npm install optimizely-as-code

Add to package.json

{
  "scripts": {
    "optimizely-as-code": "optimizely-as-code sync",
  },
}

Create optimizely-as-code/features.json.

Create optimizely-as-code/events.json.

Create optimizely-as-code/experiments.json.

Usage in React

import { createInstance, OACProvider, useDecision } from "optimizely-as-code/react"

const optimizelyClient = createInstance({
  sdkKey: "<your-optimizely-sdk-key>",
})

const App: React.FC = () => {
  return (
    <OACProvider optimizely={optimizelyClient} user={{ id: "<unique-user-id>" }}>
      <Child />
    </OACProvider>
  )
}

const Child: React.FC = () => {
  const [foobar] = useDecision("foobar")

  return (
    <div>
      <p>hello {foobar.enabled ? "foo" : "bar"}</p>
    </div>
  )
}

CLI Commands

optimizely-as-code sync

Push local features to Optimizely.

USAGE
  $ optimizely-as-code sync --accessToken <value> --projectId <value> [--dry-run]

FLAGS
  --accessToken=<value>  (required) Your Optimizely access token. Can also be provided via the environment variable
                         OPTIMIZELY_ACCESS_TOKEN.
  --dry-run              Output what changes would be made without actually making the changes.
  --projectId=<value>    (required) Your Optimizely Project Id. Can also be provided via the environment variable
                         OPTIMIZELY_PROJECT_ID.

Readme

Keywords

none

Package Sidebar

Install

npm i optimizely-as-code

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

19.8 kB

Total Files

23

Last publish

Collaborators

  • bitovi-os