-
Notifications
You must be signed in to change notification settings - Fork 83
docs(README): List supported environments, add badges, and more #136
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
Changes from 30 commits
83724bb
260b780
d4266fd
a183ea9
a4c16a1
e50ba3a
b083826
818aaa1
c866753
2aff7da
d3bb631
724d1d5
09b5afd
67cfbf6
22a353b
17d396f
23dc790
3049c92
e98687e
fe7a196
8467cb2
fae9d22
b4d981c
268c76e
2a6cd9a
0aa5b7c
a72af3f
a626342
115e025
7758b77
40013e3
8d95f8b
cedffb5
964a869
7956534
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 |
---|---|---|
|
@@ -3,20 +3,22 @@ | |
</h3> | ||
|
||
<p align="center"> | ||
This repository houses the official JavaScript SDK for use with Optimizely X Full Stack | ||
This repository houses the official JavaScript SDK for use with Optimizely X Full Stack. | ||
</p> | ||
|
||
Optimizely X Full Stack is A/B testing and feature management for product development teams. Experiment in any application. Make every feature on your roadmap an opportunity to learn. Learn more at https://www.optimizely.com/products/full-stack/, or see the [documentation](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=node). | ||
|
||
## Packages | ||
|
||
This repository is a monorepo that we manage using [Lerna](https://github.com/lerna/lerna). That means that we actually publish [several packages](/packages) to npm from the same codebase, including: | ||
This repository is a monorepo that we manage using [Lerna](https://github.com/lerna/lerna). Only one package lives here currently, but that may change in the future. | ||
|
||
| Package | Version | Docs | Description | | ||
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | ||
| [`optimizely-sdk`](/packages/optimizely-sdk) | [](https://npmjs.com/package/@optimizely/optimizely-sdk) | [](https://developers.optimizely.com/x/solutions/sdks/reference/?language=javascript) | The Optimizely SDK | | ||
| [`@optimizely/optimizely-sdk`](/packages/optimizely-sdk) | [](https://www.npmjs.com/package/@optimizely/optimizely-sdk) | [](https://developers.optimizely.com/x/solutions/sdks/reference/?language=javascript) | The Optimizely SDK | | ||
|
||
## About | ||
|
||
`optimizely-sdk` is developed and maintained by [Optimizely](https://optimizely.com) and many [contributors](https://github.com/optimizely/javascript-sdk/graphs/contributors). If you're interested in learning more about what Optimizely X FullStack can do for your company, please [get in touch](mailto:[email protected])! | ||
`@optimizely/optimizely-sdk` is developed and maintained by [Optimizely](https://optimizely.com) and many [contributors](https://github.com/optimizely/javascript-sdk/graphs/contributors). If you're interested in learning more about what Optimizely X Full Stack can do for your company, please [get in touch](mailto:[email protected])! | ||
|
||
|
||
### Contributing | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,66 @@ | ||
# Optimizely JavaScript SDK | ||
# JavaScript SDK for Optimizely X Full Stack | ||
[](https://www.npmjs.com/package/@optimizely/optimizely-sdk) | ||
[](https://www.npmjs.com/package/@optimizely/optimizely-sdk) | ||
[](https://travis-ci.org/optimizely/javascript-sdk) | ||
[](https://coveralls.io/github/optimizely/javascript-sdk) | ||
[](https://choosealicense.com/licenses/apache-2.0/) | ||
|
||
This repository houses the JavaScript SDK for Optimizely X Full Stack. | ||
|
||
Optimizely X Full Stack is A/B testing and feature management for product development teams. Experiment in any application. Make every feature on your roadmap an opportunity to learn. Learn more at the [landing page](https://www.optimizely.com/products/full-stack/), or see the [documentation](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=node). | ||
|
||
This directory contains the source code for the JavaScript SDK, which is usable in Node.js, browsers, and beyond. | ||
|
||
## Getting Started | ||
|
||
### Installing the SDK | ||
### Prerequisites | ||
|
||
The SDK is available through [npm](https://npmjs.com/package/optimizely-sdk). To install: | ||
Ensure the SDK supports all of the platforms you're targeting. In particular, we support any ES5-compliant JavaScript environment, including | ||
- Node.js >= 4.0.0. By extension, environments like AWS Lambda, Google Cloud Functions, and Auth0 Webtasks are supported as well. Older Node.js releases likely work too (try `npm test` to validate for yourself), but are not formally supported. | ||
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. nice |
||
- [Web browsers](https://caniuse.com/#feat=es5) | ||
- [Cloudflare Workers](https://developers.cloudflare.com/workers/) and [Fly](https://fly.io/), both of which are powered by V8. | ||
- Anywhere else you can think of that might embed a JavaScript engine. The sky is the limit; experiment everywhere! 🚀 | ||
|
||
Once you've validated that the SDK supports the platforms you're targeting, fetch the package from [NPM](https://www.npmjs.com/package/@optimizely/optimizely-sdk). Using `npm`: | ||
|
||
``` | ||
npm install @optimizely/optimizely-sdk --save | ||
npm install --save @optimizely/optimizely-sdk | ||
``` | ||
|
||
Or to use in a non CommonJS fashion in the Browser: | ||
### Usage | ||
See the Optimizely X Full Stack [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK. | ||
|
||
1. Run `npm run build` | ||
2. Pull in `dist/optimizely.browser.umd.min.js` as a `<script>` | ||
3. Use as global variable `window.optimizelyClient` | ||
Regarding `EventDispatcher`s: In Node.js and browser environments, the default `EventDispatcher` is powered by the [`http/s`](https://nodejs.org/api/http.html) modules and by [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Browser_compatibility), respectively. In all other environments, you must supply your own `EventDispatcher`. | ||
|
||
### Migrating from 1.x.x | ||
|
||
This version represents a major version change and, as such, introduces some breaking changes: | ||
|
||
- The Node SDK is now combined with the JavaScript SDK so that we have one `optimizely-sdk` package that works across both server + browser environments. | ||
- The Node.js SDK is now combined with the JavaScript SDK. We now have just one package, `@optimizely/optimizely-sdk`, that works in many JavaScript environments. | ||
|
||
- We no longer support legacy Node versions (under 4.0). | ||
- We no longer support Node.js < 4.0.0, which [reached end-of-life](https://github.com/nodejs/Release#end-of-life-releases) 2016-12-31. | ||
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. Super nit: by 2016-12-31 would make it true for both 0.10 and 0.12. Reads kind of weird though. 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. hah, yeah. Maybe
|
||
|
||
- You will no longer be able to pass in `revenue` value as a stand-alone argument to the `track` call. Instead you will need to pass it as an entry in the [`eventTags`](https://developers.optimizely.com/x/solutions/sdks/reference/index.html?language=javascript#event-tags). | ||
|
||
### Feature Management Access | ||
|
||
To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive. | ||
### Feature Management access | ||
|
||
### Using the SDK | ||
See the Optimizely X Full Stack testing [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first JavaScript project and use the SDK. | ||
To access Feature Management in the Optimizely web application, please contact your Optimizely account executive. | ||
|
||
## Development | ||
## Contributing | ||
This information is relevant only if you plan on contributing to the SDK itself. | ||
|
||
### Installing dependencies | ||
```sh | ||
# Prerequisite: Install dependencies. | ||
npm install | ||
|
||
```npm install``` | ||
|
||
### Unit tests | ||
|
||
You can run all unit tests with: | ||
``` | ||
# Run unit tests with mocha. | ||
npm test | ||
``` | ||
|
||
### Build distribution packages | ||
|
||
# Run unit tests in many browsers, currently via BrowserStack. | ||
# For this to work, the following environment variables must be set: | ||
# - BROWSER_STACK_USERNAME | ||
# - BROWSER_STACK_PASSWORD | ||
npm run test-xbrowser | ||
``` | ||
npm run build | ||
``` | ||
|
||
This command will build several distribution bundles under the `dist` directory: | ||
1. optimizely.browser.cjs.js - This is the main entry point for browser/client-side bundles | ||
2. optimizely.browser.umd.js - This is used when not packaging the optimizely-sdk with your own JS bundles. Instead you would load this script as a `<script>` tag and reference it via the global var `optimizelyClient` | ||
3. optimizely.node.js - This is the main entry point for Node apps | ||
|
||
The browser bundles also come with a minified / production-ready version. | ||
|
||
### Environment Variables | ||
|
||
The .yml of this project contains environment vairables for ```BROWSER_STACK_USERNAME``` and ```BROWSER_STACK_ACCESS_KEY```. | ||
[.travis.yml](/.travis.yml) contains the definitions for `BROWSER_STACK_USERNAME` and `BROWSER_STACK_ACCESS_KEY` used in CI. These values are Optimizely's BrowserStack credentials, encrypted with our Travis CI public key. These creds can be rotated by following [these docs](https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml). | ||
|
||
These variables, created in BrowserStack, are encrypted by the Travis CI public key. This is done directly with the Travis CI command line tools; for additional information see travis encrypt-file. |
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.
I wonder if we can write this a little more precisely so as not to imply supported (as in we'll fix platform-specific issues for that platform) but merely will probably work.
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.
Good point, I'll try to work something out.