Skip to content

Commit

Permalink
restore legacy logic
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherjbaker committed Jun 25, 2024
1 parent 09e7e99 commit d2a3638
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .depcheckrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ignores:
- "@types/*"
- "@oclif/*"
- "@oclif/plugin-*"
- ts-node
7 changes: 7 additions & 0 deletions .github/workflows/example-basic-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ jobs:

- name: Build
run: npm run build

- name: Sync OptimizelyAsCode
# if: github.event_name == 'workflow_dispatch'
env:
OPTIMIZELY_ACCESS_TOKEN: my-optimizely-access-token
OPTIMIZELY_PROJECT_ID: my-optimizely-project-id
run: printenv
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
# optimizely-as-code
optimizely-as-code
==================

optimizely-as-code

<!-- toc -->
* [CLI Usage](#cli-usage)
<!-- tocstop -->

## Usage
# CLI Usage

<!-- usage -->
<!-- usagestop -->
<!-- commands -->
* [`optimizely-as-code sync`](#optimizely-as-code-sync)

## Commands
## `optimizely-as-code sync`

<!-- commands -->
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.
```
<!-- commandsstop -->
8 changes: 8 additions & 0 deletions examples/basic-react/optimizely-as-code/events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"category": "other",
"description": "Clicking on the Learn More Button",
"event_type": "custom",
"key": "clickColor"
}
]
48 changes: 48 additions & 0 deletions examples/basic-react/optimizely-as-code/experiments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[
{
"description": "Link Color Pipeline POC",
"environments": {
"development": {
"status": "running"
},
"production": {
"status": "paused"
}
},
"feature_key": "link_color",
"key": "link_color_experiment",
"metrics": [
{
"aggregator": "unique",
"event_key": "clickColor",
"scope": "visitor",
"winning_direction": "increasing"
}
],
"name": "Link Color Experiment",
"project_id": 19726420380,
"type": "feature",
"variations": [
{
"feature_enabled": true,
"key": "blue",
"name": "Blue Link",
"status": "active",
"variable_values": {
"isOrange": "false"
},
"weight": 5000
},
{
"feature_enabled": true,
"key": "orange",
"name": "Orange Link",
"status": "active",
"variable_values": {
"isOrange": "true"
},
"weight": 5000
}
]
}
]
17 changes: 17 additions & 0 deletions examples/basic-react/optimizely-as-code/features.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"key": "link_color",
"project_id": 19726420380,
"variables": [
{
"default_value": "false",
"key": "isOrange",
"type": "boolean"
}
]
},
{
"key": "demo_feature1",
"project_id": 19726420380
}
]
1 change: 1 addition & 0 deletions examples/basic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"optimizely-as-code": "optimizely-as-code sync",
"typecheck": "tsc --noEmit",
"eslint": "eslint .",
"prettier": "prettier --check .",
Expand Down
4 changes: 3 additions & 1 deletion examples/basic-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
useDecision,
} from "optimizely-as-code/react"

const userId = Math.floor(Math.random() * (10000 - 1000) + 1000).toString()

const optimizelyClient = createInstance({
sdkKey: import.meta.env.VITE_OPTIMIZELY_SDK_KEY,
})

const App: React.FC = () => {
return (
<OACProvider optimizely={optimizelyClient}>
<OACProvider optimizely={optimizelyClient} user={{ id: userId }}>
<Child />
</OACProvider>
)
Expand Down
Loading

0 comments on commit d2a3638

Please sign in to comment.