-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Opticks to support Optimizely's JS SDK v5.3.2 #81
Changes from 6 commits
8c7dd43
38ab4b6
4c2ff79
28ff2e4
8c68cef
d750ed2
9b32a6a
5e2c595
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,24 +14,18 @@ The library consists of two related concepts: | |||||
|
||||||
At the heart of our experimentation framework is the `toggle` function. | ||||||
|
||||||
- `toggle` toggles that switch between multiple experiment variants (a/b/c/...) | ||||||
- `booleanToggle` toggles that turn functionality on or off (feature flags) | ||||||
A toggle allows you to switch between multiple experiment variants (a/b/c/...) | ||||||
and also turn functionality on or off (feature flags) | ||||||
|
||||||
It can be used in a variety of ways: | ||||||
|
||||||
1. Reading the value of the toggle (boolean, or a/b/c for multi toggles ) | ||||||
1. Execute code or for a variant of a multi toggle | ||||||
1. Execute code when a boolean toggle is on | ||||||
|
||||||
We use React at FindHotel and some of the code examples use JSX, but the code | ||||||
We use React at vio.com and some of the code examples use JSX, but the code | ||||||
and concept is compatible with any front-end framework or architecture. | ||||||
|
||||||
The `booleanToggle` is the simplest toggle type to use for feature flagging, but | ||||||
it's also the least flexible. As of version 2.0 `toggle` is the default and | ||||||
recommended for both a/b/c experiments and feature flags. If you're only ever | ||||||
interested in feature flags, read more about [Boolean | ||||||
Toggles](docs/booleanToggles.md). | ||||||
|
||||||
### Opticks vs other experimentation frameworks | ||||||
|
||||||
The main reason for using the Opticks library is to be able to clean your code | ||||||
|
@@ -64,9 +58,9 @@ See the [Optimizely integration documentation](docs/optimizely-integration.md). | |||||
|
||||||
## Toggles | ||||||
|
||||||
Toggles can be used to implement a/b/c style testing, instead of on/off values | ||||||
as with `booleanToggle`, we specify multiple variants of which one is active at | ||||||
any time. By convention the variants are named `a` (control), `b`, `c` etc. | ||||||
Toggles can be used to implement a/b/c style testing and on/off values as well. | ||||||
We specify multiple variants of which one is active at any time. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
By convention the variants are named `a` (control), `b`, `c` etc. | ||||||
|
||||||
### Reading values | ||||||
|
||||||
|
@@ -133,7 +127,7 @@ experimentId, then the values for `a`, `b`, etc. | |||||
For instance: | ||||||
|
||||||
``` | ||||||
// simple boolean switch: (you could use a BooleanToggle as well) | ||||||
// simple boolean switch | ||||||
const shouldDoSomething = toggle('foo', false, true) | ||||||
|
||||||
// multiple variants as strings | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to bump the version of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to do this manually - you can run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vlacerda let me know if you face any issues generating the changeset |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still see some references to
Can we clean this up as well? If not, let's mark them as deprecated and create a follow-up story. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing. Good catch. I cleaned them up. I think I managed to do so . |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,30 +5,23 @@ export const voidEventDispatcher = { | |||||
export const addNotificationListenerMock = jest.fn() | ||||||
|
||||||
export const createInstanceMock = jest.fn(() => ({ | ||||||
getEnabledFeatures: getEnabledFeaturesMock, | ||||||
isFeatureEnabled: isFeatureEnabledMock, | ||||||
notificationCenter: { | ||||||
addNotificationListener: addNotificationListenerMock | ||||||
}, | ||||||
activate: activateMock | ||||||
activate: activateMock, | ||||||
createUserContext: optimizelyUserContextMock | ||||||
})) | ||||||
|
||||||
export const isFeatureEnabledMock = jest.fn((toggleId) => toggleId === 'foo') | ||||||
|
||||||
export const getEnabledFeaturesMock = jest.fn((userId, attributes) => { | ||||||
if (userId) { | ||||||
if (attributes.deviceType) { | ||||||
return [ | ||||||
`${userId}-${attributes.deviceType}-test-1`, | ||||||
`${userId}-${attributes.deviceType}-test-2` | ||||||
] | ||||||
} | ||||||
|
||||||
return [`${userId}-test-1`, `${userId}-test-2`] | ||||||
} | ||||||
export const decideMock = jest.fn((toggleKey) => ({ | ||||||
enabled: toggleKey === "foo" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
})) | ||||||
export const optimizelyUserContextMock = jest.fn(() => ({ | ||||||
decide: decideMock | ||||||
})) | ||||||
|
||||||
|
||||||
return [] | ||||||
}) | ||||||
export const isFeatureEnabledMock = jest.fn((toggleId) => toggleId === 'foo') | ||||||
|
||||||
export const activateMock = jest.fn((toggleId, userId) => { | ||||||
const shouldReturnB = | ||||||
|
@@ -38,8 +31,12 @@ export const activateMock = jest.fn((toggleId, userId) => { | |||||
return shouldReturnB && 'b' | ||||||
}) | ||||||
|
||||||
const originalModule = jest.requireActual('@optimizely/optimizely-sdk') | ||||||
|
||||||
const mock = { | ||||||
...originalModule, | ||||||
createInstance: createInstanceMock | ||||||
} | ||||||
|
||||||
|
||||||
export default mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.